feat(issue#3 方案B): 系统配置页(/system/config KV 管理)+ SrcID 两级回退链(账号 ext_code 优先→系统默认 cmpp.default_ext_code)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { get, put } from './request'
|
||||
|
||||
/** Issue#3 方案B:系统参数配置(system_config KV;admin)。 */
|
||||
export interface SystemConfigRow {
|
||||
id: number
|
||||
cfg_key: string
|
||||
cfg_value: string
|
||||
remark: string
|
||||
updated_by: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface SystemConfigSaveReq {
|
||||
cfg_key: string
|
||||
cfg_value: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 已知键说明(表结构无白名单,新键=新能力;此处仅运营提示)。 */
|
||||
export const KNOWN_CFG_KEYS: { key: string; label: string; hint: string }[] = [
|
||||
{
|
||||
key: 'cmpp.default_ext_code',
|
||||
label: '系统默认接入码前缀',
|
||||
hint: 'CMPP/SMPP 账号未配置扩展码(ext_code)时回退此值校验 SrcID 前缀;改后受理侧 ≤30s 生效',
|
||||
},
|
||||
{
|
||||
key: 'uplink.blacklist.keywords',
|
||||
label: '上行自动拉黑词表',
|
||||
hint: '逗号分隔等值匹配(如 R,TD,退订,拒收);空=内置默认词表;改后 ≤60s 生效',
|
||||
},
|
||||
]
|
||||
|
||||
export const systemApi = {
|
||||
list: () => get<{ list: SystemConfigRow[] }>('/system/config'),
|
||||
update: (body: SystemConfigSaveReq) => put<SystemConfigRow>('/system/config', body),
|
||||
}
|
||||
@@ -75,7 +75,7 @@ export const asyncRoutes: RouteRecordRaw[] = [
|
||||
|
||||
|
||||
{ path: 'logs', name: 'logs', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '日志报表', icon: 'Document', menu: true, group: '系统管理', roles: ['admin', 'ops', 'service'] } },
|
||||
{ path: 'system', name: 'system', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '系统配置', icon: 'Setting', menu: true, group: '系统管理', roles: ['admin'] } },
|
||||
{ path: 'system', name: 'system', component: () => import('@/views/system/index.vue'), meta: { title: '系统配置', icon: 'Setting', menu: true, group: '系统管理', roles: ['admin'], subtitle: '系统级参数 KV · 默认接入码 · 拉黑词表' } },
|
||||
{ path: 'faq', name: 'faq', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '常见问题', icon: 'QuestionFilled', menu: true, group: '系统管理', roles: ['admin', 'ops', 'service', 'group', 'customer'] } },
|
||||
|
||||
// 隐藏页(不在菜单)
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<el-button link type="primary" :disabled="!apiCfg.cmpp_password" @click="copyText(apiCfg.cmpp_password, 'CMPP密码')">复制</el-button>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="通道号(接入码)">
|
||||
提交时 SrcID 自带(CMPP 2.0 协议定长 ≤21 位){{ apiCfg.ext_code ? `;须以 ${apiCfg.ext_code} 为前缀,不匹配拒收(Result=9)` : ';未配置扩展码,暂不校验前缀' }}
|
||||
提交时 SrcID 自带(CMPP 2.0 协议定长 ≤21 位){{ apiCfg.ext_code ? `;须以 ${apiCfg.ext_code} 为前缀,不匹配拒收(Result=9)` : ';未配置时回退系统默认接入码(系统配置→cmpp.default_ext_code)' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="最大连接数">
|
||||
{{ apiCfg.cmpp_max_conns_effective }}{{ apiCfg.cmpp_max_conns ? '' : '(系统默认)' }}
|
||||
@@ -269,7 +269,7 @@ function deliveryText(): string {
|
||||
`连接端口:${c.cmpp_access?.port ?? '-'}`,
|
||||
`企业ID:${acc.value?.username ?? '-'}`,
|
||||
`CMPP密码:${c.cmpp_password}`,
|
||||
`通道号(接入码):提交时 SrcID 自带(CMPP 2.0 定长 ≤21 位${c.ext_code ? `;须以 ${c.ext_code} 为前缀` : ''})`,
|
||||
`通道号(接入码):提交时 SrcID 自带(CMPP 2.0 定长 ≤21 位${c.ext_code ? `;须以 ${c.ext_code} 为前缀` : ';未配置时回退系统默认接入码'})`,
|
||||
`单链接速度:${c.cmpp_speed_effective} 条/秒`,
|
||||
`最大连接数:${c.cmpp_max_conns_effective}`,
|
||||
`协议版本:${c.cmpp_access?.version ?? 'CMPP 2.0'}`,
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
<template>
|
||||
<section class="card sc-card" data-testid="system-config">
|
||||
<div class="sc-head">
|
||||
<span class="card-head-title">系统参数配置</span>
|
||||
<el-button type="primary" size="small" data-testid="btn-cfg-new" @click="openNew">新增 / 编辑参数</el-button>
|
||||
<el-button size="small" :loading="loading" @click="reload">刷新</el-button>
|
||||
</div>
|
||||
|
||||
<el-alert v-for="k in KNOWN_CFG_KEYS" :key="k.key" class="sc-hint" type="info" :closable="false">
|
||||
<template #title>
|
||||
<span class="sc-hint-key">{{ k.key }}</span>({{ k.label }}):{{ k.hint }}
|
||||
</template>
|
||||
</el-alert>
|
||||
|
||||
<el-table v-loading="loading" :data="rows" data-testid="cfg-table">
|
||||
<el-table-column prop="cfg_key" label="配置键" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<span class="sc-key">{{ row.cfg_key }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="cfg_value" label="配置值" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<span class="sc-val">{{ row.cfg_value === '' ? '(空)' : row.cfg_value }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="updated_by" label="操作人" width="110" />
|
||||
<el-table-column prop="updated_at" label="更新时间" width="170" />
|
||||
<el-table-column label="操作" width="90" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<template #empty>
|
||||
<el-empty description="暂无配置——点「新增 / 编辑参数」配置系统默认接入码等参数" />
|
||||
</template>
|
||||
</el-table>
|
||||
|
||||
<el-dialog v-model="dlg" :title="editing ? '编辑参数' : '新增参数'" width="520px">
|
||||
<el-form label-width="90px">
|
||||
<el-form-item label="配置键">
|
||||
<el-select v-model="form.cfg_key" filterable allow-create default-first-option
|
||||
:disabled="editing" placeholder="选择已知键或输入新键" style="width: 100%" data-testid="cfg-key">
|
||||
<el-option v-for="k in KNOWN_CFG_KEYS" :key="k.key" :value="k.key" :label="`${k.key}(${k.label})`" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="配置值">
|
||||
<el-input v-model="form.cfg_value" type="textarea" :rows="2" maxlength="1024" show-word-limit
|
||||
placeholder="空值=清除语义(如拉黑词表回默认)" data-testid="cfg-value" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="form.remark" maxlength="255" placeholder="变更说明(留痕)" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dlg = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" data-testid="btn-cfg-save" @click="save">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#3 方案B:系统配置页(keep-alive 缓存锚点——组件名必须=路由 name)。
|
||||
defineOptions({ name: 'system' })
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { KNOWN_CFG_KEYS, systemApi, type SystemConfigRow } from '@/api/system'
|
||||
|
||||
const rows = ref<SystemConfigRow[]>([])
|
||||
const loading = ref(false)
|
||||
const dlg = ref(false)
|
||||
const saving = ref(false)
|
||||
const editing = ref(false)
|
||||
const form = ref({ cfg_key: '', cfg_value: '', remark: '' })
|
||||
|
||||
async function reload() {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await systemApi.list()
|
||||
rows.value = data.list
|
||||
} catch (e) {
|
||||
ElMessage.error(e instanceof Error ? `加载失败:${e.message}` : '加载失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(reload)
|
||||
|
||||
function openNew() {
|
||||
editing.value = false
|
||||
form.value = { cfg_key: '', cfg_value: '', remark: '' }
|
||||
dlg.value = true
|
||||
}
|
||||
|
||||
function openEdit(row: SystemConfigRow) {
|
||||
editing.value = true
|
||||
form.value = { cfg_key: row.cfg_key, cfg_value: row.cfg_value, remark: row.remark }
|
||||
dlg.value = true
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (!form.value.cfg_key.trim()) {
|
||||
ElMessage.warning('配置键不能为空')
|
||||
return
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
await systemApi.update({ ...form.value, cfg_key: form.value.cfg_key.trim() })
|
||||
ElMessage.success('已保存(写即刻生效,读侧按各消费域刷新周期生效)')
|
||||
dlg.value = false
|
||||
await reload()
|
||||
} catch (e) {
|
||||
ElMessage.error(e instanceof Error ? `保存失败:${e.message}` : '保存失败')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.sc-card { padding: 16px 18px 14px; }
|
||||
.sc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
|
||||
.card-head-title { font-size: var(--gosms-fs-md); font-weight: 600; color: var(--gosms-text-bright); margin-right: 8px; }
|
||||
.sc-hint { margin-bottom: 8px; }
|
||||
.sc-hint-key { font-family: monospace; }
|
||||
.sc-key { font-family: monospace; }
|
||||
.sc-val { font-family: monospace; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user