功能:完善门店能力与用户安全配置
This commit is contained in:
@@ -0,0 +1,292 @@
|
||||
<template>
|
||||
<div class="admin-page">
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<h2>参数管理</h2>
|
||||
<p>统一维护地图 Key、短信 MessageHub 对接参数等平台级配置,仅平台管理员可修改。</p>
|
||||
</div>
|
||||
<a-button type="primary" @click="openCreate">新增配置</a-button>
|
||||
</div>
|
||||
|
||||
<a-card title="地图服务配置" :bordered="false">
|
||||
<a-form layout="vertical">
|
||||
<a-form-item label="腾讯位置服务 Key">
|
||||
<a-input-password v-model:value="mapForm.configValue" placeholder="请输入腾讯位置服务 Key" />
|
||||
</a-form-item>
|
||||
<a-form-item label="备注">
|
||||
<a-textarea v-model:value="mapForm.remark" :rows="2" placeholder="例如:用于后台店铺选点和腾讯地图展示" />
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-switch v-model:checked="mapEnabled" checked-children="启用" un-checked-children="停用" />
|
||||
<a-button type="primary" :loading="savingMap" @click="saveMapConfig">保存地图配置</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
|
||||
<a-alert
|
||||
type="info"
|
||||
show-icon
|
||||
message="这里不配置 Spug、阿里云等供应商密钥;真实短信通道仍在 MessageHub 中独立管理。"
|
||||
/>
|
||||
|
||||
<a-table :columns="columns" :data-source="configs" :loading="loading" row-key="id">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'scene'">
|
||||
<strong>{{ record.sceneName }}</strong>
|
||||
<div class="muted">{{ record.sceneCode }}</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'messagehub'">
|
||||
<div>队列:{{ record.queueName }}</div>
|
||||
<div class="muted">来源:{{ record.sourceSystem }}</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'template'">
|
||||
<div>{{ record.templateCode }}</div>
|
||||
<div class="muted">通道ID:{{ record.channelId || '由 MessageHub 自动选择' }}</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'enabled'">
|
||||
<a-switch :checked="record.enabled === 1" @change="checked => toggleStatus(record as MessageHubPushConfigVO, Boolean(checked))" />
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button size="small" @click="openEdit(record as MessageHubPushConfigVO)">编辑</a-button>
|
||||
<a-button size="small" @click="openTest(record as MessageHubPushConfigVO)">测试</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
|
||||
<a-modal v-model:open="formOpen" :title="editingId ? '编辑配置' : '新增配置'" @ok="submit" :confirm-loading="saving">
|
||||
<a-form layout="vertical">
|
||||
<a-form-item label="业务场景">
|
||||
<a-select v-model:value="form.sceneCode" :options="sceneOptions" show-search @change="handleSceneChange" />
|
||||
</a-form-item>
|
||||
<a-form-item label="场景名称">
|
||||
<a-input v-model:value="form.sceneName" />
|
||||
</a-form-item>
|
||||
<a-form-item label="MessageHub 队列">
|
||||
<a-input v-model:value="form.queueName" placeholder="smsQueue" />
|
||||
</a-form-item>
|
||||
<a-form-item label="来源系统">
|
||||
<a-input v-model:value="form.sourceSystem" placeholder="yuminail" />
|
||||
</a-form-item>
|
||||
<a-form-item label="模板编码">
|
||||
<a-input v-model:value="form.templateCode" placeholder="MessageHub 中维护的模板编码" />
|
||||
</a-form-item>
|
||||
<a-form-item label="指定通道 ID">
|
||||
<a-input-number v-model:value="form.channelId" :min="1" style="width: 100%" placeholder="不填则由 MessageHub 选择" />
|
||||
</a-form-item>
|
||||
<a-form-item label="发送方式">
|
||||
<a-select v-model:value="form.sendMethod" allow-clear :options="sendMethodOptions" />
|
||||
</a-form-item>
|
||||
<a-form-item label="备注">
|
||||
<a-textarea v-model:value="form.remark" :rows="3" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
|
||||
<a-modal v-model:open="testOpen" title="测试投递" @ok="submitTest" :confirm-loading="testing">
|
||||
<a-form layout="vertical">
|
||||
<a-form-item label="测试手机号">
|
||||
<a-input v-model:value="testPhone" :maxlength="11" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* MessageHubPushConfigsView page script.
|
||||
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
||||
*/
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { adminMessageHubPushConfigApi, adminSystemParameterConfigApi, type MessageHubPushConfigVO } from '@/api/admin'
|
||||
|
||||
/** loading is a reactive state variable used by the template and event handlers. */
|
||||
const loading = ref(false)
|
||||
/** saving is a reactive state variable used by the template and event handlers. */
|
||||
const saving = ref(false)
|
||||
/** testing is a reactive state variable used by the template and event handlers. */
|
||||
const testing = ref(false)
|
||||
/** formOpen is a reactive state variable used by the template and event handlers. */
|
||||
const formOpen = ref(false)
|
||||
/** testOpen is a reactive state variable used by the template and event handlers. */
|
||||
const testOpen = ref(false)
|
||||
const editingId = ref<any>()
|
||||
const testingId = ref<any>()
|
||||
/** testPhone is a reactive state variable used by the template and event handlers. */
|
||||
const testPhone = ref('')
|
||||
const configs = ref<MessageHubPushConfigVO[]>([])
|
||||
const savingMap = ref(false)
|
||||
const mapEnabled = ref(true)
|
||||
const mapForm = reactive({
|
||||
configGroup: 'MAP',
|
||||
configKey: 'TENCENT_MAP_KEY',
|
||||
configName: '腾讯位置服务 Key',
|
||||
configValue: '',
|
||||
enabled: 1,
|
||||
remark: '用于后台店铺选点和腾讯地图展示'
|
||||
})
|
||||
|
||||
const sceneOptions = [
|
||||
{ label: '用户注册验证码', value: 'USER_REGISTER_SMS_CODE' },
|
||||
{ label: '手机号登录验证码', value: 'USER_LOGIN_SMS_CODE' },
|
||||
{ label: '找回密码验证码', value: 'USER_RESET_PASSWORD_SMS_CODE' },
|
||||
{ label: '绑定手机号验证码', value: 'USER_BIND_PHONE_SMS_CODE' },
|
||||
{ label: '修改手机号验证码', value: 'USER_CHANGE_PHONE_SMS_CODE' },
|
||||
{ label: '修改密码验证码', value: 'USER_CHANGE_PASSWORD_SMS_CODE' }
|
||||
]
|
||||
|
||||
const sendMethodOptions = [
|
||||
{ label: 'SPUG', value: 'SPUG' },
|
||||
{ label: 'OTHER', value: 'OTHER' }
|
||||
]
|
||||
|
||||
const form = reactive<any>({
|
||||
sceneCode: 'USER_LOGIN_SMS_CODE',
|
||||
sceneName: '手机号登录验证码',
|
||||
platform: 'SMS',
|
||||
msgType: 'VERIFICATION',
|
||||
queueName: 'smsQueue',
|
||||
sourceSystem: 'yuminail',
|
||||
templateCode: 'SPUG0001',
|
||||
channelId: undefined,
|
||||
sendMethod: 'SPUG',
|
||||
enabled: 1,
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const columns = [
|
||||
{ title: '业务场景', key: 'scene' },
|
||||
{ title: 'MessageHub', key: 'messagehub' },
|
||||
{ title: '模板/通道', key: 'template' },
|
||||
{ title: '消息类型', dataIndex: 'msgType', key: 'msgType', width: 110 },
|
||||
{ title: '启用', key: 'enabled', width: 90 },
|
||||
{ title: '操作', key: 'action', width: 150 }
|
||||
]
|
||||
|
||||
/** load is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const load = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const [messageConfigs, mapConfigs] = await Promise.all([
|
||||
adminMessageHubPushConfigApi.listConfigs(),
|
||||
adminSystemParameterConfigApi.listConfigs('MAP')
|
||||
])
|
||||
configs.value = messageConfigs
|
||||
const tencentMapConfig = mapConfigs.find(item => item.configKey === 'TENCENT_MAP_KEY')
|
||||
if (tencentMapConfig) {
|
||||
Object.assign(mapForm, tencentMapConfig)
|
||||
mapEnabled.value = tencentMapConfig.enabled === 1
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const saveMapConfig = async () => {
|
||||
savingMap.value = true
|
||||
try {
|
||||
await adminSystemParameterConfigApi.saveConfig({
|
||||
...mapForm,
|
||||
enabled: mapEnabled.value ? 1 : 0
|
||||
})
|
||||
message.success('地图配置已保存')
|
||||
await load()
|
||||
} finally {
|
||||
savingMap.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** resetForm is a local helper used by this page script. */
|
||||
const resetForm = () => Object.assign(form, {
|
||||
sceneCode: 'USER_LOGIN_SMS_CODE',
|
||||
sceneName: '手机号登录验证码',
|
||||
platform: 'SMS',
|
||||
msgType: 'VERIFICATION',
|
||||
queueName: 'smsQueue',
|
||||
sourceSystem: 'yuminail',
|
||||
templateCode: 'SPUG0001',
|
||||
channelId: undefined,
|
||||
sendMethod: 'SPUG',
|
||||
enabled: 1,
|
||||
remark: ''
|
||||
})
|
||||
|
||||
/** handleSceneChange is a local helper used by this page script. */
|
||||
const handleSceneChange = (value: any) => {
|
||||
const option = sceneOptions.find(item => item.value === String(value || ''))
|
||||
if (option) form.sceneName = option.label
|
||||
}
|
||||
|
||||
/** openCreate is a local helper used by this page script. */
|
||||
const openCreate = () => { editingId.value = undefined; resetForm(); formOpen.value = true }
|
||||
/** openEdit is a local helper used by this page script. */
|
||||
const openEdit = (record: MessageHubPushConfigVO) => {
|
||||
editingId.value = record.id
|
||||
Object.assign(form, record)
|
||||
formOpen.value = true
|
||||
}
|
||||
|
||||
/** submit is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const submit = async () => {
|
||||
if (!form.sceneCode || !form.sceneName || !form.queueName || !form.sourceSystem || !form.templateCode) {
|
||||
message.warning('请填写场景、队列、来源系统和模板编码')
|
||||
return
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
if (editingId.value) {
|
||||
await adminMessageHubPushConfigApi.updateConfig(editingId.value, form)
|
||||
} else {
|
||||
await adminMessageHubPushConfigApi.createConfig(form)
|
||||
}
|
||||
message.success('配置已保存')
|
||||
formOpen.value = false
|
||||
await load()
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** toggleStatus is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const toggleStatus = async (record: MessageHubPushConfigVO, checked: boolean) => {
|
||||
await adminMessageHubPushConfigApi.updateStatus(record.id, checked ? 1 : 0)
|
||||
record.enabled = checked ? 1 : 0
|
||||
}
|
||||
|
||||
/** openTest is a local helper used by this page script. */
|
||||
const openTest = (record: MessageHubPushConfigVO) => {
|
||||
testingId.value = record.id
|
||||
testPhone.value = ''
|
||||
testOpen.value = true
|
||||
}
|
||||
|
||||
/** submitTest is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const submitTest = async () => {
|
||||
if (!/^1[3-9]\d{9}$/.test(testPhone.value)) {
|
||||
message.warning('请输入正确的测试手机号')
|
||||
return
|
||||
}
|
||||
testing.value = true
|
||||
try {
|
||||
await adminMessageHubPushConfigApi.testConfig(testingId.value, testPhone.value)
|
||||
message.success('测试消息已投递到 MessageHub')
|
||||
testOpen.value = false
|
||||
} finally {
|
||||
testing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.admin-page { display: grid; gap: 18px; }
|
||||
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
|
||||
.page-head h2 { margin: 0 0 4px; }
|
||||
.page-head p, .muted { margin: 0; color: #7a6f68; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user