From 5eaeab0cfff6a099514e8e5959da540ff0179190 Mon Sep 17 00:00:00 2001 From: xuzhiqiang Date: Thu, 14 Aug 2025 14:33:42 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat(@vben/web-antd):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E5=88=86=E7=B1=BB=E8=A1=A8=E5=8D=95=E5=92=8C?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E5=88=86=E7=B1=BB=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/erp/product/category/index.ts | 9 +- .../src/views/erp/product/category/data.ts | 125 ++++++++++++ .../src/views/erp/product/category/index.vue | 187 ++++++++++++++++-- .../erp/product/category/modules/form.vue | 92 +++++++++ 4 files changed, 388 insertions(+), 25 deletions(-) create mode 100644 apps/web-antd/src/views/erp/product/category/data.ts create mode 100644 apps/web-antd/src/views/erp/product/category/modules/form.vue diff --git a/apps/web-antd/src/api/erp/product/category/index.ts b/apps/web-antd/src/api/erp/product/category/index.ts index b16a91e3a..74e5465c1 100644 --- a/apps/web-antd/src/api/erp/product/category/index.ts +++ b/apps/web-antd/src/api/erp/product/category/index.ts @@ -4,11 +4,12 @@ export namespace ErpProductCategoryApi { /** ERP 产品分类信息 */ export interface ProductCategory { id?: number; // 分类编号 - parentId: number; // 父分类编号 + parentId?: number; // 父分类编号 name: string; // 分类名称 - code: string; // 分类编码 - sort: number; // 分类排序 - status: number; // 开启状态 + code?: string; // 分类编码 + sort?: number; // 分类排序 + status?: number; // 开启状态 + children?: ProductCategory[]; // 子分类 } } diff --git a/apps/web-antd/src/views/erp/product/category/data.ts b/apps/web-antd/src/views/erp/product/category/data.ts new file mode 100644 index 000000000..9d95075cb --- /dev/null +++ b/apps/web-antd/src/views/erp/product/category/data.ts @@ -0,0 +1,125 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { ErpProductCategoryApi } from '#/api/erp/product/category'; + +import { handleTree } from '@vben/utils'; + +import { z } from '#/adapter/form'; +import { getProductCategoryList } from '#/api/erp/product/category'; +import { CommonStatusEnum, DICT_TYPE, getDictOptions } from '#/utils'; + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'parentId', + label: '上级分类', + component: 'ApiTreeSelect', + componentProps: { + allowClear: true, + api: async () => { + const data = await getProductCategoryList(); + data.unshift({ + id: 0, + name: '顶级分类', + }); + return handleTree(data); + }, + labelField: 'name', + valueField: 'id', + childrenField: 'children', + placeholder: '请选择上级分类', + treeDefaultExpandAll: true, + }, + rules: 'selectRequired', + }, + { + fieldName: 'name', + label: '分类名称', + component: 'Input', + componentProps: { + placeholder: '请输入分类名称', + }, + rules: 'required', + }, + { + fieldName: 'code', + label: '分类编码', + component: 'Input', + componentProps: { + placeholder: '请输入分类编码', + }, + rules: z.string().regex(/^[A-Z]+$/, '分类编码必须为大写字母'), + }, + { + fieldName: 'sort', + label: '显示顺序', + component: 'InputNumber', + componentProps: { + min: 0, + controlsPosition: 'right', + placeholder: '请输入显示顺序', + }, + rules: 'required', + }, + + { + fieldName: 'status', + label: '状态', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + buttonStyle: 'solid', + optionType: 'button', + }, + rules: z.number().default(CommonStatusEnum.ENABLE), + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'name', + title: '分类名称', + align: 'left', + treeNode: true, + }, + { + field: 'code', + title: '分类编码', + }, + { + field: 'sort', + title: '显示顺序', + }, + { + field: 'status', + title: '分类状态', + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, + }, + }, + { + field: 'createTime', + title: '创建时间', + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 220, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-antd/src/views/erp/product/category/index.vue b/apps/web-antd/src/views/erp/product/category/index.vue index 47c5b65b9..6645a66e0 100644 --- a/apps/web-antd/src/views/erp/product/category/index.vue +++ b/apps/web-antd/src/views/erp/product/category/index.vue @@ -1,34 +1,179 @@ diff --git a/apps/web-antd/src/views/erp/product/category/modules/form.vue b/apps/web-antd/src/views/erp/product/category/modules/form.vue new file mode 100644 index 000000000..ad6ffa89b --- /dev/null +++ b/apps/web-antd/src/views/erp/product/category/modules/form.vue @@ -0,0 +1,92 @@ + + + From 2a655a04c9f67e2c18d769428a0c276b432b7b1a Mon Sep 17 00:00:00 2001 From: xuzhiqiang Date: Thu, 14 Aug 2025 14:56:39 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix(@vben/web-antd):=20=20erp-product-categ?= =?UTF-8?q?ory=E7=A7=BB=E9=99=A4erp=E4=BA=A7=E5=93=81=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84=E5=A4=8D=E9=80=89=E6=A1=86?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/erp/product/category/index.vue | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/apps/web-antd/src/views/erp/product/category/index.vue b/apps/web-antd/src/views/erp/product/category/index.vue index 6645a66e0..01fdede9e 100644 --- a/apps/web-antd/src/views/erp/product/category/index.vue +++ b/apps/web-antd/src/views/erp/product/category/index.vue @@ -68,15 +68,6 @@ async function handleDelete(row: ErpProductCategoryApi.ProductCategory) { } } -const checkedIds = ref([]); -function handleRowCheckboxChange({ - records, -}: { - records: ErpProductCategoryApi.ProductCategory[]; -}) { - checkedIds.value = records.map((item) => item.id as number); -} - const [Grid, gridApi] = useVbenVxeGrid({ gridOptions: { columns: useGridColumns(), @@ -107,10 +98,6 @@ const [Grid, gridApi] = useVbenVxeGrid({ accordion: false, }, } as VxeTableGridOptions, - gridEvents: { - checkboxAll: handleRowCheckboxChange, - checkboxChange: handleRowCheckboxChange, - }, }); From 7fb9f6e0649017639ce0a6da2526741dec1c4a0c Mon Sep 17 00:00:00 2001 From: xuzhiqiang Date: Thu, 14 Aug 2025 16:16:34 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat(@vben/web-antd):=20erp-product-unit=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=A7=E5=93=81=E5=8D=95=E4=BD=8D=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=8C=85=E6=8B=AC=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E3=80=81=E5=88=97=E8=A1=A8=E5=8F=8A=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/erp/product/unit/data.ts | 89 ++++++++++ .../src/views/erp/product/unit/index.vue | 160 +++++++++++++++--- .../views/erp/product/unit/modules/form.vue | 88 ++++++++++ 3 files changed, 316 insertions(+), 21 deletions(-) create mode 100644 apps/web-antd/src/views/erp/product/unit/data.ts create mode 100644 apps/web-antd/src/views/erp/product/unit/modules/form.vue diff --git a/apps/web-antd/src/views/erp/product/unit/data.ts b/apps/web-antd/src/views/erp/product/unit/data.ts new file mode 100644 index 000000000..7de094158 --- /dev/null +++ b/apps/web-antd/src/views/erp/product/unit/data.ts @@ -0,0 +1,89 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; + +import { z } from '#/adapter/form'; +import { CommonStatusEnum, DICT_TYPE, getDictOptions } from '#/utils'; + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + component: 'Input', + fieldName: 'name', + label: '单位名称', + rules: 'required', + }, + { + fieldName: 'status', + label: '单位状态', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + buttonStyle: 'solid', + optionType: 'button', + }, + rules: z.number().default(CommonStatusEnum.ENABLE), + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '单位名称', + component: 'Input', + }, + { + fieldName: 'status', + label: '单位状态', + component: 'Select', + componentProps: { + allowClear: true, + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'id', + title: '单位编号', + }, + { + field: 'name', + title: '单位名称', + }, + { + field: 'status', + title: '单位状态', + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, + }, + }, + { + field: 'createTime', + title: '创建时间', + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 130, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-antd/src/views/erp/product/unit/index.vue b/apps/web-antd/src/views/erp/product/unit/index.vue index 70e5ebd61..1386c131f 100644 --- a/apps/web-antd/src/views/erp/product/unit/index.vue +++ b/apps/web-antd/src/views/erp/product/unit/index.vue @@ -1,34 +1,152 @@ diff --git a/apps/web-antd/src/views/erp/product/unit/modules/form.vue b/apps/web-antd/src/views/erp/product/unit/modules/form.vue new file mode 100644 index 000000000..4871e227c --- /dev/null +++ b/apps/web-antd/src/views/erp/product/unit/modules/form.vue @@ -0,0 +1,88 @@ + + + From 5076e3ff728543cc04d3b039741aaed18460921d Mon Sep 17 00:00:00 2001 From: xuzhiqiang Date: Thu, 14 Aug 2025 16:17:05 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feat(@vben/web-antd):=20erp-product=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=A7=E5=93=81=E7=AE=A1=E7=90=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E5=8C=85=E6=8B=AC=E8=A1=A8=E5=8D=95=E3=80=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=8F=8A=E7=9B=B8=E5=85=B3=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/erp/product/product/data.ts | 220 ++++++++++++++++++ .../src/views/erp/product/product/index.vue | 160 +++++++++++-- .../erp/product/product/modules/form.vue | 86 +++++++ 3 files changed, 445 insertions(+), 21 deletions(-) create mode 100644 apps/web-antd/src/views/erp/product/product/data.ts create mode 100644 apps/web-antd/src/views/erp/product/product/modules/form.vue diff --git a/apps/web-antd/src/views/erp/product/product/data.ts b/apps/web-antd/src/views/erp/product/product/data.ts new file mode 100644 index 000000000..8b44beef8 --- /dev/null +++ b/apps/web-antd/src/views/erp/product/product/data.ts @@ -0,0 +1,220 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; + +import { handleTree } from '@vben/utils'; + +import { z } from '#/adapter/form'; +import { getProductCategorySimpleList } from '#/api/erp/product/category'; +import { getProductUnitSimpleList } from '#/api/erp/product/unit'; +import { CommonStatusEnum, DICT_TYPE, getDictOptions } from '#/utils'; + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + component: 'Input', + fieldName: 'name', + label: '名称', + rules: 'required', + componentProps: { + placeholder: '请输入名称', + }, + }, + { + fieldName: 'barCode', + label: '条码', + component: 'Input', + rules: 'required', + componentProps: { + placeholder: '请输入条码', + }, + }, + { + fieldName: 'categoryId', + label: '分类', + component: 'ApiTreeSelect', + componentProps: { + api: async () => { + const data = await getProductCategorySimpleList(); + return handleTree(data); + }, + + labelField: 'name', + valueField: 'id', + childrenField: 'children', + placeholder: '请选择分类', + treeDefaultExpandAll: true, + }, + rules: 'required', + }, + { + fieldName: 'unitId', + label: '单位', + component: 'ApiSelect', + componentProps: { + api: getProductUnitSimpleList, + labelField: 'name', + valueField: 'id', + placeholder: '请选择单位', + }, + rules: 'required', + }, + { + fieldName: 'status', + label: '状态', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + buttonStyle: 'solid', + optionType: 'button', + }, + rules: z.number().default(CommonStatusEnum.ENABLE), + }, + { + fieldName: 'standard', + label: '规格', + component: 'Input', + componentProps: { + placeholder: '请输入规格', + }, + }, + { + fieldName: 'expiryDay', + label: '保质期天数', + component: 'InputNumber', + componentProps: { + placeholder: '请输入保质期天数', + }, + }, + { + fieldName: 'weight', + label: '重量(kg)', + component: 'InputNumber', + componentProps: { + placeholder: '请输入重量(kg)', + }, + }, + { + fieldName: 'purchasePrice', + label: '采购价格', + component: 'InputNumber', + componentProps: { + placeholder: '请输入采购价格,单位:元', + }, + }, + { + fieldName: 'salePrice', + label: '销售价格', + component: 'InputNumber', + componentProps: { + placeholder: '请输入销售价格,单位:元', + }, + }, + { + fieldName: 'minPrice', + label: '最低价格', + component: 'InputNumber', + componentProps: { + placeholder: '请输入最低价格,单位:元', + }, + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '名称', + component: 'Input', + }, + { + fieldName: 'categoryId', + label: '分类', + component: 'ApiTreeSelect', + componentProps: { + api: async () => { + const data = await getProductCategorySimpleList(); + return handleTree(data); + }, + + labelField: 'name', + valueField: 'id', + childrenField: 'children', + placeholder: '请选择分类', + treeDefaultExpandAll: true, + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'barCode', + title: '条码', + }, + { + field: 'name', + title: '名称', + }, + { + field: 'standard', + title: '规格', + }, + { + field: 'categoryName', + title: '分类', + }, + { + field: 'unitName', + title: '单位', + }, + { + field: 'purchasePrice', + title: '采购价格', + }, + { + field: 'salePrice', + title: '销售价格', + }, + { + field: 'minPrice', + title: '最低价格', + }, + { + field: 'status', + title: '状态', + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, + }, + }, + { + field: 'createTime', + title: '创建时间', + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 130, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-antd/src/views/erp/product/product/index.vue b/apps/web-antd/src/views/erp/product/product/index.vue index d52ab9c92..1748c0d09 100644 --- a/apps/web-antd/src/views/erp/product/product/index.vue +++ b/apps/web-antd/src/views/erp/product/product/index.vue @@ -1,34 +1,152 @@ diff --git a/apps/web-antd/src/views/erp/product/product/modules/form.vue b/apps/web-antd/src/views/erp/product/product/modules/form.vue new file mode 100644 index 000000000..cbaf8072c --- /dev/null +++ b/apps/web-antd/src/views/erp/product/product/modules/form.vue @@ -0,0 +1,86 @@ + + + From 133f90f34e34815d22cf5cd819a5e5c68d69d930 Mon Sep 17 00:00:00 2001 From: xuzhiqiang Date: Fri, 15 Aug 2025 09:40:34 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix(@vben/web-antd):=20erp-purchase-order?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=B0=E5=A2=9E=E9=87=87=E8=B4=AD=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=97=B6=E7=9A=84=E6=8A=A5=E9=94=99=EF=BC=8C=E6=B8=85?= =?UTF-8?q?=E9=99=A4=E9=A1=B9=E7=9A=84=20ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/views/erp/purchase/order/modules/form.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/web-antd/src/views/erp/purchase/order/modules/form.vue b/apps/web-antd/src/views/erp/purchase/order/modules/form.vue index d1399bfa2..8b93ae7e2 100644 --- a/apps/web-antd/src/views/erp/purchase/order/modules/form.vue +++ b/apps/web-antd/src/views/erp/purchase/order/modules/form.vue @@ -111,7 +111,11 @@ const [Modal, modalApi] = useVbenModal({ // 提交表单 const data = (await formApi.getValues()) as ErpPurchaseOrderApi.PurchaseOrder; - data.items = formData.value?.items; + data.items = formData.value?.items?.map((item) => ({ + ...item, + // 解决新增采购订单报错 + id: undefined, + })); // 将文件数组转换为字符串 if (data.fileUrl && Array.isArray(data.fileUrl)) { data.fileUrl = data.fileUrl.length > 0 ? data.fileUrl[0] : '';