From 338f83ab30b0bcea4c5b61a51c6688d679cb47b5 Mon Sep 17 00:00:00 2001 From: yufei0306 <13417315+yufei0306@user.noreply.gitee.com> Date: Fri, 19 Apr 2024 08:11:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E5=8F=91=E7=A5=A8?= =?UTF-8?q?=E9=87=91=E9=A2=9D=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/BasicForm/src/BasicForm.vue | 10 +++++++++- .../supplierinvoiceRequestMain/index.vue | 15 +++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/components/BasicForm/src/BasicForm.vue b/src/components/BasicForm/src/BasicForm.vue index d7241c457..9da0725be 100644 --- a/src/components/BasicForm/src/BasicForm.vue +++ b/src/components/BasicForm/src/BasicForm.vue @@ -292,6 +292,11 @@ const props = defineProps({ type:Function, required: false, default: null + }, + sumFormDataByTableCustom:{ + type:Function, + required: false, + default: null } }) @@ -419,7 +424,10 @@ const sumFormDataByTable = () => { } watch(()=>props.tableData,() => { sumFormDataByTable() - + if(props?.sumFormDataByTableCustom&&unref(formRef)?.formModel&&props.tableData){ + props?.sumFormDataByTableCustom(formRef,unref(formRef)?.formModel,props.tableData) + } + },{ deep:true }) diff --git a/src/views/wms/supplierManage/supplierinvoice/supplierinvoiceRequestMain/index.vue b/src/views/wms/supplierManage/supplierinvoice/supplierinvoiceRequestMain/index.vue index 766f0b7fb..513b99c6e 100644 --- a/src/views/wms/supplierManage/supplierinvoice/supplierinvoiceRequestMain/index.vue +++ b/src/views/wms/supplierManage/supplierinvoice/supplierinvoiceRequestMain/index.vue @@ -45,17 +45,20 @@ :tableAllSchemas="SupplierinvoiceRequestDetail.allSchemas" :tableFormRules="SupplierinvoiceRequestDetailRules" :tableData="tableData" - :sumFormDataField = "[{ - formField:'amount', - tableField:'singlePrice' - }]" + :sumFormDataByForm ="(formRef,formModel)=>{ const {taxRate=0,amount=0} = formModel formRef.value.setValues({ - taxAmount:taxRate*amount, - afterTaxAmount:amount+taxRate*amount + taxAmount:taxRate*amount*0.01, + afterTaxAmount:amount+taxRate*amount*0.01 }) }" + :sumFormDataByTableCustom ="(formRef,formModel,tableData)=>{ + const sumObject = { + amount:tableData.reduce((prev, item) => prev + (item['singlePrice']*item['invoicableQuantity']),0) + } + formRef.value.setValues(sumObject) + }" :apiUpdate="SupplierinvoiceRequestMainApi.updateSupplierinvoiceRequestMain" :apiCreate="SupplierinvoiceRequestMainApi.createSupplierinvoiceRequestMain" :isBusiness="true"