From f63cb9ed2f19045d8e05688679ddd8858883d9b2 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 4 Oct 2025 15:16:51 +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/return=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/erp/sale/return/data.ts | 183 +++++----- .../src/views/erp/sale/return/index.vue | 123 +++---- .../views/erp/sale/return/modules/form.vue | 238 +++++++++++++ .../erp/sale/return/modules/item-form.vue | 291 ++++++++++++++++ .../sale/return/modules/sale-order-select.vue | 117 +++++++ .../sale/return/modules/sale-return-form.vue | 312 ------------------ .../return/modules/sale-return-item-form.vue | 256 -------------- .../return/modules/select-sale-order-form.vue | 70 ---- .../return/modules/select-sale-order-grid.vue | 55 --- 9 files changed, 800 insertions(+), 845 deletions(-) create mode 100644 apps/web-antd/src/views/erp/sale/return/modules/form.vue create mode 100644 apps/web-antd/src/views/erp/sale/return/modules/item-form.vue create mode 100644 apps/web-antd/src/views/erp/sale/return/modules/sale-order-select.vue delete mode 100644 apps/web-antd/src/views/erp/sale/return/modules/sale-return-form.vue delete mode 100644 apps/web-antd/src/views/erp/sale/return/modules/sale-return-item-form.vue delete mode 100644 apps/web-antd/src/views/erp/sale/return/modules/select-sale-order-form.vue delete mode 100644 apps/web-antd/src/views/erp/sale/return/modules/select-sale-order-grid.vue diff --git a/apps/web-antd/src/views/erp/sale/return/data.ts b/apps/web-antd/src/views/erp/sale/return/data.ts index cb872ea43..bf4f64b1e 100644 --- a/apps/web-antd/src/views/erp/sale/return/data.ts +++ b/apps/web-antd/src/views/erp/sale/return/data.ts @@ -11,44 +11,39 @@ import { getProductSimpleList } from '#/api/erp/product/product'; import { getCustomerSimpleList } from '#/api/erp/sale/customer'; 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: '退货单号', }, { - component: 'ApiSelect', + fieldName: 'returnTime', + label: '退货时间', + component: 'DatePicker', componentProps: { - disabled: true, - placeholder: '请选择客户', - allowClear: true, - showSearch: true, - api: getCustomerSimpleList, - fieldNames: { - label: 'name', - value: 'id', - }, + disabled: formType === 'detail', + placeholder: '选择退货时间', + showTime: true, + format: 'YYYY-MM-DD HH:mm:ss', + valueFormat: 'x', }, - fieldName: 'customerId', - label: '客户', rules: 'required', }, { @@ -63,35 +58,53 @@ export function useFormSchema(formType: string): VbenFormSchema[] { }, }, { - component: 'DatePicker', + fieldName: 'customerId', + label: '客户', + component: 'ApiSelect', componentProps: { - disabled: formType === 'detail', - placeholder: '选择退货时间', - showTime: true, - format: 'YYYY-MM-DD HH:mm:ss', - valueFormat: 'x', - style: { width: '100%' }, + disabled: true, + placeholder: '请选择客户', + allowClear: true, + showSearch: true, + api: getCustomerSimpleList, + fieldNames: { + label: 'name', + value: 'id', + }, }, - fieldName: 'returnTime', - label: '退货时间', rules: 'required', }, { + fieldName: 'saleUserId', + label: '销售人员', + component: 'ApiSelect', + componentProps: { + placeholder: '请选择销售人员', + allowClear: true, + showSearch: true, + api: getSimpleUserList, + fieldNames: { + label: 'nickname', + value: 'id', + }, + }, + }, + { + fieldName: 'remark', + label: '备注', component: 'Textarea', componentProps: { placeholder: '请输入备注', - disabled: formType === 'detail', autoSize: { minRows: 1, maxRows: 1 }, - class: 'w-full', + disabled: formType === 'detail', }, - fieldName: 'remark', formItemClass: 'col-span-2', - label: '备注', }, { + fieldName: 'fileUrl', + label: '附件', component: 'FileUpload', componentProps: { - disabled: formType === 'detail', maxNumber: 1, maxSize: 10, accept: [ @@ -105,69 +118,65 @@ 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', + 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: '优惠后金额', }, { + 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: '请选择结算账户', @@ -180,26 +189,23 @@ 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 useSaleReturnItemTableColumns(): VxeTableGridOptions['columns'] { +/** 表单的明细表格列 */ +export function useFormItemColumns(): VxeTableGridOptions['columns'] { return [ { type: 'seq', title: '序号', minWidth: 50, fixed: 'left' }, { @@ -216,7 +222,7 @@ export function useSaleReturnItemTableColumns(): VxeTableGridOptions['columns'] }, { field: 'stockCount', - title: '仓库库存', + title: '库存', minWidth: 80, }, { @@ -229,6 +235,12 @@ export function useSaleReturnItemTableColumns(): VxeTableGridOptions['columns'] title: '单位', minWidth: 80, }, + { + field: 'remark', + title: '备注', + minWidth: 150, + slots: { default: 'remark' }, + }, { field: 'totalCount', title: '原数量', @@ -266,7 +278,8 @@ export function useSaleReturnItemTableColumns(): VxeTableGridOptions['columns'] fixed: 'right', field: 'taxPercent', title: '税率(%)', - minWidth: 100, + minWidth: 105, + slots: { default: 'taxPercent' }, }, { fixed: 'right', @@ -282,6 +295,12 @@ export function useSaleReturnItemTableColumns(): VxeTableGridOptions['columns'] minWidth: 120, formatter: 'formatAmount2', }, + { + title: '操作', + width: 50, + fixed: 'right', + slots: { default: 'actions' }, + }, ]; } @@ -317,10 +336,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, }, }, { @@ -378,26 +395,26 @@ export function useGridFormSchema(): VbenFormSchema[] { }, { fieldName: 'refundStatus', - label: '退货状态', + label: '退款状态', component: 'Select', componentProps: { options: [ - { label: '未退货', value: 0 }, - { label: '部分退货', value: 1 }, - { label: '全部退货', value: 2 }, + { label: '未退款', value: 0 }, + { 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, }, }, { @@ -456,7 +473,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { }, { field: 'totalPrice', - title: '应退金额', + title: '应收金额', formatter: 'formatAmount2', minWidth: 120, }, @@ -476,7 +493,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { }, { field: 'status', - title: '状态', + title: '审批状态', minWidth: 120, cellRender: { name: 'CellDict', @@ -485,12 +502,13 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { }, { title: '操作', - minWidth: 250, + width: 220, fixed: 'right', slots: { default: 'actions' }, }, ]; } + /** 列表的搜索表单 */ export function useOrderGridFormSchema(): VbenFormSchema[] { return [ @@ -501,7 +519,6 @@ export function useOrderGridFormSchema(): VbenFormSchema[] { componentProps: { placeholder: '请输入订单单号', allowClear: true, - disabled: true, }, }, { @@ -524,10 +541,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/sale/return/index.vue b/apps/web-antd/src/views/erp/sale/return/index.vue index 812e9c4b0..712ecb15d 100644 --- a/apps/web-antd/src/views/erp/sale/return/index.vue +++ b/apps/web-antd/src/views/erp/sale/return/index.vue @@ -19,7 +19,7 @@ import { import { $t } from '#/locales'; import { useGridColumns, useGridFormSchema } from './data'; -import SaleReturnForm from './modules/sale-return-form.vue'; +import SaleReturnForm from './modules/form.vue'; /** ERP 销售退货列表 */ defineOptions({ name: 'ErpSaleReturn' }); @@ -30,11 +30,59 @@ const [FormModal, formModalApi] = useVbenModal({ }); /** 刷新表格 */ -function onRefresh() { +function handleRefresh() { gridApi.query(); } -// TODO @Xuzhiqiang:批量删除待实现 +/** 导出表格 */ +async function handleExport() { + const data = await exportSaleReturn(await gridApi.formApi.getValues()); + downloadFileFromBlobPart({ fileName: '销售退货.xls', source: data }); +} + +/** 新增销售退货 */ +function handleCreate() { + formModalApi.setData({ type: 'create' }).open(); +} + +/** 编辑销售退货 */ +function handleEdit(row: ErpSaleReturnApi.SaleReturn) { + formModalApi.setData({ type: 'edit', id: row.id }).open(); +} + +/** 删除销售退货 */ +async function handleDelete(ids: number[]) { + const hideLoading = message.loading({ + content: $t('ui.actionMessage.deleting'), + duration: 0, + }); + try { + await deleteSaleReturn(ids); + message.success($t('ui.actionMessage.deleteSuccess')); + handleRefresh(); + } finally { + hideLoading(); + } +} + +/** 审批/反审批操作 */ +async function handleUpdateStatus( + row: ErpSaleReturnApi.SaleReturn, + status: number, +) { + const hideLoading = message.loading({ + content: `确定${status === 20 ? '审批' : '反审批'}该订单吗?`, + duration: 0, + }); + try { + await updateSaleReturnStatus(row.id!, status); + message.success(`${status === 20 ? '审批' : '反审批'}成功`); + handleRefresh(); + } finally { + hideLoading(); + } +} + const checkedIds = ref([]); function handleRowCheckboxChange({ records, @@ -44,69 +92,11 @@ function handleRowCheckboxChange({ checkedIds.value = records.map((item) => item.id!); } -/** 详情 */ +/** 查看详情 */ function handleDetail(row: ErpSaleReturnApi.SaleReturn) { formModalApi.setData({ type: 'detail', id: row.id }).open(); } -/** 新增 */ -function handleCreate() { - formModalApi.setData({ type: 'create' }).open(); -} - -/** 编辑 */ -function handleEdit(row: ErpSaleReturnApi.SaleReturn) { - formModalApi.setData({ type: 'update', 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 deleteSaleReturn(ids); - message.success({ - content: $t('ui.actionMessage.deleteSuccess'), - key: 'action_process_msg', - }); - onRefresh(); - } finally { - hideLoading(); - } -} - -/** 审批/反审批操作 */ -function handleUpdateStatus(row: ErpSaleReturnApi.SaleReturn, status: number) { - const hideLoading = message.loading({ - content: `确定${status === 20 ? '审批' : '反审批'}该订单吗?`, - duration: 0, - key: 'action_process_msg', - }); - updateSaleReturnStatus({ id: row.id!, status }) - .then(() => { - message.success({ - content: `${status === 20 ? '审批' : '反审批'}成功`, - key: 'action_process_msg', - }); - onRefresh(); - }) - .catch(() => { - // 处理错误 - }) - .finally(() => { - hideLoading(); - }); -} - -/** 导出 */ -async function handleExport() { - const data = await exportSaleReturn(await gridApi.formApi.getValues()); - downloadFileFromBlobPart({ fileName: '销售退货.xls', source: data }); -} - const [Grid, gridApi] = useVbenVxeGrid({ formOptions: { schema: useGridFormSchema(), @@ -150,8 +140,8 @@ const [Grid, gridApi] = useVbenVxeGrid({ url="https://doc.iocoder.cn/erp/sale/" /> - +