diff --git a/src/api/wms/supplierinvoiceRequestMain/index.ts b/src/api/wms/supplierinvoiceRequestMain/index.ts index 5358945de..338cd176e 100644 --- a/src/api/wms/supplierinvoiceRequestMain/index.ts +++ b/src/api/wms/supplierinvoiceRequestMain/index.ts @@ -147,3 +147,8 @@ export const getLoginUserRoleList = async () => { } +// 编辑的时候计算主表系统税额 +export const getTaxAmount = async ({id,taxRate}) => { + return await request.get({ url: `/wms/supplierinvoice-request-main/computeById?id=${id}&taxRate=${taxRate}`}) + +} \ No newline at end of file diff --git a/src/components/BasicForm/src/BasicForm.vue b/src/components/BasicForm/src/BasicForm.vue index 82c91d1c7..5444c2218 100644 --- a/src/components/BasicForm/src/BasicForm.vue +++ b/src/components/BasicForm/src/BasicForm.vue @@ -500,9 +500,13 @@ let originFormModel = {} const updateOriginFormModel = (data)=>{ originFormModel = JSON.parse(JSON.stringify(data)) } +const sumFormDataHandle1 = ()=>{ + emit('sumFormDataHandle',formRef,unref(formRef)?.formModel,props.tableData,formType.value,originFormModel,updateOriginFormModel) +} + watch(()=>unref(formRef)?.formModel,async () => { if(props?.sumFormDataByForm&&unref(formRef)?.formModel){ - props?.sumFormDataByForm(formRef,unref(formRef)?.formModel,props.tableData,formType.value,originFormModel,updateOriginFormModel) + props?.sumFormDataByForm(formRef,unref(formRef)?.formModel,props.tableData,formType.value,originFormModel,updateOriginFormModel,sumFormDataHandle1) } },{ deep:true @@ -678,7 +682,8 @@ const emit = defineEmits([ 'formFormDateChange', 'footButtonClick', 'clearSearchInput', - 'clearInput' + 'clearInput', + 'sumFormDataHandle' ]) //普通下拉改变事件 const formSelectChange = (field, val, row) => { diff --git a/src/views/wms/supplierManage/supplierinvoice/supplierinvoiceRequestMain/index.vue b/src/views/wms/supplierManage/supplierinvoice/supplierinvoiceRequestMain/index.vue index 77de5e34e..a43eff0e3 100644 --- a/src/views/wms/supplierManage/supplierinvoice/supplierinvoiceRequestMain/index.vue +++ b/src/views/wms/supplierManage/supplierinvoice/supplierinvoiceRequestMain/index.vue @@ -53,26 +53,42 @@ :tableAllSchemas="SupplierinvoiceRequestDetail.allSchemas" :tableFormRules="SupplierinvoiceRequestDetailRules" :tableData="tableData" - :sumFormDataByForm ="(formRef,formModel,tableData,formType,originFormModel,updateOriginFormModel)=>{ - const {taxRate=0,amount=0,taxAmount=0,beforeTaxAmount=0,totalTaxAmount=0,discountAmount1=0,beforeTaxDiffAmount=0,taxAmountDiff=0} = formModel + :sumFormDataByForm ="(formRef,formModel,tableData,formType,originFormModel,updateOriginFormModel,sumFormDataHandle1)=>{ + const {taxRate=0,amount=0,taxAmount=0,beforeTaxAmount=0,totalTaxAmount=0,discountAmount1=0,beforeTaxDiffAmount=0,taxAmountDiff=0} = formModel // 2、系统税额:每条数据的合同价格X可开票数量,计算结果取两位小数之后*税率的计算结果,再保留2位。所有子表数据再求和 - let taxAmount_ = 0.00 if(formType=='update'){ // 编辑 - taxAmount_ = taxAmount + console.log('taxRate',taxRate) + console.log('originFormModel',originFormModel.taxRate) + console.log('taxAmount',taxAmount) + if(taxRate!=originFormModel.taxRate){ + if(originFormModel){ + sumFormDataHandle1() + } + updateOriginFormModel(formModel) + } + formRef.value.setValues({ + afterTaxAmount:amount+taxAmount, // 3、系统价税合计:系统未税金额+系统税额 + adTaxAmount:beforeTaxAmount+totalTaxAmount, //6、价税合计金额:未税金额+税额 + beforeTaxDiffAmount:beforeTaxAmount-amount-discountAmount1,//未税差额:未税金额-系统未税金额-折扣金额 + taxAmountDiff:totalTaxAmount-taxAmount,// 税额差异:税额-系统税额 + totalTaxDiffAmount:beforeTaxDiffAmount+taxAmountDiff // 价税合计差额=未税差额+税额差异 + }) }else if(formType=='create'){ // 新增 + let taxAmount_ = taxAmount if(taxRate!=originFormModel.taxRate){ taxAmount_ = tableData.reduce((prev, item) => prev + Number(Number(taxRate*0.01*Number(Number(item['singlePrice']*item['invoicableQuantity']).toFixed(2))).toFixed(2)),0) updateOriginFormModel(formModel) } + formRef.value.setValues({ + taxAmount:taxAmount_, + afterTaxAmount:amount+taxAmount, // 3、系统价税合计:系统未税金额+系统税额 + adTaxAmount:beforeTaxAmount+totalTaxAmount, //6、价税合计金额:未税金额+税额 + beforeTaxDiffAmount:beforeTaxAmount-amount-discountAmount1,//未税差额:未税金额-系统未税金额-折扣金额 + taxAmountDiff:totalTaxAmount-taxAmount,// 税额差异:税额-系统税额 + totalTaxDiffAmount:beforeTaxDiffAmount+taxAmountDiff // 价税合计差额=未税差额+税额差异 + }) } - formRef.value.setValues({ - taxAmount:taxAmount_, - afterTaxAmount:amount+taxAmount, // 3、系统价税合计:系统未税金额+系统税额 - adTaxAmount:beforeTaxAmount+totalTaxAmount, //6、价税合计金额:未税金额+税额 - beforeTaxDiffAmount:beforeTaxAmount-amount-discountAmount1,//未税差额:未税金额-系统未税金额-折扣金额 - taxAmountDiff:totalTaxAmount-taxAmount,// 税额差异:税额-系统税额 - totalTaxDiffAmount:beforeTaxDiffAmount+taxAmountDiff // 价税合计差额=未税差额+税额差异 - }) + }" :sumFormDataByTableCustom ="(formRef,formModel,tableData)=>{ @@ -92,6 +108,7 @@ @tableSelectionDelete="tableSelectionDelete" @searchTableSuccess="searchTableSuccess" @submitForm="submitForm" + @sumFormDataHandle="sumFormDataHandle" >