feat: add product publish controls
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
import { BasicForm, useForm } from '@/components/Form';
|
||||
import { BasicTable, TableAction } from '@/components/Table';
|
||||
import { usePermission } from '@/hooks/web/usePermission';
|
||||
import { ProductDelete, ProductList, ProductRecommend } from '@/api/productTask';
|
||||
import { ProductDelete, ProductList, ProductRecommend, ProductStatus } from '@/api/productTask';
|
||||
import { columns, loadOptions, schemas } from './model';
|
||||
import Edit from './edit.vue';
|
||||
|
||||
@@ -82,15 +82,21 @@
|
||||
onClick: () => editRef.value.open(row),
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
auth: ['/product/delete'],
|
||||
onClick: () => remove(row),
|
||||
label: row.publishStatus === 3 ? '下架' : '发布',
|
||||
type: row.publishStatus === 3 ? 'warning' : 'success',
|
||||
auth: ['/product/status'],
|
||||
onClick: () => changeStatus(row),
|
||||
},
|
||||
{
|
||||
label: row.isRecommended === 1 ? '不推荐' : '推荐',
|
||||
auth: ['/product/recommend'],
|
||||
onClick: () => recommend(row),
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
auth: ['/product/delete'],
|
||||
onClick: () => remove(row),
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
@@ -110,6 +116,27 @@
|
||||
reload();
|
||||
}
|
||||
|
||||
function changeStatus(row) {
|
||||
const publishing = row.publishStatus !== 3;
|
||||
dialog.warning({
|
||||
title: publishing ? '发布商品' : '下架商品',
|
||||
content: publishing
|
||||
? `确定发布商品“${row.name}”吗?发布后可用于订单匹配。`
|
||||
: `确定下架商品“${row.name}”吗?下架后将不能用于新订单匹配。`,
|
||||
positiveText: publishing ? '确认发布' : '确认下架',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
await ProductStatus({
|
||||
id: row.id,
|
||||
version: row.version,
|
||||
publishStatus: publishing ? 3 : 4,
|
||||
});
|
||||
message.success(publishing ? '商品已发布' : '商品已下架');
|
||||
reload();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function remove(row) {
|
||||
dialog.warning({
|
||||
title: '警告',
|
||||
|
||||
Reference in New Issue
Block a user