From 31a3906e24de6b8e5baeecf08f8c16c19dba98de Mon Sep 17 00:00:00 2001 From: zhouz <> Date: Wed, 22 Jul 2026 10:35:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E3=80=81=E6=97=A5=E6=9C=9F=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC=E3=80=81=E5=AD=90=E5=BC=B9=E7=AA=97=E6=89=93=E5=BC=80?= =?UTF-8?q?/=E5=85=B3=E9=97=AD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 业务日期默认当天(dayjs) - 表单 col-span-1 多列布局 - 子弹窗改为 ref + defineExpose 调用,解决 connectedComponent 冲突 - 物料选择弹窗路径修正 --- .../src/views/wms/iostorinv/modules/form.vue | 62 ++++++++++++------- .../iostorinv/modules/inventory-select.vue | 6 ++ .../wms/iostorinv/modules/manual-detail.vue | 23 +++---- 3 files changed, 57 insertions(+), 34 deletions(-) diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/iostorinv/modules/form.vue b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/iostorinv/modules/form.vue index c38f46fb..66005e0c 100644 --- a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/iostorinv/modules/form.vue +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/iostorinv/modules/form.vue @@ -5,10 +5,10 @@ import { computed, ref, watch } from 'vue'; import { useVbenModal } from '@vben/common-ui'; +import dayjs from 'dayjs'; import { message } from 'antdv-next'; import { useVbenForm } from '#/adapter/form'; -import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { type OutboundCreateReq, type OutboundDetail, @@ -18,11 +18,10 @@ import { getBsrealStorAttrSimpleList } from '#/api/wms/bsrealstorattr'; import { getSimpleDictDataList } from '#/api/system/dict/data'; import { $t } from '#/locales'; -import InventorySelect from './inventory-select.vue'; -import ManualDetail from './manual-detail.vue'; +import InventorySelectModalComponent from './inventory-select.vue'; +import ManualDetailModalComponent from './manual-detail.vue'; const emit = defineEmits(['success']); -const formData = ref(); // ========== 仓库选项 ========== const storOptions = ref< @@ -51,7 +50,7 @@ async function loadBillTypeOptions() { const [Form, formApi] = useVbenForm({ commonConfig: { componentProps: { class: 'w-full' }, - formItemClass: 'col-span-2', + formItemClass: 'col-span-1', labelWidth: 80, }, layout: 'horizontal', @@ -87,7 +86,6 @@ const [Form, formApi] = useVbenForm({ fieldName: 'bizDate', label: '业务日期', rules: 'required', - defaultValue: new Date(), component: 'DatePicker', componentProps: { showTime: true, @@ -127,7 +125,8 @@ const [Form, formApi] = useVbenForm({ }); // ========== 明细数据 ========== -const detailList = ref<(OutboundDetail & { vehicleCode?: string; materialName?: string })[]>([]); +type DetailRow = OutboundDetail & { vehicleCode?: string; materialName?: string }; +const detailList = ref([]); function updateSummary() { const totalWeight = detailList.value @@ -149,6 +148,7 @@ watch( ); // ========== 明细表格 ========== +const vxeGridRef = ref(); const gridOptions = computed(() => ({ columns: [ { type: 'seq', title: '序号', width: 50 }, @@ -164,6 +164,8 @@ const gridOptions = computed(() => ({ data: detailList.value, height: 'auto', rowConfig: { keyField: 'materialCode', isHover: true }, + toolbarConfig: false, + pagerConfig: false, })); function handleDeleteDetail(index: number) { @@ -171,11 +173,8 @@ function handleDeleteDetail(index: number) { updateSummary(); } -// ========== 库存选择弹窗 ========== -const [InventorySelectModal, inventorySelectModalApi] = useVbenModal({ - connectedComponent: InventorySelect, - destroyOnClose: true, -}); +// ========== 库存选择弹窗(子组件自带 Modal,用 ref 调用 open) ========== +const inventorySelectRef = ref>(); function handleSelectFromInventory() { const storId = formApi.getValues().storId; @@ -183,7 +182,7 @@ function handleSelectFromInventory() { message.warning('请先选择仓库'); return; } - inventorySelectModalApi.setData({ storId }).open(); + inventorySelectRef.value?.open({ storId }); } function onInventorySelected(rows: any[]) { @@ -205,18 +204,24 @@ function onInventorySelected(rows: any[]) { updateSummary(); } -// ========== 手动新增弹窗 ========== -const [ManualDetailModal, manualDetailModalApi] = useVbenModal({ - connectedComponent: ManualDetail, - destroyOnClose: true, -}); +// ========== 手动新增弹窗(子组件自带 Modal,用 ref 调用 open) ========== +const manualDetailRef = ref>(); function handleManualAdd() { - manualDetailModalApi.setData({}).open(); + manualDetailRef.value?.open(); } function onManualAdded(detail: any) { - detailList.value.push(detail); + detailList.value.push({ + materialCode: detail.materialCode, + materialId: String(detail.materialId ?? ''), + materialName: detail.materialName, + planQty: detail.planQty, + qtyUnitId: String(detail.qtyUnitId ?? ''), + qtyUnitName: detail.qtyUnitName, + pcsn: detail.pcsn, + remark: detail.remark, + }); updateSummary(); } @@ -269,6 +274,10 @@ const [Modal, modalApi] = useVbenModal({ if (isOpen) { await loadStorOptions(); await loadBillTypeOptions(); + // 业务日期默认当天 + formApi.setValues({ + bizDate: dayjs().format('YYYY-MM-DD HH:mm:ss'), + }); } if (!isOpen) { detailList.value = []; @@ -294,7 +303,7 @@ const [Modal, modalApi] = useVbenModal({ - + diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/iostorinv/modules/inventory-select.vue b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/iostorinv/modules/inventory-select.vue index fb95bcb1..c9081143 100644 --- a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/iostorinv/modules/inventory-select.vue +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/iostorinv/modules/inventory-select.vue @@ -101,6 +101,12 @@ const [Modal, modalApi] = useVbenModal({ } }, }); + +/** 暴露给父组件调用 */ +function open(data: { storId: string }) { + modalApi.setData(data).open(); +} +defineExpose({ open });