礼物
This commit is contained in:
parent
74e1d20aa1
commit
1db5607cb8
@ -22,6 +22,7 @@ import { regionConfigTable } from '#/api/legacy/system';
|
|||||||
import { normalizeResourceCode } from '#/views/_shared/resource-code';
|
import { normalizeResourceCode } from '#/views/_shared/resource-code';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
CP_RELATION_TYPE_OPTIONS,
|
||||||
GIFT_CONFIG_TAB_OPTIONS,
|
GIFT_CONFIG_TAB_OPTIONS,
|
||||||
GIFT_SPECIAL_OPTIONS,
|
GIFT_SPECIAL_OPTIONS,
|
||||||
} from '../constants';
|
} from '../constants';
|
||||||
@ -78,6 +79,7 @@ const emit = defineEmits<{
|
|||||||
const DEFAULT_GIFT_SPECIAL_LIST = ['MUSIC', 'ANIMATION'];
|
const DEFAULT_GIFT_SPECIAL_LIST = ['MUSIC', 'ANIMATION'];
|
||||||
|
|
||||||
const batchForm = reactive({
|
const batchForm = reactive({
|
||||||
|
cpRelationType: 'CP',
|
||||||
giftTab: 'ORDINARY',
|
giftTab: 'ORDINARY',
|
||||||
regionList: [] as Array<number | string>,
|
regionList: [] as Array<number | string>,
|
||||||
specialList: [...DEFAULT_GIFT_SPECIAL_LIST],
|
specialList: [...DEFAULT_GIFT_SPECIAL_LIST],
|
||||||
@ -103,6 +105,10 @@ const giftTabOptions = GIFT_CONFIG_TAB_OPTIONS.map((item) => ({
|
|||||||
label: item.name,
|
label: item.name,
|
||||||
value: item.value as any,
|
value: item.value as any,
|
||||||
}));
|
}));
|
||||||
|
const cpRelationTypeOptions = CP_RELATION_TYPE_OPTIONS.map((item) => ({
|
||||||
|
label: item.name,
|
||||||
|
value: item.value as any,
|
||||||
|
}));
|
||||||
const defaultSpecialText = computed(() =>
|
const defaultSpecialText = computed(() =>
|
||||||
GIFT_SPECIAL_OPTIONS.filter((item) =>
|
GIFT_SPECIAL_OPTIONS.filter((item) =>
|
||||||
DEFAULT_GIFT_SPECIAL_LIST.includes(item.value),
|
DEFAULT_GIFT_SPECIAL_LIST.includes(item.value),
|
||||||
@ -184,10 +190,20 @@ const rowSelection = computed(() => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => batchForm.giftTab,
|
||||||
|
(giftTab) => {
|
||||||
|
if (giftTab === 'CP' && !batchForm.cpRelationType) {
|
||||||
|
batchForm.cpRelationType = 'CP';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
function resetBatch() {
|
function resetBatch() {
|
||||||
batchForm.sysOrigin =
|
batchForm.sysOrigin =
|
||||||
String(props.initialSysOrigin || props.sysOriginOptions[0]?.value || 'LIKEI');
|
String(props.initialSysOrigin || props.sysOriginOptions[0]?.value || 'LIKEI');
|
||||||
batchForm.giftTab = 'ORDINARY';
|
batchForm.giftTab = 'ORDINARY';
|
||||||
|
batchForm.cpRelationType = 'CP';
|
||||||
batchForm.regionList = [];
|
batchForm.regionList = [];
|
||||||
batchForm.specialList = [...DEFAULT_GIFT_SPECIAL_LIST];
|
batchForm.specialList = [...DEFAULT_GIFT_SPECIAL_LIST];
|
||||||
rows.value = [];
|
rows.value = [];
|
||||||
@ -672,6 +688,7 @@ function customRow(record: Record<string, any>) {
|
|||||||
function buildPayload(row: BatchGiftRow) {
|
function buildPayload(row: BatchGiftRow) {
|
||||||
return {
|
return {
|
||||||
account: '',
|
account: '',
|
||||||
|
cpRelationType: batchForm.giftTab === 'CP' ? batchForm.cpRelationType : '',
|
||||||
explanationGift: false,
|
explanationGift: false,
|
||||||
expiredTime: '',
|
expiredTime: '',
|
||||||
giftCandy: Number(row.giftCandy || 0),
|
giftCandy: Number(row.giftCandy || 0),
|
||||||
@ -763,6 +780,14 @@ async function submitBatch() {
|
|||||||
:options="giftTabOptions"
|
:options="giftTabOptions"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="batchForm.giftTab === 'CP'" class="common-field">
|
||||||
|
<span class="common-label">CP礼物类型</span>
|
||||||
|
<Select
|
||||||
|
v-model:value="batchForm.cpRelationType"
|
||||||
|
option-label-prop="label"
|
||||||
|
:options="cpRelationTypeOptions"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div class="common-field common-field--wide">
|
<div class="common-field common-field--wide">
|
||||||
<span class="common-label">区域</span>
|
<span class="common-label">区域</span>
|
||||||
<Select
|
<Select
|
||||||
|
|||||||
@ -32,6 +32,7 @@ import {
|
|||||||
} from '#/api/legacy/system';
|
} from '#/api/legacy/system';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
CP_RELATION_TYPE_OPTIONS,
|
||||||
GIFT_CONFIG_TAB_OPTIONS,
|
GIFT_CONFIG_TAB_OPTIONS,
|
||||||
GIFT_SPECIAL_OPTIONS,
|
GIFT_SPECIAL_OPTIONS,
|
||||||
} from '../constants';
|
} from '../constants';
|
||||||
@ -62,6 +63,7 @@ function createForm(sysOrigin = '') {
|
|||||||
giftSourceUrl: '',
|
giftSourceUrl: '',
|
||||||
giftTab: 'ORDINARY',
|
giftTab: 'ORDINARY',
|
||||||
id: '',
|
id: '',
|
||||||
|
cpRelationType: 'CP',
|
||||||
regionList: [] as Array<number | string>,
|
regionList: [] as Array<number | string>,
|
||||||
sort: '',
|
sort: '',
|
||||||
specialList: [] as string[],
|
specialList: [] as string[],
|
||||||
@ -95,6 +97,10 @@ const giftTabOptions = GIFT_CONFIG_TAB_OPTIONS.map((item) => ({
|
|||||||
label: item.name,
|
label: item.name,
|
||||||
value: item.value as any,
|
value: item.value as any,
|
||||||
}));
|
}));
|
||||||
|
const cpRelationTypeOptions = CP_RELATION_TYPE_OPTIONS.map((item) => ({
|
||||||
|
label: item.name,
|
||||||
|
value: item.value as any,
|
||||||
|
}));
|
||||||
const chargeTypeOptions = [
|
const chargeTypeOptions = [
|
||||||
{ label: '金币', value: 'GOLD' },
|
{ label: '金币', value: 'GOLD' },
|
||||||
{ label: '钻石', value: 'DIAMOND' },
|
{ label: '钻石', value: 'DIAMOND' },
|
||||||
@ -164,6 +170,7 @@ watch(
|
|||||||
...props.row,
|
...props.row,
|
||||||
explanationGift: Boolean(props.row.explanationGift),
|
explanationGift: Boolean(props.row.explanationGift),
|
||||||
expiredTime: normalizeTimestampValue(props.row.expiredTime),
|
expiredTime: normalizeTimestampValue(props.row.expiredTime),
|
||||||
|
cpRelationType: props.row.cpRelationType || 'CP',
|
||||||
regionList: normalizeMultiValue(props.row.regions || props.row.regionList),
|
regionList: normalizeMultiValue(props.row.regions || props.row.regionList),
|
||||||
specialList: normalizeMultiValue(props.row.special || props.row.specialList),
|
specialList: normalizeMultiValue(props.row.special || props.row.specialList),
|
||||||
sysOrigin: props.row.sysOrigin || props.sysOrigin,
|
sysOrigin: props.row.sysOrigin || props.sysOrigin,
|
||||||
@ -186,6 +193,15 @@ watch(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => form.giftTab,
|
||||||
|
(giftTab) => {
|
||||||
|
if (giftTab === 'CP' && !form.cpRelationType) {
|
||||||
|
form.cpRelationType = 'CP';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
function toggleAllRegions() {
|
function toggleAllRegions() {
|
||||||
if (form.regionList.length === regions.value.length) {
|
if (form.regionList.length === regions.value.length) {
|
||||||
form.regionList = [];
|
form.regionList = [];
|
||||||
@ -273,6 +289,10 @@ async function handleSubmit() {
|
|||||||
message.warning('请输入归属人账号');
|
message.warning('请输入归属人账号');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (form.giftTab === 'CP' && !form.cpRelationType) {
|
||||||
|
message.warning('请选择CP礼物类型');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isLuckyOrMagic.value && !form.standardId) {
|
if (isLuckyOrMagic.value && !form.standardId) {
|
||||||
message.warning('幸运/魔法礼物必须选择规格');
|
message.warning('幸运/魔法礼物必须选择规格');
|
||||||
return;
|
return;
|
||||||
@ -294,6 +314,7 @@ async function handleSubmit() {
|
|||||||
try {
|
try {
|
||||||
const payload = {
|
const payload = {
|
||||||
...form,
|
...form,
|
||||||
|
cpRelationType: form.giftTab === 'CP' ? form.cpRelationType : '',
|
||||||
giftCandy: form.type === 'FREE' ? '' : form.giftCandy,
|
giftCandy: form.type === 'FREE' ? '' : form.giftCandy,
|
||||||
giftIntegral: form.type === 'FREE' ? '' : form.giftIntegral,
|
giftIntegral: form.type === 'FREE' ? '' : form.giftIntegral,
|
||||||
};
|
};
|
||||||
@ -456,6 +477,14 @@ async function handleSubmit() {
|
|||||||
placeholder="请选择幸运规格"
|
placeholder="请选择幸运规格"
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
<FormItem v-if="form.giftTab === 'CP'" label="CP礼物类型">
|
||||||
|
<Select
|
||||||
|
v-model:value="form.cpRelationType"
|
||||||
|
:options="cpRelationTypeOptions"
|
||||||
|
option-label-prop="label"
|
||||||
|
placeholder="请选择CP礼物类型"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
<FormItem v-if="form.giftTab === 'CP'" label="告白礼物">
|
<FormItem v-if="form.giftTab === 'CP'" label="告白礼物">
|
||||||
<Switch v-model:checked="form.explanationGift" />
|
<Switch v-model:checked="form.explanationGift" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|||||||
@ -105,6 +105,12 @@ export const GIFT_CONFIG_TAB_OPTIONS = [
|
|||||||
{ value: 'CUSTOMIZED', name: '定制礼物' },
|
{ value: 'CUSTOMIZED', name: '定制礼物' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const CP_RELATION_TYPE_OPTIONS = [
|
||||||
|
{ value: 'CP', name: 'CP' },
|
||||||
|
{ value: 'BROTHER', name: '兄弟' },
|
||||||
|
{ value: 'SISTERS', name: '姐妹' },
|
||||||
|
];
|
||||||
|
|
||||||
export const GIFT_SPECIAL_OPTIONS = [
|
export const GIFT_SPECIAL_OPTIONS = [
|
||||||
{ value: 'ANIMATION', name: '动画' },
|
{ value: 'ANIMATION', name: '动画' },
|
||||||
{ value: 'MUSIC', name: '音乐' },
|
{ value: 'MUSIC', name: '音乐' },
|
||||||
|
|||||||
@ -53,6 +53,7 @@ import { formatDate, getAllowedSysOrigins } from '#/views/system/shared';
|
|||||||
import GiftBatchDrawer from './components/gift-batch-drawer.vue';
|
import GiftBatchDrawer from './components/gift-batch-drawer.vue';
|
||||||
import GiftFormModal from './components/gift-form-modal.vue';
|
import GiftFormModal from './components/gift-form-modal.vue';
|
||||||
import {
|
import {
|
||||||
|
CP_RELATION_TYPE_OPTIONS,
|
||||||
GIFT_CONFIG_TAB_OPTIONS,
|
GIFT_CONFIG_TAB_OPTIONS,
|
||||||
GIFT_SPECIAL_OPTIONS,
|
GIFT_SPECIAL_OPTIONS,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
@ -73,6 +74,9 @@ const GIFT_CHARGE_TYPE_OPTIONS = [
|
|||||||
const GIFT_TAB_LABEL_MAP = new Map(
|
const GIFT_TAB_LABEL_MAP = new Map(
|
||||||
GIFT_CONFIG_TAB_OPTIONS.map((item) => [String(item.value), item.name]),
|
GIFT_CONFIG_TAB_OPTIONS.map((item) => [String(item.value), item.name]),
|
||||||
);
|
);
|
||||||
|
const CP_RELATION_TYPE_LABEL_MAP = new Map(
|
||||||
|
CP_RELATION_TYPE_OPTIONS.map((item) => [String(item.value), item.name]),
|
||||||
|
);
|
||||||
|
|
||||||
const accessStore = useAccessStore();
|
const accessStore = useAccessStore();
|
||||||
const sysOriginOptions = computed(() => {
|
const sysOriginOptions = computed(() => {
|
||||||
@ -116,6 +120,7 @@ const selectedGiftRowMap = ref<Record<string, Record<string, any>>>({});
|
|||||||
const batchEditOpen = ref(false);
|
const batchEditOpen = ref(false);
|
||||||
const batchEditSaving = ref(false);
|
const batchEditSaving = ref(false);
|
||||||
const batchEditFields = reactive({
|
const batchEditFields = reactive({
|
||||||
|
cpRelationType: false,
|
||||||
del: false,
|
del: false,
|
||||||
giftCandy: false,
|
giftCandy: false,
|
||||||
giftIntegral: false,
|
giftIntegral: false,
|
||||||
@ -125,6 +130,7 @@ const batchEditFields = reactive({
|
|||||||
type: false,
|
type: false,
|
||||||
});
|
});
|
||||||
const batchEditForm = reactive({
|
const batchEditForm = reactive({
|
||||||
|
cpRelationType: 'CP',
|
||||||
del: false as boolean,
|
del: false as boolean,
|
||||||
giftCandy: null as null | number,
|
giftCandy: null as null | number,
|
||||||
giftIntegral: null as null | number,
|
giftIntegral: null as null | number,
|
||||||
@ -182,6 +188,7 @@ const settingColumns = [
|
|||||||
{ dataIndex: 'giftIntegral', key: 'giftIntegral', title: '积分', width: 100 },
|
{ dataIndex: 'giftIntegral', key: 'giftIntegral', title: '积分', width: 100 },
|
||||||
{ dataIndex: 'regionNameStr', key: 'regionNameStr', title: '区域', width: 180 },
|
{ dataIndex: 'regionNameStr', key: 'regionNameStr', title: '区域', width: 180 },
|
||||||
{ dataIndex: 'giftTab', key: 'giftTab', title: '礼物类型', width: 120 },
|
{ dataIndex: 'giftTab', key: 'giftTab', title: '礼物类型', width: 120 },
|
||||||
|
{ dataIndex: 'cpRelationType', key: 'cpRelationType', title: 'CP礼物类型', width: 120 },
|
||||||
{ dataIndex: 'typeName', key: 'typeName', title: '收费类型', width: 120 },
|
{ dataIndex: 'typeName', key: 'typeName', title: '收费类型', width: 120 },
|
||||||
{ dataIndex: 'sort', key: 'sort', title: '排序权重', width: 100 },
|
{ dataIndex: 'sort', key: 'sort', title: '排序权重', width: 100 },
|
||||||
{ align: 'center' as const, className: 'switch-column', dataIndex: 'del', fixed: 'right' as const, key: 'del', title: '上/下架', width: 84 },
|
{ align: 'center' as const, className: 'switch-column', dataIndex: 'del', fixed: 'right' as const, key: 'del', title: '上/下架', width: 84 },
|
||||||
@ -588,6 +595,11 @@ function getGiftTabName(value: any) {
|
|||||||
return GIFT_TAB_LABEL_MAP.get(stringValue) || stringifyCellValue(value);
|
return GIFT_TAB_LABEL_MAP.get(stringValue) || stringifyCellValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCpRelationTypeName(value: any) {
|
||||||
|
const stringValue = String(value || '');
|
||||||
|
return CP_RELATION_TYPE_LABEL_MAP.get(stringValue) || stringifyCellValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeMultiValue(value: any) {
|
function normalizeMultiValue(value: any) {
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
return value.filter((item) => item !== '' && item !== null && item !== undefined);
|
return value.filter((item) => item !== '' && item !== null && item !== undefined);
|
||||||
@ -603,6 +615,7 @@ function normalizeMultiValue(value: any) {
|
|||||||
|
|
||||||
function resetBatchEditForm() {
|
function resetBatchEditForm() {
|
||||||
Object.assign(batchEditFields, {
|
Object.assign(batchEditFields, {
|
||||||
|
cpRelationType: false,
|
||||||
del: false,
|
del: false,
|
||||||
giftCandy: false,
|
giftCandy: false,
|
||||||
giftIntegral: false,
|
giftIntegral: false,
|
||||||
@ -612,6 +625,7 @@ function resetBatchEditForm() {
|
|||||||
type: false,
|
type: false,
|
||||||
});
|
});
|
||||||
Object.assign(batchEditForm, {
|
Object.assign(batchEditForm, {
|
||||||
|
cpRelationType: 'CP',
|
||||||
del: false,
|
del: false,
|
||||||
giftCandy: null,
|
giftCandy: null,
|
||||||
giftIntegral: null,
|
giftIntegral: null,
|
||||||
@ -644,6 +658,10 @@ function validateBatchEditForm() {
|
|||||||
message.warning('请选择礼物类型');
|
message.warning('请选择礼物类型');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (batchEditFields.cpRelationType && !batchEditForm.cpRelationType) {
|
||||||
|
message.warning('请选择CP礼物类型');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (batchEditFields.type && !batchEditForm.type) {
|
if (batchEditFields.type && !batchEditForm.type) {
|
||||||
message.warning('请选择收费类型');
|
message.warning('请选择收费类型');
|
||||||
return false;
|
return false;
|
||||||
@ -678,8 +696,15 @@ function validateBatchEditForm() {
|
|||||||
|
|
||||||
function buildGiftBatchEditPayload(row: Record<string, any>) {
|
function buildGiftBatchEditPayload(row: Record<string, any>) {
|
||||||
const nextType = batchEditFields.type ? batchEditForm.type : row.type;
|
const nextType = batchEditFields.type ? batchEditForm.type : row.type;
|
||||||
|
const nextGiftTab = batchEditFields.giftTab ? batchEditForm.giftTab : row.giftTab;
|
||||||
return {
|
return {
|
||||||
...row,
|
...row,
|
||||||
|
cpRelationType:
|
||||||
|
nextGiftTab === 'CP'
|
||||||
|
? batchEditFields.cpRelationType
|
||||||
|
? batchEditForm.cpRelationType
|
||||||
|
: row.cpRelationType || 'CP'
|
||||||
|
: '',
|
||||||
giftCandy:
|
giftCandy:
|
||||||
nextType === 'FREE'
|
nextType === 'FREE'
|
||||||
? ''
|
? ''
|
||||||
@ -692,7 +717,7 @@ function buildGiftBatchEditPayload(row: Record<string, any>) {
|
|||||||
: batchEditFields.giftIntegral
|
: batchEditFields.giftIntegral
|
||||||
? batchEditForm.giftIntegral
|
? batchEditForm.giftIntegral
|
||||||
: row.giftIntegral,
|
: row.giftIntegral,
|
||||||
giftTab: batchEditFields.giftTab ? batchEditForm.giftTab : row.giftTab,
|
giftTab: nextGiftTab,
|
||||||
regionList: normalizeMultiValue(row.regions || row.regionList),
|
regionList: normalizeMultiValue(row.regions || row.regionList),
|
||||||
sort: batchEditFields.sort ? batchEditForm.sort : row.sort,
|
sort: batchEditFields.sort ? batchEditForm.sort : row.sort,
|
||||||
specialList: batchEditFields.specialList
|
specialList: batchEditFields.specialList
|
||||||
@ -713,6 +738,7 @@ async function handleBatchEditSubmit() {
|
|||||||
}
|
}
|
||||||
const shouldUpdateConfig =
|
const shouldUpdateConfig =
|
||||||
batchEditFields.giftTab ||
|
batchEditFields.giftTab ||
|
||||||
|
batchEditFields.cpRelationType ||
|
||||||
batchEditFields.type ||
|
batchEditFields.type ||
|
||||||
batchEditFields.giftCandy ||
|
batchEditFields.giftCandy ||
|
||||||
batchEditFields.giftIntegral ||
|
batchEditFields.giftIntegral ||
|
||||||
@ -1062,6 +1088,9 @@ async function handleCpSave() {
|
|||||||
<template v-else-if="column.key === 'giftTab'">
|
<template v-else-if="column.key === 'giftTab'">
|
||||||
{{ getGiftTabName(record.giftTab) }}
|
{{ getGiftTabName(record.giftTab) }}
|
||||||
</template>
|
</template>
|
||||||
|
<template v-else-if="column.key === 'cpRelationType'">
|
||||||
|
{{ record.giftTab === 'CP' ? getCpRelationTypeName(record.cpRelationType || 'CP') : '-' }}
|
||||||
|
</template>
|
||||||
<template v-else-if="column.key === 'regionNameStr'">
|
<template v-else-if="column.key === 'regionNameStr'">
|
||||||
<Tooltip :title="stringifyCellValue(record.regionNameStr)">
|
<Tooltip :title="stringifyCellValue(record.regionNameStr)">
|
||||||
<span class="region-cell">
|
<span class="region-cell">
|
||||||
@ -1233,6 +1262,15 @@ async function handleCpSave() {
|
|||||||
option-label-prop="label"
|
option-label-prop="label"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="batch-edit-field">
|
||||||
|
<Checkbox v-model:checked="batchEditFields.cpRelationType">CP礼物类型</Checkbox>
|
||||||
|
<Select
|
||||||
|
v-model:value="batchEditForm.cpRelationType"
|
||||||
|
:disabled="!batchEditFields.cpRelationType"
|
||||||
|
:options="CP_RELATION_TYPE_OPTIONS.map((item) => ({ label: `${item.name}`, value: item.value as any }))"
|
||||||
|
option-label-prop="label"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div class="batch-edit-field">
|
<div class="batch-edit-field">
|
||||||
<Checkbox v-model:checked="batchEditFields.type">收费类型</Checkbox>
|
<Checkbox v-model:checked="batchEditFields.type">收费类型</Checkbox>
|
||||||
<Select
|
<Select
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user