feat: add product publish controls
This commit is contained in:
@@ -44,7 +44,7 @@
|
|||||||
import { BasicForm, useForm } from '@/components/Form';
|
import { BasicForm, useForm } from '@/components/Form';
|
||||||
import { BasicTable, TableAction } from '@/components/Table';
|
import { BasicTable, TableAction } from '@/components/Table';
|
||||||
import { usePermission } from '@/hooks/web/usePermission';
|
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 { columns, loadOptions, schemas } from './model';
|
||||||
import Edit from './edit.vue';
|
import Edit from './edit.vue';
|
||||||
|
|
||||||
@@ -82,15 +82,21 @@
|
|||||||
onClick: () => editRef.value.open(row),
|
onClick: () => editRef.value.open(row),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '删除',
|
label: row.publishStatus === 3 ? '下架' : '发布',
|
||||||
auth: ['/product/delete'],
|
type: row.publishStatus === 3 ? 'warning' : 'success',
|
||||||
onClick: () => remove(row),
|
auth: ['/product/status'],
|
||||||
|
onClick: () => changeStatus(row),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: row.isRecommended === 1 ? '不推荐' : '推荐',
|
label: row.isRecommended === 1 ? '不推荐' : '推荐',
|
||||||
auth: ['/product/recommend'],
|
auth: ['/product/recommend'],
|
||||||
onClick: () => recommend(row),
|
onClick: () => recommend(row),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
auth: ['/product/delete'],
|
||||||
|
onClick: () => remove(row),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
@@ -110,6 +116,27 @@
|
|||||||
reload();
|
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) {
|
function remove(row) {
|
||||||
dialog.warning({
|
dialog.warning({
|
||||||
title: '警告',
|
title: '警告',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { computed, h, ref } from 'vue';
|
import { computed, h, ref } from 'vue';
|
||||||
import { NImage } from 'naive-ui';
|
import { NImage, NTag } from 'naive-ui';
|
||||||
import { FormSchema } from '@/components/Form';
|
import { FormSchema } from '@/components/Form';
|
||||||
import { useDictStore } from '@/store/modules/dict';
|
import { useDictStore } from '@/store/modules/dict';
|
||||||
|
|
||||||
@@ -42,6 +42,17 @@ export const columns = [
|
|||||||
{ title: '名称', key: 'name', width: 145, ellipsis: { tooltip: true } },
|
{ title: '名称', key: 'name', width: 145, ellipsis: { tooltip: true } },
|
||||||
{ title: '商品价格', key: 'price', width: 90 },
|
{ title: '商品价格', key: 'price', width: 90 },
|
||||||
{ title: '店铺名称', key: 'shopName', width: 100, ellipsis: { tooltip: true } },
|
{ title: '店铺名称', key: 'shopName', width: 100, ellipsis: { tooltip: true } },
|
||||||
|
{
|
||||||
|
title: '发布状态',
|
||||||
|
key: 'publishStatus',
|
||||||
|
width: 90,
|
||||||
|
render: (row) =>
|
||||||
|
h(
|
||||||
|
NTag,
|
||||||
|
{ type: dict.getType('bizPublishStatus', row.publishStatus), bordered: false },
|
||||||
|
{ default: () => dict.getLabel('bizPublishStatus', row.publishStatus) || '-' }
|
||||||
|
),
|
||||||
|
},
|
||||||
{ title: '创建时间', key: 'createdAt', width: 125 },
|
{ title: '创建时间', key: 'createdAt', width: 125 },
|
||||||
{
|
{
|
||||||
title: '是否推荐',
|
title: '是否推荐',
|
||||||
@@ -51,4 +62,4 @@ export const columns = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const loadOptions = () => dict.loadOptions(['productCategoryOption']);
|
export const loadOptions = () => dict.loadOptions(['productCategoryOption', 'bizPublishStatus']);
|
||||||
|
|||||||
Reference in New Issue
Block a user