重构Salon后台系统设置并整合个人账号信息
This commit is contained in:
@@ -176,7 +176,7 @@ const visibleModules = computed(() => {
|
||||
{
|
||||
key: 'parameters',
|
||||
title: '参数管理',
|
||||
description: '维护地图 Key、短信 MessageHub 等系统参数。',
|
||||
description: '维护短信验证码场景的 MessageHub 模板、队列和通道。',
|
||||
path: '/admin/messagehub-push-configs',
|
||||
icon: SettingOutlined,
|
||||
permissionCode: 'messagehub:config:manage'
|
||||
|
||||
@@ -3,75 +3,11 @@
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<h2>参数管理</h2>
|
||||
<p>统一维护地图 Key、短信 MessageHub 对接参数等平台级配置,仅平台管理员可修改。</p>
|
||||
<p>维护短信验证码场景的 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="当前地图渠道">
|
||||
<a-radio-group v-model:value="mapProvider">
|
||||
<a-radio-button value="TENCENT">腾讯地图</a-radio-button>
|
||||
<a-radio-button value="AMAP">高德地图</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="腾讯 Web Key">
|
||||
<a-input-password v-model:value="mapForms.tencentWeb.configValue" placeholder="用于后台腾讯地图选点和 Web 展示" />
|
||||
</a-form-item>
|
||||
<a-form-item label="高德 Web Key">
|
||||
<a-input-password v-model:value="mapForms.amapWeb.configValue" placeholder="用于后台高德地图选点和 Web 展示" />
|
||||
</a-form-item>
|
||||
<a-form-item label="高德小程序 Key">
|
||||
<a-input-password v-model:value="mapForms.amapMini.configValue" placeholder="用于后续小程序端高德 SDK / API 调用" />
|
||||
</a-form-item>
|
||||
<a-form-item label="备注">
|
||||
<a-textarea v-model:value="mapRemark" :rows="2" placeholder="例如:默认使用腾讯地图,高德小程序 Key 单独申请填写" />
|
||||
</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-card title="用户默认密码" :bordered="false">
|
||||
<a-form layout="vertical">
|
||||
<a-alert
|
||||
type="info"
|
||||
show-icon
|
||||
message="后台新增用户时,密码留空会自动使用这里配置的默认密码。"
|
||||
class="inline-alert"
|
||||
/>
|
||||
<a-form-item label="后台新增用户默认密码">
|
||||
<a-input-password
|
||||
v-model:value="defaultPasswordForm.configValue"
|
||||
placeholder="请输入 8-32 位强密码"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注">
|
||||
<a-textarea v-model:value="defaultPasswordForm.remark" :rows="2" />
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-switch v-model:checked="defaultPasswordEnabled" checked-children="启用" un-checked-children="停用" />
|
||||
<a-button type="primary" :loading="savingDefaultPassword" @click="saveDefaultPasswordConfig">
|
||||
保存默认密码
|
||||
</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" :scroll="{ x: 'max-content' }">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'scene'">
|
||||
@@ -150,9 +86,7 @@ import { message } from 'ant-design-vue'
|
||||
*/
|
||||
import {
|
||||
adminMessageHubPushConfigApi,
|
||||
adminSystemParameterConfigApi,
|
||||
type MessageHubPushConfigVO,
|
||||
type SystemParameterConfigVO
|
||||
type MessageHubPushConfigVO
|
||||
} from '@/api/admin'
|
||||
|
||||
/** loading is a reactive state variable used by the template and event handlers. */
|
||||
@@ -182,59 +116,6 @@ const testPhone = ref('')
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const configs = ref<MessageHubPushConfigVO[]>([])
|
||||
/**
|
||||
* Purpose: savingMap supports MessageHubPushConfigsView.vue by holding or executing the saving map page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const savingMap = ref(false)
|
||||
const savingDefaultPassword = ref(false)
|
||||
/**
|
||||
* Purpose: mapEnabled supports MessageHubPushConfigsView.vue by holding or executing the map enabled page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const mapEnabled = ref(true)
|
||||
const defaultPasswordEnabled = ref(true)
|
||||
/**
|
||||
* Purpose: mapProvider supports MessageHubPushConfigsView.vue by holding or executing the map provider page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const mapProvider = ref<'TENCENT' | 'AMAP'>('TENCENT')
|
||||
/**
|
||||
* Purpose: mapRemark supports MessageHubPushConfigsView.vue by holding or executing the map remark page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const mapRemark = ref('地图渠道由平台管理员选择;高德 Web Key 与高德小程序 Key 分开填写。')
|
||||
/**
|
||||
* Purpose: createMapForm supports MessageHubPushConfigsView.vue by holding or executing the create map form page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const createMapForm = (configKey: string, configName: string, remark: string) => ({
|
||||
configGroup: 'MAP',
|
||||
configKey,
|
||||
configName,
|
||||
configValue: '',
|
||||
enabled: 1,
|
||||
remark
|
||||
})
|
||||
/**
|
||||
* Purpose: mapForms supports MessageHubPushConfigsView.vue by holding or executing the map forms page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const mapForms = reactive({
|
||||
provider: createMapForm('MAP_PROVIDER', '当前地图渠道', 'TENCENT 或 AMAP;决定后台店铺选点默认使用哪个地图渠道'),
|
||||
tencentWeb: createMapForm('TENCENT_MAP_KEY', '腾讯 Web Key', '用于后台腾讯地图选点和 Web 展示'),
|
||||
amapWeb: createMapForm('AMAP_WEB_KEY', '高德 Web Key', '用于后台高德地图选点和 Web 展示'),
|
||||
amapMini: createMapForm('AMAP_MINI_KEY', '高德小程序 Key', '用于后续小程序端高德 SDK / API 调用')
|
||||
})
|
||||
const defaultPasswordForm = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'USER',
|
||||
configKey: 'DEFAULT_PASSWORD',
|
||||
configName: '后台新增用户默认密码',
|
||||
configValue: 'Fingertip@123',
|
||||
enabled: 1,
|
||||
remark: '后台新增用户不填写密码时使用;需满足 8-32 位且至少包含数字、小写字母、大写字母、特殊符号中的 3 类'
|
||||
})
|
||||
|
||||
/**
|
||||
* Purpose: sceneOptions supports MessageHubPushConfigsView.vue by holding or executing the scene options page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -292,102 +173,12 @@ const columns = [
|
||||
const load = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const [messageConfigs, mapConfigs, userConfigs] = await Promise.all([
|
||||
adminMessageHubPushConfigApi.listConfigs(),
|
||||
adminSystemParameterConfigApi.listConfigs('MAP'),
|
||||
adminSystemParameterConfigApi.listConfigs('USER')
|
||||
])
|
||||
configs.value = messageConfigs
|
||||
const providerConfig = mapConfigs.find(item => item.configKey === 'MAP_PROVIDER')
|
||||
const tencentMapConfig = mapConfigs.find(item => item.configKey === 'TENCENT_MAP_KEY')
|
||||
const amapWebConfig = mapConfigs.find(item => item.configKey === 'AMAP_WEB_KEY')
|
||||
const amapMiniConfig = mapConfigs.find(item => item.configKey === 'AMAP_MINI_KEY')
|
||||
if (providerConfig?.configValue) {
|
||||
mapProvider.value = providerConfig.configValue === 'AMAP' ? 'AMAP' : 'TENCENT'
|
||||
mapEnabled.value = providerConfig.enabled === 1
|
||||
Object.assign(mapForms.provider, providerConfig)
|
||||
}
|
||||
if (tencentMapConfig) Object.assign(mapForms.tencentWeb, tencentMapConfig)
|
||||
if (amapWebConfig) Object.assign(mapForms.amapWeb, amapWebConfig)
|
||||
if (amapMiniConfig) Object.assign(mapForms.amapMini, amapMiniConfig)
|
||||
const defaultPasswordConfig = userConfigs.find(item => item.configKey === 'DEFAULT_PASSWORD')
|
||||
if (defaultPasswordConfig) {
|
||||
Object.assign(defaultPasswordForm, defaultPasswordConfig)
|
||||
defaultPasswordEnabled.value = defaultPasswordConfig.enabled === 1
|
||||
}
|
||||
configs.value = await adminMessageHubPushConfigApi.listConfigs()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: saveMapConfig supports MessageHubPushConfigsView.vue by holding or executing the save map config page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const saveMapConfig = async () => {
|
||||
savingMap.value = true
|
||||
try {
|
||||
await adminSystemParameterConfigApi.saveConfig({
|
||||
...mapForms.provider,
|
||||
configValue: mapProvider.value,
|
||||
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('地图配置已保存')
|
||||
await load()
|
||||
} finally {
|
||||
savingMap.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const validateDefaultPasswordInput = () => {
|
||||
const password = defaultPasswordForm.configValue.trim()
|
||||
if (password.length < 8 || password.length > 32) {
|
||||
message.warning('默认密码长度需为 8-32 位')
|
||||
return false
|
||||
}
|
||||
const categoryCount = [
|
||||
/\d/.test(password),
|
||||
/[a-z]/.test(password),
|
||||
/[A-Z]/.test(password),
|
||||
/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(password)
|
||||
].filter(Boolean).length
|
||||
if (categoryCount < 3) {
|
||||
message.warning('默认密码需至少包含数字、小写字母、大写字母、特殊符号中的 3 类')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
const saveDefaultPasswordConfig = async () => {
|
||||
if (!validateDefaultPasswordInput()) {
|
||||
return
|
||||
}
|
||||
savingDefaultPassword.value = true
|
||||
try {
|
||||
await adminSystemParameterConfigApi.saveConfig({
|
||||
...defaultPasswordForm,
|
||||
configValue: defaultPasswordForm.configValue.trim(),
|
||||
enabled: defaultPasswordEnabled.value ? 1 : 0
|
||||
})
|
||||
message.success('默认密码已保存')
|
||||
await load()
|
||||
} finally {
|
||||
savingDefaultPassword.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** resetForm is a local helper used by this page script. */
|
||||
const resetForm = () => Object.assign(form, {
|
||||
sceneCode: 'USER_LOGIN_SMS_CODE',
|
||||
|
||||
@@ -1,186 +1,67 @@
|
||||
<template>
|
||||
<div class="admin-profile">
|
||||
<section class="admin-page-intro">
|
||||
<span class="admin-page-intro__eyebrow">{{ userInfo?.account || '后台账号' }}</span>
|
||||
<h1 class="admin-page-intro__title">{{ userInfo?.nickname || '未设置昵称' }}</h1>
|
||||
<div class="admin-page-intro__meta">
|
||||
<span class="admin-page-chip">权限 {{ permissionCount }}</span>
|
||||
<span class="admin-page-chip">门店 {{ shopOptions.length || 0 }}</span>
|
||||
<span class="admin-page-chip">{{ roleLabel }}</span>
|
||||
<span v-if="isPlatformOverview" class="admin-page-chip">平台总览</span>
|
||||
<section class="profile-head">
|
||||
<div>
|
||||
<span class="profile-eyebrow">后台账号</span>
|
||||
<h1>{{ userInfo?.nickname || '未设置昵称' }}</h1>
|
||||
<p>{{ userInfo?.account || '当前登录账号' }} · {{ roleLabel }}</p>
|
||||
</div>
|
||||
<span class="profile-chip">{{ isPlatformOverview ? '平台总览' : currentShopName }}</span>
|
||||
</section>
|
||||
|
||||
<div class="admin-mobile-grid admin-mobile-grid--two">
|
||||
<section class="admin-mobile-stat">
|
||||
<div class="admin-mobile-stat__label">当前门店</div>
|
||||
<div class="admin-mobile-stat__value">{{ currentShopName }}</div>
|
||||
</section>
|
||||
<section class="admin-mobile-stat">
|
||||
<div class="admin-mobile-stat__label">角色</div>
|
||||
<div class="admin-mobile-stat__value">{{ roleLabel }}</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section class="admin-mobile-section-card">
|
||||
<div class="admin-mobile-section-card__title">账号信息</div>
|
||||
<div class="profile-meta-list">
|
||||
<div class="profile-meta-list__row">
|
||||
<span>账号</span>
|
||||
<strong>{{ userInfo?.account || '--' }}</strong>
|
||||
</div>
|
||||
<div class="profile-meta-list__row">
|
||||
<span>昵称</span>
|
||||
<strong>{{ userInfo?.nickname || '--' }}</strong>
|
||||
</div>
|
||||
<div class="profile-meta-list__row">
|
||||
<span>权限数量</span>
|
||||
<strong>{{ permissionCount }}</strong>
|
||||
</div>
|
||||
<div class="profile-meta-list__row">
|
||||
<span>可登录门店</span>
|
||||
<strong>{{ shopScopeText }}</strong>
|
||||
<section class="profile-section">
|
||||
<div class="profile-section__head">
|
||||
<div>
|
||||
<h2>账号与门店</h2>
|
||||
<p>账号资料、权限范围和门店切换已集中到系统设置。</p>
|
||||
</div>
|
||||
</div>
|
||||
<button class="profile-link" type="button" @click="router.push({ path: '/admin/settings', query: { section: 'account' } })">
|
||||
<span class="profile-link__icon">◎</span>
|
||||
<span class="profile-link__body"><strong>打开当前账号设置</strong><small>查看后台账号、权限范围和可用门店</small></span>
|
||||
<span class="profile-link__arrow">›</span>
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<section class="admin-mobile-section-card">
|
||||
<div class="admin-mobile-section-card__title">{{ isPlatformOverview ? '管理范围' : '门店切换' }}</div>
|
||||
<div v-if="isPlatformOverview" class="profile-static-shop">
|
||||
平台总览模式,店铺业务仅可查看
|
||||
<section class="profile-section">
|
||||
<div class="profile-section__head">
|
||||
<div>
|
||||
<h2>常用入口</h2>
|
||||
<p>继续处理日常经营工作。</p>
|
||||
</div>
|
||||
</div>
|
||||
<a-select
|
||||
v-else-if="shopOptions.length > 1"
|
||||
v-model:value="selectedShopId"
|
||||
class="profile-shop-select"
|
||||
:options="shopSelectOptions"
|
||||
:loading="shopSwitchLoading"
|
||||
@change="handleShopChange"
|
||||
/>
|
||||
<div v-else class="profile-static-shop">
|
||||
{{ currentShopName }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="admin-mobile-section-card">
|
||||
<div class="admin-mobile-section-card__title">常用入口</div>
|
||||
<div class="profile-actions">
|
||||
<a-button type="default" size="large" block @click="router.push('/admin/orders')">查看订单</a-button>
|
||||
<a-button type="default" size="large" block @click="router.push('/admin/manage')">进入经营模块</a-button>
|
||||
<a-button type="default" size="large" @click="router.push('/admin/orders')">查看订单</a-button>
|
||||
<a-button type="default" size="large" @click="router.push('/admin/manage')">进入经营模块</a-button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="admin-mobile-section-card">
|
||||
<div class="admin-mobile-section-card__title">退出登录</div>
|
||||
<section class="profile-section profile-section--logout">
|
||||
<div class="profile-section__head">
|
||||
<div>
|
||||
<h2>退出登录</h2>
|
||||
<p>退出后需要重新登录后台。</p>
|
||||
</div>
|
||||
</div>
|
||||
<a-button danger size="large" block @click="handleLogout">退出当前账号</a-button>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* ProfileView 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 { computed, onMounted, ref } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { adminAuthApi } from '@/api/admin'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
import { runWithGlobalLoading } from '@/utils/action-loading'
|
||||
import { notifyShopThemeChanged } from '@/utils/shop-theme'
|
||||
import { completeAdminLogout } from '@/utils/admin-logout'
|
||||
import {
|
||||
getAdminCurrentShopName,
|
||||
getAdminRoleLabel,
|
||||
getAdminShopOptions,
|
||||
isBootstrapAdminUser,
|
||||
loadCachedAdminUserInfo
|
||||
} from './admin-helpers'
|
||||
import { runWithGlobalLoading } from '@/utils/action-loading'
|
||||
import { getAdminCurrentShopName, getAdminRoleLabel, isBootstrapAdminUser, loadCachedAdminUserInfo } from './admin-helpers'
|
||||
|
||||
/**
|
||||
* Purpose: router supports ProfileView.vue by holding or executing the router page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const router = useRouter()
|
||||
const { userPermissions, loadUserPermissions } = usePermission()
|
||||
|
||||
/** userInfo is a reactive state variable used by the template and event handlers. */
|
||||
const userInfo = ref(loadCachedAdminUserInfo())
|
||||
/** selectedShopId is a reactive state variable used by the template and event handlers. */
|
||||
const selectedShopId = ref(userInfo.value?.shopId ? String(userInfo.value.shopId) : undefined)
|
||||
/** shopSwitchLoading is a reactive state variable used by the template and event handlers. */
|
||||
const shopSwitchLoading = ref(false)
|
||||
|
||||
/** currentShopName is a reactive state variable used by the template and event handlers. */
|
||||
const currentShopName = computed(() => getAdminCurrentShopName(userInfo.value))
|
||||
/**
|
||||
* Purpose: isPlatformOverview supports ProfileView.vue by holding or executing the is platform overview page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const isPlatformOverview = computed(() => isBootstrapAdminUser(userInfo.value))
|
||||
/** roleLabel is a reactive state variable used by the template and event handlers. */
|
||||
const roleLabel = computed(() => getAdminRoleLabel(userInfo.value?.type))
|
||||
/** shopOptions is a reactive state variable used by the template and event handlers. */
|
||||
const shopOptions = computed(() => getAdminShopOptions(userInfo.value))
|
||||
/** shopSelectOptions is a reactive state variable used by the template and event handlers. */
|
||||
const shopSelectOptions = computed(() => {
|
||||
const options = shopOptions.value.map(shop => ({ label: shop.name, value: shop.id }))
|
||||
return options
|
||||
})
|
||||
/** permissionCount is a reactive state variable used by the template and event handlers. */
|
||||
const permissionCount = computed(() => userPermissions.value.length)
|
||||
/** shopScopeText is a reactive state variable used by the template and event handlers. */
|
||||
const shopScopeText = computed(() => {
|
||||
if (!shopOptions.value.length) {
|
||||
return isPlatformOverview.value ? '平台总览模式' : '游客模式'
|
||||
}
|
||||
return shopOptions.value.map(item => item.name).join(' / ')
|
||||
})
|
||||
const currentShopName = computed(() => getAdminCurrentShopName(userInfo.value))
|
||||
const isPlatformOverview = computed(() => isBootstrapAdminUser(userInfo.value))
|
||||
|
||||
/** persistAdminSession is a local helper used by this page script. */
|
||||
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)
|
||||
}
|
||||
|
||||
/** refreshLocalUserInfo is a local helper used by this page script. */
|
||||
const refreshLocalUserInfo = () => {
|
||||
userInfo.value = loadCachedAdminUserInfo()
|
||||
selectedShopId.value = userInfo.value?.shopId ? String(userInfo.value.shopId) : undefined
|
||||
}
|
||||
|
||||
/** handleShopChange is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handleShopChange = async (shopId: unknown) => {
|
||||
if (typeof shopId !== 'string' && typeof shopId !== 'number') {
|
||||
return
|
||||
}
|
||||
const normalizedShopId = String(shopId)
|
||||
if (!normalizedShopId || normalizedShopId === String(userInfo.value?.shopId || '')) {
|
||||
return
|
||||
}
|
||||
shopSwitchLoading.value = true
|
||||
try {
|
||||
await runWithGlobalLoading(async () => {
|
||||
const response = await adminAuthApi.switchShop(normalizedShopId)
|
||||
persistAdminSession(response as any)
|
||||
refreshLocalUserInfo()
|
||||
await loadUserPermissions()
|
||||
notifyShopThemeChanged()
|
||||
})
|
||||
message.success('门店切换成功')
|
||||
window.location.reload()
|
||||
} catch (error: any) {
|
||||
selectedShopId.value = userInfo.value?.shopId ? String(userInfo.value.shopId) : undefined
|
||||
message.error(error?.message || '切换门店失败')
|
||||
} finally {
|
||||
shopSwitchLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** handleLogout is a local helper used by this page script. */
|
||||
const handleLogout = () => {
|
||||
Modal.confirm({
|
||||
title: '确认退出登录',
|
||||
@@ -195,55 +76,30 @@ const handleLogout = () => {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
refreshLocalUserInfo()
|
||||
await loadUserPermissions()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.admin-profile {
|
||||
display: grid;
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
.profile-meta-list {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.profile-meta-list__row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.profile-meta-list__row strong {
|
||||
color: var(--admin-mobile-ink);
|
||||
}
|
||||
|
||||
.profile-shop-select {
|
||||
width: 100%;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.profile-static-shop {
|
||||
margin-top: 14px;
|
||||
min-height: 46px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 14px;
|
||||
border-radius: 16px;
|
||||
background: var(--admin-mobile-accent-soft);
|
||||
color: var(--admin-mobile-ink);
|
||||
}
|
||||
|
||||
.profile-actions {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
margin-top: 14px;
|
||||
.admin-profile { display: grid; gap: 18px; color: var(--admin-mobile-ink); }
|
||||
.profile-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--admin-mobile-border); }
|
||||
.profile-eyebrow { color: var(--theme-primary-action); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
|
||||
.profile-head h1 { margin: 7px 0 4px; font-size: 27px; }
|
||||
.profile-head p, .profile-section__head p { margin: 0; color: var(--admin-mobile-muted); font-size: 13px; }
|
||||
.profile-chip { padding: 7px 10px; border-radius: 999px; background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); font-size: 12px; font-weight: 700; white-space: nowrap; }
|
||||
.profile-section { padding-top: 16px; border-top: 1px solid var(--admin-mobile-border); }
|
||||
.profile-section__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
|
||||
.profile-section__head h2 { margin: 0 0 4px; font-size: 15px; }
|
||||
.profile-link { display: flex; width: 100%; align-items: center; gap: 12px; padding: 14px 2px; border: 0; border-bottom: 1px solid var(--admin-mobile-border); background: transparent; color: inherit; text-align: left; cursor: pointer; }
|
||||
.profile-link:hover { color: var(--theme-primary-action); }
|
||||
.profile-link__icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 12px; background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); font-size: 20px; }
|
||||
.profile-link__body { display: grid; flex: 1; gap: 3px; min-width: 0; }
|
||||
.profile-link__body strong { font-size: 14px; }
|
||||
.profile-link__body small { color: var(--admin-mobile-muted); font-size: 12px; }
|
||||
.profile-link__arrow { color: var(--admin-mobile-muted); font-size: 24px; line-height: 1; }
|
||||
.profile-actions { display: flex; flex-wrap: wrap; gap: 10px; }
|
||||
.profile-actions .ant-btn { flex: 1 1 180px; }
|
||||
.profile-section--logout .ant-btn { max-width: 240px; }
|
||||
@media (max-width: 560px) {
|
||||
.profile-head { align-items: flex-start; flex-direction: column; }
|
||||
.profile-section--logout .ant-btn { max-width: none; }
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1582,8 +1582,8 @@ const openMapLocationPicker = async () => {
|
||||
const key = provider === 'AMAP' ? (response?.amapWebKey || '') : (response?.tencentWebKey || '')
|
||||
if (!key) {
|
||||
message.warning(provider === 'AMAP'
|
||||
? '请先在参数管理中配置高德 Web Key'
|
||||
: '请先在参数管理中配置腾讯 Web Key')
|
||||
? '请先在系统设置的服务接入中配置高德 Web Key'
|
||||
: '请先在系统设置的服务接入中配置腾讯 Web Key')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -279,7 +279,7 @@
|
||||
v-if="!isEdit"
|
||||
label="密码"
|
||||
name="password"
|
||||
extra="留空则使用参数管理中配置的店长默认密码"
|
||||
extra="留空则使用系统设置中配置的店长默认密码"
|
||||
>
|
||||
<a-input-password
|
||||
v-model:value="formState.password"
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# 项目变更记录
|
||||
|
||||
## 2026-10-25 Salon 后台系统设置重构
|
||||
|
||||
- 系统设置改为左侧分类导航和紧凑设置行,分为运行参数、服务接入、当前账号;运行参数、地图和短信分别保存。
|
||||
- 将后台个人设置中的账号资料、权限范围、当前门店与门店切换迁入“当前账号”;后台个人设置保留常用入口和退出登录,小程序账号设置未修改。
|
||||
- 地图 Key、默认用户密码从 MessageHub 参数管理页移出;该页只保留短信模板、队列和通道配置。同步更新店铺地图和用户新增页的入口提示。
|
||||
- GitNexus 对 Vue 文件同名局部方法产生跨语言误关联,`detect-changes` 报告大量无关流程及 critical;通过静态路由/API 引用检查确认改动仅限 Salon 后台管理前端。
|
||||
- 验证:Salon 前端 26 个单元测试文件、83 项测试通过;Vue 类型检查和 Vite 生产构建通过;`git diff --check` 通过。
|
||||
|
||||
## 2026-10-25 Salon 美甲师资料审核补齐
|
||||
|
||||
- 美甲师身份、经验、技能标签和作品集编辑统一提交内容审核;待审期间继续展示上一版,审核通过后才应用新版本。
|
||||
|
||||
Reference in New Issue
Block a user