feat: toggle manager gift permission

This commit is contained in:
zhx 2026-05-17 01:04:07 +08:00
parent fa5663bdbf
commit 5ddd79d116

View File

@ -21,7 +21,6 @@ import {
Space,
Switch,
Table,
Tag,
Tooltip,
} from 'antdv-next';
@ -92,7 +91,7 @@ const columns = [
{ dataIndex: 'del', key: 'del', title: '上/下架', width: 120 },
{ dataIndex: 'amount', key: 'amount', title: '底价', width: 100 },
{ dataIndex: 'storeShelfStatus', key: 'storeShelfStatus', title: '是否上架道具商店', width: 160 },
{ dataIndex: 'adminFree', key: 'adminFree', title: 'Admin Free', width: 120 },
{ dataIndex: 'adminFree', key: 'adminFree', title: '经理赠送权限', width: 140 },
{ dataIndex: 'actions', key: 'actions', title: '操作', width: 180 },
];
@ -157,10 +156,13 @@ function cancelAmountEdit() {
amountDraft.value = null;
}
function buildPropsSourceUpdatePayload(record: Record<string, any>, amount: number) {
function buildPropsSourceUpdatePayload(
record: Record<string, any>,
overrides: Record<string, any> = {},
) {
return {
adminFree: Boolean(record.adminFree),
amount,
amount: Number(record.amount ?? 0),
code: record.code,
cover: record.cover,
expand: record.expand,
@ -169,6 +171,7 @@ function buildPropsSourceUpdatePayload(record: Record<string, any>, amount: numb
sourceUrl: record.sourceUrl,
sysOrigin: record.sysOrigin,
type: record.type,
...overrides,
};
}
@ -189,7 +192,7 @@ async function handleAmountConfirm(record: Record<string, any>) {
amountSavingId.value = getRecordId(record);
record.amount = amount;
try {
await updatePropsSource(buildPropsSourceUpdatePayload(record, amount));
await updatePropsSource(buildPropsSourceUpdatePayload(record, { amount }));
message.success('底价已更新');
cancelAmountEdit();
} catch (error) {
@ -200,6 +203,18 @@ async function handleAmountConfirm(record: Record<string, any>) {
}
}
async function handleAdminFreeChange(record: Record<string, any>, checked: boolean) {
const previous = record.adminFree;
record.adminFree = checked;
try {
await updatePropsSource(buildPropsSourceUpdatePayload(record, { adminFree: checked }));
message.success('经理赠送权限已更新');
} catch (error) {
record.adminFree = previous;
throw error;
}
}
function getStoreCommodity(record: Record<string, any>) {
return record.storeCommodity || null;
}
@ -365,9 +380,12 @@ loadData(true);
</Tooltip>
</template>
<template v-else-if="column.key === 'adminFree'">
<Tag :color="record.adminFree ? 'green' : 'default'">
{{ record.adminFree ? '是' : '否' }}
</Tag>
<Switch
:checked="Boolean(record.adminFree)"
checked-children="开启"
un-checked-children="关闭"
@change="(checked: boolean) => handleAdminFreeChange(record, checked)"
/>
</template>
<template v-else-if="column.key === 'actions'">
<Space>