feat: 租户应用配置支持自定义参数
All checks were successful
continuous-integration/drone/push Build is passing

- 后端: TenantApp 模型添加 custom_configs 字段 (LONGTEXT)
- 后端: tenant_apps API 支持自定义配置的增删改查
- 前端: 应用订阅编辑对话框增加自定义配置编辑区域
- 支持 key-value-备注 三字段结构
- value 使用 textarea 支持超长文本(如提示词)
This commit is contained in:
2026-01-27 17:15:19 +08:00
parent 7134947c0c
commit e37466a7cc
6 changed files with 1273 additions and 1160 deletions

View File

@@ -1,6 +1,7 @@
<script setup>
import { ref, reactive, onMounted, computed, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Delete, Plus } from '@element-plus/icons-vue'
import api from '@/api'
import { useAuthStore } from '@/stores/auth'
@@ -36,7 +37,8 @@ const form = reactive({
tenant_id: '',
app_code: '',
app_name: '',
wechat_app_id: null
wechat_app_id: null,
custom_configs: [] // 自定义配置 [{key, value, remark}]
})
// 当前选择的应用是否需要 JS-SDK
@@ -142,7 +144,8 @@ function handleCreate() {
tenant_id: '',
app_code: '',
app_name: '',
wechat_app_id: null
wechat_app_id: null,
custom_configs: []
})
wechatAppList.value = []
dialogVisible.value = true
@@ -155,12 +158,22 @@ async function handleEdit(row) {
tenant_id: row.tenant_id,
app_code: row.app_code,
app_name: row.app_name || '',
wechat_app_id: row.wechat_app_id || null
wechat_app_id: row.wechat_app_id || null,
custom_configs: row.custom_configs ? [...row.custom_configs] : []
})
await fetchWechatApps(row.tenant_id)
dialogVisible.value = true
}
// 自定义配置管理
function addCustomConfig() {
form.custom_configs.push({ key: '', value: '', remark: '' })
}
function removeCustomConfig(index) {
form.custom_configs.splice(index, 1)
}
async function handleSubmit() {
await formRef.value.validate()
@@ -301,6 +314,14 @@ onMounted(() => {
<el-tag v-else type="danger" size="small">未生成</el-tag>
</template>
</el-table-column>
<el-table-column label="自定义配置" width="100">
<template #default="{ row }">
<el-tag v-if="row.custom_configs && row.custom_configs.length > 0" type="primary" size="small">
{{ row.custom_configs.length }}
</el-tag>
<span v-else style="color: #909399; font-size: 12px">-</span>
</template>
</el-table-column>
<el-table-column label="状态" width="80">
<template #default="{ row }">
<el-tag :type="row.status === 1 ? 'success' : 'info'" size="small">
@@ -330,7 +351,7 @@ onMounted(() => {
</div>
<!-- 编辑对话框 -->
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="550px">
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="750px">
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
<el-form-item label="租户" prop="tenant_id">
<el-select
@@ -379,6 +400,51 @@ onMounted(() => {
</div>
</el-form-item>
</template>
<!-- 自定义配置 -->
<el-divider content-position="left">自定义配置</el-divider>
<div class="custom-configs-section">
<div v-for="(config, index) in form.custom_configs" :key="index" class="config-item">
<div class="config-row">
<el-input
v-model="config.key"
placeholder="配置键 (如: industry)"
style="width: 150px"
/>
<el-input
v-model="config.remark"
placeholder="备注说明"
style="width: 180px; margin-left: 8px"
/>
<el-button
type="danger"
:icon="Delete"
circle
size="small"
style="margin-left: 8px"
@click="removeCustomConfig(index)"
/>
</div>
<el-input
v-model="config.value"
type="textarea"
:rows="3"
:autosize="{ minRows: 2, maxRows: 10 }"
placeholder="配置值(支持超长文本,如提示词等)"
style="margin-top: 8px"
/>
</div>
<el-button type="primary" plain @click="addCustomConfig" style="margin-top: 8px">
<el-icon><Plus /></el-icon>
添加配置项
</el-button>
<div v-if="form.custom_configs.length === 0" class="config-empty-tip">
暂无自定义配置点击上方按钮添加
</div>
</div>
</el-form>
<template #footer>
<el-button @click="dialogVisible = false">取消</el-button>
@@ -449,4 +515,28 @@ onMounted(() => {
margin-bottom: 8px;
color: #303133;
}
/* 自定义配置样式 */
.custom-configs-section {
padding: 0 10px;
}
.config-item {
background: #f5f7fa;
border-radius: 8px;
padding: 12px;
margin-bottom: 12px;
}
.config-row {
display: flex;
align-items: center;
}
.config-empty-tip {
color: #909399;
font-size: 13px;
text-align: center;
padding: 20px 0;
}
</style>

File diff suppressed because it is too large Load Diff