2026-09-05 23:46:35 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="system-settings">
|
|
|
|
|
<a-page-header title="系统设置" sub-title="管理店长账号默认密码" />
|
2026-09-06 21:41:09 +08:00
|
|
|
<a-card title="短信供应商" :loading="loading">
|
|
|
|
|
<a-alert message="全局统一切换短信发送渠道" description="保存后会同步所有短信验证码场景的 MessageHub 模板、通道和发送方式。" show-icon type="info" />
|
|
|
|
|
<a-form class="settings-form" layout="vertical">
|
|
|
|
|
<a-form-item label="当前供应商">
|
|
|
|
|
<a-select v-model:value="smsProviderForm.configValue" :options="smsProviderOptions" />
|
|
|
|
|
</a-form-item>
|
|
|
|
|
<a-button type="primary" :loading="savingSmsProvider" @click="saveSmsProvider">保存短信供应商</a-button>
|
|
|
|
|
</a-form>
|
|
|
|
|
</a-card>
|
2026-09-05 23:46:35 +08:00
|
|
|
<a-card title="店长默认密码" :loading="loading">
|
|
|
|
|
<a-alert
|
|
|
|
|
message="用于新增或重置店长账号"
|
|
|
|
|
description="店长未设置密码时,以及管理员执行重置密码时,系统会使用这里配置的默认密码。修改后只对后续新增或重置生效。"
|
|
|
|
|
show-icon
|
|
|
|
|
type="info"
|
|
|
|
|
/>
|
|
|
|
|
<a-form class="settings-form" layout="vertical" @submit.prevent="save">
|
|
|
|
|
<a-form-item label="默认密码">
|
|
|
|
|
<a-input-password v-model:value="form.configValue" autocomplete="new-password" placeholder="请输入默认密码" />
|
|
|
|
|
</a-form-item>
|
|
|
|
|
<a-form-item label="状态">
|
|
|
|
|
<a-switch v-model:checked="enabled" checked-children="启用" un-checked-children="停用" />
|
|
|
|
|
</a-form-item>
|
|
|
|
|
<a-button type="primary" :loading="saving" @click="save">保存默认密码</a-button>
|
|
|
|
|
</a-form>
|
|
|
|
|
</a-card>
|
2026-10-12 16:45:42 +08:00
|
|
|
<a-card title="店长员工审核提醒" :loading="loading">
|
|
|
|
|
<a-alert
|
|
|
|
|
message="控制店长登录小程序后的待审核弹窗"
|
|
|
|
|
description="关闭后只是不再主动弹窗,员工页面中的审核入口和待审核数量仍然保留。"
|
|
|
|
|
show-icon
|
|
|
|
|
type="info"
|
|
|
|
|
/>
|
|
|
|
|
<a-form class="settings-form" layout="vertical">
|
|
|
|
|
<a-form-item label="登录提醒">
|
|
|
|
|
<a-switch v-model:checked="reviewNoticeEnabled" checked-children="显示" un-checked-children="隐藏" />
|
|
|
|
|
</a-form-item>
|
|
|
|
|
<a-button type="primary" :loading="savingReviewNotice" @click="saveReviewNotice">保存审核提醒设置</a-button>
|
|
|
|
|
</a-form>
|
|
|
|
|
</a-card>
|
2026-09-05 23:46:35 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { onMounted, reactive, ref } from 'vue'
|
|
|
|
|
import { message } from 'ant-design-vue'
|
|
|
|
|
import { adminSystemParameterConfigApi, type SystemParameterConfigVO } from '@/api/admin'
|
|
|
|
|
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
const saving = ref(false)
|
2026-09-06 21:41:09 +08:00
|
|
|
const savingSmsProvider = ref(false)
|
2026-10-12 16:45:42 +08:00
|
|
|
const savingReviewNotice = ref(false)
|
2026-09-05 23:46:35 +08:00
|
|
|
const enabled = ref(true)
|
2026-10-12 16:45:42 +08:00
|
|
|
const reviewNoticeEnabled = ref(true)
|
2026-09-05 23:46:35 +08:00
|
|
|
const form = reactive<SystemParameterConfigVO>({
|
|
|
|
|
configGroup: 'USER',
|
|
|
|
|
configKey: 'DEFAULT_PASSWORD',
|
|
|
|
|
configName: '店长默认密码',
|
|
|
|
|
configValue: 'Fingertip@123',
|
|
|
|
|
enabled: 1,
|
|
|
|
|
remark: '新增或重置店长账号时使用的默认密码'
|
|
|
|
|
})
|
2026-09-06 21:41:09 +08:00
|
|
|
const smsProviderOptions = [
|
|
|
|
|
{ label: 'Spug 短信', value: 'SPUG' },
|
|
|
|
|
{ label: '阿里云短信认证服务', value: 'ALIYUN_SMS_VERIFY' }
|
|
|
|
|
]
|
|
|
|
|
const smsProviderForm = reactive<SystemParameterConfigVO>({
|
|
|
|
|
configGroup: 'SMS', configKey: 'SMS_PROVIDER', configName: '短信供应商', configValue: 'SPUG', enabled: 1,
|
|
|
|
|
remark: '全局切换短信供应商时同步验证码模板和 MessageHub 通道'
|
|
|
|
|
})
|
2026-10-12 16:45:42 +08:00
|
|
|
const reviewNoticeForm = reactive<SystemParameterConfigVO>({
|
|
|
|
|
configGroup: 'WORKBENCH',
|
|
|
|
|
configKey: 'MANAGER_REGISTRATION_REVIEW_NOTICE',
|
|
|
|
|
configName: '店长员工审核提醒',
|
|
|
|
|
configValue: 'true',
|
|
|
|
|
enabled: 1,
|
|
|
|
|
remark: '控制店长登录小程序后是否显式提示当前门店的待审核员工申请'
|
|
|
|
|
})
|
2026-09-05 23:46:35 +08:00
|
|
|
|
|
|
|
|
const load = async () => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
2026-10-12 16:45:42 +08:00
|
|
|
const [configs, smsConfigs, workbenchConfigs] = await Promise.all([
|
2026-09-06 21:41:09 +08:00
|
|
|
adminSystemParameterConfigApi.listConfigs('USER'),
|
2026-10-12 16:45:42 +08:00
|
|
|
adminSystemParameterConfigApi.listConfigs('SMS'),
|
|
|
|
|
adminSystemParameterConfigApi.listConfigs('WORKBENCH')
|
2026-09-06 21:41:09 +08:00
|
|
|
])
|
2026-09-05 23:46:35 +08:00
|
|
|
const config = configs.find(item => item.configKey === 'DEFAULT_PASSWORD')
|
|
|
|
|
if (config) {
|
|
|
|
|
Object.assign(form, config)
|
|
|
|
|
enabled.value = config.enabled === 1
|
|
|
|
|
}
|
2026-09-06 21:41:09 +08:00
|
|
|
const smsProvider = smsConfigs.find(item => item.configKey === 'SMS_PROVIDER')
|
|
|
|
|
if (smsProvider) Object.assign(smsProviderForm, smsProvider)
|
2026-10-12 16:45:42 +08:00
|
|
|
const reviewNotice = workbenchConfigs.find(item => item.configKey === 'MANAGER_REGISTRATION_REVIEW_NOTICE')
|
|
|
|
|
if (reviewNotice) {
|
|
|
|
|
Object.assign(reviewNoticeForm, reviewNotice)
|
|
|
|
|
reviewNoticeEnabled.value = reviewNotice.enabled === 1 && String(reviewNotice.configValue).toLowerCase() === 'true'
|
|
|
|
|
}
|
2026-09-05 23:46:35 +08:00
|
|
|
} catch (error) {
|
|
|
|
|
message.error(error instanceof Error ? error.message : '默认密码加载失败')
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-06 21:41:09 +08:00
|
|
|
const saveSmsProvider = async () => {
|
|
|
|
|
const confirmed = window.confirm('保存后会同步全部短信验证码场景的模板、通道和发送方式,确认切换吗?')
|
|
|
|
|
if (!confirmed) return
|
|
|
|
|
savingSmsProvider.value = true
|
|
|
|
|
try {
|
|
|
|
|
await adminSystemParameterConfigApi.saveConfig({ ...smsProviderForm, configValue: smsProviderForm.configValue.toUpperCase(), enabled: 1 })
|
|
|
|
|
message.success('短信供应商已切换')
|
|
|
|
|
await load()
|
|
|
|
|
} finally {
|
|
|
|
|
savingSmsProvider.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-05 23:46:35 +08:00
|
|
|
const save = async () => {
|
|
|
|
|
const password = form.configValue.trim()
|
|
|
|
|
if (password.length < 8 || password.length > 32) {
|
|
|
|
|
message.warning('默认密码长度需为 8-32 位')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const categoryCount = [/[0-9]/.test(password), /[a-z]/.test(password), /[A-Z]/.test(password), /[^A-Za-z0-9]/.test(password)].filter(Boolean).length
|
|
|
|
|
if (categoryCount < 3) {
|
|
|
|
|
message.warning('默认密码需至少包含数字、小写字母、大写字母、特殊符号中的 3 类')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
saving.value = true
|
|
|
|
|
try {
|
|
|
|
|
await adminSystemParameterConfigApi.saveConfig({ ...form, configValue: password, enabled: enabled.value ? 1 : 0 })
|
|
|
|
|
message.success('默认密码已保存')
|
|
|
|
|
await load()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
message.error(error instanceof Error ? error.message : '默认密码保存失败')
|
|
|
|
|
} finally {
|
|
|
|
|
saving.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-12 16:45:42 +08:00
|
|
|
const saveReviewNotice = async () => {
|
|
|
|
|
savingReviewNotice.value = true
|
|
|
|
|
try {
|
|
|
|
|
await adminSystemParameterConfigApi.saveConfig({
|
|
|
|
|
...reviewNoticeForm,
|
|
|
|
|
configValue: 'true',
|
|
|
|
|
enabled: reviewNoticeEnabled.value ? 1 : 0
|
|
|
|
|
})
|
|
|
|
|
message.success(reviewNoticeEnabled.value ? '店长员工审核提醒已开启' : '店长员工审核提醒已关闭')
|
|
|
|
|
await load()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
message.error(error instanceof Error ? error.message : '审核提醒设置保存失败')
|
|
|
|
|
} finally {
|
|
|
|
|
savingReviewNotice.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-05 23:46:35 +08:00
|
|
|
onMounted(() => {
|
|
|
|
|
void load()
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.system-settings {
|
|
|
|
|
display: grid;
|
|
|
|
|
gap: 18px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.settings-form {
|
|
|
|
|
max-width: 560px;
|
|
|
|
|
margin-top: 24px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|