From b6ea9bc5bb95c0e6d33e5d8a41c9b38bc2b19bdc Mon Sep 17 00:00:00 2001 From: fyy <2717885210@qq.com> Date: Tue, 15 Jul 2025 16:45:51 +0800 Subject: [PATCH] =?UTF-8?q?=20fix:=20=E4=BF=AE=E5=A4=8D=E7=BB=BF=E6=A4=8D?= =?UTF-8?q?=E7=A7=9F=E8=B5=81=E5=8F=AF=E9=80=89=E5=A4=9A=E6=AC=A1=E7=9B=B8?= =?UTF-8?q?=E5=90=8C=E4=BA=A7=E5=93=81bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rentalPlan-detial-modal.vue | 32 +++++++++++++++---- .../rentalPlan-modal.vue | 8 +++-- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/apps/web-antd/src/views/property/greenPlantRentalManagement/leasePogramManagement/rentalPlan-detial-modal.vue b/apps/web-antd/src/views/property/greenPlantRentalManagement/leasePogramManagement/rentalPlan-detial-modal.vue index f7af2e4f..44edba3b 100644 --- a/apps/web-antd/src/views/property/greenPlantRentalManagement/leasePogramManagement/rentalPlan-detial-modal.vue +++ b/apps/web-antd/src/views/property/greenPlantRentalManagement/leasePogramManagement/rentalPlan-detial-modal.vue @@ -26,6 +26,9 @@ const title = computed(() => { let plantListData: any[] = []; const detailIndex = ref();//传index对应详情的某条数据,对该条数据进行编辑修改 +// 新增:接收已选产品id +const selectedIds = ref([]); + // 添加数量最大值 const productNumMax = ref(0); @@ -39,7 +42,9 @@ const detailSchema = [ api: async () => { const res = await plantsProductList({state:1,inventory:0}); plantListData = res.rows || []; - return res; + // 过滤掉已选产品 + const filtered = plantListData.filter(item => !selectedIds.value.includes(item.id)); + return { ...res, rows: filtered }; }, resultField: 'rows', labelField: 'plantName', @@ -82,6 +87,7 @@ const detailSchema = [ componentProps: { min: 1, max: productNumMax, + disabled: isView, }, rules: 'required', }, @@ -197,19 +203,25 @@ const [BasicModal, modalApi] = useVbenModal({ } modalApi.modalLoading(true); const data = modalApi.getData(); - detailIndex.value = modalApi.getData().index; - if(!data || Object.keys(data).length === 0){ - //modalApi.getData()为空时表示添加 - isAdd.value = true; - }else if(data.readonly){ + console.log(data); + + detailIndex.value = data.index; + // 新增:弹窗打开时同步 selectedIds + selectedIds.value = data.selectedIds || []; + if(data.readonly){ //不存在detailIndex.value时表示查看 isView.value = true; + } else if(data.add){ + //modalApi.getData()为空时表示添加 + isAdd.value = true; + console.log(123); + }else{ //表示编辑 isUpdate.value = true; } // TODO: 获取详情数据 - await formApi.setValues(modalApi.getData()); + await formApi.setValues(data); await markInitialized(); modalApi.modalLoading(false); }, @@ -223,6 +235,8 @@ async function handleConfirm() { return; } const data = cloneDeep(await formApi.getValues()); + console.log(data); + // 获取选中的产品 const selectedService = plantListData.find(item => item.id === data.plantName); if (selectedService) { @@ -231,8 +245,12 @@ async function handleConfirm() { } if (isUpdate.value) { data.index = detailIndex.value; + console.log(data); + emit('editReload', data); }else if(isAdd.value){ + console.log(12); + emit('reload', data); } handleClosed() diff --git a/apps/web-antd/src/views/property/greenPlantRentalManagement/leasePogramManagement/rentalPlan-modal.vue b/apps/web-antd/src/views/property/greenPlantRentalManagement/leasePogramManagement/rentalPlan-modal.vue index b6a9a9c2..59cc2dc3 100644 --- a/apps/web-antd/src/views/property/greenPlantRentalManagement/leasePogramManagement/rentalPlan-modal.vue +++ b/apps/web-antd/src/views/property/greenPlantRentalManagement/leasePogramManagement/rentalPlan-modal.vue @@ -146,7 +146,9 @@ const detailColumns = [ }, ]; function handleAddDetail() { - detailModalApi.setData({}); + // 传递已选产品id列表 + const selectedIds = detailTable.value.map((item: any) => item.productId || item.plantName); + detailModalApi.setData({ selectedIds,add:true }); detailModalApi.open(); } //添加植物组合包产品 @@ -169,7 +171,9 @@ function handleViewDetail(record: any) { } // 编辑产品详情 function handleEditDetail(record: any, index: number) { - detailModalApi.setData({ ...record, index, readonly: false }); + // 编辑时,排除当前项id + const selectedIds = detailTable.value.filter((_: any, i: number) => i !== index).map((item: any) => item.productId || item.plantName); + detailModalApi.setData({ ...record, index, selectedIds,edit:true }); detailModalApi.open(); } //分类字典