后台管理功能进行一些优化
This commit is contained in:
@@ -92,7 +92,8 @@ import {
|
||||
DownOutlined,
|
||||
LogoutOutlined,
|
||||
GiftOutlined,
|
||||
TagOutlined
|
||||
TagOutlined,
|
||||
ShoppingOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { userApi, type UserVO, adminAuthApi } from '@/api/admin'
|
||||
@@ -154,6 +155,12 @@ const menuItems = [
|
||||
icon: TagOutlined,
|
||||
label: '标签管理',
|
||||
permissionCode: 'tag:view'
|
||||
},
|
||||
{
|
||||
key: '/admin/orders',
|
||||
icon: ShoppingOutlined,
|
||||
label: '订单管理',
|
||||
permissionCode: 'order:view'
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -52,7 +52,10 @@
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space>
|
||||
<a-button type="link" size="small" @click="showEditModal(record)">
|
||||
<a-button v-if="hasPermission('coupon:view')" type="link" size="small" @click="showViewModal(record)">
|
||||
查看
|
||||
</a-button>
|
||||
<a-button v-if="hasPermission('coupon:edit')" type="link" size="small" @click="showEditModal(record)">
|
||||
编辑
|
||||
</a-button>
|
||||
<a-button v-if="hasPermission('coupon:assign') && record.status === 1" type="link" size="small" @click="showDistributeModal(record)">
|
||||
@@ -199,6 +202,86 @@
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
|
||||
<!-- 查看优惠券详情模态框 -->
|
||||
<a-modal
|
||||
v-model:open="viewModalVisible"
|
||||
title="查看优惠券详情"
|
||||
@cancel="handleViewModalCancel"
|
||||
width="800px"
|
||||
>
|
||||
<a-form
|
||||
:model="viewFormState"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 16 }"
|
||||
>
|
||||
<a-form-item label="优惠券编码">
|
||||
<a-input v-model:value="viewFormState.couponCode" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="优惠券名称">
|
||||
<a-input v-model:value="viewFormState.couponName" :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 shops"
|
||||
: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.couponType" :disabled="true">
|
||||
<a-select-option :value="1">折扣券</a-select-option>
|
||||
<a-select-option :value="2">满减券</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="viewFormState.couponType === 1" label="折扣值">
|
||||
<a-input-number v-model:value="viewFormState.discountValue" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item v-if="viewFormState.couponType === 2" label="最低消费">
|
||||
<a-input-number v-model:value="viewFormState.minAmount" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item v-if="viewFormState.couponType === 2" label="减免金额">
|
||||
<a-input-number v-model:value="viewFormState.reduceAmount" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="总数量">
|
||||
<a-input-number v-model:value="viewFormState.totalCount" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="开始时间">
|
||||
<a-date-picker v-model:value="viewFormState.startTime" show-time format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="结束时间">
|
||||
<a-date-picker v-model:value="viewFormState.endTime" show-time format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="可用标签">
|
||||
<a-select
|
||||
v-model:value="viewFormState.availableTagIds"
|
||||
mode="multiple"
|
||||
:disabled="true"
|
||||
style="width: 100%"
|
||||
>
|
||||
<a-select-option v-for="tag in tagList" :key="tag.id" :value="tag.id">
|
||||
{{ tag.tagName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="不可用标签">
|
||||
<a-select
|
||||
v-model:value="viewFormState.unavailableTagIds"
|
||||
mode="multiple"
|
||||
:disabled="true"
|
||||
style="width: 100%"
|
||||
>
|
||||
<a-select-option v-for="tag in tagList" :key="tag.id" :value="tag.id">
|
||||
{{ tag.tagName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -255,6 +338,7 @@ const getCurrentUserInfo = () => {
|
||||
|
||||
const loading = ref(false)
|
||||
const modalVisible = ref(false)
|
||||
const viewModalVisible = ref(false)
|
||||
const modalLoading = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const searchText = ref('')
|
||||
@@ -267,6 +351,22 @@ const distributeLoading = ref(false)
|
||||
const distributeFormRef = ref<FormInstance>()
|
||||
const currentDistributeCoupon = ref<Coupon | null>(null)
|
||||
|
||||
// 查看优惠券相关状态
|
||||
const viewFormState = reactive({
|
||||
couponCode: '',
|
||||
couponName: '',
|
||||
couponType: 1,
|
||||
discountValue: 9.5,
|
||||
minAmount: 100,
|
||||
reduceAmount: 20,
|
||||
totalCount: 100,
|
||||
startTime: undefined,
|
||||
endTime: undefined,
|
||||
availableTagIds: [] as number[],
|
||||
unavailableTagIds: [] as number[],
|
||||
shopId: undefined as number | undefined
|
||||
})
|
||||
|
||||
const couponList = ref<Coupon[]>([])
|
||||
const tagList = ref<TagVO[]>([])
|
||||
const userList = ref<any[]>([])
|
||||
@@ -453,6 +553,37 @@ const showEditModal = (record: Coupon) => {
|
||||
}
|
||||
}
|
||||
|
||||
const showViewModal = (record: Coupon) => {
|
||||
if (!record) {
|
||||
message.error('优惠券数据不存在')
|
||||
return
|
||||
}
|
||||
try {
|
||||
Object.assign(viewFormState, {
|
||||
couponCode: record.couponCode || '',
|
||||
couponName: record.couponName || '',
|
||||
couponType: record.couponType || 1,
|
||||
discountValue: record.discountValue || 0,
|
||||
minAmount: record.minAmount || 0,
|
||||
reduceAmount: record.reduceAmount || 0,
|
||||
totalCount: record.totalCount || 0,
|
||||
startTime: record.startTime ? dayjs(record.startTime) : undefined,
|
||||
endTime: record.endTime ? dayjs(record.endTime) : undefined,
|
||||
availableTagIds: record.availableTags ? record.availableTags.map(tag => tag.id) : [],
|
||||
unavailableTagIds: record.unavailableTags ? record.unavailableTags.map(tag => tag.id) : [],
|
||||
shopId: record.shopId
|
||||
})
|
||||
viewModalVisible.value = true
|
||||
} catch (error) {
|
||||
console.error('Error in showViewModal:', error)
|
||||
message.error('打开查看模态框失败')
|
||||
}
|
||||
}
|
||||
|
||||
const handleViewModalCancel = () => {
|
||||
viewModalVisible.value = false
|
||||
}
|
||||
|
||||
const handleModalOk = async () => {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
@@ -525,8 +656,14 @@ const handleModalOk = async () => {
|
||||
}
|
||||
|
||||
const handleModalCancel = () => {
|
||||
modalVisible.value = false
|
||||
formRef.value?.resetFields()
|
||||
message.confirm({
|
||||
title: '确认关闭',
|
||||
content: '确定要关闭编辑模态框吗?未保存的更改将会丢失。',
|
||||
onOk: () => {
|
||||
modalVisible.value = false
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const handleDelete = (record: Coupon) => {
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</a-statistic>
|
||||
</a-card>
|
||||
</a-col>
|
||||
<a-col :span="6">
|
||||
<a-col :span="6" v-if="isAdmin">
|
||||
<a-card>
|
||||
<a-statistic
|
||||
title="店铺数量"
|
||||
@@ -110,7 +110,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import {
|
||||
UserOutlined,
|
||||
@@ -131,6 +131,26 @@ const stats = reactive<DashboardStats>({
|
||||
recentActivities: []
|
||||
})
|
||||
|
||||
// 获取当前用户信息
|
||||
const getCurrentUserInfo = () => {
|
||||
try {
|
||||
const userInfoStr = localStorage.getItem('adminUserInfo')
|
||||
if (userInfoStr) {
|
||||
const userInfo = JSON.parse(userInfoStr)
|
||||
return userInfo
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取当前用户信息失败', error)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// 判断是否为管理员
|
||||
const isAdmin = computed(() => {
|
||||
const userInfo = getCurrentUserInfo()
|
||||
return userInfo?.type === 4
|
||||
})
|
||||
|
||||
const formatTime = (timeStr: string) => {
|
||||
if (!timeStr) return ''
|
||||
const time = new Date(timeStr)
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space>
|
||||
<a-button type="link" size="small" @click="showOrderDetail(record)">
|
||||
查看
|
||||
</a-button>
|
||||
<a-button v-if="record.status === 1" type="primary" size="small" @click="processOrder(record.id, 2)">
|
||||
确认完成
|
||||
</a-button>
|
||||
@@ -40,6 +43,38 @@
|
||||
</a-table>
|
||||
</a-card>
|
||||
</div>
|
||||
|
||||
<!-- 订单详情模态框 -->
|
||||
<a-modal
|
||||
v-model:open="detailModalVisible"
|
||||
title="订单详情"
|
||||
@cancel="handleDetailModalCancel"
|
||||
width="800px"
|
||||
>
|
||||
<div v-if="currentOrder">
|
||||
<a-descriptions :column="2">
|
||||
<a-descriptions-item label="订单编号">{{ currentOrder.orderNo }}</a-descriptions-item>
|
||||
<a-descriptions-item label="用户ID">{{ currentOrder.userId }}</a-descriptions-item>
|
||||
<a-descriptions-item label="总金额">¥{{ currentOrder.totalAmount.toFixed(2) }}</a-descriptions-item>
|
||||
<a-descriptions-item label="实际金额">¥{{ currentOrder.actualAmount.toFixed(2) }}</a-descriptions-item>
|
||||
<a-descriptions-item label="优惠券">{{ currentOrder.couponName || '无' }}</a-descriptions-item>
|
||||
<a-descriptions-item label="订单状态">{{ currentOrder.statusText }}</a-descriptions-item>
|
||||
<a-descriptions-item label="创建时间" :span="2">{{ currentOrder.createTime }}</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
|
||||
<a-divider>订单商品</a-divider>
|
||||
<a-table :columns="orderItemColumns" :data-source="currentOrder.items" row-key="id">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'price'">
|
||||
¥{{ record.price.toFixed(2) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'totalPrice'">
|
||||
¥{{ (record.price * record.quantity).toFixed(2) }}
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</div>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -64,6 +99,8 @@ interface Order {
|
||||
const orders = ref<Order[]>([])
|
||||
const loading = ref(false)
|
||||
const searchText = ref('')
|
||||
const detailModalVisible = ref(false)
|
||||
const currentOrder = ref<Order | null>(null)
|
||||
|
||||
const pagination = reactive({
|
||||
current: 1,
|
||||
@@ -74,6 +111,14 @@ const pagination = reactive({
|
||||
showTotal: (total: number) => `共 ${total} 条`
|
||||
})
|
||||
|
||||
const orderItemColumns = [
|
||||
{ title: '商品ID', dataIndex: 'productId', key: 'productId' },
|
||||
{ title: '商品名称', dataIndex: 'productTitle', key: 'productTitle' },
|
||||
{ title: '单价', key: 'price', width: 100 },
|
||||
{ title: '数量', dataIndex: 'quantity', key: 'quantity', width: 100 },
|
||||
{ title: '总价', key: 'totalPrice', width: 100 }
|
||||
]
|
||||
|
||||
const columns = [
|
||||
{ title: '订单编号', dataIndex: 'orderNo', key: 'orderNo' },
|
||||
{ title: '用户ID', dataIndex: 'userId', key: 'userId' },
|
||||
@@ -138,6 +183,16 @@ const processOrder = async (orderId: number, status: number) => {
|
||||
}
|
||||
}
|
||||
|
||||
const showOrderDetail = (order: Order) => {
|
||||
currentOrder.value = order
|
||||
detailModalVisible.value = true
|
||||
}
|
||||
|
||||
const handleDetailModalCancel = () => {
|
||||
detailModalVisible.value = false
|
||||
currentOrder.value = null
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadOrders()
|
||||
})
|
||||
|
||||
@@ -256,13 +256,43 @@ const getUserTypeText = (type: number) => {
|
||||
|
||||
const filteredUserList = computed(() => {
|
||||
if (!currentLoginUser.value) return []
|
||||
return userList.value.filter(user => user.type < currentLoginUser.value!.type && user.type !== 0)
|
||||
|
||||
// 管理员可以看到所有用户(除了普通用户和自己)
|
||||
if (currentLoginUser.value.type === 4) {
|
||||
return userList.value.filter(user => user.type !== 0 && user.id !== currentLoginUser.value!.id)
|
||||
}
|
||||
|
||||
// 店长只能看到美甲师(除了自己)
|
||||
if (currentLoginUser.value.type === 2) {
|
||||
return userList.value.filter(user => user.type === 3 && user.id !== currentLoginUser.value!.id)
|
||||
}
|
||||
|
||||
// 其他用户类型(如美甲师)不能管理权限
|
||||
return []
|
||||
})
|
||||
|
||||
const fetchCurrentUser = async () => {
|
||||
try {
|
||||
const res = await userApi.getUserInfo()
|
||||
currentLoginUser.value = res as unknown as UserVO
|
||||
// 尝试从API获取用户信息
|
||||
try {
|
||||
const res = await userApi.getUserInfo()
|
||||
currentLoginUser.value = res as unknown as UserVO
|
||||
console.log('从API获取当前用户信息:', currentLoginUser.value)
|
||||
} catch (apiError) {
|
||||
// 如果API调用失败,尝试从本地存储获取
|
||||
const userInfoStr = localStorage.getItem('adminUserInfo')
|
||||
if (userInfoStr) {
|
||||
try {
|
||||
const userInfo = JSON.parse(userInfoStr)
|
||||
currentLoginUser.value = userInfo as UserVO
|
||||
console.log('从本地存储获取当前用户信息:', currentLoginUser.value)
|
||||
} catch (parseError) {
|
||||
console.error('解析本地存储的用户信息失败:', parseError)
|
||||
}
|
||||
} else {
|
||||
console.error('获取当前用户信息失败,本地存储也没有用户信息')
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取当前用户信息失败:', error)
|
||||
}
|
||||
@@ -284,11 +314,18 @@ const fetchPermissionList = async () => {
|
||||
const fetchUserList = async () => {
|
||||
userLoading.value = true
|
||||
try {
|
||||
const res = await userApi.listUsers({
|
||||
const params: any = {
|
||||
page: 1,
|
||||
size: 100,
|
||||
keyword: userSearchText.value
|
||||
})
|
||||
}
|
||||
|
||||
// 如果当前用户不是管理员,只获取当前店铺的用户
|
||||
if (currentLoginUser.value && currentLoginUser.value.type !== 4 && currentLoginUser.value.shopId) {
|
||||
params.shopId = currentLoginUser.value.shopId
|
||||
}
|
||||
|
||||
const res = await userApi.listUsers(params)
|
||||
userList.value = res.list || []
|
||||
} catch (error) {
|
||||
message.error('获取用户列表失败')
|
||||
@@ -397,7 +434,10 @@ onMounted(async () => {
|
||||
await fetchCurrentUser()
|
||||
await loadUserPermissions()
|
||||
fetchPermissionList()
|
||||
fetchUserList()
|
||||
// 确保在获取当前用户信息后再获取用户列表
|
||||
setTimeout(() => {
|
||||
fetchUserList()
|
||||
}, 100)
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -61,6 +61,9 @@
|
||||
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space>
|
||||
<a-button type="link" size="small" @click="showViewModal(record)">
|
||||
查看
|
||||
</a-button>
|
||||
<a-button v-if="hasPermission('product:edit')" type="link" size="small" @click="showEditModal(record)">
|
||||
编辑
|
||||
</a-button>
|
||||
@@ -241,6 +244,117 @@
|
||||
</template>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
|
||||
<!-- 查看商品详情模态框 -->
|
||||
<a-modal
|
||||
v-model:open="viewModalVisible"
|
||||
title="查看商品详情"
|
||||
width="700px"
|
||||
@cancel="handleViewModalCancel"
|
||||
>
|
||||
<a-form
|
||||
:model="viewFormState"
|
||||
:label-col="{ span: 5 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<a-form-item label="商品名称">
|
||||
<a-input v-model:value="viewFormState.title" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="商品描述">
|
||||
<a-textarea
|
||||
v-model:value="viewFormState.description"
|
||||
:rows="3"
|
||||
: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 shops"
|
||||
:key="shop.id"
|
||||
:value="shop.id"
|
||||
>
|
||||
{{ shop.shopName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="商品图片">
|
||||
<div class="product-images">
|
||||
<a-image
|
||||
v-for="(url, index) in viewImageUrls"
|
||||
:key="index"
|
||||
:width="80"
|
||||
:height="80"
|
||||
:src="url"
|
||||
style="object-fit: cover; border-radius: 4px; margin-right: 8px; margin-bottom: 8px;"
|
||||
:preview="false"
|
||||
/>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="价格">
|
||||
<a-input-number
|
||||
v-model:value="viewFormState.price"
|
||||
:disabled="true"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="预计时长">
|
||||
<a-input-number
|
||||
v-model:value="viewFormState.approximateDuration"
|
||||
:disabled="true"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="标签">
|
||||
<a-select
|
||||
v-model:value="viewFormState.tags"
|
||||
mode="multiple"
|
||||
:disabled="true"
|
||||
style="width: 100%"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="tag in tags"
|
||||
:key="tag.id"
|
||||
:value="tag.id.toString()"
|
||||
>
|
||||
{{ tag.tagName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="可预约美甲师">
|
||||
<a-select
|
||||
v-model:value="viewFormState.bookableArtists"
|
||||
mode="multiple"
|
||||
:disabled="true"
|
||||
style="width: 100%"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="artist in artists"
|
||||
:key="artist.id"
|
||||
:value="artist.id.toString()"
|
||||
>
|
||||
{{ artist.nickname }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="可用优惠券">
|
||||
<a-select
|
||||
v-model:value="viewFormState.availableCoupons"
|
||||
mode="multiple"
|
||||
:disabled="true"
|
||||
style="width: 100%"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="coupon in coupons"
|
||||
:key="coupon?.id"
|
||||
:value="coupon?.id?.toString()"
|
||||
>
|
||||
{{ coupon?.couponName || '' }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -258,6 +372,7 @@ const loading = ref(false)
|
||||
const searchText = ref('')
|
||||
const productList = ref<Product[]>([])
|
||||
const modalVisible = ref(false)
|
||||
const viewModalVisible = ref(false)
|
||||
const modalLoading = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const currentProduct = ref<Product | null>(null)
|
||||
@@ -274,10 +389,23 @@ const previewImage = ref('')
|
||||
const imageFileList = ref<any[]>([])
|
||||
const uploadedFileIds = ref<string[]>([])
|
||||
const imageUrls = ref<Record<number, string[]>>({})
|
||||
const viewImageUrls = ref<string[]>([])
|
||||
const imageIdCache = ref<Record<string, string>>({})
|
||||
const isAdmin = ref(false)
|
||||
const formRef = ref<any>(null)
|
||||
|
||||
const viewFormState = reactive({
|
||||
shopId: undefined,
|
||||
title: '',
|
||||
description: '',
|
||||
imageFileIds: '',
|
||||
price: 0,
|
||||
tags: [] as string[],
|
||||
approximateDuration: undefined,
|
||||
bookableArtists: [] as string[],
|
||||
availableCoupons: [] as string[]
|
||||
})
|
||||
|
||||
const pagination = reactive({
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
@@ -585,6 +713,64 @@ const showEditModal = async (record: Product) => {
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
const showViewModal = async (record: Product) => {
|
||||
// 处理标签
|
||||
const tagsArray = record.tags ? record.tags.split(';').filter(tag => tag) : []
|
||||
// 处理美甲师
|
||||
const artistsArray = record.bookableArtists ? record.bookableArtists.split(',').filter(artist => artist) : []
|
||||
// 处理优惠券
|
||||
const couponsArray = record.availableCoupons ? record.availableCoupons.split(',').filter(coupon => coupon) : []
|
||||
// 处理预计时长,将字符串转换为数字
|
||||
const durationNumber = record.approximateDuration ? parseInt(record.approximateDuration.replace('分钟', '')) : undefined
|
||||
|
||||
Object.assign(viewFormState, {
|
||||
shopId: record.shopId,
|
||||
title: record.title,
|
||||
description: record.description,
|
||||
imageFileIds: record.imageFileIds,
|
||||
price: record.price,
|
||||
tags: tagsArray,
|
||||
approximateDuration: durationNumber,
|
||||
bookableArtists: artistsArray,
|
||||
availableCoupons: couponsArray
|
||||
})
|
||||
|
||||
// 加载图片URL
|
||||
if (record.imageFileIds) {
|
||||
const ids = record.imageFileIds.split(',')
|
||||
const urls: string[] = []
|
||||
|
||||
for (const id of ids) {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const signedUrl = await adminFileApi.getSignedUrl(Number(id))
|
||||
imageIdCache.value[id] = signedUrl
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
urls.push(DEFAULT_PRODUCT_IMAGE)
|
||||
}
|
||||
}
|
||||
viewImageUrls.value = urls
|
||||
} else {
|
||||
viewImageUrls.value = [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
|
||||
// 获取该店铺的美甲师列表
|
||||
if (record.shopId) {
|
||||
await fetchArtists(record.shopId)
|
||||
}
|
||||
|
||||
viewModalVisible.value = true
|
||||
}
|
||||
|
||||
const handleViewModalCancel = () => {
|
||||
viewModalVisible.value = false
|
||||
viewImageUrls.value = []
|
||||
}
|
||||
|
||||
const beforeUpload = (file: File) => {
|
||||
const isImage = file.type.startsWith('image/')
|
||||
if (!isImage) {
|
||||
|
||||
@@ -52,6 +52,9 @@
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space>
|
||||
<a-button v-if="hasPermission('shop:view')" type="link" size="small" @click="showViewModal(record)">
|
||||
查看
|
||||
</a-button>
|
||||
<a-button v-if="hasPermission('shop:edit')" type="link" size="small" @click="showEditModal(record)">
|
||||
编辑
|
||||
</a-button>
|
||||
@@ -122,6 +125,50 @@
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
|
||||
<!-- 查看店铺详情模态框 -->
|
||||
<a-modal
|
||||
v-model:open="viewModalVisible"
|
||||
title="查看店铺详情"
|
||||
width="600px"
|
||||
@cancel="handleViewModalCancel"
|
||||
>
|
||||
<a-form
|
||||
:model="viewFormState"
|
||||
:label-col="{ span: 5 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<a-form-item label="店铺名称">
|
||||
<a-input v-model:value="viewFormState.shopName" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="店铺描述">
|
||||
<a-textarea
|
||||
v-model:value="viewFormState.description"
|
||||
:rows="3"
|
||||
:disabled="true"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="店铺地址">
|
||||
<a-input v-model:value="viewFormState.address" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="营业时间">
|
||||
<a-input v-model:value="viewFormState.businessHours" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="店铺图片">
|
||||
<div class="shop-images">
|
||||
<a-image
|
||||
v-for="(url, index) in viewImageUrls"
|
||||
:key="index"
|
||||
:width="80"
|
||||
:height="80"
|
||||
:src="url"
|
||||
style="object-fit: cover; border-radius: 4px; margin-right: 8px; margin-bottom: 8px;"
|
||||
:preview="false"
|
||||
/>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -140,6 +187,7 @@ const loading = ref(false)
|
||||
const searchText = ref('')
|
||||
const shopList = ref<Shop[]>([])
|
||||
const modalVisible = ref(false)
|
||||
const viewModalVisible = ref(false)
|
||||
const modalLoading = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
@@ -151,9 +199,19 @@ const imageFileList = ref<any[]>([])
|
||||
const uploadedFileIds = ref<string[]>([])
|
||||
const imageIdCache = ref<Record<string, string>>({})
|
||||
const shopImageUrls = ref<Record<number, string[]>>({})
|
||||
const viewImageUrls = ref<string[]>([])
|
||||
const previewVisible = ref(false)
|
||||
const previewImage = ref('')
|
||||
|
||||
// 查看店铺相关状态
|
||||
const viewFormState = reactive({
|
||||
shopName: '',
|
||||
description: '',
|
||||
address: '',
|
||||
businessHours: '',
|
||||
imageFileIds: ''
|
||||
})
|
||||
|
||||
const pagination = reactive({
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
@@ -387,6 +445,46 @@ const showEditModal = async (record: Shop) => {
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
const showViewModal = async (record: Shop) => {
|
||||
Object.assign(viewFormState, {
|
||||
shopName: record.shopName,
|
||||
description: record.description,
|
||||
address: record.address,
|
||||
businessHours: record.businessHours,
|
||||
imageFileIds: record.imageFileIds
|
||||
})
|
||||
|
||||
// 加载图片URL
|
||||
if (record.imageFileIds) {
|
||||
const ids = record.imageFileIds.split(',')
|
||||
const urls: string[] = []
|
||||
|
||||
for (const id of ids) {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const signedUrl = await adminFileApi.getSignedUrl(Number(id))
|
||||
imageIdCache.value[id] = signedUrl
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
urls.push(DEFAULT_SHOP_IMAGE)
|
||||
}
|
||||
}
|
||||
viewImageUrls.value = urls
|
||||
} else {
|
||||
viewImageUrls.value = [DEFAULT_SHOP_IMAGE]
|
||||
}
|
||||
|
||||
viewModalVisible.value = true
|
||||
}
|
||||
|
||||
const handleViewModalCancel = () => {
|
||||
viewModalVisible.value = false
|
||||
viewImageUrls.value = []
|
||||
}
|
||||
|
||||
const handleModalOk = async () => {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
|
||||
@@ -0,0 +1,427 @@
|
||||
<template>
|
||||
<div class="tags">
|
||||
<a-page-header title="标签管理" sub-title="管理系统标签" />
|
||||
|
||||
<a-card :bordered="false">
|
||||
<template #extra>
|
||||
<a-space>
|
||||
<a-input-search
|
||||
v-model:value="searchText"
|
||||
placeholder="搜索标签名称"
|
||||
style="width: 250px"
|
||||
@search="handleSearch"
|
||||
/>
|
||||
<a-button v-if="hasPermission('tag:create')" type="primary" @click="showAddModal">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
新增标签
|
||||
</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<a-table
|
||||
:columns="columns"
|
||||
:data-source="tagList"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
@change="handleTableChange"
|
||||
row-key="id"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'color'">
|
||||
<span
|
||||
class="tag-preview"
|
||||
:style="{
|
||||
backgroundColor: record.bgColor,
|
||||
color: record.textColor,
|
||||
borderColor: record.borderColor
|
||||
}"
|
||||
>
|
||||
{{ record.tagName }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'shop'">
|
||||
<span>{{ getShopName(record.shopId) }}</span>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space>
|
||||
<a-button v-if="hasPermission('tag:view')" type="link" size="small" @click="showViewModal(record)">
|
||||
查看
|
||||
</a-button>
|
||||
<a-button v-if="hasPermission('tag:edit')" type="link" size="small" @click="showEditModal(record)">
|
||||
编辑
|
||||
</a-button>
|
||||
<a-button v-if="hasPermission('tag:delete')" type="link" size="small" danger @click="handleDelete(record)">
|
||||
删除
|
||||
</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
|
||||
<a-modal
|
||||
v-model:open="modalVisible"
|
||||
:title="isEdit ? '编辑标签' : '新增标签'"
|
||||
@ok="handleModalOk"
|
||||
@cancel="handleModalCancel"
|
||||
:confirmLoading="modalLoading"
|
||||
width="600px"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="formState"
|
||||
:rules="formRules"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 16 }"
|
||||
>
|
||||
<a-form-item label="标签名称" name="tagName">
|
||||
<a-input v-model:value="formState.tagName" placeholder="请输入标签名称" />
|
||||
</a-form-item>
|
||||
<a-form-item label="所属店铺" name="shopId">
|
||||
<a-select
|
||||
v-model:value="formState.shopId"
|
||||
placeholder="请选择所属店铺"
|
||||
style="width: 100%"
|
||||
:loading="loadingShops"
|
||||
:disabled="getCurrentUserInfo()?.type === 2"
|
||||
>
|
||||
<a-select-option
|
||||
v-if="shops.length === 0"
|
||||
disabled
|
||||
value=""
|
||||
>
|
||||
暂无店铺数据
|
||||
</a-select-option>
|
||||
<a-select-option
|
||||
v-for="shop in shops"
|
||||
:key="shop.id"
|
||||
:value="shop.id"
|
||||
>
|
||||
{{ shop.shopName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="文字颜色" name="textColor">
|
||||
<el-color-picker v-model="formState.textColor" />
|
||||
</a-form-item>
|
||||
<a-form-item label="背景颜色" name="bgColor">
|
||||
<el-color-picker v-model="formState.bgColor" />
|
||||
</a-form-item>
|
||||
<a-form-item label="边框颜色" name="borderColor">
|
||||
<el-color-picker v-model="formState.borderColor" />
|
||||
</a-form-item>
|
||||
<a-form-item label="预览">
|
||||
<span
|
||||
class="tag-preview"
|
||||
:style="{
|
||||
backgroundColor: formState.bgColor,
|
||||
color: formState.textColor,
|
||||
borderColor: formState.borderColor
|
||||
}"
|
||||
>
|
||||
{{ formState.tagName }}
|
||||
</span>
|
||||
</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.tagName" :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 shops"
|
||||
:key="shop.id"
|
||||
:value="shop.id"
|
||||
>
|
||||
{{ shop.shopName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="文字颜色">
|
||||
<el-color-picker v-model="viewFormState.textColor" disabled />
|
||||
</a-form-item>
|
||||
<a-form-item label="背景颜色">
|
||||
<el-color-picker v-model="viewFormState.bgColor" disabled />
|
||||
</a-form-item>
|
||||
<a-form-item label="边框颜色">
|
||||
<el-color-picker v-model="viewFormState.borderColor" disabled />
|
||||
</a-form-item>
|
||||
<a-form-item label="预览">
|
||||
<span
|
||||
class="tag-preview"
|
||||
:style="{
|
||||
backgroundColor: viewFormState.bgColor,
|
||||
color: viewFormState.textColor,
|
||||
borderColor: viewFormState.borderColor
|
||||
}"
|
||||
>
|
||||
{{ viewFormState.tagName }}
|
||||
</span>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import { PlusOutlined } from '@ant-design/icons-vue'
|
||||
import { adminTagApi, adminShopApi, type Shop } from '@/api/admin'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
|
||||
const { hasPermission, loadUserPermissions } = usePermission()
|
||||
|
||||
const getCurrentUserInfo = () => {
|
||||
try {
|
||||
const userInfoStr = localStorage.getItem('adminUserInfo')
|
||||
if (userInfoStr) {
|
||||
const userInfo = JSON.parse(userInfoStr)
|
||||
return userInfo
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取当前用户信息失败', error)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const loading = ref(false)
|
||||
const modalVisible = ref(false)
|
||||
const viewModalVisible = ref(false)
|
||||
const modalLoading = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const searchText = ref('')
|
||||
const formRef = ref<FormInstance>()
|
||||
const currentTag = ref<any>(null)
|
||||
|
||||
// 查看标签相关状态
|
||||
const viewFormState = reactive({
|
||||
tagName: '',
|
||||
shopId: undefined as number | undefined,
|
||||
textColor: '#333333',
|
||||
bgColor: '#FFFFFF',
|
||||
borderColor: '#E5E5E5'
|
||||
})
|
||||
|
||||
const tagList = ref<any[]>([])
|
||||
const shops = ref<Shop[]>([])
|
||||
const loadingShops = ref(false)
|
||||
|
||||
const pagination = reactive({
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
showTotal: (total: number) => `共 ${total} 条`
|
||||
})
|
||||
|
||||
const formState = reactive({
|
||||
tagName: '',
|
||||
shopId: undefined as number | undefined,
|
||||
textColor: '#333333',
|
||||
bgColor: '#FFFFFF',
|
||||
borderColor: '#E5E5E5'
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
tagName: [{ required: true, message: '请输入标签名称', trigger: 'blur' }],
|
||||
shopId: [{ required: true, message: '请选择所属店铺', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const columns = [
|
||||
{ title: '标签名称', dataIndex: 'tagName', key: 'tagName' },
|
||||
{ title: '所属店铺', key: 'shop', width: 150 },
|
||||
{ title: '预览', key: 'color', width: 150 },
|
||||
{ title: '文字颜色', dataIndex: 'textColor', key: 'textColor', width: 120 },
|
||||
{ title: '背景颜色', dataIndex: 'bgColor', key: 'bgColor', width: 120 },
|
||||
{ title: '边框颜色', dataIndex: 'borderColor', key: 'borderColor', width: 120 },
|
||||
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime' },
|
||||
{ title: '操作', key: 'actions', width: 150, fixed: 'right' as const }
|
||||
]
|
||||
|
||||
const fetchTags = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const currentUser = getCurrentUserInfo()
|
||||
const shopId = (currentUser && currentUser.shopId) ? currentUser.shopId : undefined
|
||||
let tags
|
||||
if (shopId) {
|
||||
tags = await adminTagApi.listTagsByShopId(shopId)
|
||||
} else {
|
||||
tags = await adminTagApi.listAllTags()
|
||||
}
|
||||
console.log('Tags data:', tags)
|
||||
tagList.value = tags || []
|
||||
pagination.total = tagList.value.length
|
||||
} catch (error) {
|
||||
console.error('获取标签列表失败:', error)
|
||||
message.error('获取标签列表失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const fetchShops = async () => {
|
||||
loadingShops.value = true
|
||||
try {
|
||||
const res = await adminShopApi.listAllShops()
|
||||
shops.value = res || []
|
||||
} catch (error) {
|
||||
console.error('获取店铺列表失败:', error)
|
||||
} finally {
|
||||
loadingShops.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const getShopName = (shopId: number) => {
|
||||
const shop = shops.value.find(s => s.id === shopId)
|
||||
return shop ? shop.shopName : '未知店铺'
|
||||
}
|
||||
|
||||
const handleSearch = () => {
|
||||
pagination.current = 1
|
||||
fetchTags()
|
||||
}
|
||||
|
||||
const handleTableChange = (pag: any) => {
|
||||
pagination.current = pag.current
|
||||
pagination.pageSize = pag.pageSize
|
||||
fetchTags()
|
||||
}
|
||||
|
||||
const showAddModal = () => {
|
||||
isEdit.value = false
|
||||
const currentUser = getCurrentUserInfo()
|
||||
const shopId = (currentUser && currentUser.shopId) ? currentUser.shopId : undefined
|
||||
Object.assign(formState, {
|
||||
tagName: '',
|
||||
shopId: shopId,
|
||||
textColor: '#333333',
|
||||
bgColor: '#FFFFFF',
|
||||
borderColor: '#E5E5E5'
|
||||
})
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
const showEditModal = (record: any) => {
|
||||
console.log('Edit record:', record)
|
||||
isEdit.value = true
|
||||
currentTag.value = record
|
||||
Object.assign(formState, {
|
||||
tagName: record.tagName,
|
||||
shopId: record.shopId,
|
||||
textColor: record.textColor,
|
||||
bgColor: record.bgColor,
|
||||
borderColor: record.borderColor
|
||||
})
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
const showViewModal = (record: any) => {
|
||||
Object.assign(viewFormState, {
|
||||
tagName: record.tagName,
|
||||
shopId: record.shopId,
|
||||
textColor: record.textColor,
|
||||
bgColor: record.bgColor,
|
||||
borderColor: record.borderColor
|
||||
})
|
||||
viewModalVisible.value = true
|
||||
}
|
||||
|
||||
const handleViewModalCancel = () => {
|
||||
viewModalVisible.value = false
|
||||
}
|
||||
|
||||
const handleModalOk = async () => {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
modalLoading.value = true
|
||||
|
||||
const requestData = {
|
||||
tagName: formState.tagName,
|
||||
shopId: formState.shopId,
|
||||
textColor: formState.textColor,
|
||||
bgColor: formState.bgColor,
|
||||
borderColor: formState.borderColor
|
||||
}
|
||||
|
||||
console.log('Request data:', requestData)
|
||||
console.log('Current tag:', currentTag.value)
|
||||
|
||||
if (isEdit.value && currentTag.value) {
|
||||
console.log('Updating tag with id:', currentTag.value.id)
|
||||
await adminTagApi.updateTag(currentTag.value.id, requestData)
|
||||
message.success('更新成功')
|
||||
} else {
|
||||
await adminTagApi.createTag(requestData)
|
||||
message.success('创建成功')
|
||||
}
|
||||
|
||||
modalVisible.value = false
|
||||
fetchTags()
|
||||
} catch (error) {
|
||||
console.error('Error:', error)
|
||||
} finally {
|
||||
modalLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleModalCancel = () => {
|
||||
modalVisible.value = false
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
const handleDelete = (record: any) => {
|
||||
message.confirm({
|
||||
title: '确认删除',
|
||||
content: `确定要删除标签 ${record.tagName} 吗?`,
|
||||
onOk: async () => {
|
||||
try {
|
||||
await adminTagApi.deleteTag(record.id)
|
||||
message.success('删除成功')
|
||||
fetchTags()
|
||||
} catch (error) {
|
||||
message.error('删除失败')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadUserPermissions()
|
||||
await fetchShops()
|
||||
await fetchTags()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.tags {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.tag-preview {
|
||||
display: inline-block;
|
||||
padding: 4px 12px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
@@ -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 })
|
||||
|
||||
Reference in New Issue
Block a user