杂务:整理文档并收口 YumiNail 修复
This commit is contained in:
@@ -217,9 +217,7 @@
|
||||
|
||||
<a-form-item v-if="isVipAutoForm" label="所需 VIP 等级" name="requiredVipLevel">
|
||||
<a-select v-model:value="formState.requiredVipLevel" placeholder="请选择 VIP 等级">
|
||||
<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>
|
||||
|
||||
@@ -249,7 +247,7 @@
|
||||
|
||||
<a-form-item label="可用标签" name="availableTagIds">
|
||||
<a-select v-model:value="formState.availableTagIds" mode="multiple" placeholder="请选择可用标签">
|
||||
<a-select-option v-for="tag in tagList" :key="tag.id" :value="tag.id">
|
||||
<a-select-option v-for="tag in tagList" :key="tag.id" :value="tag.id" :disabled="formState.unavailableTagIds.includes(Number(tag.id))">
|
||||
{{ tag.tagName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
@@ -257,7 +255,7 @@
|
||||
|
||||
<a-form-item label="不可用标签" name="unavailableTagIds">
|
||||
<a-select v-model:value="formState.unavailableTagIds" mode="multiple" placeholder="请选择不可用标签">
|
||||
<a-select-option v-for="tag in tagList" :key="tag.id" :value="tag.id">
|
||||
<a-select-option v-for="tag in tagList" :key="tag.id" :value="tag.id" :disabled="formState.availableTagIds.includes(Number(tag.id))">
|
||||
{{ tag.tagName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
@@ -343,6 +341,7 @@ import DraftActions from '@/components/DraftActions.vue'
|
||||
import dayjs, { type Dayjs } from 'dayjs'
|
||||
import {
|
||||
adminCouponApi,
|
||||
adminVipRechargePlanApi,
|
||||
adminShopApi,
|
||||
adminTagApi,
|
||||
adminUserApi,
|
||||
@@ -413,6 +412,7 @@ const couponList = ref<Coupon[]>([])
|
||||
const tagList = ref<Tag[]>([])
|
||||
const userList = ref<UserVO[]>([])
|
||||
const shops = ref<Shop[]>([])
|
||||
const vipLevelOptions = ref<string[]>(['普通', '青铜', '白银', '黄金'])
|
||||
|
||||
/** distributeModalVisible is a reactive state variable used by the template and event handlers. */
|
||||
const distributeModalVisible = ref(false)
|
||||
@@ -554,8 +554,8 @@ const buildDraftPayload = () => ({
|
||||
minAmount: formState.minAmount,
|
||||
reduceAmount: formState.reduceAmount,
|
||||
totalCount: formState.totalCount,
|
||||
startTime: formState.startTime?.format('YYYY-MM-DD HH:mm:ss'),
|
||||
endTime: formState.endTime?.format('YYYY-MM-DD HH:mm:ss'),
|
||||
startTime: formState.startTime?.format('YYYY-MM-DDTHH:mm:ss'),
|
||||
endTime: formState.endTime?.format('YYYY-MM-DDTHH:mm:ss'),
|
||||
availableTagIds: [...formState.availableTagIds],
|
||||
unavailableTagIds: [...formState.unavailableTagIds],
|
||||
shopId: formState.shopId,
|
||||
@@ -597,13 +597,21 @@ const handleClearDraft = (showMessage = true) => {
|
||||
}
|
||||
}
|
||||
|
||||
const isSameTagSelection = (left: number[], right: number[]) =>
|
||||
left.length === right.length && left.every((id, index) => Number(id) === Number(right[index]))
|
||||
|
||||
const removeSelectedTags = (target: number[], selected: number[]) => {
|
||||
const selectedIds = new Set(selected.map(Number))
|
||||
return target.filter(id => !selectedIds.has(Number(id)))
|
||||
}
|
||||
|
||||
watch(
|
||||
() => formState.couponScene,
|
||||
value => {
|
||||
if (value === 'VIP_AUTO') {
|
||||
formState.autoMatch = 1
|
||||
if (!formState.requiredVipLevel) {
|
||||
formState.requiredVipLevel = '青铜'
|
||||
formState.requiredVipLevel = vipLevelOptions.value.find(level => level !== '普通') || vipLevelOptions.value[0]
|
||||
}
|
||||
} else {
|
||||
formState.autoMatch = 0
|
||||
@@ -612,6 +620,26 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => formState.availableTagIds.slice(),
|
||||
value => {
|
||||
const nextUnavailableTagIds = removeSelectedTags(formState.unavailableTagIds, value)
|
||||
if (!isSameTagSelection(formState.unavailableTagIds, nextUnavailableTagIds)) {
|
||||
formState.unavailableTagIds = nextUnavailableTagIds
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => formState.unavailableTagIds.slice(),
|
||||
value => {
|
||||
const nextAvailableTagIds = removeSelectedTags(formState.availableTagIds, value)
|
||||
if (!isSameTagSelection(formState.availableTagIds, nextAvailableTagIds)) {
|
||||
formState.availableTagIds = nextAvailableTagIds
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
/** handleAutoMatchChange is a local helper used by this page script. */
|
||||
const handleAutoMatchChange = (checked: boolean) => {
|
||||
formState.autoMatch = checked ? 1 : 0
|
||||
@@ -737,8 +765,8 @@ const buildCouponPayload = () => ({
|
||||
minAmount: formState.couponType === 2 ? formState.minAmount : undefined,
|
||||
reduceAmount: formState.couponType === 2 ? formState.reduceAmount : undefined,
|
||||
totalCount: formState.totalCount,
|
||||
startTime: formState.startTime?.format('YYYY-MM-DD HH:mm:ss'),
|
||||
endTime: formState.endTime?.format('YYYY-MM-DD HH:mm:ss'),
|
||||
startTime: formState.startTime?.format('YYYY-MM-DDTHH:mm:ss'),
|
||||
endTime: formState.endTime?.format('YYYY-MM-DDTHH:mm:ss'),
|
||||
availableTagIds: formState.availableTagIds,
|
||||
unavailableTagIds: formState.unavailableTagIds,
|
||||
shopId: formState.shopId,
|
||||
@@ -850,9 +878,20 @@ const handleDistributeCancel = () => {
|
||||
distributeFormRef.value?.resetFields()
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadUserPermissions()
|
||||
await Promise.all([fetchTags(), fetchShops(), fetchCoupons()])
|
||||
await Promise.all([fetchTags(), fetchShops(), fetchCoupons(), fetchVipLevelOptions()])
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user