杂务:整理文档并收口 YumiNail 修复

This commit is contained in:
xiaowang
2026-05-21 18:43:59 +08:00
parent 3797938616
commit 9227ec6175
362 changed files with 8358 additions and 19928 deletions
+119 -13
View File
@@ -31,6 +31,49 @@
</div>
</template>
<div class="admin-filter-bar">
<a-select
v-model:value="shopFilter"
:allow-clear="currentUserType === 4"
placeholder="所属店铺"
style="width: 180px"
:loading="shopLoading"
:disabled="currentUserType !== 4 && !!currentUserInfo?.shopId"
@change="handleSearch"
>
<a-select-option
v-for="shop in shopList"
:key="shop.id"
:value="getShopOptionValue(shop)"
>
{{ shop.shopName }}
</a-select-option>
</a-select>
<a-select v-model:value="typeFilter" allow-clear placeholder="用户类型" style="width: 140px" @change="handleSearch">
<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-select v-model:value="vipLevelFilter" allow-clear placeholder="VIP等级" style="width: 140px" @change="handleSearch">
<a-select-option v-for="level in vipLevelOptions" :key="level" :value="level">{{ level }}</a-select-option>
</a-select>
<a-select v-model:value="statusFilter" allow-clear placeholder="账号状态" style="width: 140px" @change="handleSearch">
<a-select-option :value="1">启用</a-select-option>
<a-select-option :value="0">停用</a-select-option>
</a-select>
<a-range-picker v-model:value="createdRange" value-format="YYYY-MM-DD HH:mm:ss" show-time @change="handleSearch" />
<a-select v-model:value="hasPhoneFilter" allow-clear placeholder="手机号" style="width: 130px" @change="handleSearch">
<a-select-option value="true">有手机号</a-select-option>
<a-select-option value="false">无手机号</a-select-option>
</a-select>
<a-select v-model:value="hasOrderFilter" allow-clear placeholder="订单情况" style="width: 130px" @change="handleSearch">
<a-select-option value="true">有订单</a-select-option>
<a-select-option value="false">无订单</a-select-option>
</a-select>
<a-button @click="resetFilters">重置筛选</a-button>
</div>
<a-table
v-if="!isMobile"
:columns="columns"
@@ -206,9 +249,9 @@
<a-select
v-model:value="formState.shopIds"
mode="multiple"
:placeholder="currentUserType === 4 ? '请选择一个或多个店铺' : '请选择店铺'"
:placeholder="Number(formState.type) === 4 ? '平台管理员无需绑定店铺' : (currentUserType === 4 ? '请选择一个或多个店铺' : '请选择店铺')"
:loading="shopLoading"
:disabled="currentUserType !== 4 && !!currentUserInfo?.shopId"
:disabled="Number(formState.type) === 4 || (currentUserType !== 4 && !!currentUserInfo?.shopId)"
>
<a-select-option
v-for="shop in shopList"
@@ -364,10 +407,7 @@
<a-form layout="vertical">
<a-form-item label="目标等级">
<a-select v-model:value="vipForm.vipLevel">
<a-select-option value="普通">普通</a-select-option>
<a-select-option value="青铜">青铜</a-select-option>
<a-select-option value="白银">白银</a-select-option>
<a-select-option value="黄金">黄金</a-select-option>
<a-select-option v-for="level in vipLevelOptions" :key="level" :value="level">{{ level }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="备注">
@@ -461,6 +501,7 @@ import { userApi, type AvailabilityCheckResponse } from '@/api/user'
import {
adminShopApi,
adminUserApi,
adminVipRechargePlanApi,
type AdminUserBalanceChangeRequest,
type AdminUserVipOverrideRequest,
type Shop,
@@ -511,9 +552,17 @@ const viewModalVisible = ref(false)
const isEdit = ref(false)
/** searchText is a reactive state variable used by the template and event handlers. */
const searchText = ref('')
const shopFilter = ref<string | undefined>()
const typeFilter = ref<number | undefined>()
const vipLevelFilter = ref<string | undefined>()
const statusFilter = ref<number | undefined>()
const createdRange = ref<[string, string] | undefined>()
const hasPhoneFilter = ref<'true' | 'false' | undefined>()
const hasOrderFilter = ref<'true' | 'false' | undefined>()
const formRef = ref<FormInstance>()
const userList = ref<UserVO[]>([])
const shopList = ref<Shop[]>([])
const vipLevelOptions = ref<string[]>(['普通', '青铜', '白银', '黄金'])
const currentUser = ref<UserVO | null>(null)
const viewRecord = ref<UserVO | null>(null)
const draftSavedAt = ref<number | null>(null)
@@ -743,9 +792,15 @@ const formRules = {
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
shopIds: [{
validator: async (_rule: unknown, value: string[]) => {
if (Number(formState.type) === 4) {
return Promise.resolve()
}
if (Array.isArray(value) && value.length > 0) {
return Promise.resolve()
}
if (currentUserType.value === 4 && shopList.value.length === 0) {
return Promise.reject('请先新增店铺后再创建店铺用户')
}
return Promise.reject('请选择至少一个店铺')
},
trigger: 'change'
@@ -933,6 +988,7 @@ const fetchShopList = async () => {
const shops = await adminShopApi.listAllShops() as unknown as Shop[]
shopList.value = shops || []
if (currentUserType.value !== 4 && currentUserInfo?.shopId) {
shopFilter.value = normalizeShopId(currentUserInfo.shopId)
formState.shopIds = [normalizeShopId(currentUserInfo.shopId)!]
}
} catch (error) {
@@ -949,11 +1005,19 @@ const fetchUserList = async () => {
const params: Record<string, unknown> = {
page: pagination.current,
size: pagination.pageSize,
keyword: searchText.value || undefined
keyword: searchText.value || undefined,
type: typeFilter.value,
vipLevel: vipLevelFilter.value,
status: statusFilter.value,
createdFrom: createdRange.value?.[0],
createdTo: createdRange.value?.[1],
hasPhone: hasPhoneFilter.value === undefined ? undefined : hasPhoneFilter.value === 'true',
hasOrder: hasOrderFilter.value === undefined ? undefined : hasOrderFilter.value === 'true'
}
if (currentUserInfo?.shopId) {
params.shopId = currentUserInfo.shopId
const scopedShopId = shopFilter.value || (currentUserType.value !== 4 ? normalizeShopId(currentUserInfo?.shopId) : undefined)
if (scopedShopId) {
params.shopId = scopedShopId
}
const res = await adminUserApi.listUsers(params as any)
@@ -968,14 +1032,30 @@ const fetchUserList = async () => {
}
}
const resetFilters = () => {
searchText.value = ''
shopFilter.value = currentUserType.value !== 4 ? normalizeShopId(currentUserInfo?.shopId) : undefined
typeFilter.value = undefined
vipLevelFilter.value = undefined
statusFilter.value = undefined
createdRange.value = undefined
hasPhoneFilter.value = undefined
hasOrderFilter.value = undefined
handleSearch()
}
/** resetFormState is a local helper used by this page script. */
const resetFormState = () => {
const defaultUserType = currentUserType.value === 4 && shopList.value.length === 0
? availableUserTypeOptions.value.find(option => option.value === 4)?.value
: availableUserTypeOptions.value[0]?.value
Object.assign(formState, {
account: '',
nickname: '',
phone: '',
password: '',
type: availableUserTypeOptions.value[0]?.value ?? 0,
type: defaultUserType ?? 0,
shopIds: currentUserType.value !== 4 && currentUserInfo?.shopId
? [normalizeShopId(currentUserInfo.shopId)!]
: []
@@ -1130,13 +1210,14 @@ const handleModalOk = async () => {
await formRef.value?.validate()
modalLoading.value = true
await runWithGlobalLoading(async () => {
const requestShopIds = Number(formState.type) === 4 ? [] : formState.shopIds
const requestData: Record<string, unknown> = {
account: formState.account.trim(),
nickname: formState.nickname.trim(),
phone: formState.phone.trim(),
type: formState.type,
shopIds: formState.shopIds,
shopId: formState.shopIds.length ? formState.shopIds[0] : undefined,
shopIds: requestShopIds,
shopId: requestShopIds.length ? requestShopIds[0] : undefined,
...(formState.password.trim() ? { password: formState.password.trim() } : {})
}
@@ -1384,9 +1465,27 @@ const handleVipRecalculate = () => {
})
}
const fetchVipLevelOptions = async () => {
try {
const levels = await adminVipRechargePlanApi.listVipLevelOptions(currentUserInfo?.shopId)
if (Array.isArray(levels) && levels.length) {
vipLevelOptions.value = ['普通', ...levels.filter(level => level !== '普通')]
}
} catch (error) {
console.error('VIP 等级选项加载失败:', error)
}
}
watch(() => formState.type, type => {
if (Number(type) === 4) {
formState.shopIds = []
formRef.value?.clearValidate?.(['shopIds'])
}
})
onMounted(async () => {
await loadUserPermissions()
await fetchShopList()
await Promise.all([fetchShopList(), fetchVipLevelOptions()])
await fetchUserList()
})
</script>
@@ -1402,6 +1501,13 @@ onMounted(async () => {
gap: 16px;
}
.admin-filter-bar {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-bottom: 16px;
}
.mobile-user-head {
display: flex;
align-items: center;