美甲师信息管理
This commit is contained in:
@@ -0,0 +1,421 @@
|
||||
<template>
|
||||
<div class="nail-artists">
|
||||
<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-space>
|
||||
</template>
|
||||
|
||||
<a-table
|
||||
:columns="columns"
|
||||
:data-source="nailArtistList"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
@change="handleTableChange"
|
||||
row-key="userId"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag :color="getStatusColor(record.status)">
|
||||
{{ getStatusText(record.status) }}
|
||||
</a-tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space>
|
||||
<a-button v-if="hasPermission('nail_artist:view')" type="link" size="small" @click="showViewModal(record)">
|
||||
查看
|
||||
</a-button>
|
||||
<a-button v-if="hasPermission('nail_artist:edit')" type="link" size="small" @click="showEditModal(record)">
|
||||
编辑
|
||||
</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑美甲师信息模态框 -->
|
||||
<a-modal
|
||||
v-model:open="modalVisible"
|
||||
title="编辑美甲师信息"
|
||||
@ok="handleModalOk"
|
||||
@cancel="handleModalCancel"
|
||||
:confirmLoading="modalLoading"
|
||||
width="800px"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="formState"
|
||||
:rules="formRules"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 16 }"
|
||||
>
|
||||
<a-form-item label="美甲师姓名" name="nickname">
|
||||
<a-input v-model:value="formState.nickname" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="身份" name="identity">
|
||||
<a-input
|
||||
v-model:value="formState.identity"
|
||||
placeholder="请输入身份"
|
||||
:disabled="!isShopOwner"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="从业年限" name="experience">
|
||||
<a-input-number
|
||||
v-model:value="formState.experience"
|
||||
:min="0"
|
||||
placeholder="请输入从业年限"
|
||||
:disabled="!isShopOwner"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="技能标签" name="skills">
|
||||
<a-select
|
||||
v-model:value="formState.skills"
|
||||
mode="multiple"
|
||||
placeholder="请选择技能标签"
|
||||
:loading="tagLoading"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="tag in tagList"
|
||||
:key="tag.id"
|
||||
:value="tag.id.toString()"
|
||||
>
|
||||
{{ tag.tagName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="状态" name="status">
|
||||
<a-select
|
||||
v-model:value="formState.status"
|
||||
placeholder="请选择状态"
|
||||
:disabled="!isShopOwner"
|
||||
>
|
||||
<a-select-option :value="1">营业中</a-select-option>
|
||||
<a-select-option :value="0">休息中</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="作品集" name="portfolio">
|
||||
<a-select
|
||||
v-model:value="formState.portfolio"
|
||||
mode="multiple"
|
||||
placeholder="请选择作品集商品"
|
||||
:loading="productLoading"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="product in productList"
|
||||
:key="product.id"
|
||||
:value="product.id.toString()"
|
||||
>
|
||||
{{ product.title }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="评分">
|
||||
<a-input v-model:value="formState.rating" :disabled="true" />
|
||||
</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.nickname" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="所属店铺">
|
||||
<a-input v-model:value="viewFormState.shopName" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="身份">
|
||||
<a-input v-model:value="viewFormState.identity" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="从业年限">
|
||||
<a-input v-model:value="viewFormState.experience" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="技能标签">
|
||||
<a-input v-model:value="viewFormState.skillsText" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="状态">
|
||||
<a-input v-model:value="viewFormState.statusText" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="评分">
|
||||
<a-input v-model:value="viewFormState.rating" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="作品集">
|
||||
<a-input v-model:value="viewFormState.portfolioText" :disabled="true" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import { adminNailArtistApi, type NailArtistInfoVO } from '@/api/admin'
|
||||
import { adminTagApi, type Tag } from '@/api/admin'
|
||||
import { adminProductApi, type Product } 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)
|
||||
isAdmin.value = userInfo.type === 4
|
||||
isShopOwner.value = userInfo.type === 2
|
||||
return userInfo
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取当前用户信息失败', error)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const loading = ref(false)
|
||||
const tagLoading = ref(false)
|
||||
const productLoading = ref(false)
|
||||
const searchText = ref('')
|
||||
const nailArtistList = ref<NailArtistInfoVO[]>([])
|
||||
const tagList = ref<Tag[]>([])
|
||||
const productList = ref<Product[]>([])
|
||||
const modalVisible = ref(false)
|
||||
const modalLoading = ref(false)
|
||||
const viewModalVisible = ref(false)
|
||||
const isAdmin = ref(false)
|
||||
const isShopOwner = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
const currentNailArtist = ref<NailArtistInfoVO | null>(null)
|
||||
const currentUserInfo = getCurrentUserInfo()
|
||||
|
||||
const viewFormState = reactive({
|
||||
nickname: '',
|
||||
shopName: '',
|
||||
identity: '',
|
||||
experience: '',
|
||||
skillsText: '',
|
||||
statusText: '',
|
||||
rating: '',
|
||||
portfolioText: ''
|
||||
})
|
||||
|
||||
const pagination = reactive({
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
showTotal: (total: number) => `共 ${total} 条`
|
||||
})
|
||||
|
||||
const formState = reactive({
|
||||
userId: 0,
|
||||
identity: '',
|
||||
experience: 0,
|
||||
skills: [] as string[],
|
||||
rating: 0,
|
||||
status: 1,
|
||||
portfolio: [] as string[],
|
||||
nickname: ''
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
identity: [{ required: true, message: '请输入身份', trigger: 'blur' }],
|
||||
experience: [{ required: true, message: '请输入从业年限', trigger: 'blur' }],
|
||||
skills: [{ required: true, message: '请选择技能标签', trigger: 'change' }],
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
portfolio: [{ required: true, message: '请选择作品集商品', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const columns = [
|
||||
{ title: '美甲师姓名', dataIndex: 'nickname', key: 'nickname' },
|
||||
{ title: '所属店铺', dataIndex: 'shopName', key: 'shopName' },
|
||||
{ title: '身份', dataIndex: 'identity', key: 'identity' },
|
||||
{ title: '从业年限', dataIndex: 'experience', key: 'experience' },
|
||||
{ title: '评分', dataIndex: 'rating', key: 'rating' },
|
||||
{ title: '状态', key: 'status', width: 100 },
|
||||
{ title: '操作', key: 'actions', width: 150, fixed: 'right' as const }
|
||||
]
|
||||
|
||||
const getStatusText = (status: number) => {
|
||||
return status === 1 ? '营业中' : '休息中'
|
||||
}
|
||||
|
||||
const getStatusColor = (status: number) => {
|
||||
return status === 1 ? 'green' : 'default'
|
||||
}
|
||||
|
||||
const fetchTagList = async () => {
|
||||
tagLoading.value = true
|
||||
try {
|
||||
const res = await adminTagApi.listAllTags()
|
||||
tagList.value = res || []
|
||||
} catch (error) {
|
||||
console.error('获取标签列表失败:', error)
|
||||
} finally {
|
||||
tagLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const fetchProductList = async () => {
|
||||
productLoading.value = true
|
||||
try {
|
||||
const params: any = {
|
||||
page: 1,
|
||||
size: 1000
|
||||
}
|
||||
if (currentUserInfo && currentUserInfo.type !== 4 && currentUserInfo.shopId) {
|
||||
params.shopId = currentUserInfo.shopId
|
||||
}
|
||||
const res = await adminProductApi.listProducts(params)
|
||||
productList.value = res.list || []
|
||||
} catch (error) {
|
||||
console.error('获取商品列表失败:', error)
|
||||
} finally {
|
||||
productLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const fetchNailArtistList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await adminNailArtistApi.listNailArtists()
|
||||
let filteredList = res || []
|
||||
|
||||
// 按搜索词过滤
|
||||
if (searchText.value) {
|
||||
filteredList = filteredList.filter(item =>
|
||||
item.nickname?.includes(searchText.value)
|
||||
)
|
||||
}
|
||||
|
||||
nailArtistList.value = filteredList
|
||||
pagination.total = filteredList.length || 0
|
||||
} catch (error) {
|
||||
message.error('获取美甲师列表失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleSearch = () => {
|
||||
pagination.current = 1
|
||||
fetchNailArtistList()
|
||||
}
|
||||
|
||||
const handleTableChange = (pag: any) => {
|
||||
pagination.current = pag.current
|
||||
pagination.pageSize = pag.pageSize
|
||||
fetchNailArtistList()
|
||||
}
|
||||
|
||||
const showEditModal = (record: NailArtistInfoVO) => {
|
||||
currentNailArtist.value = record
|
||||
Object.assign(formState, {
|
||||
userId: record.userId,
|
||||
identity: record.identity || '',
|
||||
experience: record.experience || 0,
|
||||
skills: record.skills ? record.skills.split(',').filter(Boolean) : [],
|
||||
rating: record.rating || 0,
|
||||
status: record.status || 1,
|
||||
portfolio: record.portfolio ? record.portfolio.split(',').filter(Boolean) : [],
|
||||
nickname: record.nickname || ''
|
||||
})
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
const showViewModal = (record: NailArtistInfoVO) => {
|
||||
// 构建技能标签文本
|
||||
const skillsArray = record.skills ? record.skills.split(',').filter(Boolean) : []
|
||||
const skillsText = skillsArray.map(skillId => {
|
||||
const tag = tagList.value.find(t => t.id.toString() === skillId)
|
||||
return tag ? tag.tagName : skillId
|
||||
}).join(', ')
|
||||
|
||||
// 构建作品集文本
|
||||
const portfolioArray = record.portfolio ? record.portfolio.split(',').filter(Boolean) : []
|
||||
const portfolioText = portfolioArray.map(productId => {
|
||||
const product = productList.value.find(p => p.id.toString() === productId)
|
||||
return product ? product.title : productId
|
||||
}).join(', ')
|
||||
|
||||
Object.assign(viewFormState, {
|
||||
nickname: record.nickname || '',
|
||||
shopName: record.shopName || '',
|
||||
identity: record.identity || '',
|
||||
experience: (record.experience || 0).toString(),
|
||||
skillsText: skillsText,
|
||||
statusText: getStatusText(record.status || 1),
|
||||
rating: (record.rating || 0).toString(),
|
||||
portfolioText: portfolioText
|
||||
})
|
||||
viewModalVisible.value = true
|
||||
}
|
||||
|
||||
const handleViewModalCancel = () => {
|
||||
viewModalVisible.value = false
|
||||
}
|
||||
|
||||
const handleModalOk = async () => {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
|
||||
modalLoading.value = true
|
||||
|
||||
// 准备提交数据
|
||||
const submitData = {
|
||||
...formState,
|
||||
skills: formState.skills.join(','),
|
||||
portfolio: formState.portfolio.join(',')
|
||||
}
|
||||
|
||||
await adminNailArtistApi.saveNailArtistInfo(submitData)
|
||||
message.success('保存成功')
|
||||
|
||||
modalVisible.value = false
|
||||
fetchNailArtistList()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
message.error('操作失败')
|
||||
} finally {
|
||||
modalLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleModalCancel = () => {
|
||||
modalVisible.value = false
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadUserPermissions()
|
||||
fetchTagList()
|
||||
fetchProductList()
|
||||
fetchNailArtistList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.nail-artists {
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user