From f242f1c37db3cc2108d6b793ded75b0310cfc707 Mon Sep 17 00:00:00 2001 From: nehc <934298133@qq.com> Date: Sat, 26 Jul 2025 17:36:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(@vben/web-antd):=20erp-=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E9=99=84=E4=BB=B6=E5=8F=8A=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改订单时间格式为 timestamp - 限制文件上传数量为 1 - 调整表格列宽和显示逻辑 - 优化子表单验证和提交逻辑 - 修复文件上传组件的兼容性问题 - 优化产品清单的初始化和验证 --- .../src/views/erp/purchase/order/data.ts | 19 +++-- .../order/modules/PurchaseOrderItemForm.vue | 66 +++++++++++---- .../views/erp/purchase/order/modules/form.vue | 84 ++++++++++++++++--- 3 files changed, 138 insertions(+), 31 deletions(-) diff --git a/apps/web-antd/src/views/erp/purchase/order/data.ts b/apps/web-antd/src/views/erp/purchase/order/data.ts index 9a037f94f..a623680cf 100644 --- a/apps/web-antd/src/views/erp/purchase/order/data.ts +++ b/apps/web-antd/src/views/erp/purchase/order/data.ts @@ -44,7 +44,7 @@ export function useFormSchema(): VbenFormSchema[] { placeholder: '选择订单时间', showTime: true, format: 'YYYY-MM-DD HH:mm:ss', - valueFormat: 'YYYY-MM-DD HH:mm:ss', + valueFormat: 'x', style: { width: '100%' }, }, fieldName: 'orderTime', @@ -65,7 +65,7 @@ export function useFormSchema(): VbenFormSchema[] { { component: 'FileUpload', componentProps: { - maxNumber: 5, + maxNumber: 1, maxSize: 10, accept: [ 'pdf', @@ -340,17 +340,19 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'no', title: '订单单号', - width: 260, + width: 200, fixed: 'left', }, { field: 'productNames', title: '产品信息', showOverflow: 'tooltip', + minWidth: 120, }, { field: 'supplierName', title: '供应商', + minWidth: 120, }, { field: 'orderTime', @@ -361,40 +363,45 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'creatorName', title: '创建人', + minWidth: 120, }, { field: 'totalCount', title: '总数量', - formatter: 'formatNumber', + minWidth: 120, }, { field: 'inCount', title: '入库数量', - formatter: 'formatNumber', + minWidth: 120, }, { field: 'returnCount', title: '退货数量', - formatter: 'formatNumber', + minWidth: 120, }, { field: 'totalProductPrice', title: '金额合计', formatter: 'formatNumber', + minWidth: 120, }, { field: 'totalPrice', title: '含税金额', formatter: 'formatNumber', + minWidth: 120, }, { field: 'depositPrice', title: '支付订金', formatter: 'formatNumber', + minWidth: 120, }, { field: 'status', title: '状态', + minWidth: 120, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.ERP_AUDIT_STATUS }, diff --git a/apps/web-antd/src/views/erp/purchase/order/modules/PurchaseOrderItemForm.vue b/apps/web-antd/src/views/erp/purchase/order/modules/PurchaseOrderItemForm.vue index 7bcede093..6ecde04c2 100644 --- a/apps/web-antd/src/views/erp/purchase/order/modules/PurchaseOrderItemForm.vue +++ b/apps/web-antd/src/views/erp/purchase/order/modules/PurchaseOrderItemForm.vue @@ -58,6 +58,16 @@ const [Grid, gridApi] = useVbenVxeGrid({ enabled: false, }, }, + gridEvents: { + // editClosed: ({ row }) => { + // // 当单元格编辑完成时,同步更新tableData + // const index = tableData.value.findIndex((item) => item.id === row.id); + // if (index !== -1) { + // tableData.value[index] = { ...row }; + // emit('update:items', [...tableData.value]); + // } + // }, + }, }); /** 监听外部传入的列数据 */ @@ -107,7 +117,25 @@ onMounted(async () => { }); function handleAdd() { - gridApi.grid.insertAt(null, -1); + const newRow = { + id: tableData.value.length + 1, + productId: null, + productName: '', + productUnitId: null, + productUnitName: '', + productBarCode: '', + count: 1, + productPrice: 0, + totalProductPrice: 0, + taxPercent: 0, + taxPrice: 0, + totalPrice: 0, + stockCount: 0, + remark: '', + }; + tableData.value.push(newRow); + gridApi.grid.insertAt(newRow, -1); + emit('update:items', [...tableData.value]); } function handleDelete(row: ErpPurchaseOrderApi.PurchaseOrderItem) { @@ -185,20 +213,26 @@ const getSummaries = (): { }; }; -const validate = async (): Promise => { - for (let i = 0; i < tableData.value.length; i++) { - const item = tableData.value[i]; - if (item) { - if (!item.productId) { - throw new Error(`第 ${i + 1} 行:产品不能为空`); - } - if (!item.count || item.count <= 0) { - throw new Error(`第 ${i + 1} 行:产品数量不能为空`); - } - if (!item.productPrice || item.productPrice <= 0) { - throw new Error(`第 ${i + 1} 行:产品单价不能为空`); +const validate = async (): Promise => { + try { + for (let i = 0; i < tableData.value.length; i++) { + const item = tableData.value[i]; + if (item) { + if (!item.productId) { + throw new Error(`第 ${i + 1} 行:产品不能为空`); + } + if (!item.count || item.count <= 0) { + throw new Error(`第 ${i + 1} 行:产品数量不能为空`); + } + if (!item.productPrice || item.productPrice <= 0) { + throw new Error(`第 ${i + 1} 行:产品单价不能为空`); + } } } + return true; + } catch (error) { + console.error('验证失败:', error); + throw error; } }; @@ -212,7 +246,11 @@ const init = ( }); }; -defineExpose({ validate, getData, init }); +defineExpose({ + validate, + getData, + init, +});