增加默认商店配置
This commit is contained in:
parent
02cbe30117
commit
9ad05f8aef
@ -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<string, any>) {
|
||||
}
|
||||
|
||||
function buildStoreShelfPayload(record: Record<string, any>, 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<string, any>, 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);
|
||||
</template>
|
||||
<template v-else-if="column.key === 'storeShelfStatus'">
|
||||
<Tooltip
|
||||
:title="getStoreCommodity(record) ? '' : '请先在道具商店配置该资源'"
|
||||
:title="getStoreCommodity(record) ? '' : '点击后默认以金币售卖 7 天'"
|
||||
>
|
||||
<Switch
|
||||
class="compact-switch"
|
||||
:checked="Boolean(getStoreCommodity(record)?.shelfStatus)"
|
||||
:disabled="!getStoreCommodity(record)"
|
||||
size="small"
|
||||
@change="
|
||||
(checked: boolean) => handleStoreShelfStatusChange(record, checked)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user