后台管理功能进行一些优化

This commit is contained in:
xiaowang
2026-02-28 14:32:28 +08:00
parent 36e2950a99
commit 725cb07fcf
23 changed files with 2297 additions and 92 deletions
+83
View File
@@ -48,6 +48,9 @@
</template>
<template v-else-if="column.key === 'actions'">
<a-space>
<a-button v-if="hasPermission('user:view')" type="link" size="small" @click="showViewModal(record)">
查看
</a-button>
<a-button v-if="hasPermission('user:edit')" type="link" size="small" @click="showEditModal(record)">
编辑
</a-button>
@@ -128,12 +131,66 @@
</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>
</a-form-item>
</a-form>
</a-modal>
<!-- 查看用户详情模态框 -->
<a-modal
v-model:open="viewModalVisible"
title="查看用户详情"
@cancel="handleViewModalCancel"
width="600px"
>
<a-form
:model="viewFormState"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 16 }"
>
<a-form-item label="账号">
<a-input v-model:value="viewFormState.account" :disabled="true" />
</a-form-item>
<a-form-item label="昵称">
<a-input v-model:value="viewFormState.nickname" :disabled="true" />
</a-form-item>
<a-form-item label="手机号">
<a-input v-model:value="viewFormState.phone" :disabled="true" />
</a-form-item>
<a-form-item label="所属店铺">
<a-select v-model:value="viewFormState.shopId" :disabled="true">
<a-select-option
v-for="shop in shopList"
:key="shop.id"
:value="shop.id"
>
{{ shop.shopName }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="用户类型">
<a-select v-model:value="viewFormState.type" :disabled="true">
<a-select-option :value="0">用户</a-select-option>
<a-select-option :value="2">店长</a-select-option>
<a-select-option :value="3">美甲师</a-select-option>
<a-select-option :value="4">管理员</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="创建时间">
<a-input v-model:value="viewFormState.createTime" :disabled="true" />
</a-form-item>
</a-form>
</a-modal>
</div>
@@ -172,12 +229,22 @@ const userList = ref<UserVO[]>([])
const shopList = ref<Shop[]>([])
const modalVisible = ref(false)
const modalLoading = ref(false)
const viewModalVisible = ref(false)
const isEdit = ref(false)
const isAdmin = ref(false)
const formRef = ref<FormInstance>()
const currentUser = ref<UserVO | null>(null)
const currentUserInfo = getCurrentUserInfo()
const viewFormState = reactive({
account: '',
nickname: '',
phone: '',
shopId: undefined as number | undefined,
type: 0,
createTime: ''
})
const pagination = reactive({
current: 1,
pageSize: 10,
@@ -339,6 +406,22 @@ const showEditModal = (record: UserVO) => {
modalVisible.value = true
}
const showViewModal = (record: UserVO) => {
Object.assign(viewFormState, {
account: record.account,
nickname: record.nickname,
phone: record.phone,
shopId: record.shopId,
type: record.type,
createTime: record.createTime
})
viewModalVisible.value = true
}
const handleViewModalCancel = () => {
viewModalVisible.value = false
}
const checkAccountExists = async (account: string) => {
try {
const res = await userApi.listUsers({ page: 1, size: 1000, keyword: account, status: 1 })