From 9ad05f8aef7911ea0452c2a5705a9697f0f7e28c Mon Sep 17 00:00:00 2001 From: zhx Date: Mon, 18 May 2026 10:55:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4=E5=95=86?= =?UTF-8?q?=E5=BA=97=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/src/views/props/resource-config.vue | 32 ++++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/apps/src/views/props/resource-config.vue b/apps/src/views/props/resource-config.vue index ca1dba9..8db266d 100644 --- a/apps/src/views/props/resource-config.vue +++ b/apps/src/views/props/resource-config.vue @@ -90,6 +90,8 @@ const adminFreeOptions = [ { label: '是', value: true as any }, { label: '否', value: false as any }, ]; +const DEFAULT_STORE_CURRENCY_TYPES = 'GOLD'; +const DEFAULT_STORE_VALID_DAYS = '7'; let tableResizeObserver: null | ResizeObserver = null; const query = reactive({ @@ -417,30 +419,39 @@ function getStoreCommodity(record: Record) { } function buildStoreShelfPayload(record: Record, checked: boolean) { - const commodity = getStoreCommodity(record); + const commodity = getStoreCommodity(record) || {}; return { ...commodity, + currencyTypes: commodity.currencyTypes || DEFAULT_STORE_CURRENCY_TYPES, + discount: commodity.discount ?? 0, label: commodity.label || '', propsType: commodity.propsType || record.type, shelfStatus: checked, + sort: commodity.sort ?? 0, sourceId: commodity.sourceId || record.id, sysOrigin: commodity.sysOrigin || record.sysOrigin, + validDays: commodity.validDays || DEFAULT_STORE_VALID_DAYS, }; } async function handleStoreShelfStatusChange(record: Record, checked: boolean) { const commodity = getStoreCommodity(record); - if (!commodity) { - message.warning('请先在道具商店配置该资源'); - return; - } - const previous = commodity.shelfStatus; - commodity.shelfStatus = checked; + const previous = commodity?.shelfStatus; + const nextCommodity = buildStoreShelfPayload(record, checked); + record.storeCommodity = nextCommodity; try { - await addOrUpdatePropsStore(buildStoreShelfPayload(record, checked)); + await addOrUpdatePropsStore(nextCommodity); message.success('道具商店状态已更新'); + if (!commodity) { + await loadData(); + } } catch (error) { - commodity.shelfStatus = previous; + if (commodity) { + commodity.shelfStatus = previous; + record.storeCommodity = commodity; + } else { + record.storeCommodity = null; + } throw error; } } @@ -719,12 +730,11 @@ loadData(true);