重构Salon后台系统设置并整合个人账号信息
This commit is contained in:
@@ -1,97 +1,261 @@
|
||||
<template>
|
||||
<div class="system-settings">
|
||||
<a-page-header title="系统设置" sub-title="管理店长账号默认密码" />
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<header class="settings-header">
|
||||
<div>
|
||||
<span class="settings-eyebrow">SALON ADMIN</span>
|
||||
<h1>系统设置</h1>
|
||||
<p>集中管理后台运行参数、服务接入和当前账号。</p>
|
||||
</div>
|
||||
<span class="settings-health"><i />配置服务正常</span>
|
||||
</header>
|
||||
|
||||
<div class="settings-layout">
|
||||
<nav class="settings-nav" aria-label="系统设置分类">
|
||||
<span class="settings-nav__label">设置目录</span>
|
||||
<button
|
||||
v-for="item in sections"
|
||||
:key="item.key"
|
||||
type="button"
|
||||
:aria-pressed="activeSection === item.key"
|
||||
:class="['settings-nav__item', { 'is-active': activeSection === item.key }]"
|
||||
@click="activeSection = item.key"
|
||||
>
|
||||
<span class="settings-nav__icon"><component :is="item.icon" /></span>
|
||||
<span>{{ item.label }}</span>
|
||||
</button>
|
||||
<p class="settings-nav__hint">复杂业务继续在独立页面管理,这里只保留影响后台运行的设置。</p>
|
||||
</nav>
|
||||
|
||||
<main class="settings-pane" :aria-busy="loading">
|
||||
<section v-if="activeSection === 'runtime'" class="settings-section-panel">
|
||||
<div class="pane-head">
|
||||
<div>
|
||||
<h2>运行参数</h2>
|
||||
<p>控制账号创建和店长登录后的默认行为。</p>
|
||||
</div>
|
||||
<span />
|
||||
</div>
|
||||
|
||||
<div class="setting-group">
|
||||
<div class="setting-group__head setting-group__head--with-action"><strong>账号默认值</strong><span>USER</span><a-button size="small" type="primary" :loading="savingDefaultPassword" @click="saveDefaultPassword">保存密码设置</a-button></div>
|
||||
<div class="setting-row setting-row--last">
|
||||
<div class="setting-copy">
|
||||
<strong>后台新增用户默认密码</strong>
|
||||
<span>新增或重置店长账号时使用,不影响已有账号。</span>
|
||||
</div>
|
||||
<div class="setting-control setting-control--password">
|
||||
<a-input-password v-model:value="defaultPasswordForm.configValue" autocomplete="new-password" placeholder="请输入 8-32 位强密码" />
|
||||
<span class="control-note">{{ defaultPasswordForm.configValue ? '已填写' : '未设置' }}</span>
|
||||
<a-switch v-model:checked="defaultPasswordEnabled" checked-children="启用" un-checked-children="停用" />
|
||||
</div>
|
||||
<span :class="['status-pill', { 'is-muted': !defaultPasswordEnabled }]">{{ defaultPasswordEnabled ? '启用' : '停用' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-group">
|
||||
<div class="setting-group__head setting-group__head--with-action"><strong>店长登录提醒</strong><span>WORKBENCH</span><a-button size="small" type="primary" :loading="savingReviewNotice" @click="saveReviewNotice">保存提醒设置</a-button></div>
|
||||
<div class="setting-row setting-row--last">
|
||||
<div class="setting-copy">
|
||||
<strong>店长员工审核提醒</strong>
|
||||
<span>店长登录小程序时提醒处理待审核员工申请。</span>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<a-switch v-model:checked="reviewNoticeEnabled" checked-children="显示" un-checked-children="隐藏" />
|
||||
<span class="control-note">登录时{{ reviewNoticeEnabled ? '显示' : '不显示' }}</span>
|
||||
</div>
|
||||
<span :class="['status-pill', { 'is-muted': !reviewNoticeEnabled }]">{{ reviewNoticeEnabled ? '启用' : '停用' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="section-footnote">默认密码的强度规则仍按后台账号接口校验;审核入口和数量角标不会受提醒开关影响。</p>
|
||||
</section>
|
||||
|
||||
<section v-else-if="activeSection === 'services'" class="settings-section-panel">
|
||||
<div class="pane-head">
|
||||
<div>
|
||||
<h2>服务接入</h2>
|
||||
<p>维护后台地图选点和短信验证码使用的服务渠道。</p>
|
||||
</div>
|
||||
<span />
|
||||
</div>
|
||||
|
||||
<div class="setting-group">
|
||||
<div class="setting-group__head setting-group__head--with-action"><strong>地图服务</strong><span>MAP</span><a-button size="small" type="primary" :loading="savingMap" @click="saveMapConfig">保存地图设置</a-button></div>
|
||||
<div class="setting-row">
|
||||
<div class="setting-copy"><strong>默认地图渠道</strong><span>店铺选点和后台地图展示使用的默认渠道。</span></div>
|
||||
<div class="setting-control"><a-select v-model:value="mapForms.provider.configValue" :options="mapProviderOptions" /></div>
|
||||
<span class="status-pill">{{ mapEnabled ? '已配置' : '停用' }}</span>
|
||||
</div>
|
||||
<div v-for="item in mapKeyRows" :key="item.key" class="setting-row">
|
||||
<div class="setting-copy"><strong>{{ item.label }}</strong><span>{{ item.description }}</span></div>
|
||||
<div class="setting-control setting-control--password"><a-input-password v-model:value="mapForms[item.key].configValue" :placeholder="item.placeholder" /></div>
|
||||
<span class="status-pill" :class="{ 'is-muted': !mapForms[item.key].configValue }">{{ mapForms[item.key].configValue ? '已填写' : '待配置' }}</span>
|
||||
</div>
|
||||
<div class="setting-row setting-row--last">
|
||||
<div class="setting-copy"><strong>地图服务状态</strong><span>停用后店铺地图选点不会调用已保存的渠道。</span></div>
|
||||
<div class="setting-control"><a-switch v-model:checked="mapEnabled" checked-children="启用" un-checked-children="停用" /></div>
|
||||
<span :class="['status-pill', { 'is-muted': !mapEnabled }]">{{ mapEnabled ? '启用' : '停用' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-group">
|
||||
<div class="setting-group__head setting-group__head--with-action"><strong>短信服务</strong><span>SMS</span><a-button size="small" type="primary" :loading="savingSmsProvider" @click="saveSmsProvider">保存短信设置</a-button></div>
|
||||
<div class="setting-row setting-row--last">
|
||||
<div class="setting-copy"><strong>短信供应商</strong><span>统一控制登录、绑定和找回密码的验证码通道。</span></div>
|
||||
<div class="setting-control"><a-select v-model:value="smsProviderForm.configValue" :options="smsProviderOptions" /></div>
|
||||
<span class="warning-note">切换会影响全部验证码</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-else class="settings-section-panel">
|
||||
<div class="pane-head">
|
||||
<div>
|
||||
<h2>当前账号</h2>
|
||||
<p>查看后台账号、权限范围和当前门店,不与小程序账号设置混用。</p>
|
||||
</div>
|
||||
<span class="account-status"><i />会话正常</span>
|
||||
</div>
|
||||
|
||||
<div class="setting-group">
|
||||
<div class="setting-group__head"><strong>账号信息</strong><span>ACCOUNT</span></div>
|
||||
<div class="setting-row">
|
||||
<div class="setting-copy"><strong>登录账号</strong><span>用于进入后台的账号标识。</span></div>
|
||||
<div class="setting-value">{{ userInfo?.account || '--' }}</div>
|
||||
<span class="status-pill">当前账号</span>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<div class="setting-copy"><strong>显示昵称</strong><span>后台顶部和操作记录中使用的昵称。</span></div>
|
||||
<div class="setting-value">{{ userInfo?.nickname || '未设置昵称' }}</div>
|
||||
<span class="control-note">只读</span>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<div class="setting-copy"><strong>角色</strong><span>当前后台角色与平台管理范围。</span></div>
|
||||
<div class="setting-value">{{ roleLabel }}</div>
|
||||
<span v-if="isPlatformOverview" class="status-pill">平台总览</span>
|
||||
<span v-else class="control-note">只读</span>
|
||||
</div>
|
||||
<div class="setting-row setting-row--last">
|
||||
<div class="setting-copy"><strong>权限范围</strong><span>当前账号可访问的功能权限数量。</span></div>
|
||||
<div class="setting-value">{{ permissionCount }} 项权限</div>
|
||||
<span class="control-note">{{ shopScopeText }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-group">
|
||||
<div class="setting-group__head"><strong>{{ isPlatformOverview ? '管理范围' : '当前门店' }}</strong><span>SHOP</span></div>
|
||||
<div class="setting-row setting-row--last">
|
||||
<div class="setting-copy"><strong>{{ isPlatformOverview ? '平台总览模式' : '门店上下文' }}</strong><span>{{ isPlatformOverview ? '平台管理员可查看全平台数据。' : '切换后会刷新权限和业务数据上下文。' }}</span></div>
|
||||
<div v-if="isPlatformOverview" class="setting-value">平台总览模式</div>
|
||||
<a-select v-else-if="shopOptions.length > 1" v-model:value="selectedShopId" class="account-shop-select" :options="shopSelectOptions" :loading="shopSwitchLoading" @change="handleShopChange" />
|
||||
<div v-else class="setting-value">{{ currentShopName }}</div>
|
||||
<span class="control-note">{{ shopOptions.length > 1 ? `${shopOptions.length} 家可用门店` : '当前会话' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { adminSystemParameterConfigApi, type SystemParameterConfigVO } from '@/api/admin'
|
||||
import { ApiOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons-vue'
|
||||
import { adminAuthApi, adminSystemParameterConfigApi, type SystemParameterConfigVO } from '@/api/admin'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
import { runWithGlobalLoading } from '@/utils/action-loading'
|
||||
import { notifyShopThemeChanged } from '@/utils/shop-theme'
|
||||
import { getAdminCurrentShopName, getAdminRoleLabel, getAdminShopOptions, isBootstrapAdminUser, loadCachedAdminUserInfo } from './admin-helpers'
|
||||
|
||||
type SettingsSection = 'runtime' | 'services' | 'account'
|
||||
type MapKey = 'tencentWeb' | 'amapWeb' | 'amapMini'
|
||||
|
||||
const route = useRoute()
|
||||
const activeSection = ref<SettingsSection>(route.query.section === 'account' ? 'account' : 'runtime')
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const savingSmsProvider = ref(false)
|
||||
const savingDefaultPassword = ref(false)
|
||||
const savingReviewNotice = ref(false)
|
||||
const enabled = ref(true)
|
||||
const savingMap = ref(false)
|
||||
const savingSmsProvider = ref(false)
|
||||
const shopSwitchLoading = ref(false)
|
||||
const defaultPasswordEnabled = ref(true)
|
||||
const reviewNoticeEnabled = ref(true)
|
||||
const form = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'USER',
|
||||
configKey: 'DEFAULT_PASSWORD',
|
||||
configName: '店长默认密码',
|
||||
configValue: 'Fingertip@123',
|
||||
enabled: 1,
|
||||
remark: '新增或重置店长账号时使用的默认密码'
|
||||
})
|
||||
const mapEnabled = ref(true)
|
||||
const smsProviderOptions = [
|
||||
{ label: 'Spug 短信', value: 'SPUG' },
|
||||
{ label: '阿里云短信认证服务', value: 'ALIYUN_SMS_VERIFY' }
|
||||
]
|
||||
const mapProviderOptions = [
|
||||
{ label: '腾讯地图', value: 'TENCENT' },
|
||||
{ label: '高德地图', value: 'AMAP' }
|
||||
]
|
||||
const sections = [
|
||||
{ key: 'runtime' as const, label: '运行参数', icon: SettingOutlined },
|
||||
{ key: 'services' as const, label: '服务接入', icon: ApiOutlined },
|
||||
{ key: 'account' as const, label: '当前账号', icon: UserOutlined }
|
||||
]
|
||||
const mapKeyRows: Array<{ key: MapKey; label: string; description: string; placeholder: string }> = [
|
||||
{ key: 'tencentWeb', label: '腾讯 Web Key', description: '用于后台腾讯地图选点和 Web 展示。', placeholder: '填写腾讯 Web Key' },
|
||||
{ key: 'amapWeb', label: '高德 Web Key', description: '用于后台高德地图选点和 Web 展示。', placeholder: '填写高德 Web Key' },
|
||||
{ key: 'amapMini', label: '高德小程序 Key', description: '供 Salon 小程序后续地图能力使用。', placeholder: '填写高德小程序 Key' }
|
||||
]
|
||||
|
||||
const defaultPasswordForm = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'USER', configKey: 'DEFAULT_PASSWORD', configName: '后台新增用户默认密码', configValue: 'Fingertip@123', enabled: 1,
|
||||
remark: '后台新增用户不填写密码时使用;需满足 8-32 位且至少包含数字、小写字母、大写字母、特殊符号中的 3 类'
|
||||
})
|
||||
const reviewNoticeForm = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'WORKBENCH', configKey: 'MANAGER_REGISTRATION_REVIEW_NOTICE', configName: '店长员工审核提醒', configValue: 'true', enabled: 1,
|
||||
remark: '控制店长登录小程序后是否显式提示当前门店的待审核员工申请'
|
||||
})
|
||||
const smsProviderForm = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'SMS', configKey: 'SMS_PROVIDER', configName: '短信供应商', configValue: 'SPUG', enabled: 1,
|
||||
remark: '全局切换短信供应商时同步验证码模板和 MessageHub 通道'
|
||||
})
|
||||
const reviewNoticeForm = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'WORKBENCH',
|
||||
configKey: 'MANAGER_REGISTRATION_REVIEW_NOTICE',
|
||||
configName: '店长员工审核提醒',
|
||||
configValue: 'true',
|
||||
enabled: 1,
|
||||
remark: '控制店长登录小程序后是否显式提示当前门店的待审核员工申请'
|
||||
const mapForms = reactive<Record<MapKey | 'provider', SystemParameterConfigVO>>({
|
||||
provider: { configGroup: 'MAP', configKey: 'MAP_PROVIDER', configName: '当前地图渠道', configValue: 'TENCENT', enabled: 1, remark: 'TENCENT 或 AMAP;决定后台店铺选点默认使用哪个地图渠道' },
|
||||
tencentWeb: { configGroup: 'MAP', configKey: 'TENCENT_MAP_KEY', configName: '腾讯 Web Key', configValue: '', enabled: 1, remark: '用于后台腾讯地图选点和 Web 展示' },
|
||||
amapWeb: { configGroup: 'MAP', configKey: 'AMAP_WEB_KEY', configName: '高德 Web Key', configValue: '', enabled: 1, remark: '用于后台高德地图选点和 Web 展示' },
|
||||
amapMini: { configGroup: 'MAP', configKey: 'AMAP_MINI_KEY', configName: '高德小程序 Key', configValue: '', enabled: 1, remark: '供 Salon 小程序地图能力使用' }
|
||||
})
|
||||
|
||||
const userInfo = ref(loadCachedAdminUserInfo())
|
||||
const selectedShopId = ref(userInfo.value?.shopId ? String(userInfo.value.shopId) : undefined)
|
||||
const { userPermissions, loadUserPermissions } = usePermission()
|
||||
const currentShopName = computed(() => getAdminCurrentShopName(userInfo.value))
|
||||
const isPlatformOverview = computed(() => isBootstrapAdminUser(userInfo.value))
|
||||
const roleLabel = computed(() => getAdminRoleLabel(userInfo.value?.type))
|
||||
const shopOptions = computed(() => getAdminShopOptions(userInfo.value))
|
||||
const shopSelectOptions = computed(() => shopOptions.value.map(shop => ({ label: shop.name, value: shop.id })))
|
||||
const permissionCount = computed(() => userPermissions.value.length)
|
||||
const shopScopeText = computed(() => shopOptions.value.length ? shopOptions.value.map(item => item.name).join(' / ') : (isPlatformOverview.value ? '平台总览模式' : '游客模式'))
|
||||
|
||||
const persistAdminSession = (payload: any) => {
|
||||
localStorage.setItem('adminAccessToken', payload.accessToken)
|
||||
localStorage.setItem('adminRefreshToken', payload.refreshToken)
|
||||
localStorage.setItem('adminUserInfo', JSON.stringify(payload.userInfo))
|
||||
sessionStorage.setItem('adminAccessToken', payload.accessToken)
|
||||
}
|
||||
|
||||
const refreshLocalUserInfo = () => {
|
||||
userInfo.value = loadCachedAdminUserInfo()
|
||||
selectedShopId.value = userInfo.value?.shopId ? String(userInfo.value.shopId) : undefined
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const [configs, smsConfigs, workbenchConfigs] = await Promise.all([
|
||||
const [userConfigs, smsConfigs, workbenchConfigs, mapConfigs] = await Promise.all([
|
||||
adminSystemParameterConfigApi.listConfigs('USER'),
|
||||
adminSystemParameterConfigApi.listConfigs('SMS'),
|
||||
adminSystemParameterConfigApi.listConfigs('WORKBENCH')
|
||||
adminSystemParameterConfigApi.listConfigs('WORKBENCH'),
|
||||
adminSystemParameterConfigApi.listConfigs('MAP')
|
||||
])
|
||||
const config = configs.find(item => item.configKey === 'DEFAULT_PASSWORD')
|
||||
if (config) {
|
||||
Object.assign(form, config)
|
||||
enabled.value = config.enabled === 1
|
||||
const defaultPassword = userConfigs.find(item => item.configKey === 'DEFAULT_PASSWORD')
|
||||
if (defaultPassword) {
|
||||
Object.assign(defaultPasswordForm, defaultPassword)
|
||||
defaultPasswordEnabled.value = defaultPassword.enabled === 1
|
||||
}
|
||||
const smsProvider = smsConfigs.find(item => item.configKey === 'SMS_PROVIDER')
|
||||
if (smsProvider) Object.assign(smsProviderForm, smsProvider)
|
||||
@@ -100,13 +264,76 @@ const load = async () => {
|
||||
Object.assign(reviewNoticeForm, reviewNotice)
|
||||
reviewNoticeEnabled.value = reviewNotice.enabled === 1 && String(reviewNotice.configValue).toLowerCase() === 'true'
|
||||
}
|
||||
const mapByKey = Object.fromEntries(mapConfigs.map(item => [item.configKey, item])) as Record<string, SystemParameterConfigVO | undefined>
|
||||
if (mapByKey.MAP_PROVIDER) Object.assign(mapForms.provider, mapByKey.MAP_PROVIDER)
|
||||
if (mapByKey.TENCENT_MAP_KEY) Object.assign(mapForms.tencentWeb, mapByKey.TENCENT_MAP_KEY)
|
||||
if (mapByKey.AMAP_WEB_KEY) Object.assign(mapForms.amapWeb, mapByKey.AMAP_WEB_KEY)
|
||||
if (mapByKey.AMAP_MINI_KEY) Object.assign(mapForms.amapMini, mapByKey.AMAP_MINI_KEY)
|
||||
mapForms.provider.configValue = mapForms.provider.configValue === 'AMAP' ? 'AMAP' : 'TENCENT'
|
||||
mapEnabled.value = mapForms.provider.enabled === 1
|
||||
refreshLocalUserInfo()
|
||||
await loadUserPermissions()
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '默认密码加载失败')
|
||||
message.error(error instanceof Error ? error.message : '系统设置加载失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const validateDefaultPassword = () => {
|
||||
const password = defaultPasswordForm.configValue.trim()
|
||||
if (password.length < 8 || password.length > 32) {
|
||||
message.warning('默认密码长度需为 8-32 位')
|
||||
return false
|
||||
}
|
||||
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 false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
const saveDefaultPassword = async () => {
|
||||
if (!validateDefaultPassword()) return
|
||||
savingDefaultPassword.value = true
|
||||
try {
|
||||
await adminSystemParameterConfigApi.saveConfig({ ...defaultPasswordForm, configValue: defaultPasswordForm.configValue.trim(), enabled: defaultPasswordEnabled.value ? 1 : 0 })
|
||||
message.success('账号默认密码已保存')
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '默认密码保存失败')
|
||||
} finally {
|
||||
savingDefaultPassword.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const saveReviewNotice = async () => {
|
||||
savingReviewNotice.value = true
|
||||
try {
|
||||
await adminSystemParameterConfigApi.saveConfig({ ...reviewNoticeForm, configValue: 'true', enabled: reviewNoticeEnabled.value ? 1 : 0 })
|
||||
message.success(reviewNoticeEnabled.value ? '店长员工审核提醒已开启' : '店长员工审核提醒已关闭')
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '审核提醒设置保存失败')
|
||||
} finally {
|
||||
savingReviewNotice.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const saveMapConfig = async () => {
|
||||
savingMap.value = true
|
||||
try {
|
||||
await adminSystemParameterConfigApi.saveConfig({ ...mapForms.provider, configValue: String(mapForms.provider.configValue).toUpperCase(), enabled: mapEnabled.value ? 1 : 0 })
|
||||
await adminSystemParameterConfigApi.saveConfig({ ...mapForms.tencentWeb, enabled: mapEnabled.value ? 1 : 0 })
|
||||
await adminSystemParameterConfigApi.saveConfig({ ...mapForms.amapWeb, enabled: mapEnabled.value ? 1 : 0 })
|
||||
await adminSystemParameterConfigApi.saveConfig({ ...mapForms.amapMini, enabled: mapEnabled.value ? 1 : 0 })
|
||||
message.success('地图配置已保存')
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '地图配置保存失败')
|
||||
} finally {
|
||||
savingMap.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const saveSmsProvider = async () => {
|
||||
const confirmed = window.confirm('保存后会同步全部短信验证码场景的模板、通道和发送方式,确认切换吗?')
|
||||
if (!confirmed) return
|
||||
@@ -114,49 +341,31 @@ const saveSmsProvider = async () => {
|
||||
try {
|
||||
await adminSystemParameterConfigApi.saveConfig({ ...smsProviderForm, configValue: smsProviderForm.configValue.toUpperCase(), enabled: 1 })
|
||||
message.success('短信供应商已切换')
|
||||
await load()
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '短信供应商保存失败')
|
||||
} finally {
|
||||
savingSmsProvider.value = false
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
const handleShopChange = async (shopId: unknown) => {
|
||||
if ((typeof shopId !== 'string' && typeof shopId !== 'number') || !String(shopId) || String(shopId) === String(userInfo.value?.shopId || '')) return
|
||||
shopSwitchLoading.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
|
||||
}
|
||||
}
|
||||
|
||||
const saveReviewNotice = async () => {
|
||||
savingReviewNotice.value = true
|
||||
try {
|
||||
await adminSystemParameterConfigApi.saveConfig({
|
||||
...reviewNoticeForm,
|
||||
configValue: 'true',
|
||||
enabled: reviewNoticeEnabled.value ? 1 : 0
|
||||
await runWithGlobalLoading(async () => {
|
||||
const response = await adminAuthApi.switchShop(String(shopId))
|
||||
persistAdminSession(response as any)
|
||||
refreshLocalUserInfo()
|
||||
await loadUserPermissions()
|
||||
notifyShopThemeChanged()
|
||||
})
|
||||
message.success(reviewNoticeEnabled.value ? '店长员工审核提醒已开启' : '店长员工审核提醒已关闭')
|
||||
await load()
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '审核提醒设置保存失败')
|
||||
message.success('门店切换成功')
|
||||
window.location.reload()
|
||||
} catch (error: any) {
|
||||
selectedShopId.value = userInfo.value?.shopId ? String(userInfo.value.shopId) : undefined
|
||||
message.error(error?.message || '切换门店失败')
|
||||
} finally {
|
||||
savingReviewNotice.value = false
|
||||
shopSwitchLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,13 +375,63 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.system-settings {
|
||||
display: grid;
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
.settings-form {
|
||||
max-width: 560px;
|
||||
margin-top: 24px;
|
||||
.system-settings { display: grid; gap: 22px; color: var(--admin-mobile-ink); }
|
||||
.settings-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
|
||||
.settings-eyebrow { color: var(--theme-primary-action); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
|
||||
.settings-header h1 { margin: 7px 0 4px; font-size: 27px; }
|
||||
.settings-header p, .pane-head p { margin: 0; color: var(--admin-mobile-muted); font-size: 13px; }
|
||||
.settings-health, .account-status { display: inline-flex; align-items: center; gap: 7px; color: var(--admin-mobile-muted); font-size: 12px; white-space: nowrap; }
|
||||
.settings-health i, .account-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--theme-primary); }
|
||||
.settings-layout { display: grid; grid-template-columns: 214px minmax(0, 1fr); gap: 22px; align-items: start; }
|
||||
.settings-nav { padding: 9px; border: 1px solid var(--admin-mobile-border); border-radius: 16px; background: color-mix(in srgb, var(--theme-card-bg) 84%, transparent); }
|
||||
.settings-nav__label { display: block; padding: 7px 10px 8px; color: var(--admin-mobile-muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
|
||||
.settings-nav__item { display: flex; width: 100%; align-items: center; gap: 9px; padding: 11px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--admin-mobile-muted); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
|
||||
.settings-nav__item:hover, .settings-nav__item.is-active { background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); font-weight: 700; }
|
||||
.settings-nav__icon { display: inline-flex; width: 22px; justify-content: center; color: var(--theme-primary); }
|
||||
.settings-nav__hint { margin: 13px 8px 5px; padding-top: 12px; border-top: 1px solid var(--admin-mobile-border); color: var(--admin-mobile-muted); font-size: 11px; line-height: 1.55; }
|
||||
.settings-pane, .settings-section-panel { min-width: 0; }
|
||||
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 2px 0 14px; border-bottom: 1px solid var(--admin-mobile-border); }
|
||||
.pane-head h2 { margin: 0 0 5px; font-size: 18px; }
|
||||
.setting-group { margin-top: 17px; border-top: 1px solid var(--admin-mobile-border); }
|
||||
.setting-group__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 13px 2px 8px; }
|
||||
.setting-group__head--with-action { align-items: center; }
|
||||
.setting-group__head--with-action .ant-btn { margin-left: auto; }
|
||||
.setting-group__head strong { font-size: 13px; }
|
||||
.setting-group__head span { color: var(--admin-mobile-muted); font-size: 11px; letter-spacing: .08em; }
|
||||
.setting-row { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(220px, 1.35fr) auto; align-items: center; gap: 18px; min-height: 72px; padding: 10px 14px; border-bottom: 1px solid color-mix(in srgb, var(--admin-mobile-border) 70%, transparent); background: color-mix(in srgb, var(--theme-card-bg) 82%, transparent); }
|
||||
.setting-row:first-of-type { border-radius: 10px 10px 0 0; }
|
||||
.setting-row--last { border-radius: 0 0 10px 10px; }
|
||||
.setting-copy { display: grid; gap: 4px; min-width: 0; }
|
||||
.setting-copy strong { font-size: 13px; }
|
||||
.setting-copy span { color: var(--admin-mobile-muted); font-size: 11px; line-height: 1.45; }
|
||||
.setting-control { display: flex; align-items: center; gap: 9px; min-width: 0; }
|
||||
.setting-control > :deep(.ant-select) { width: 100%; }
|
||||
.setting-control--password > :deep(.ant-input-affix-wrapper) { flex: 1; width: auto; min-width: 100px; }
|
||||
.setting-control--password { min-width: 0; }
|
||||
.control-note { color: var(--admin-mobile-muted); font-size: 11px; white-space: nowrap; }
|
||||
.setting-row > .control-note { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
|
||||
.setting-value { min-width: 0; color: var(--admin-mobile-ink); font-size: 13px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.status-pill { display: inline-flex; align-items: center; gap: 5px; color: var(--theme-primary-action); font-size: 11px; white-space: nowrap; }
|
||||
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--theme-primary); }
|
||||
.status-pill.is-muted { color: var(--admin-mobile-muted); }
|
||||
.status-pill.is-muted::before { background: var(--admin-mobile-muted); }
|
||||
.warning-note { display: inline-flex; align-items: center; gap: 5px; color: #a66d22; font-size: 11px; white-space: nowrap; }
|
||||
.warning-note::before { content: '!'; display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: #fff3d9; font-size: 10px; font-weight: 800; }
|
||||
.section-footnote { margin: 12px 2px 0; color: var(--admin-mobile-muted); font-size: 11px; }
|
||||
.account-shop-select { width: 100%; min-width: 0; }
|
||||
@media (max-width: 760px) {
|
||||
.settings-header { align-items: flex-start; }
|
||||
.settings-health, .account-status { display: none; }
|
||||
.settings-layout { grid-template-columns: 1fr; gap: 14px; }
|
||||
.settings-nav { display: flex; gap: 4px; overflow-x: auto; padding: 6px; }
|
||||
.settings-nav__label, .settings-nav__hint { display: none; }
|
||||
.settings-nav__item { width: auto; flex: 0 0 auto; white-space: nowrap; }
|
||||
.pane-head { align-items: flex-start; flex-direction: column; }
|
||||
.pane-head .ant-btn { width: 100%; }
|
||||
.setting-group__head--with-action { flex-wrap: wrap; }
|
||||
.setting-group__head--with-action .ant-btn { width: 100%; margin-left: 0; }
|
||||
.setting-row { grid-template-columns: 1fr; gap: 9px; padding: 13px 12px; }
|
||||
.setting-control { width: 100%; }
|
||||
.status-pill, .warning-note, .control-note { justify-self: start; }
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user