From 7c2c249e5d2de6b23669e16d511a9b0f6754b32d Mon Sep 17 00:00:00 2001
From: nehc <934298133@qq.com>
Date: Wed, 23 Jul 2025 17:02:38 +0800
Subject: [PATCH] =?UTF-8?q?feat(@vben/web-antd):=20erp-=E9=87=8D=E6=9E=84?=
=?UTF-8?q?=E9=87=87=E8=B4=AD=E8=AE=A2=E5=8D=95=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 更新表单组件,使用已有的 VbenForm 组件
- 优化表单字段定义,使用 useFormSchema 函数统一管理
- 重构表格组件,使用 VxeTable
- 优化数据处理逻辑,提高代码复用性和可维护性
- 调整界面布局和样式,提升用户体验
---
.../order/components/PurchaseOrderForm.vue | 338 ------------------
.../src/views/erp/purchase/order/data.ts | 313 +++++++++++++---
.../src/views/erp/purchase/order/index.vue | 2 +-
.../PurchaseOrderItemForm.vue | 0
.../views/erp/purchase/order/modules/form.vue | 139 +++++++
5 files changed, 399 insertions(+), 393 deletions(-)
delete mode 100644 apps/web-antd/src/views/erp/purchase/order/components/PurchaseOrderForm.vue
rename apps/web-antd/src/views/erp/purchase/order/{components => modules}/PurchaseOrderItemForm.vue (100%)
create mode 100644 apps/web-antd/src/views/erp/purchase/order/modules/form.vue
diff --git a/apps/web-antd/src/views/erp/purchase/order/components/PurchaseOrderForm.vue b/apps/web-antd/src/views/erp/purchase/order/components/PurchaseOrderForm.vue
deleted file mode 100644
index 2c7d8635c..000000000
--- a/apps/web-antd/src/views/erp/purchase/order/components/PurchaseOrderForm.vue
+++ /dev/null
@@ -1,338 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
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 045c038ee..897d25ee5 100644
--- a/apps/web-antd/src/views/erp/purchase/order/data.ts
+++ b/apps/web-antd/src/views/erp/purchase/order/data.ts
@@ -1,10 +1,132 @@
import type { VbenFormSchema } from '#/adapter/form';
-import type { VxeGridPropTypes } from '#/adapter/vxe-table';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import { erpCountInputFormatter, erpPriceInputFormatter } from '@vben/utils';
+
+import { getAccountSimpleList } from '#/api/erp/finance/account';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getSupplierSimpleList } from '#/api/erp/purchase/supplier';
import { getSimpleUserList } from '#/api/system/user';
-import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
+import { DICT_TYPE, getDictOptions } from '#/utils';
+
+/** 表单的配置项 */
+export function useFormSchema(): VbenFormSchema[] {
+ return [
+ {
+ component: 'ApiSelect',
+ componentProps: {
+ placeholder: '请选择供应商',
+ allowClear: true,
+ showSearch: true,
+ api: getSupplierSimpleList,
+ fieldNames: {
+ label: 'name',
+ value: 'id',
+ },
+ },
+ fieldName: 'supplierId',
+ label: '供应商',
+ rules: 'required',
+ },
+ {
+ component: 'DatePicker',
+ componentProps: {
+ placeholder: '选择订单时间',
+ showTime: true,
+ format: 'YYYY-MM-DD HH:mm:ss',
+ valueFormat: 'YYYY-MM-DD HH:mm:ss',
+ style: { width: '100%' },
+ },
+ fieldName: 'orderTime',
+ label: '订单时间',
+ rules: 'required',
+ },
+ {
+ component: 'Textarea',
+ componentProps: {
+ placeholder: '请输入备注',
+ autoSize: { minRows: 2, maxRows: 4 },
+ class: 'w-full',
+ },
+ fieldName: 'remark',
+ label: '备注',
+ formItemClass: 'col-span-2',
+ },
+ {
+ component: 'Input',
+ componentProps: {
+ placeholder: '请输入附件地址',
+ class: 'w-full',
+ },
+ fieldName: 'fileUrl',
+ label: '附件',
+ formItemClass: 'col-span-2',
+ },
+ {
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '请输入优惠率',
+ min: 0,
+ max: 100,
+ precision: 2,
+ formatter: erpPriceInputFormatter,
+ style: { width: '100%' },
+ },
+ fieldName: 'discountPercent',
+ label: '优惠率(%)',
+ },
+ {
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '付款优惠',
+ precision: 2,
+ formatter: erpPriceInputFormatter,
+ disabled: true,
+ style: { width: '100%' },
+ },
+ fieldName: 'discountPrice',
+ label: '付款优惠',
+ },
+ {
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '优惠后金额',
+ precision: 2,
+ formatter: erpPriceInputFormatter,
+ disabled: true,
+ style: { width: '100%' },
+ },
+ fieldName: 'totalPrice',
+ label: '优惠后金额',
+ },
+ {
+ component: 'ApiSelect',
+ componentProps: {
+ placeholder: '请选择结算账户',
+ allowClear: true,
+ showSearch: true,
+ api: getAccountSimpleList,
+ fieldNames: {
+ label: 'name',
+ value: 'id',
+ },
+ },
+ fieldName: 'accountId',
+ label: '结算账户',
+ },
+ {
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '请输入支付订金',
+ precision: 2,
+ formatter: erpPriceInputFormatter,
+ style: { width: '100%' },
+ },
+ fieldName: 'depositPrice',
+ label: '支付订金',
+ },
+ ];
+}
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
@@ -23,14 +145,14 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '产品',
component: 'ApiSelect',
componentProps: {
+ placeholder: '请选择产品',
+ allowClear: true,
+ showSearch: true,
api: getProductSimpleList,
fieldNames: {
label: 'name',
value: 'id',
},
- placeholder: '请选择产品',
- allowClear: true,
- showSearch: true,
},
},
{
@@ -38,8 +160,10 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '订单时间',
component: 'RangePicker',
componentProps: {
- ...getRangePickerDefaultProps(),
- allowClear: true,
+ placeholder: ['开始时间', '结束时间'],
+ showTime: true,
+ format: 'YYYY-MM-DD HH:mm:ss',
+ valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
},
{
@@ -47,14 +171,14 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '供应商',
component: 'ApiSelect',
componentProps: {
+ placeholder: '请选择供应商',
+ allowClear: true,
+ showSearch: true,
api: getSupplierSimpleList,
fieldNames: {
label: 'name',
value: 'id',
},
- placeholder: '请选择供应商',
- allowClear: true,
- showSearch: true,
},
},
{
@@ -62,14 +186,14 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '创建人',
component: 'ApiSelect',
componentProps: {
+ placeholder: '请选择创建人',
+ allowClear: true,
+ showSearch: true,
api: getSimpleUserList,
fieldNames: {
label: 'nickname',
value: 'id',
},
- placeholder: '请选择创建人',
- allowClear: true,
- showSearch: true,
},
},
{
@@ -82,29 +206,6 @@ export function useGridFormSchema(): VbenFormSchema[] {
allowClear: true,
},
},
- {
- fieldName: 'remark',
- label: '备注',
- component: 'Input',
- componentProps: {
- placeholder: '请输入备注',
- allowClear: true,
- },
- },
- {
- fieldName: 'inStatus',
- label: '入库状态',
- component: 'Select',
- componentProps: {
- options: [
- { label: '未入库', value: 0 },
- { label: '部分入库', value: 1 },
- { label: '全部入库', value: 2 },
- ],
- placeholder: '请选择入库状态',
- allowClear: true,
- },
- },
{
fieldName: 'returnStatus',
label: '退货状态',
@@ -122,73 +223,68 @@ export function useGridFormSchema(): VbenFormSchema[] {
];
}
-/** 表格列配置 */
-export function useGridColumns(): VxeGridPropTypes.Columns {
+/** 列表的字段 */
+export function useGridColumns(): VxeTableGridOptions['columns'] {
return [
{
type: 'checkbox',
- width: 60,
+ width: 50,
fixed: 'left',
},
{
field: 'no',
title: '订单单号',
+ width: 260,
fixed: 'left',
- minWidth: 180,
},
{
field: 'productNames',
title: '产品信息',
- minWidth: 200,
+ showOverflow: 'tooltip',
},
{
field: 'supplierName',
title: '供应商',
- minWidth: 120,
},
{
field: 'orderTime',
title: '订单时间',
+ width: 160,
formatter: 'formatDateTime',
- minWidth: 160,
},
{
field: 'creatorName',
title: '创建人',
- minWidth: 100,
},
{
field: 'totalCount',
title: '总数量',
- minWidth: 100,
+ formatter: 'formatNumber',
},
{
field: 'inCount',
title: '入库数量',
- minWidth: 100,
+ formatter: 'formatNumber',
},
{
field: 'returnCount',
title: '退货数量',
- minWidth: 100,
+ formatter: 'formatNumber',
},
{
field: 'totalProductPrice',
title: '金额合计',
- formatter: 'formatAmount2',
- minWidth: 120,
+ formatter: 'formatNumber',
},
{
field: 'totalPrice',
title: '含税金额',
- formatter: 'formatAmount2',
- minWidth: 120,
+ formatter: 'formatNumber',
},
{
field: 'depositPrice',
title: '支付订金',
- formatter: 'formatAmount2',
- minWidth: 120,
+ formatter: 'formatNumber',
},
{
field: 'status',
@@ -197,7 +293,6 @@ export function useGridColumns(): VxeGridPropTypes.Columns {
name: 'CellDict',
props: { type: DICT_TYPE.ERP_AUDIT_STATUS },
},
- minWidth: 100,
},
{
title: '操作',
@@ -207,3 +302,113 @@ export function useGridColumns(): VxeGridPropTypes.Columns {
},
];
}
+
+/** 采购订单明细项表单配置 */
+export function useItemFormSchema(
+ onProductChange?: (productId: number) => void,
+): VbenFormSchema[] {
+ return [
+ {
+ component: 'ApiSelect',
+ componentProps: {
+ placeholder: '请选择产品',
+ allowClear: true,
+ showSearch: true,
+ api: getProductSimpleList,
+ fieldNames: {
+ label: 'name',
+ value: 'id',
+ },
+ onChange: onProductChange,
+ },
+ fieldName: 'productId',
+ label: '产品名称',
+ rules: 'required',
+ },
+ {
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '请输入数量',
+ min: 1,
+ precision: 2,
+ formatter: erpCountInputFormatter,
+ style: { width: '100%' },
+ },
+ fieldName: 'count',
+ label: '数量',
+ rules: 'required',
+ },
+ {
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '请输入单价',
+ min: 0,
+ precision: 2,
+ formatter: erpPriceInputFormatter,
+ style: { width: '100%' },
+ },
+ fieldName: 'productPrice',
+ label: '产品单价',
+ rules: 'required',
+ },
+ {
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '金额',
+ precision: 2,
+ formatter: erpPriceInputFormatter,
+ disabled: true,
+ style: { width: '100%' },
+ },
+ fieldName: 'totalPrice',
+ label: '金额',
+ },
+ {
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '请输入税率',
+ min: 0,
+ max: 100,
+ precision: 2,
+ style: { width: '100%' },
+ },
+ fieldName: 'taxPercent',
+ label: '税率(%)',
+ },
+ {
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '税额',
+ precision: 2,
+ formatter: erpPriceInputFormatter,
+ disabled: true,
+ style: { width: '100%' },
+ },
+ fieldName: 'taxPrice',
+ label: '税额',
+ },
+ {
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '税额合计',
+ precision: 2,
+ formatter: erpPriceInputFormatter,
+ disabled: true,
+ style: { width: '100%' },
+ },
+ fieldName: 'totalTaxPrice',
+ label: '税额合计',
+ },
+ {
+ component: 'Textarea',
+ componentProps: {
+ placeholder: '请输入备注',
+ autoSize: { minRows: 2, maxRows: 4 },
+ class: 'w-full',
+ },
+ fieldName: 'remark',
+ label: '备注',
+ formItemClass: 'col-span-2',
+ },
+ ];
+}
diff --git a/apps/web-antd/src/views/erp/purchase/order/index.vue b/apps/web-antd/src/views/erp/purchase/order/index.vue
index 892f13359..f491b0f4d 100644
--- a/apps/web-antd/src/views/erp/purchase/order/index.vue
+++ b/apps/web-antd/src/views/erp/purchase/order/index.vue
@@ -19,8 +19,8 @@ import {
} from '#/api/erp/purchase/order';
import { $t } from '#/locales';
-import PurchaseOrderForm from './components/PurchaseOrderForm.vue';
import { useGridColumns, useGridFormSchema } from './data';
+import PurchaseOrderForm from './modules/form.vue';
/** ERP 采购订单列表 */
defineOptions({ name: 'ErpPurchaseOrder' });
diff --git a/apps/web-antd/src/views/erp/purchase/order/components/PurchaseOrderItemForm.vue b/apps/web-antd/src/views/erp/purchase/order/modules/PurchaseOrderItemForm.vue
similarity index 100%
rename from apps/web-antd/src/views/erp/purchase/order/components/PurchaseOrderItemForm.vue
rename to apps/web-antd/src/views/erp/purchase/order/modules/PurchaseOrderItemForm.vue
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
new file mode 100644
index 000000000..67f4ee2fb
--- /dev/null
+++ b/apps/web-antd/src/views/erp/purchase/order/modules/form.vue
@@ -0,0 +1,139 @@
+
+
+
+
+
+
+
+
+
+