修复:修复店长新增美甲师选项

This commit is contained in:
xiaowang
2026-03-27 10:05:03 +08:00
parent 4862a2000e
commit f4b535cebd
2 changed files with 84 additions and 19 deletions
+47 -19
View File
@@ -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
}