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);