Browse Source

发票申请计算金额

master_hella_20240701
wangyufei 5 months ago
parent
commit
f562aacf21
  1. 5
      src/api/wms/supplierinvoiceRequestMain/index.ts
  2. 9
      src/components/BasicForm/src/BasicForm.vue
  3. 53
      src/views/wms/supplierManage/supplierinvoice/supplierinvoiceRequestMain/index.vue

5
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}`})
}

9
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) => {

53
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
// 2X*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"
>
<!-- <template #foorter>
<div style="text-align: left">
@ -279,6 +296,7 @@ const searchTableSuccessDetail = async (formField, searchField, val, formRef,sea
subList:val
})
detailRef.value.updateList()
getList()
}
// const basicFormFooter = computed(()=>{
@ -941,6 +959,17 @@ const handleImport = () => {
tableData.value = tableData.value.filter(item => !selection.includes(item))
}
const sumFormDataHandle = async (formRef1,formModel,tableData,formType,originFormModel,updateOriginFormModel)=>{
if(formType=='update'){
if(formModel&&formModel.id&&formModel.taxRate&&originFormModel){
let res = await SupplierinvoiceRequestMainApi.getTaxAmount({id:formModel.id,taxRate:formModel.taxRate})
console.log('更新taxAmount',res)
formRef1.value.setValues({
taxAmount:res
})
}
}
}
//
const submitForm = async (formType, submitData) => {
let data = {...submitData}

Loading…
Cancel
Save