清理Salon管理页面电商残留

This commit is contained in:
2026-11-01 15:26:36 +08:00
parent 52b7dcb7d3
commit 9e47371442
7 changed files with 5 additions and 983 deletions
+4 -474
View File
@@ -49,9 +49,6 @@
{{ shop.shopName }}
</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>
@@ -115,14 +112,6 @@
<a-button v-if="hasPermission('user:edit')" type="link" size="small" @click="showEditModal(record)">
编辑
</a-button>
<a-button
v-if="canOpenAssetPanel"
type="link"
size="small"
@click="showAssetModal(record)"
>
余额/VIP
</a-button>
<a-button
v-if="hasPermission('user:reset_password')"
type="link"
@@ -174,10 +163,6 @@
<span>所属店铺</span>
<strong>{{ getShopDisplay(item) || '-' }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>VIP 等级</span>
<strong>{{ item.level || '普通' }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>状态</span>
<strong>{{ item.status === 1 ? '正常' : '禁用' }}</strong>
@@ -186,7 +171,6 @@
<div class="admin-mobile-card__actions">
<a-button v-if="hasPermission('user:view')" size="small" @click="showViewModal(item)">查看</a-button>
<a-button v-if="hasPermission('user:edit')" size="small" @click="showEditModal(item)">编辑</a-button>
<a-button v-if="canOpenAssetPanel" size="small" @click="showAssetModal(item)">余额/VIP</a-button>
<a-button v-if="hasPermission('user:reset_password')" size="small" @click="handleResetPassword(item)">
重置密码
</a-button>
@@ -342,15 +326,13 @@
<a-descriptions-item label="手机号">{{ viewRecord?.phone || '-' }}</a-descriptions-item>
<a-descriptions-item label="所属店铺">{{ getShopDisplay(viewRecord) || '-' }}</a-descriptions-item>
<a-descriptions-item label="用户类型">{{ getUserTypeText(viewRecord?.type || 0) }}</a-descriptions-item>
<a-descriptions-item label="VIP 等级">{{ viewRecord?.level || '普通' }}</a-descriptions-item>
<a-descriptions-item label="状态">{{ viewRecord?.status === 1 ? '正常' : '禁用' }}</a-descriptions-item>
<a-descriptions-item label="创建时间">{{ viewRecord?.createTime || '-' }}</a-descriptions-item>
</a-descriptions>
</AdminResponsiveModal>
<AdminResponsiveModal
<AdminMobileFab
:visible="isMobile && canCreateUser && !modalVisible && !viewModalVisible && !assetModalVisible"
:visible="isMobile && canCreateUser && !modalVisible && !viewModalVisible"
label="新增店长"
@click="showAddModal"
/>
@@ -362,7 +344,7 @@
* UsersView 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 { computed, h, onMounted, reactive, ref } from 'vue'
import { computed, h, onMounted, reactive, ref, watch } from 'vue'
import { message, Modal } from 'ant-design-vue'
import type { FormInstance, UploadProps } from 'ant-design-vue'
import { PlusOutlined } from '@ant-design/icons-vue'
@@ -380,15 +362,9 @@ import {
adminShopApi,
adminSystemParameterConfigApi,
adminUserApi,
adminVipRechargePlanApi,
type AdminUserBalanceChangeRequest,
type AdminUserVipOverrideRequest,
type Shop,
type UserAssetVO,
type UserBalanceHistoryItem,
type UserVO
} from '@/api/admin'
import type { IdType } from '@/utils/id'
import { sameId } from '@/utils/id'
import { usePermission } from '@/utils/permission'
import { runWithGlobalLoading } from '@/utils/action-loading'
@@ -399,7 +375,7 @@ import AdminMobileFab from '@/components/admin/AdminMobileFab.vue'
import AdminFilterPanel from '@/components/admin/AdminFilterPanel.vue'
import AdminResponsiveModal from '@/components/admin/AdminResponsiveModal.vue'
const { hasPermission, hasAnyPermission, loadUserPermissions } = usePermission()
const { hasPermission, loadUserPermissions } = usePermission()
const { isMobile } = useAdminViewport()
const FALLBACK_ADMIN_DEFAULT_PASSWORD = 'Fingertip@123'
@@ -502,11 +478,6 @@ const shopFilter = ref<string | undefined>()
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const typeFilter = ref<number | undefined>(2)
/**
* Purpose: vipLevelFilter supports UsersView.vue by holding or executing the vip level filter page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const vipLevelFilter = ref<string | undefined>()
/**
* Purpose: statusFilter supports UsersView.vue by holding or executing the status filter page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -542,11 +513,6 @@ const userList = ref<UserVO[]>([])
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const shopList = ref<Shop[]>([])
/**
* Purpose: vipLevelOptions supports UsersView.vue by holding or executing the vip level options page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const vipLevelOptions = ref<string[]>(['普通', '青铜', '白银', '黄金'])
/**
* Purpose: currentUser supports UsersView.vue by holding or executing the current user page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -563,42 +529,6 @@ const viewRecord = ref<UserVO | null>(null)
*/
const draftSavedAt = ref<number | null>(null)
/** assetModalVisible is a reactive state variable used by the template and event handlers. */
const assetModalVisible = ref(false)
/** assetLoading is a reactive state variable used by the template and event handlers. */
const assetLoading = ref(false)
/** assetSaving is a reactive state variable used by the template and event handlers. */
const assetSaving = ref(false)
/**
* Purpose: assetTargetUser supports UsersView.vue by holding or executing the asset target user page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const assetTargetUser = ref<UserVO | null>(null)
/**
* Purpose: assetData supports UsersView.vue by holding or executing the asset data page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const assetData = ref<UserAssetVO | null>(null)
/**
* Purpose: balanceHistory supports UsersView.vue by holding or executing the balance history page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const balanceHistory = ref<UserBalanceHistoryItem[]>([])
/**
* Purpose: balanceDraftSavedAt supports UsersView.vue by holding or executing the balance draft saved at page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const balanceDraftSavedAt = ref<number | null>(null)
/**
* Purpose: vipDraftSavedAt supports UsersView.vue by holding or executing the vip draft saved at page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const vipDraftSavedAt = ref<number | null>(null)
/** canOpenAssetPanel is a reactive state variable used by the template and event handlers. */
const canOpenAssetPanel = computed(() =>
hasAnyPermission(['user:balance:view', 'user:balance:manage', 'user:vip:manage'])
)
/** currentUserType is a reactive state variable used by the template and event handlers. */
const currentUserType = computed(() => normalizeUserType(currentUserInfo?.type))
/** availableUserTypeOptions is a reactive state variable used by the template and event handlers. */
@@ -641,7 +571,6 @@ const activeMobileFilterCount = computed(() => {
const values = [
currentUserType.value === 4 ? shopFilter.value : undefined,
typeFilter.value,
vipLevelFilter.value,
statusFilter.value,
createdRange.value,
hasPhoneFilter.value,
@@ -805,106 +734,6 @@ const validateOptionalPasswordStrength = (value?: string) => {
}
}
/**
* Purpose: balanceForm supports UsersView.vue by holding or executing the balance form page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const balanceForm = reactive<AdminUserBalanceChangeRequest>({
changeScene: 'RECHARGE',
amount: undefined as unknown as number,
relatedOrderId: undefined,
externalOrderNo: '',
remark: ''
})
/**
* Purpose: vipForm supports UsersView.vue by holding or executing the vip form page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const vipForm = reactive<AdminUserVipOverrideRequest>({
vipLevel: '普通',
remark: ''
})
/** getBalanceDraftKey is a local helper used by this page script. */
const getBalanceDraftKey = () => buildDraftStorageKey('admin-user-assets', 'balance', assetTargetUser.value?.id ?? 'unknown')
/** getVipDraftKey is a local helper used by this page script. */
const getVipDraftKey = () => buildDraftStorageKey('admin-user-assets', 'vip', assetTargetUser.value?.id ?? 'unknown')
/** restoreBalanceDraft is a local helper used by this page script. */
const restoreBalanceDraft = () => {
const draft = loadDraftRecord<{
changeScene: string
amount?: number
relatedOrderId?: number
externalOrderNo: string
remark: string
}>(getBalanceDraftKey())
if (!draft) {
balanceDraftSavedAt.value = null
return
}
Object.assign(balanceForm, draft.payload)
balanceDraftSavedAt.value = draft.savedAt
message.success('已恢复余额变动暂存')
}
/** handleSaveBalanceDraft is a local helper used by this page script. */
const handleSaveBalanceDraft = () => {
const draft = saveDraftRecord(getBalanceDraftKey(), {
changeScene: balanceForm.changeScene,
amount: balanceForm.amount,
relatedOrderId: balanceForm.relatedOrderId,
externalOrderNo: balanceForm.externalOrderNo,
remark: balanceForm.remark
})
balanceDraftSavedAt.value = draft.savedAt
message.success('余额变动已暂存到本地')
}
/** handleClearBalanceDraft is a local helper used by this page script. */
const handleClearBalanceDraft = (showMessage = true) => {
clearDraftRecord(getBalanceDraftKey())
balanceDraftSavedAt.value = null
if (showMessage) {
message.success('已清除余额变动暂存')
}
}
/** restoreVipDraft is a local helper used by this page script. */
const restoreVipDraft = () => {
const draft = loadDraftRecord<{
vipLevel: string
remark: string
}>(getVipDraftKey())
if (!draft) {
vipDraftSavedAt.value = null
return
}
Object.assign(vipForm, draft.payload)
vipDraftSavedAt.value = draft.savedAt
message.success('已恢复 VIP 暂存')
}
/** handleSaveVipDraft is a local helper used by this page script. */
const handleSaveVipDraft = () => {
const draft = saveDraftRecord(getVipDraftKey(), {
vipLevel: vipForm.vipLevel,
remark: vipForm.remark || ''
})
vipDraftSavedAt.value = draft.savedAt
message.success('VIP 设置已暂存到本地')
}
/** handleClearVipDraft is a local helper used by this page script. */
const handleClearVipDraft = (showMessage = true) => {
clearDraftRecord(getVipDraftKey())
vipDraftSavedAt.value = null
if (showMessage) {
message.success('已清除 VIP 暂存')
}
}
/**
* Purpose: formRules supports UsersView.vue by holding or executing the form rules page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -977,25 +806,11 @@ const columns = [
{ title: '手机号', dataIndex: 'phone', key: 'phone' },
{ title: '所属店铺', key: 'shopName', width: 140 },
{ title: '用户类型', key: 'type', width: 110 },
{ title: 'VIP 等级', key: 'level', width: 110 },
{ title: '状态', key: 'status', width: 100 },
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime', width: 180 },
{ title: '操作', key: 'actions', width: 280, fixed: 'right' as const }
]
/**
* Purpose: historyColumns supports UsersView.vue by holding or executing the history columns page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const historyColumns = [
{ title: '场景', key: 'changeScene', width: 120 },
{ title: '金额', key: 'amount', width: 110 },
{ title: '余额变化', key: 'balanceRange', width: 170 },
{ title: '关联单号', key: 'relatedOrder', width: 180 },
{ title: '备注', dataIndex: 'remark', key: 'remark' },
{ title: '时间', key: 'changeTime', width: 180 }
]
/** getUserTypeText is a local helper used by this page script. */
const getUserTypeText = (type: number) => {
const map: Record<number, string> = {
@@ -1045,34 +860,6 @@ const getUnbindConfirmText = (record: Partial<UserVO> | Record<string, any>) =>
return '确定要解绑该用户与当前店铺的关系吗?'
}
/** getSceneText is a local helper used by this page script. */
const getSceneText = (scene?: string) => {
const map: Record<string, string> = {
RECHARGE: '充值',
MANUAL_ADD: '手工增加',
MANUAL_DEDUCT: '手工扣减',
ORDER_CONSUME: '订单消费',
ORDER_REFUND: '订单退款'
}
return scene ? map[scene] || scene : '-'
}
/** formatMoney is a local helper used by this page script. */
const formatMoney = (value?: number | string | null) => {
if (value === undefined || value === null || value === '') {
return '0.00'
}
return Number(value).toFixed(2)
}
/** formatDate is a local helper used by this page script. */
const formatDate = (value?: string) => {
if (!value) {
return '-'
}
return value.replace('T', ' ').slice(0, 19)
}
/** filterVisibleUsers is a local helper used by this page script. */
const filterVisibleUsers = (list: UserVO[]) => {
if (!currentUserInfo || currentUserType.value === 4) {
@@ -1173,7 +960,6 @@ const fetchUserList = async () => {
size: pagination.pageSize,
keyword: searchText.value || undefined,
type: typeFilter.value,
vipLevel: vipLevelFilter.value,
status: statusFilter.value,
createdFrom: createdRange.value?.[0],
createdTo: createdRange.value?.[1],
@@ -1206,7 +992,6 @@ const resetFilters = () => {
searchText.value = ''
shopFilter.value = currentUserType.value !== 4 ? normalizeShopId(currentUserInfo?.shopId) : undefined
typeFilter.value = 2
vipLevelFilter.value = undefined
statusFilter.value = undefined
createdRange.value = undefined
hasPhoneFilter.value = undefined
@@ -1335,62 +1120,6 @@ const showViewModal = (record: any) => {
viewModalVisible.value = true
}
/** loadUserAssetData is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadUserAssetData = async (userId: IdType) => {
const [asset, history] = await Promise.all([
adminUserApi.getUserAsset(userId),
adminUserApi.getUserBalanceHistory(userId)
])
assetData.value = asset
balanceHistory.value = history || []
vipForm.vipLevel = asset.vipLevel || '普通'
}
/** resetAssetForms is a local helper used by this page script. */
const resetAssetForms = () => {
Object.assign(balanceForm, {
changeScene: 'RECHARGE',
amount: undefined,
relatedOrderId: undefined,
externalOrderNo: '',
remark: ''
})
Object.assign(vipForm, {
vipLevel: assetData.value?.vipLevel || '普通',
remark: ''
})
}
/** showAssetModal is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const showAssetModal = async (record: any) => {
assetTargetUser.value = record
assetModalVisible.value = true
assetLoading.value = true
assetData.value = null
balanceHistory.value = []
resetAssetForms()
try {
await runWithGlobalLoading(() => loadUserAssetData(record.id))
resetAssetForms()
restoreBalanceDraft()
restoreVipDraft()
} catch (error) {
console.error('获取用户资产失败:', error)
message.error('获取用户资产失败')
} finally {
assetLoading.value = false
}
}
/** handleAssetModalCancel is a local helper used by this page script. */
const handleAssetModalCancel = () => {
assetModalVisible.value = false
assetTargetUser.value = null
assetData.value = null
balanceHistory.value = []
resetAssetForms()
}
/** handleModalOk is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleModalOk = async () => {
try {
@@ -1553,140 +1282,6 @@ const handleUnbind = async (record: any) => {
}
}
/** refreshAssetPanel is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const refreshAssetPanel = async () => {
if (!assetTargetUser.value) {
return
}
assetLoading.value = true
try {
await loadUserAssetData(assetTargetUser.value.id)
const matchedUser = userList.value.find(user => sameId(user.id, assetTargetUser.value?.id))
if (matchedUser && assetData.value) {
matchedUser.level = assetData.value.vipLevel
matchedUser.vipId = assetData.value.vipInfoId
}
} finally {
assetLoading.value = false
}
}
/** handleBalanceChange is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleBalanceChange = async () => {
if (!assetTargetUser.value) {
return
}
const targetUserId = assetTargetUser.value.id
if (!balanceForm.amount || Number(balanceForm.amount) <= 0) {
message.warning('请输入大于 0 的金额')
return
}
if (
balanceForm.changeScene === 'MANUAL_DEDUCT'
&& !balanceForm.relatedOrderId
&& !balanceForm.externalOrderNo?.trim()
) {
message.warning('手工扣减余额时必须填写系统订单 ID 或外部单号')
return
}
assetSaving.value = true
try {
await runWithGlobalLoading(async () => {
await adminUserApi.changeUserBalance(targetUserId, {
amount: Number(balanceForm.amount),
changeScene: balanceForm.changeScene,
relatedOrderId: balanceForm.relatedOrderId,
externalOrderNo: balanceForm.externalOrderNo?.trim() || undefined,
remark: balanceForm.remark?.trim() || undefined
})
message.success('余额变动已保存')
handleClearBalanceDraft(false)
Object.assign(balanceForm, {
amount: undefined,
relatedOrderId: undefined,
externalOrderNo: '',
remark: ''
})
await refreshAssetPanel()
})
} catch (error: any) {
console.error('余额变动失败:', error)
message.error(error.message || '余额变动失败')
} finally {
assetSaving.value = false
}
}
/** handleVipOverride is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleVipOverride = async () => {
if (!assetTargetUser.value) {
return
}
const targetUserId = assetTargetUser.value.id
assetSaving.value = true
try {
await runWithGlobalLoading(async () => {
await adminUserApi.overrideUserVip(targetUserId, {
vipLevel: vipForm.vipLevel,
remark: vipForm.remark?.trim() || undefined
})
message.success('VIP 已更新')
handleClearVipDraft(false)
vipForm.remark = ''
await refreshAssetPanel()
})
} catch (error: any) {
console.error('VIP 更新失败:', error)
message.error(error.message || 'VIP 更新失败')
} finally {
assetSaving.value = false
}
}
/** handleVipRecalculate is a local helper used by this page script. */
const handleVipRecalculate = () => {
if (!assetTargetUser.value) {
return
}
Modal.confirm({
title: '恢复自动判级',
content: '恢复后会清除手工指定状态,并按累计充值金额重新计算 VIP 等级,是否继续?',
async onOk() {
assetSaving.value = true
try {
await runWithGlobalLoading(async () => {
await adminUserApi.recalculateUserVip(assetTargetUser.value!.id)
message.success('已恢复自动判级')
handleClearVipDraft(false)
vipForm.remark = ''
await refreshAssetPanel()
})
} catch (error: any) {
console.error('恢复自动判级失败:', error)
message.error(error.message || '恢复自动判级失败')
} finally {
assetSaving.value = false
}
}
})
}
/**
* Purpose: fetchVipLevelOptions supports UsersView.vue by holding or executing the fetch vip level options page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
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 = []
@@ -1696,7 +1291,7 @@ watch(() => formState.type, type => {
onMounted(async () => {
await loadUserPermissions()
await Promise.all([fetchShopList(), fetchVipLevelOptions()])
await fetchShopList()
await fetchUserList()
})
</script>
@@ -1706,12 +1301,6 @@ onMounted(async () => {
padding: 0;
}
.asset-modal {
display: flex;
flex-direction: column;
gap: 16px;
}
.mobile-user-head {
display: flex;
align-items: center;
@@ -1737,65 +1326,6 @@ onMounted(async () => {
object-fit: cover;
}
.asset-summary,
.asset-actions,
.history-card {
margin-top: 0;
}
.summary-value {
font-size: 22px;
font-weight: 600;
line-height: 1.4;
}
.summary-sub {
margin-top: 8px;
color: var(--text-secondary);
font-size: 12px;
line-height: 1.6;
}
.vip-note {
margin-top: 12px;
color: var(--text-secondary);
font-size: 12px;
}
.amount-plus {
color: #52c41a;
font-weight: 600;
}
.amount-minus {
color: #ff4d4f;
font-weight: 600;
}
@media (max-width: 960px) {
.asset-summary,
.asset-actions {
row-gap: 12px;
}
.asset-summary :deep(.ant-col),
.asset-actions :deep(.ant-col) {
flex: 0 0 100%;
max-width: 100%;
}
.asset-actions :deep(.ant-space) {
width: 100%;
display: flex;
flex-wrap: wrap;
gap: 8px !important;
}
.asset-actions :deep(.ant-space-item) {
max-width: 100%;
}
}
:global(.default-password-notice) {
display: grid;
gap: 12px;