功能:完善门店能力与用户安全配置

This commit is contained in:
xiaowang
2026-05-18 10:04:57 +08:00
parent 4563dd2538
commit 3797938616
356 changed files with 24983 additions and 1858 deletions
@@ -43,6 +43,19 @@
{{ getStatusText(record.status) }}
</a-tag>
</template>
<template v-else-if="column.key === 'userTypeName'">
<a-tag :color="record.userType === 2 ? 'gold' : 'blue'">
{{ record.userTypeName || (record.userType === 2 ? '店长' : '美甲师') }}
</a-tag>
</template>
<template v-else-if="column.key === 'participateProduction'">
<a-tag :color="record.participateProduction === 1 ? 'green' : 'default'">
{{ record.participateProduction === 1 ? '参与制作' : '不参与' }}
</a-tag>
</template>
<template v-else-if="column.key === 'workTime'">
{{ formatWorkTime(record) }}
</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)">
@@ -154,6 +167,19 @@
<a-select-option :value="0">休息中</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="参与制作" name="participateProduction">
<a-switch
v-model:checked="formState.participateProduction"
:checked-value="1"
:un-checked-value="0"
:disabled="!isShopOwner"
/>
</a-form-item>
<a-form-item label="工作时间">
<a-input v-model:value="formState.workStartTime" type="time" placeholder="开始" />
<span class="time-separator">至</span>
<a-input v-model:value="formState.workEndTime" type="time" placeholder="结束" />
</a-form-item>
<a-form-item label="作品" name="portfolio">
<a-select
v-model:value="formState.portfolio"
@@ -207,6 +233,12 @@
<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.userTypeName" :disabled="true" />
</a-form-item>
<a-form-item label="工作时间">
<a-input v-model:value="viewFormState.workTime" :disabled="true" />
</a-form-item>
<a-form-item label="评分">
<a-input v-model:value="viewFormState.rating" :disabled="true" />
</a-form-item>
@@ -219,6 +251,10 @@
</template>
<script setup lang="ts">
/**
* NailArtistsView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { ref, reactive, onMounted } from 'vue'
import { message } from 'ant-design-vue'
import type { FormInstance } from 'ant-design-vue'
@@ -236,6 +272,7 @@ import AdminResponsiveModal from '@/components/admin/AdminResponsiveModal.vue'
const { hasPermission, loadUserPermissions } = usePermission()
const { isMobile } = useAdminViewport()
/** getCurrentUserInfo is a local helper used by this page script. */
const getCurrentUserInfo = () => {
try {
const userInfoStr = localStorage.getItem('adminUserInfo')
@@ -251,17 +288,26 @@ const getCurrentUserInfo = () => {
return null
}
/** loading is a reactive state variable used by the template and event handlers. */
const loading = ref(false)
/** tagLoading is a reactive state variable used by the template and event handlers. */
const tagLoading = ref(false)
/** productLoading is a reactive state variable used by the template and event handlers. */
const productLoading = ref(false)
/** searchText is a reactive state variable used by the template and event handlers. */
const searchText = ref('')
const nailArtistList = ref<NailArtistInfoVO[]>([])
const tagList = ref<Tag[]>([])
const productList = ref<Product[]>([])
/** modalVisible is a reactive state variable used by the template and event handlers. */
const modalVisible = ref(false)
/** modalLoading is a reactive state variable used by the template and event handlers. */
const modalLoading = ref(false)
/** viewModalVisible is a reactive state variable used by the template and event handlers. */
const viewModalVisible = ref(false)
/** isAdmin is a reactive state variable used by the template and event handlers. */
const isAdmin = ref(false)
/** isShopOwner is a reactive state variable used by the template and event handlers. */
const isShopOwner = ref(false)
const formRef = ref<FormInstance>()
const currentNailArtist = ref<NailArtistInfoVO | null>(null)
@@ -275,6 +321,8 @@ const viewFormState = reactive({
experience: '',
skillsText: '',
statusText: '',
userTypeName: '',
workTime: '',
rating: '',
portfolioText: ''
})
@@ -295,20 +343,29 @@ const formState = reactive({
skills: [] as string[],
rating: 0,
status: 1,
participateProduction: 1,
workStartTime: '',
workEndTime: '',
portfolio: [] as string[],
nickname: ''
})
/** getDraftKey is a local helper used by this page script. */
const getDraftKey = () => buildDraftStorageKey('admin-nail-artists', 'edit', currentNailArtist.value?.userId ?? formState.userId ?? 'unknown')
/** buildDraftPayload is a local helper used by this page script. */
const buildDraftPayload = () => ({
identity: formState.identity,
experience: formState.experience,
skills: [...formState.skills],
status: formState.status,
participateProduction: formState.participateProduction,
workStartTime: formState.workStartTime,
workEndTime: formState.workEndTime,
portfolio: [...formState.portfolio]
})
/** restoreDraft is a local helper used by this page script. */
const restoreDraft = () => {
const draft = loadDraftRecord<ReturnType<typeof buildDraftPayload>>(getDraftKey())
if (!draft) {
@@ -322,18 +379,25 @@ const restoreDraft = () => {
status: typeof draft.payload.status === 'number'
? (draft.payload.status === 0 ? 0 : 1)
: formState.status,
participateProduction: typeof draft.payload.participateProduction === 'number'
? (draft.payload.participateProduction === 1 ? 1 : 0)
: formState.participateProduction,
workStartTime: draft.payload.workStartTime ?? formState.workStartTime,
workEndTime: draft.payload.workEndTime ?? formState.workEndTime,
portfolio: Array.isArray(draft.payload.portfolio) ? draft.payload.portfolio : formState.portfolio
})
draftSavedAt.value = draft.savedAt
message.success('已恢复暂存内容')
}
/** handleSaveDraft is a local helper used by this page script. */
const handleSaveDraft = () => {
const draft = saveDraftRecord(getDraftKey(), buildDraftPayload())
draftSavedAt.value = draft.savedAt
message.success('已暂存到本地')
}
/** handleClearDraft is a local helper used by this page script. */
const handleClearDraft = (showMessage = true) => {
clearDraftRecord(getDraftKey())
draftSavedAt.value = null
@@ -353,6 +417,9 @@ const formRules = {
const columns = [
{ title: '美甲师姓名', dataIndex: 'nickname', key: 'nickname' },
{ title: '所属店铺', dataIndex: 'shopName', key: 'shopName' },
{ title: '人员类型', key: 'userTypeName', width: 110 },
{ title: '参与制作', key: 'participateProduction', width: 120 },
{ title: '工作时间', key: 'workTime', width: 150 },
{ title: '身份', dataIndex: 'identity', key: 'identity' },
{ title: '从业年限', dataIndex: 'experience', key: 'experience' },
{ title: '评分', dataIndex: 'rating', key: 'rating' },
@@ -360,14 +427,27 @@ const columns = [
{ title: '操作', key: 'actions', width: 150, fixed: 'right' as const }
]
/** getStatusText is a local helper used by this page script. */
const getStatusText = (status: number) => {
return status === 1 ? '营业中' : '休息中'
}
/** getStatusColor is a local helper used by this page script. */
const getStatusColor = (status: number) => {
return status === 1 ? 'green' : 'default'
}
/** formatWorkTime is a local helper used by this page script. */
const formatWorkTime = (record: Partial<NailArtistInfoVO>) => {
const start = record.workStartTime ? String(record.workStartTime).slice(0, 5) : ''
const end = record.workEndTime ? String(record.workEndTime).slice(0, 5) : ''
return start && end ? `${start} - ${end}` : '--'
}
/** normalizeTime is a local helper used by this page script. */
const normalizeTime = (value?: string) => value ? (String(value).length === 5 ? `${value}:00` : String(value)) : undefined
/** fetchTagList is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const fetchTagList = async () => {
tagLoading.value = true
try {
@@ -380,6 +460,7 @@ const fetchTagList = async () => {
}
}
/** fetchProductList is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const fetchProductList = async () => {
productLoading.value = true
try {
@@ -399,6 +480,7 @@ const fetchProductList = async () => {
}
}
/** fetchNailArtistList is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const fetchNailArtistList = async () => {
loading.value = true
try {
@@ -421,17 +503,20 @@ const fetchNailArtistList = async () => {
}
}
/** handleSearch is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleSearch = async () => {
pagination.current = 1
await runWithGlobalLoading(() => fetchNailArtistList())
}
/** handleTableChange is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleTableChange = async (pag: any) => {
pagination.current = pag.current
pagination.pageSize = pag.pageSize
await runWithGlobalLoading(() => fetchNailArtistList())
}
/** showEditModal is a local helper used by this page script. */
const showEditModal = (record: Record<string, any>) => {
currentNailArtist.value = record as NailArtistInfoVO
const lockedFields = {
@@ -444,6 +529,9 @@ const showEditModal = (record: Record<string, any>) => {
experience: record.experience || 0,
skills: record.skills ? record.skills.split(',').filter(Boolean) : [],
status: record.status || 1,
participateProduction: record.participateProduction ?? (record.userType === 3 ? 1 : 0),
workStartTime: record.workStartTime || '',
workEndTime: record.workEndTime || '',
portfolio: record.portfolio ? record.portfolio.split(',').filter(Boolean) : [],
...lockedFields
})
@@ -452,6 +540,7 @@ const showEditModal = (record: Record<string, any>) => {
modalVisible.value = true
}
/** showViewModal is a local helper used by this page script. */
const showViewModal = (record: Record<string, any>) => {
const nailArtist = record as NailArtistInfoVO
// 构建技能标签文本
@@ -475,16 +564,20 @@ const showViewModal = (record: Record<string, any>) => {
experience: (nailArtist.experience || 0).toString(),
skillsText: skillsText,
statusText: getStatusText(nailArtist.status || 1),
userTypeName: nailArtist.userTypeName || (nailArtist.userType === 2 ? '店长' : '美甲师'),
workTime: formatWorkTime(nailArtist),
rating: (nailArtist.rating || 0).toString(),
portfolioText: portfolioText
})
viewModalVisible.value = true
}
/** handleViewModalCancel is a local helper used by this page script. */
const handleViewModalCancel = () => {
viewModalVisible.value = false
}
/** handleModalOk is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleModalOk = async () => {
try {
await formRef.value?.validate()
@@ -505,6 +598,9 @@ const handleModalOk = async () => {
experience: formState.experience,
rating: formState.rating,
status: formState.status,
participateProduction: formState.participateProduction,
workStartTime: normalizeTime(formState.workStartTime),
workEndTime: normalizeTime(formState.workEndTime),
skills: formState.skills.join(','),
portfolio: formState.portfolio.join(',')
}
@@ -529,6 +625,7 @@ const handleModalOk = async () => {
}
}
/** handleModalCancel is a local helper used by this page script. */
const handleModalCancel = () => {
modalVisible.value = false
currentNailArtist.value = null