From a944241a0ea4822b5849616970f981035114e9ec Mon Sep 17 00:00:00 2001 From: richjohnrambo Date: Wed, 14 Oct 2026 19:18:53 +0800 Subject: [PATCH] feat: add product publish controls --- web/src/views/product-task/product/index.vue | 35 +++++++++++++++++--- web/src/views/product-task/product/model.ts | 15 +++++++-- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/web/src/views/product-task/product/index.vue b/web/src/views/product-task/product/index.vue index 3ff6bed..7532382 100644 --- a/web/src/views/product-task/product/index.vue +++ b/web/src/views/product-task/product/index.vue @@ -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: '警告', diff --git a/web/src/views/product-task/product/model.ts b/web/src/views/product-task/product/model.ts index 5f8ad35..99edb95 100644 --- a/web/src/views/product-task/product/model.ts +++ b/web/src/views/product-task/product/model.ts @@ -1,5 +1,5 @@ import { computed, h, ref } from 'vue'; -import { NImage } from 'naive-ui'; +import { NImage, NTag } from 'naive-ui'; import { FormSchema } from '@/components/Form'; import { useDictStore } from '@/store/modules/dict'; @@ -42,6 +42,17 @@ export const columns = [ { title: '名称', key: 'name', width: 145, ellipsis: { tooltip: true } }, { title: '商品价格', key: 'price', width: 90 }, { 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: '是否推荐', @@ -51,4 +62,4 @@ export const columns = [ }, ]; -export const loadOptions = () => dict.loadOptions(['productCategoryOption']); +export const loadOptions = () => dict.loadOptions(['productCategoryOption', 'bizPublishStatus']);