feat: toggle manager gift permission
This commit is contained in:
parent
fa5663bdbf
commit
5ddd79d116
@ -21,7 +21,6 @@ import {
|
|||||||
Space,
|
Space,
|
||||||
Switch,
|
Switch,
|
||||||
Table,
|
Table,
|
||||||
Tag,
|
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from 'antdv-next';
|
} from 'antdv-next';
|
||||||
|
|
||||||
@ -92,7 +91,7 @@ const columns = [
|
|||||||
{ dataIndex: 'del', key: 'del', title: '上/下架', width: 120 },
|
{ dataIndex: 'del', key: 'del', title: '上/下架', width: 120 },
|
||||||
{ dataIndex: 'amount', key: 'amount', title: '底价', width: 100 },
|
{ dataIndex: 'amount', key: 'amount', title: '底价', width: 100 },
|
||||||
{ dataIndex: 'storeShelfStatus', key: 'storeShelfStatus', title: '是否上架道具商店', width: 160 },
|
{ 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 },
|
{ dataIndex: 'actions', key: 'actions', title: '操作', width: 180 },
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -157,10 +156,13 @@ function cancelAmountEdit() {
|
|||||||
amountDraft.value = null;
|
amountDraft.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildPropsSourceUpdatePayload(record: Record<string, any>, amount: number) {
|
function buildPropsSourceUpdatePayload(
|
||||||
|
record: Record<string, any>,
|
||||||
|
overrides: Record<string, any> = {},
|
||||||
|
) {
|
||||||
return {
|
return {
|
||||||
adminFree: Boolean(record.adminFree),
|
adminFree: Boolean(record.adminFree),
|
||||||
amount,
|
amount: Number(record.amount ?? 0),
|
||||||
code: record.code,
|
code: record.code,
|
||||||
cover: record.cover,
|
cover: record.cover,
|
||||||
expand: record.expand,
|
expand: record.expand,
|
||||||
@ -169,6 +171,7 @@ function buildPropsSourceUpdatePayload(record: Record<string, any>, amount: numb
|
|||||||
sourceUrl: record.sourceUrl,
|
sourceUrl: record.sourceUrl,
|
||||||
sysOrigin: record.sysOrigin,
|
sysOrigin: record.sysOrigin,
|
||||||
type: record.type,
|
type: record.type,
|
||||||
|
...overrides,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +192,7 @@ async function handleAmountConfirm(record: Record<string, any>) {
|
|||||||
amountSavingId.value = getRecordId(record);
|
amountSavingId.value = getRecordId(record);
|
||||||
record.amount = amount;
|
record.amount = amount;
|
||||||
try {
|
try {
|
||||||
await updatePropsSource(buildPropsSourceUpdatePayload(record, amount));
|
await updatePropsSource(buildPropsSourceUpdatePayload(record, { amount }));
|
||||||
message.success('底价已更新');
|
message.success('底价已更新');
|
||||||
cancelAmountEdit();
|
cancelAmountEdit();
|
||||||
} catch (error) {
|
} 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>) {
|
function getStoreCommodity(record: Record<string, any>) {
|
||||||
return record.storeCommodity || null;
|
return record.storeCommodity || null;
|
||||||
}
|
}
|
||||||
@ -365,9 +380,12 @@ loadData(true);
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="column.key === 'adminFree'">
|
<template v-else-if="column.key === 'adminFree'">
|
||||||
<Tag :color="record.adminFree ? 'green' : 'default'">
|
<Switch
|
||||||
{{ record.adminFree ? '是' : '否' }}
|
:checked="Boolean(record.adminFree)"
|
||||||
</Tag>
|
checked-children="开启"
|
||||||
|
un-checked-children="关闭"
|
||||||
|
@change="(checked: boolean) => handleAdminFreeChange(record, checked)"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="column.key === 'actions'">
|
<template v-else-if="column.key === 'actions'">
|
||||||
<Space>
|
<Space>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user