diff --git a/apps/web-antd/src/views/erp/stock/in/data.ts b/apps/web-antd/src/views/erp/stock/in/data.ts index bd54761d7..7111cae9c 100644 --- a/apps/web-antd/src/views/erp/stock/in/data.ts +++ b/apps/web-antd/src/views/erp/stock/in/data.ts @@ -1,8 +1,6 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; -import { erpPriceInputFormatter } from '@vben/utils'; - import { getSupplierSimpleList } from '#/api/erp/purchase/supplier'; import { getSimpleUserList } from '#/api/system/user'; import { DICT_TYPE, getDictOptions } from '#/utils'; @@ -96,29 +94,6 @@ export function useFormSchema(): VbenFormSchema[] { component: 'Input', formItemClass: 'col-span-3', }, - { - component: 'InputNumber', - componentProps: { - placeholder: '合计数量', - precision: 2, - disabled: true, - style: { width: '100%' }, - }, - fieldName: 'totalCount', - label: '合计数量', - }, - { - component: 'InputNumber', - componentProps: { - placeholder: '合计金额', - precision: 2, - formatter: erpPriceInputFormatter, - disabled: true, - style: { width: '100%' }, - }, - fieldName: 'totalPrice', - label: '合计金额', - }, ]; } @@ -296,28 +271,6 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { title: '创建人', minWidth: 100, }, - { - field: 'totalCount', - title: '数量', - minWidth: 100, - cellRender: { - name: 'CellAmount', - props: { - digits: 2, - }, - }, - }, - { - field: 'totalPrice', - title: '金额', - minWidth: 120, - cellRender: { - name: 'CellAmount', - props: { - digits: 2, - }, - }, - }, { field: 'status', title: '状态', diff --git a/apps/web-antd/src/views/erp/stock/in/modules/StockInItemForm.vue b/apps/web-antd/src/views/erp/stock/in/modules/StockInItemForm.vue index 159e4e4a5..fd5f10a44 100644 --- a/apps/web-antd/src/views/erp/stock/in/modules/StockInItemForm.vue +++ b/apps/web-antd/src/views/erp/stock/in/modules/StockInItemForm.vue @@ -19,11 +19,7 @@ const props = withDefaults(defineProps(), { disabled: false, }); -const emit = defineEmits([ - 'update:items', - 'update:total-count', - 'update:total-price', -]); +const emit = defineEmits(['update:items']); interface Props { items?: ErpStockInApi.StockInItem[]; @@ -58,6 +54,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ enabled: false, }, showFooter: true, + footerCellClassName: 'stock-in-footer-cell', footerMethod: ({ columns }) => { const footers: any[][] = []; const sums = getSummaries(); @@ -96,31 +93,6 @@ watch( }, ); -/** 计算 totalCount、totalPrice */ -watch( - () => tableData.value, - () => { - if (!tableData.value || tableData.value.length === 0) { - emit('update:total-count', 0); - emit('update:total-price', 0); - return; - } - const totalCount = tableData.value.reduce( - (prev, curr) => prev + (curr.count || 0), - 0, - ); - const totalPrice = tableData.value.reduce( - (prev, curr) => prev + (curr.totalPrice || 0), - 0, - ); - - // 发送计算结果给父组件 - emit('update:total-count', totalCount); - emit('update:total-price', totalPrice); - }, - { deep: true }, -); - /** 初始化 */ onMounted(async () => { productOptions.value = await getProductSimpleList(); @@ -260,23 +232,14 @@ function init(items: ErpStockInApi.StockInItem[]) { defineExpose({ validate, init, + handleAdd, }); + + + + diff --git a/apps/web-antd/src/views/erp/stock/in/modules/form.vue b/apps/web-antd/src/views/erp/stock/in/modules/form.vue index 108ef2600..2f09d5215 100644 --- a/apps/web-antd/src/views/erp/stock/in/modules/form.vue +++ b/apps/web-antd/src/views/erp/stock/in/modules/form.vue @@ -49,24 +49,6 @@ const handleUpdateItems = (items: ErpStockInApi.StockInItem[]) => { } }; -const handleUpdateTotalCount = (totalCount: number) => { - if (formData.value) { - formData.value.totalCount = totalCount; - formApi.setValues({ - totalCount: formData.value.totalCount, - }); - } -}; - -const handleUpdateTotalPrice = (totalPrice: number) => { - if (formData.value) { - formData.value.totalPrice = totalPrice; - formApi.setValues({ - totalPrice: formData.value.totalPrice, - }); - } -}; - /** * 创建或更新其它入库单 */ @@ -145,6 +127,10 @@ const [Modal, modalApi] = useVbenModal({ if (itemFormInstance && typeof itemFormInstance.init === 'function') { itemFormInstance.init([]); } + // 如果是新增,自动添加一行 + if (formType.value === 'create' && itemFormInstance) { + itemFormInstance.handleAdd(); + } return; } @@ -209,8 +195,6 @@ defineExpose({ modalApi, handleUpdateStatus }); :items="formData?.items ?? []" :disabled="formType === 'detail'" @update:items="handleUpdateItems" - @update:total-count="handleUpdateTotalCount" - @update:total-price="handleUpdateTotalPrice" />