From f98cef8c71d1b62d5e591ef150a8a6f8b3f95325 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 5 Oct 2025 09:00:39 +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=91stock/check=201/1=20=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/erp/stock/check/data.ts | 168 ++++---- .../src/views/erp/stock/check/index.vue | 154 ++++---- .../views/erp/stock/check/modules/form.vue | 119 ++---- .../erp/stock/check/modules/item-form.vue | 308 +++++++++++++++ .../check/modules/stock-check-item-form.vue | 374 ------------------ 5 files changed, 497 insertions(+), 626 deletions(-) create mode 100644 apps/web-antd/src/views/erp/stock/check/modules/item-form.vue delete mode 100644 apps/web-antd/src/views/erp/stock/check/modules/stock-check-item-form.vue diff --git a/apps/web-antd/src/views/erp/stock/check/data.ts b/apps/web-antd/src/views/erp/stock/check/data.ts index 95b3e9fcc..36ddef0e3 100644 --- a/apps/web-antd/src/views/erp/stock/check/data.ts +++ b/apps/web-antd/src/views/erp/stock/check/data.ts @@ -4,62 +4,58 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import { DICT_TYPE } from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; -import { createRequiredValidation } from '#/adapter/vxe-table'; import { getProductSimpleList } from '#/api/erp/product/product'; 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: 'checkTime', + label: '盘点时间', component: 'DatePicker', componentProps: { placeholder: '选择盘点时间', showTime: true, format: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x', - style: { width: '100%' }, }, - disabled: formType === 'detail', - fieldName: 'checkTime', - label: '盘点时间', rules: 'required', }, { + fieldName: 'remark', + label: '备注', component: 'Textarea', componentProps: { placeholder: '请输入备注', - autoSize: { minRows: 2, maxRows: 4 }, - class: 'w-full', + autoSize: { minRows: 1, maxRows: 1 }, + disabled: formType === 'detail', }, - disabled: formType === 'detail', - fieldName: 'remark', - label: '备注', - formItemClass: 'col-span-3', + formItemClass: 'col-span-2', }, { + fieldName: 'fileUrl', + label: '附件', component: 'FileUpload', - disabled: formType === 'detail', componentProps: { maxNumber: 1, maxSize: 10, @@ -74,15 +70,13 @@ 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', - disabled: formType === 'detail', + fieldName: 'items', label: '产品清单', component: 'Input', formItemClass: 'col-span-3', @@ -90,10 +84,8 @@ export function useFormSchema(formType: string): VbenFormSchema[] { ]; } -/** 库存盘点清单表格列定义 */ -export function useStockCheckItemTableColumns( - isValidating?: any, -): VxeTableGridOptions['columns'] { +/** 表单的明细表格列 */ +export function useFormItemColumns(): VxeTableGridOptions['columns'] { return [ { type: 'seq', title: '序号', minWidth: 50, fixed: 'left' }, { @@ -101,19 +93,17 @@ export function useStockCheckItemTableColumns( title: '仓库名称', minWidth: 150, slots: { default: 'warehouseId' }, - className: createRequiredValidation(isValidating, 'warehouseId'), }, { field: 'productId', title: '产品名称', minWidth: 200, slots: { default: 'productId' }, - className: createRequiredValidation(isValidating, 'productId'), }, { field: 'stockCount', title: '账面库存', - minWidth: 100, + minWidth: 80, }, { field: 'productBarCode', @@ -125,38 +115,40 @@ export function useStockCheckItemTableColumns( title: '单位', minWidth: 80, }, + { + field: 'remark', + title: '备注', + minWidth: 150, + slots: { default: 'remark' }, + }, { field: 'actualCount', title: '实际库存', minWidth: 120, + fixed: 'right', slots: { default: 'actualCount' }, - className: createRequiredValidation(isValidating, 'actualCount'), }, { field: 'count', title: '盈亏数量', minWidth: 120, - slots: { default: 'count' }, - className: createRequiredValidation(isValidating, 'count'), + fixed: 'right', + formatter: 'formatAmount3', }, { field: 'productPrice', title: '产品单价', minWidth: 120, + fixed: 'right', slots: { default: 'productPrice' }, }, { field: 'totalPrice', - title: '合计金额', + title: '金额', minWidth: 120, + fixed: 'right', formatter: 'formatAmount2', }, - { - field: 'remark', - title: '备注', - minWidth: 150, - slots: { default: 'remark' }, - }, { title: '操作', width: 50, @@ -187,8 +179,10 @@ export function useGridFormSchema(): VbenFormSchema[] { allowClear: true, showSearch: true, api: getProductSimpleList, - labelField: 'name', - valueField: 'id', + fieldNames: { + label: 'name', + value: 'id', + }, }, }, { @@ -196,10 +190,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, }, }, { @@ -211,27 +203,10 @@ export function useGridFormSchema(): VbenFormSchema[] { allowClear: true, showSearch: true, api: getWarehouseSimpleList, - labelField: 'name', - valueField: 'id', - }, - }, - { - fieldName: 'status', - label: '状态', - component: 'Select', - componentProps: { - placeholder: '请选择状态', - allowClear: true, - options: getDictOptions(DICT_TYPE.ERP_AUDIT_STATUS, 'number'), - }, - }, - { - fieldName: 'remark', - label: '备注', - component: 'Input', - componentProps: { - placeholder: '请输入备注', - allowClear: true, + fieldNames: { + label: 'name', + value: 'id', + }, }, }, { @@ -243,8 +218,29 @@ export function useGridFormSchema(): VbenFormSchema[] { allowClear: true, showSearch: true, api: getSimpleUserList, - labelField: 'nickname', - valueField: 'id', + fieldNames: { + label: 'nickname', + value: 'id', + }, + }, + }, + { + fieldName: 'status', + label: '状态', + component: 'Select', + componentProps: { + options: getDictOptions(DICT_TYPE.ERP_AUDIT_STATUS, 'number'), + placeholder: '请选择状态', + allowClear: true, + }, + }, + { + fieldName: 'remark', + label: '备注', + component: 'Input', + componentProps: { + placeholder: '请输入备注', + allowClear: true, }, }, ]; @@ -261,44 +257,42 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'no', title: '盘点单号', - minWidth: 180, + width: 200, + fixed: 'left', }, { field: 'productNames', title: '产品信息', - minWidth: 200, showOverflow: 'tooltip', + minWidth: 120, }, { field: 'checkTime', - title: '出库时间', - minWidth: 180, - cellRender: { - name: 'CellDateTime', - }, + title: '盘点时间', + width: 160, + formatter: 'formatDate', }, { field: 'creatorName', title: '创建人', - minWidth: 100, + minWidth: 120, }, { field: 'totalCount', - title: '数量', + title: '总数量', formatter: 'formatAmount3', - minWidth: 100, + minWidth: 120, }, { field: 'totalPrice', - title: '金额', + title: '总金额', formatter: 'formatAmount2', - minWidth: 100, + minWidth: 120, }, { field: 'status', title: '状态', - minWidth: 90, - fixed: 'right', + minWidth: 120, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.ERP_AUDIT_STATUS }, @@ -306,7 +300,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { }, { title: '操作', - width: 300, + width: 220, fixed: 'right', slots: { default: 'actions' }, }, diff --git a/apps/web-antd/src/views/erp/stock/check/index.vue b/apps/web-antd/src/views/erp/stock/check/index.vue index 941f8eba8..e41dda017 100644 --- a/apps/web-antd/src/views/erp/stock/check/index.vue +++ b/apps/web-antd/src/views/erp/stock/check/index.vue @@ -2,8 +2,10 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { ErpStockCheckApi } from '#/api/erp/stock/check'; +import { ref } from 'vue'; + import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; -import { downloadFileFromBlobPart } from '@vben/utils'; +import { downloadFileFromBlobPart, isEmpty } from '@vben/utils'; import { message } from 'ant-design-vue'; @@ -17,71 +19,84 @@ import { import { $t } from '#/locales'; import { useGridColumns, useGridFormSchema } from './data'; -import StockInForm from './modules/form.vue'; +import Form from './modules/form.vue'; -/** 库存盘点管理 */ +/** ERP 库存盘点单列表 */ defineOptions({ name: 'ErpStockCheck' }); const [FormModal, formModalApi] = useVbenModal({ - connectedComponent: StockInForm, + connectedComponent: Form, destroyOnClose: true, }); /** 刷新表格 */ -function onRefresh() { +function handleRefresh() { gridApi.query(); } -/** 导出库存盘点单 */ +/** 导出表格 */ async function handleExport() { const data = await exportStockCheck(await gridApi.formApi.getValues()); downloadFileFromBlobPart({ fileName: '库存盘点单.xls', source: data }); } -/** 新增/编辑/详情 */ -function openForm(type: string, id?: number) { - formModalApi.setData({ type, id }).open(); +/** 新增库存盘点单 */ +function handleCreate() { + formModalApi.setData({ type: 'create' }).open(); } -/** 删除 */ -async function handleDelete(ids: any[]) { +/** 编辑库存盘点单 */ +function handleEdit(row: ErpStockCheckApi.StockCheck) { + formModalApi.setData({ type: 'edit', id: row.id }).open(); +} + +/** 删除库存盘点单 */ +async function handleDelete(ids: number[]) { const hideLoading = message.loading({ - content: '删除中...', + content: $t('ui.actionMessage.deleting'), duration: 0, - key: 'action_process_msg', }); try { await deleteStockCheck(ids); - message.success({ - content: '删除成功', - key: 'action_process_msg', - }); - onRefresh(); + message.success($t('ui.actionMessage.deleteSuccess')); + handleRefresh(); } finally { hideLoading(); } } -/** 审核/反审核 */ -async function handleUpdateStatus(id: any, status: number) { - const statusText = status === 20 ? '审核' : '反审核'; +/** 审批/反审批操作 */ +async function handleUpdateStatus( + row: ErpStockCheckApi.StockCheck, + status: number, +) { const hideLoading = message.loading({ - content: `${statusText}中...`, + content: `确定${status === 20 ? '审批' : '反审批'}该盘点单吗?`, duration: 0, - key: 'action_process_msg', }); try { - await updateStockCheckStatus({ id, status }); - message.success({ - content: `${statusText}成功`, - key: 'action_process_msg', - }); - onRefresh(); + await updateStockCheckStatus({ id: row.id!, status }); + message.success(`${status === 20 ? '审批' : '反审批'}成功`); + handleRefresh(); } finally { hideLoading(); } } +const checkedIds = ref([]); +function handleRowCheckboxChange({ + records, +}: { + records: ErpStockCheckApi.StockCheck[]; +}) { + checkedIds.value = records.map((item) => item.id!); +} + +/** 查看详情 */ +function handleDetail(row: ErpStockCheckApi.StockCheck) { + formModalApi.setData({ type: 'detail', id: row.id }).open(); +} + const [Grid, gridApi] = useVbenVxeGrid({ formOptions: { schema: useGridFormSchema(), @@ -103,15 +118,17 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, rowConfig: { keyField: 'id', + isHover: true, }, toolbarConfig: { refresh: true, search: true, }, - checkboxConfig: { - reserve: true, - }, } as VxeTableGridOptions, + gridEvents: { + checkboxAll: handleRowCheckboxChange, + checkboxChange: handleRowCheckboxChange, + }, }); @@ -123,97 +140,86 @@ const [Grid, gridApi] = useVbenVxeGrid({ url="https://doc.iocoder.cn/erp/stock-move-check/" /> + + - - - - diff --git a/apps/web-antd/src/views/erp/stock/check/modules/form.vue b/apps/web-antd/src/views/erp/stock/check/modules/form.vue index 7999e0038..96eb0c969 100644 --- a/apps/web-antd/src/views/erp/stock/check/modules/form.vue +++ b/apps/web-antd/src/views/erp/stock/check/modules/form.vue @@ -1,7 +1,7 @@