修复:修复店长新增美甲师选项
This commit is contained in:
@@ -151,9 +151,9 @@
|
||||
<a-select
|
||||
v-model:value="formState.shopIds"
|
||||
mode="multiple"
|
||||
:placeholder="currentUserInfo?.type === 4 ? '请选择一个或多个店铺' : '请选择店铺'"
|
||||
:placeholder="currentUserType === 4 ? '请选择一个或多个店铺' : '请选择店铺'"
|
||||
:loading="shopLoading"
|
||||
:disabled="currentUserInfo?.type !== 4 && !!currentUserInfo?.shopId"
|
||||
:disabled="currentUserType !== 4 && !!currentUserInfo?.shopId"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="shop in shopList"
|
||||
@@ -166,13 +166,13 @@
|
||||
</a-form-item>
|
||||
<a-form-item label="用户类型" name="type">
|
||||
<a-select v-model:value="formState.type" placeholder="请选择用户类型">
|
||||
<a-select-option v-if="currentUserInfo?.type === 4" :value="0">用户</a-select-option>
|
||||
<a-select-option v-if="currentUserInfo?.type === 4" :value="2">店长</a-select-option>
|
||||
<a-select-option v-if="currentUserInfo?.type === 4" :value="3">美甲师</a-select-option>
|
||||
<a-select-option v-if="currentUserInfo?.type === 4" :value="4">管理员</a-select-option>
|
||||
<a-select-option v-else-if="currentUserInfo?.type === 2" :value="0">用户</a-select-option>
|
||||
<a-select-option v-else-if="currentUserInfo?.type === 2" :value="3">美甲师</a-select-option>
|
||||
<a-select-option v-else-if="currentUserInfo?.type === 3" :value="0">用户</a-select-option>
|
||||
<a-select-option
|
||||
v-for="option in availableUserTypeOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
>
|
||||
{{ option.label }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
@@ -417,6 +417,11 @@ const currentUserInfo = (() => {
|
||||
}
|
||||
})()
|
||||
|
||||
const normalizeUserType = (value: unknown) => {
|
||||
const type = Number(value)
|
||||
return Number.isFinite(type) ? type : -1
|
||||
}
|
||||
|
||||
const loading = ref(false)
|
||||
const shopLoading = ref(false)
|
||||
const modalVisible = ref(false)
|
||||
@@ -443,11 +448,34 @@ const vipDraftSavedAt = ref<number | null>(null)
|
||||
const canOpenAssetPanel = computed(() =>
|
||||
hasAnyPermission(['user:balance:view', 'user:balance:manage', 'user:vip:manage'])
|
||||
)
|
||||
const currentUserType = computed(() => normalizeUserType(currentUserInfo?.type))
|
||||
const availableUserTypeOptions = computed(() => {
|
||||
if (currentUserType.value === 4) {
|
||||
return [
|
||||
{ value: 0, label: '用户' },
|
||||
{ value: 2, label: '店长' },
|
||||
{ value: 3, label: '美甲师' },
|
||||
{ value: 4, label: '管理员' }
|
||||
]
|
||||
}
|
||||
if (currentUserType.value === 2) {
|
||||
return [
|
||||
{ value: 0, label: '用户' },
|
||||
{ value: 3, label: '美甲师' }
|
||||
]
|
||||
}
|
||||
if (currentUserType.value === 3) {
|
||||
return [
|
||||
{ value: 0, label: '用户' }
|
||||
]
|
||||
}
|
||||
return []
|
||||
})
|
||||
const canCreateUser = computed(() =>
|
||||
hasPermission('user:create') || currentUserInfo?.type === 2 || currentUserInfo?.type === 4
|
||||
hasPermission('user:create') || currentUserType.value === 2 || currentUserType.value === 4
|
||||
)
|
||||
const canDeleteUser = computed(() =>
|
||||
currentUserInfo?.type === 4 && hasPermission('user:delete')
|
||||
currentUserType.value === 4 && hasPermission('user:delete')
|
||||
)
|
||||
const canUnbindUser = computed(() =>
|
||||
hasPermission('user:unbind')
|
||||
@@ -708,13 +736,13 @@ const formatDate = (value?: string) => {
|
||||
}
|
||||
|
||||
const filterVisibleUsers = (list: UserVO[]) => {
|
||||
if (!currentUserInfo || currentUserInfo.type === 4) {
|
||||
if (!currentUserInfo || currentUserType.value === 4) {
|
||||
return list
|
||||
}
|
||||
if (currentUserInfo.type === 2) {
|
||||
if (currentUserType.value === 2) {
|
||||
return list.filter(user => user.type === 0 || user.type === 3)
|
||||
}
|
||||
if (currentUserInfo.type === 3) {
|
||||
if (currentUserType.value === 3) {
|
||||
return list.filter(user => user.type === 0)
|
||||
}
|
||||
return list
|
||||
@@ -770,7 +798,7 @@ const resolveEditableShopIds = (user?: UserVO | null) => {
|
||||
return normalizedIds
|
||||
}
|
||||
|
||||
return currentUserInfo?.type !== 4 && currentUserInfo?.shopId
|
||||
return currentUserType.value !== 4 && currentUserInfo?.shopId
|
||||
? [normalizeShopId(currentUserInfo.shopId)!]
|
||||
: []
|
||||
}
|
||||
@@ -780,7 +808,7 @@ const fetchShopList = async () => {
|
||||
try {
|
||||
const shops = await adminShopApi.listAllShops() as unknown as Shop[]
|
||||
shopList.value = shops || []
|
||||
if (currentUserInfo?.type !== 4 && currentUserInfo?.shopId) {
|
||||
if (currentUserType.value !== 4 && currentUserInfo?.shopId) {
|
||||
formState.shopIds = [normalizeShopId(currentUserInfo.shopId)!]
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -821,8 +849,8 @@ const resetFormState = () => {
|
||||
nickname: '',
|
||||
phone: '',
|
||||
password: '',
|
||||
type: 0,
|
||||
shopIds: currentUserInfo?.type !== 4 && currentUserInfo?.shopId
|
||||
type: availableUserTypeOptions.value[0]?.value ?? 0,
|
||||
shopIds: currentUserType.value !== 4 && currentUserInfo?.shopId
|
||||
? [normalizeShopId(currentUserInfo.shopId)!]
|
||||
: []
|
||||
})
|
||||
@@ -970,7 +998,7 @@ const handleModalOk = async () => {
|
||||
...(formState.password.trim() ? { password: formState.password.trim() } : {})
|
||||
}
|
||||
|
||||
if (isEdit.value && currentUserInfo?.type !== 4) {
|
||||
if (isEdit.value && currentUserType.value !== 4) {
|
||||
delete requestData.shopIds
|
||||
delete requestData.shopId
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
# 2026-03-27 店长新增美甲师下拉选项修复
|
||||
|
||||
## 问题现象
|
||||
|
||||
- 店长进入后台“用户管理”新增用户时,“用户类型”下拉框只能看到“用户”,看不到“美甲师”。
|
||||
- 结果是店长无法按预期创建本店的美甲师账号。
|
||||
|
||||
## 根因
|
||||
|
||||
- 文件:`Frontend/src/views/admin/UsersView.vue`
|
||||
- 原实现把店长可选角色写成了连续的 `v-else-if` 模板链:
|
||||
- 先命中“用户”
|
||||
- 后续“美甲师”分支不再执行
|
||||
- 因此前端虽然业务上允许店长创建美甲师,但界面实际上把“美甲师”选项吞掉了。
|
||||
|
||||
## 本次修改
|
||||
|
||||
- 将“用户类型”下拉改为基于计算属性 `availableUserTypeOptions` 渲染,不再依赖易出错的模板分支链。
|
||||
- 新增 `currentUserType` 数字化判断,避免本地缓存中的角色类型出现字符串/数字不一致时导致判断失效。
|
||||
- 店长当前可见的新增角色恢复为:
|
||||
- `用户`
|
||||
- `美甲师`
|
||||
|
||||
## 影响范围
|
||||
|
||||
- 仅前端页面:
|
||||
- `Frontend/src/views/admin/UsersView.vue`
|
||||
- 后端创建用户权限与角色范围逻辑本轮未改,现有后端规则本身已允许店长创建美甲师。
|
||||
|
||||
## SQL 变更
|
||||
|
||||
- 无
|
||||
|
||||
## 验证
|
||||
|
||||
- 前端执行 `npm run build`,确认通过。
|
||||
- 进入后台“用户管理 -> 新增用户”,店长账号现在应能在“用户类型”中看到“美甲师”选项。
|
||||
Reference in New Issue
Block a user