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"