From e9fafab07c94413d21df02c9dc1756bf1eb2b8bd Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 3 Oct 2025 20:06:05 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90antd=E3=80=91=E3=80=90erp?= =?UTF-8?q?=20=E7=B3=BB=E7=BB=9F=E3=80=91sale/order=20=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96(form=20=E7=BB=A7=E7=BB=AD?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web-antd/src/views/erp/sale/order/data.ts | 55 +++++++-------- .../src/views/erp/sale/order/modules/form.vue | 10 +-- .../erp/sale/order/modules/item-form.vue | 67 +++++++------------ 3 files changed, 57 insertions(+), 75 deletions(-) diff --git a/apps/web-antd/src/views/erp/sale/order/data.ts b/apps/web-antd/src/views/erp/sale/order/data.ts index 5770b2813..2586ac5ea 100644 --- a/apps/web-antd/src/views/erp/sale/order/data.ts +++ b/apps/web-antd/src/views/erp/sale/order/data.ts @@ -15,38 +15,37 @@ import { getSimpleUserList } from '#/api/system/user'; export function useFormSchema(): VbenFormSchema[] { return [ { - component: 'Input', - componentProps: { - style: { display: 'none' }, - }, fieldName: 'id', - label: 'ID', - hideLabel: true, - formItemClass: 'hidden', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, }, { + fieldName: 'no', + label: '订单单号', component: 'Input', componentProps: { placeholder: '系统自动生成', disabled: true, }, - fieldName: 'no', - label: '订单单号', }, { + fieldName: 'orderTime', + label: '订单时间', component: 'DatePicker', componentProps: { placeholder: '选择订单时间', showTime: true, format: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', - style: { width: '100%' }, }, - fieldName: 'orderTime', - label: '订单时间', rules: 'required', }, { + label: '客户', + fieldName: 'customerId', component: 'ApiSelect', componentProps: { placeholder: '请选择客户', @@ -58,8 +57,6 @@ export function useFormSchema(): VbenFormSchema[] { value: 'id', }, }, - fieldName: 'customerId', - label: '客户', rules: 'required', }, { @@ -78,15 +75,18 @@ export function useFormSchema(): VbenFormSchema[] { }, }, { + fieldName: 'remark', + label: '备注', component: 'Textarea', componentProps: { placeholder: '请输入备注', autoSize: { minRows: 1, maxRows: 1 }, }, - fieldName: 'remark', - label: '备注', + formItemClass: 'col-span-2', }, { + fieldName: 'fileUrl', + label: '附件', component: 'FileUpload', componentProps: { maxNumber: 1, @@ -104,54 +104,51 @@ export function useFormSchema(): VbenFormSchema[] { ], showDescription: true, }, - fieldName: 'fileUrl', - label: '附件', formItemClass: 'col-span-3', }, { - fieldName: 'product', + fieldName: 'items', label: '产品清单', component: 'Input', formItemClass: 'col-span-3', }, { + fieldName: 'discountPercent', + label: '优惠率(%)', component: 'InputNumber', componentProps: { placeholder: '请输入优惠率', min: 0, max: 100, precision: 2, - style: { width: '100%' }, }, - fieldName: 'discountPercent', - label: '优惠率(%)', rules: z.number().min(0).optional(), }, { + fieldName: 'discountPrice', + label: '付款优惠', component: 'InputNumber', componentProps: { placeholder: '收款优惠', precision: 2, formatter: erpPriceInputFormatter, disabled: true, - style: { width: '100%' }, }, - fieldName: 'discountPrice', - label: '付款优惠', }, { + fieldName: 'totalPrice', + label: '优惠后金额', component: 'InputNumber', componentProps: { placeholder: '优惠后金额', precision: 2, formatter: erpPriceInputFormatter, disabled: true, - style: { width: '100%' }, }, - fieldName: 'totalPrice', - label: '优惠后金额', }, { + fieldName: 'accountId', + label: '结算账户', component: 'ApiSelect', componentProps: { placeholder: '请选择结算账户', @@ -163,8 +160,6 @@ export function useFormSchema(): VbenFormSchema[] { value: 'id', }, }, - fieldName: 'accountId', - label: '结算账户', }, { component: 'InputNumber', diff --git a/apps/web-antd/src/views/erp/sale/order/modules/form.vue b/apps/web-antd/src/views/erp/sale/order/modules/form.vue index 2a1096aca..3145fd2f8 100644 --- a/apps/web-antd/src/views/erp/sale/order/modules/form.vue +++ b/apps/web-antd/src/views/erp/sale/order/modules/form.vue @@ -45,6 +45,7 @@ const [Form, formApi] = useVbenForm({ schema: useFormSchema(), showDefaultActions: false, handleValuesChange: (values, changedFields) => { + // 目的:同步到 item-form 组件,触发整体的价格计算 if (formData.value && changedFields.includes('discountPercent')) { formData.value.discountPercent = values.discountPercent; } @@ -54,9 +55,10 @@ const [Form, formApi] = useVbenForm({ /** 更新商品项 */ const handleUpdateItems = (items: ErpSaleOrderApi.SaleOrderItem[]) => { formData.value = modalApi.getData(); - if (formData.value) { - formData.value.items = items; - } + formData.value.items = items; + formApi.setValues({ + items, + }); }; /** 更新优惠金额 */ @@ -140,7 +142,7 @@ const [Modal, modalApi] = useVbenModal({ :show-confirm-button="formType !== 'detail'" >
-