From f7c0b411999091251bdb8dc43ffe26207bca2866 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 4 Oct 2025 20:05:58 +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=91purchase/in=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=201/4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/erp/purchase/in/data.ts | 219 +++++++----- .../src/views/erp/purchase/in/index.vue | 87 +++-- .../views/erp/purchase/in/modules/form.vue | 223 +++++++++++++ .../erp/purchase/in/modules/item-form.vue | 293 +++++++++++++++++ .../purchase/in/modules/purchase-in-form.vue | 311 ------------------ .../in/modules/purchase-in-item-form.vue | 256 -------------- ...rid.vue => purchase-order-select-grid.vue} | 0 ...der-form.vue => purchase-order-select.vue} | 2 +- 8 files changed, 687 insertions(+), 704 deletions(-) create mode 100644 apps/web-antd/src/views/erp/purchase/in/modules/form.vue create mode 100644 apps/web-antd/src/views/erp/purchase/in/modules/item-form.vue delete mode 100644 apps/web-antd/src/views/erp/purchase/in/modules/purchase-in-form.vue delete mode 100644 apps/web-antd/src/views/erp/purchase/in/modules/purchase-in-item-form.vue rename apps/web-antd/src/views/erp/purchase/in/modules/{select-purchase-order-grid.vue => purchase-order-select-grid.vue} (100%) rename apps/web-antd/src/views/erp/purchase/in/modules/{select-purchase-order-form.vue => purchase-order-select.vue} (96%) diff --git a/apps/web-antd/src/views/erp/purchase/in/data.ts b/apps/web-antd/src/views/erp/purchase/in/data.ts index 49b71a06b..e7d5ecc59 100644 --- a/apps/web-antd/src/views/erp/purchase/in/data.ts +++ b/apps/web-antd/src/views/erp/purchase/in/data.ts @@ -3,7 +3,7 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import { DICT_TYPE } from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; -import { erpPriceInputFormatter } from '@vben/utils'; +import { erpNumberFormatter, erpPriceInputFormatter } from '@vben/utils'; import { z } from '#/adapter/form'; import { getAccountSimpleList } from '#/api/erp/finance/account'; @@ -11,31 +11,55 @@ import { getProductSimpleList } from '#/api/erp/product/product'; import { getSupplierSimpleList } from '#/api/erp/purchase/supplier'; import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse'; import { getSimpleUserList } from '#/api/system/user'; +import { getRangePickerDefaultProps } from '#/utils'; /** 表单的配置项 */ export function useFormSchema(formType: string): 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: 'inTime', + label: '入库时间', + component: 'DatePicker', + componentProps: { + disabled: formType === 'detail', + placeholder: '选择入库时间', + showTime: true, + format: 'YYYY-MM-DD HH:mm:ss', + valueFormat: 'x', + }, + rules: 'required', + }, + { + fieldName: 'orderNo', + label: '关联订单', + component: 'Input', + formItemClass: 'col-span-1', + rules: 'required', + componentProps: { + placeholder: '请选择关联订单', + disabled: formType === 'detail', + }, + }, + { + fieldName: 'supplierId', + label: '供应商', component: 'ApiSelect', componentProps: { disabled: true, @@ -48,53 +72,39 @@ export function useFormSchema(formType: string): VbenFormSchema[] { value: 'id', }, }, - fieldName: 'supplierId', - label: '供应商', rules: 'required', }, { - fieldName: 'orderNo', - label: '关联订单', - component: 'Input', - formItemClass: 'col-span-1', + fieldName: 'purchaseUserId', + label: '采购人员', + component: 'ApiSelect', componentProps: { - disabled: formType === 'detail', - placeholder: '请选择关联订单', + placeholder: '请选择采购人员', + allowClear: true, + showSearch: true, + api: getSimpleUserList, + fieldNames: { + label: 'nickname', + value: 'id', + }, }, - rules: 'required', }, { - component: 'DatePicker', - componentProps: { - disabled: formType === 'detail', - placeholder: '选择订单时间', - showTime: true, - format: 'YYYY-MM-DD HH:mm:ss', - valueFormat: 'x', - style: { width: '100%' }, - }, - fieldName: 'inTime', - label: '入库时间', - rules: 'required', - }, - - { + fieldName: 'remark', + label: '备注', component: 'Textarea', componentProps: { placeholder: '请输入备注', - disabled: formType === 'detail', autoSize: { minRows: 1, maxRows: 1 }, - class: 'w-full', + disabled: formType === 'detail', }, - fieldName: 'remark', - label: '备注', formItemClass: 'col-span-2', }, - { + fieldName: 'fileUrl', + label: '附件', component: 'FileUpload', componentProps: { - disabled: formType === 'detail', maxNumber: 1, maxSize: 10, accept: [ @@ -108,69 +118,74 @@ export function useFormSchema(formType: string): VbenFormSchema[] { 'jpeg', 'png', ], - showDescription: true, + showDescription: formType !== 'detail', + disabled: formType === 'detail', }, - fieldName: 'fileUrl', - label: '附件', formItemClass: 'col-span-3', }, { - fieldName: 'product', - label: '产品清单', + fieldName: 'items', + label: '入库产品清单', component: 'Input', formItemClass: 'col-span-3', }, { - component: 'InputNumber', fieldName: 'discountPercent', + label: '优惠率(%)', + component: 'InputNumber', componentProps: { - placeholder: '优惠率', + placeholder: '请输入优惠率', min: 0, max: 100, - disabled: true, precision: 2, - style: { width: '100%' }, }, - - 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: 'discountedPrice', + label: '优惠后金额', component: 'InputNumber', componentProps: { placeholder: '优惠后金额', precision: 2, formatter: erpPriceInputFormatter, disabled: true, - style: { width: '100%' }, }, - fieldName: 'discountedPrice', - label: '优惠后金额', + dependencies: { + triggerFields: ['totalPrice', 'otherPrice'], + componentProps: (values) => { + const totalPrice = values.totalPrice || 0; + const otherPrice = values.otherPrice || 0; + values.discountedPrice = totalPrice - otherPrice; + return {}; + }, + }, }, { + fieldName: 'otherPrice', + label: '其他费用', component: 'InputNumber', componentProps: { disabled: formType === 'detail', placeholder: '请输入其他费用', precision: 2, formatter: erpPriceInputFormatter, - style: { width: '100%' }, }, - fieldName: 'otherPrice', - label: '其他费用', }, { + fieldName: 'accountId', + label: '结算账户', component: 'ApiSelect', componentProps: { placeholder: '请选择结算账户', @@ -183,26 +198,25 @@ export function useFormSchema(formType: string): VbenFormSchema[] { value: 'id', }, }, - fieldName: 'accountId', - label: '结算账户', }, { + fieldName: 'totalPrice', + label: '应付金额', component: 'InputNumber', componentProps: { precision: 2, - style: { width: '100%' }, - disabled: true, min: 0, + disabled: true, }, - fieldName: 'totalPrice', - label: '应付金额', rules: z.number().min(0).optional(), }, ]; } -/** 采购订单项表格列定义 */ -export function usePurchaseOrderItemTableColumns(): VxeTableGridOptions['columns'] { +/** 表单的明细表格列 */ +export function useFormItemColumns( + formData?: any[], +): VxeTableGridOptions['columns'] { return [ { type: 'seq', title: '序号', minWidth: 50, fixed: 'left' }, { @@ -219,7 +233,7 @@ export function usePurchaseOrderItemTableColumns(): VxeTableGridOptions['columns }, { field: 'stockCount', - title: '仓库库存', + title: '库存', minWidth: 80, }, { @@ -232,15 +246,27 @@ export function usePurchaseOrderItemTableColumns(): VxeTableGridOptions['columns title: '单位', minWidth: 80, }, + { + field: 'remark', + title: '备注', + minWidth: 150, + slots: { default: 'remark' }, + }, { field: 'totalCount', title: '原数量', + formatter: 'formatAmount3', minWidth: 120, + fixed: 'right', + visible: formData && formData[0]?.inCount !== undefined, }, { field: 'inCount', - title: '已入库数量', + title: '已入库', + formatter: 'formatAmount3', minWidth: 120, + fixed: 'right', + visible: formData && formData[0]?.returnCount !== undefined, }, { field: 'count', @@ -267,7 +293,8 @@ export function usePurchaseOrderItemTableColumns(): VxeTableGridOptions['columns fixed: 'right', field: 'taxPercent', title: '税率(%)', - minWidth: 100, + minWidth: 105, + slots: { default: 'taxPercent' }, }, { fixed: 'right', @@ -283,9 +310,22 @@ export function usePurchaseOrderItemTableColumns(): VxeTableGridOptions['columns minWidth: 120, formatter: 'formatAmount2', }, + { + title: '操作', + width: 50, + fixed: 'right', + slots: { default: 'actions' }, + }, ]; } +/** 采购订单项表格列(兼容旧代码) */ +export function usePurchaseOrderItemTableColumns( + formData?: any[], +): VxeTableGridOptions['columns'] { + return useFormItemColumns(formData); +} + /** 列表的搜索表单 */ export function useGridFormSchema(): VbenFormSchema[] { return [ @@ -318,10 +358,8 @@ export function useGridFormSchema(): VbenFormSchema[] { label: '入库时间', component: 'RangePicker', componentProps: { - placeholder: ['开始时间', '结束时间'], - showTime: true, - format: 'YYYY-MM-DD HH:mm:ss', - valueFormat: 'YYYY-MM-DD HH:mm:ss', + ...getRangePickerDefaultProps(), + allowClear: true, }, }, { @@ -386,18 +424,18 @@ export function useGridFormSchema(): VbenFormSchema[] { { label: '部分付款', value: 1 }, { label: '全部付款', value: 2 }, ], - placeholder: '请选择退货状态', + placeholder: '请选择付款状态', allowClear: true, }, }, { fieldName: 'status', - label: '状态', + label: '审批状态', component: 'Select', componentProps: { - placeholder: '请选择状态', - allowClear: true, options: getDictOptions(DICT_TYPE.ERP_AUDIT_STATUS, 'number'), + placeholder: '请选择审批状态', + allowClear: true, }, }, { @@ -441,7 +479,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { field: 'inTime', title: '入库时间', width: 160, - formatter: 'formatDateTime', + formatter: 'formatDate', }, { field: 'creatorName', @@ -466,9 +504,17 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { formatter: 'formatAmount2', minWidth: 120, }, + { + field: 'unPaymentPrice', + title: '未付金额', + formatter: ({ row }) => { + return `${erpNumberFormatter(row.totalPrice - row.paymentPrice, 2)}元`; + }, + minWidth: 120, + }, { field: 'status', - title: '状态', + title: '审批状态', minWidth: 120, cellRender: { name: 'CellDict', @@ -477,7 +523,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { }, { title: '操作', - minWidth: 250, + width: 220, fixed: 'right', slots: { default: 'actions' }, }, @@ -493,7 +539,6 @@ export function useOrderGridFormSchema(): VbenFormSchema[] { componentProps: { placeholder: '请输入订单单号', allowClear: true, - disabled: true, }, }, { @@ -516,10 +561,8 @@ export function useOrderGridFormSchema(): VbenFormSchema[] { label: '订单时间', component: 'RangePicker', componentProps: { - placeholder: ['开始时间', '结束时间'], - showTime: true, - format: 'YYYY-MM-DD HH:mm:ss', - valueFormat: 'YYYY-MM-DD HH:mm:ss', + ...getRangePickerDefaultProps(), + allowClear: true, }, }, ]; diff --git a/apps/web-antd/src/views/erp/purchase/in/index.vue b/apps/web-antd/src/views/erp/purchase/in/index.vue index 9ba9b6df1..77d1eebbe 100644 --- a/apps/web-antd/src/views/erp/purchase/in/index.vue +++ b/apps/web-antd/src/views/erp/purchase/in/index.vue @@ -19,85 +19,79 @@ import { import { $t } from '#/locales'; import { useGridColumns, useGridFormSchema } from './data'; -import PurchaseInForm from './modules/purchase-in-form.vue'; +import Form from './modules/form.vue'; /** ERP 采购入库列表 */ defineOptions({ name: 'ErpPurchaseIn' }); const [FormModal, formModalApi] = useVbenModal({ - connectedComponent: PurchaseInForm, + connectedComponent: Form, destroyOnClose: true, }); /** 刷新表格 */ -function onRefresh() { +function handleRefresh() { gridApi.query(); } -// TODO @Xuzhiqiang:批量删除待实现 -const checkedIds = ref([]); - -/** 详情 */ -function handleDetail(row: ErpPurchaseInApi.PurchaseIn) { - formModalApi.setData({ type: 'detail', id: row.id }).open(); +/** 导出表格 */ +async function handleExport() { + const data = await exportPurchaseIn(await gridApi.formApi.getValues()); + downloadFileFromBlobPart({ fileName: '采购入库.xls', source: data }); } -/** 新增 */ +/** 新增采购入库 */ function handleCreate() { formModalApi.setData({ type: 'create' }).open(); } -/** 编辑 */ +/** 编辑采购入库 */ function handleEdit(row: ErpPurchaseInApi.PurchaseIn) { formModalApi.setData({ type: 'edit', id: row.id }).open(); } -/** 删除 */ +/** 删除采购入库 */ async function handleDelete(ids: number[]) { const hideLoading = message.loading({ content: $t('ui.actionMessage.deleting'), duration: 0, - key: 'action_process_msg', }); try { await deletePurchaseIn(ids); - message.success({ - content: $t('ui.actionMessage.deleteSuccess'), - key: 'action_process_msg', - }); - onRefresh(); + message.success($t('ui.actionMessage.deleteSuccess')); + handleRefresh(); } finally { hideLoading(); } } /** 审批/反审批操作 */ -function handleUpdateStatus(row: ErpPurchaseInApi.PurchaseIn, status: number) { +async function handleUpdateStatus(row: ErpPurchaseInApi.PurchaseIn, status: number) { const hideLoading = message.loading({ content: `确定${status === 20 ? '审批' : '反审批'}该订单吗?`, duration: 0, - key: 'action_process_msg', }); - updatePurchaseInStatus(row.id!, status) - .then(() => { - message.success({ - content: `${status === 20 ? '审批' : '反审批'}成功`, - key: 'action_process_msg', - }); - onRefresh(); - }) - .catch(() => { - // 处理错误 - }) - .finally(() => { - hideLoading(); - }); + try { + await updatePurchaseInStatus(row.id!, status); + message.success(`${status === 20 ? '审批' : '反审批'}成功`); + handleRefresh(); + } finally { + hideLoading(); + } } -/** 导出 */ -async function handleExport() { - const data = await exportPurchaseIn(await gridApi.formApi.getValues()); - downloadFileFromBlobPart({ fileName: '采购入库.xls', source: data }); +const checkedIds = ref([]); +function handleRowCheckboxChange({ + records, +}: { + records: ErpPurchaseInApi.PurchaseIn[]; +}) { + checkedIds.value = records.map((item) => item.id!); +} + +/** 查看详情 */ +function handleDetail(row: ErpPurchaseInApi.PurchaseIn) { + formModalApi.setData({ type: 'detail', id: row.id }).open(); } const [Grid, gridApi] = useVbenVxeGrid({ @@ -128,6 +122,10 @@ const [Grid, gridApi] = useVbenVxeGrid({ search: true, }, } as VxeTableGridOptions, + gridEvents: { + checkboxAll: handleRowCheckboxChange, + checkboxChange: handleRowCheckboxChange, + }, }); @@ -139,8 +137,8 @@ const [Grid, gridApi] = useVbenVxeGrid({ url="https://doc.iocoder.cn/erp/purchase/" /> - +