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