From 263440d521a99258a5593a49593dff9310b5dd38 Mon Sep 17 00:00:00 2001 From: zhaoxiao Date: Thu, 16 Sep 2021 11:19:49 +0800 Subject: [PATCH] =?UTF-8?q?[update]=20=E6=94=B6=E5=85=A5=E3=80=81=E6=94=AF?= =?UTF-8?q?=E5=87=BA=E5=90=88=E5=90=8C=E7=AD=BE=E8=AE=A2=E5=90=88=E5=90=8C?= =?UTF-8?q?=E6=80=BB=E9=87=91=E9=A2=9D=E3=80=81=E6=9C=AA=E7=A8=8E=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E8=AE=A1=E7=AE=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/ExpenditureContractModule.vue | 48 ++++++++++++++++--- .../modules/RevenueContractModule.vue | 44 +++++++++++++++-- 2 files changed, 80 insertions(+), 12 deletions(-) diff --git a/src/views/contractManagement/expenditureContract/modules/ExpenditureContractModule.vue b/src/views/contractManagement/expenditureContract/modules/ExpenditureContractModule.vue index 6555cea..c3d1f30 100644 --- a/src/views/contractManagement/expenditureContract/modules/ExpenditureContractModule.vue +++ b/src/views/contractManagement/expenditureContract/modules/ExpenditureContractModule.vue @@ -88,11 +88,10 @@ + @change="noTaxChange"> @@ -265,8 +264,9 @@ export default { model: {}, selectedCompany: null, selectedContact: null, - rateNum: null, - contractAmountNum: null, + rateNum: null, // 税率 + contractAmountNum: null, // 合同总金额 + inputNoTaxAmount: null, // 未税金额 amountReceivedNum: null, // 已收金额 accountsReceivableNum: null, // 应收金额 isPackage: false, @@ -307,6 +307,10 @@ export default { rules: [{ required: true, message: '请输入税率' }], validateTrigger: 'blur' }, + noTaxAmount: { + rules: [{ required: false, validator: this.checkMoney }], + validateTrigger: 'blur' + }, accountsReceivableAmount: { rules: [{ required: true, validator: this.checkMoney }], validateTrigger: 'blur' @@ -339,6 +343,11 @@ export default { add() { this.title = '新建支出合同' this.$refs.installmentForm.initInstallmentList([]) + // 税率默认为6 + this.$nextTick(() => { + this.form.setFieldsValue({rate: 6}) + }) + this.rateNum = 6 / 100 }, edit(id) { this.title = '编辑支出合同' @@ -510,7 +519,7 @@ export default { */ contractAmountChange(e) { e.target.value = (e.target.value.replace(/[^0-9.]/g, '')).trim() - this.contractAmountNum = e.target.value + this.contractAmountNum = Number(e.target.value) this.calculateNoTaxAmount() }, /** @@ -520,7 +529,21 @@ export default { rateChange(e) { e.target.value = (e.target.value.replace(/[^0-9.]/g, '')).trim() this.rateNum = Number(e.target.value) / 100 - this.calculateNoTaxAmount() + // 签订合同总金额为空--计算签订合同总金额,否则计算未税金额 + if (!this.contractAmountNum) { + this.calculateContractAmount() + } else { + this.calculateNoTaxAmount() + } + }, + /** + * 未税金额修改 + * @param e + */ + noTaxChange(e) { + e.target.value = (e.target.value.replace(/[^0-9.]/g,'')).trim() + this.inputNoTaxAmount = Number(e.target.value) + this.calculateContractAmount() }, /** * 计算未税金额 @@ -536,6 +559,17 @@ export default { }) } }, + /** + * 计算合同总金额 + */ + calculateContractAmount() { + if (!this.rateNum && !this.inputNoTaxAmount) { + return + } + let contractNum = this.inputNoTaxAmount * (1 + this.rateNum) + contractNum = contractNum.toFixed(2) + this.form.setFieldsValue({contractAmount: contractNum}) + }, /** * 应收金额输入 * @param value diff --git a/src/views/contractManagement/revenueContract/modules/RevenueContractModule.vue b/src/views/contractManagement/revenueContract/modules/RevenueContractModule.vue index 9e4d313..22019bd 100644 --- a/src/views/contractManagement/revenueContract/modules/RevenueContractModule.vue +++ b/src/views/contractManagement/revenueContract/modules/RevenueContractModule.vue @@ -92,11 +92,10 @@ + @change="noTaxChange"> @@ -369,6 +368,10 @@ export default { rules: [{ required: true, message: '请输入税率' }], validateTrigger: 'blur' }, + noTaxAmount: { + rules: [{ required: false, validator: this.checkMoney }], + validateTrigger: 'blur' + }, accountsReceivableAmount: { rules: [{ required: true, validator: this.checkMoney }], validateTrigger: 'blur' @@ -400,6 +403,7 @@ export default { amountReceivedNum: null, // 输入的未收金额 contractAmountNum: null, // 输入的签订合同总金额 rateNum: null, // 输入的税率 + inputNoTaxAmount: null, // 未税金额 selectedContact: null, // 联系人回显 associatedProjectLoading: false, contractId: '', // 收入合同id @@ -424,6 +428,11 @@ export default { add() { this.title = '新建收入合同' this.$refs.installmentForm.initInstallmentList([]) + // 税率默认为6 + this.$nextTick(() => { + this.form.setFieldsValue({rate: 6}) + }) + this.rateNum = 6 / 100 }, edit(id) { this.title = '编辑收入合同' @@ -568,7 +577,7 @@ export default { */ contractAmountChange(e) { e.target.value = (e.target.value.replace(/[^0-9.]/g, '')).trim() - this.contractAmountNum = e.target.value + this.contractAmountNum = Number(e.target.value) this.calculateNoTaxAmount() }, /** @@ -578,7 +587,21 @@ export default { rateChange(e) { e.target.value = (e.target.value.replace(/[^0-9.]/g, '')).trim() this.rateNum = Number(e.target.value) / 100 - this.calculateNoTaxAmount() + // 签订合同总金额为空--计算签订合同总金额,否则计算未税金额 + if (!this.contractAmountNum) { + this.calculateContractAmount() + } else { + this.calculateNoTaxAmount() + } + }, + /** + * 未税金额修改 + * @param e + */ + noTaxChange(e) { + e.target.value = (e.target.value.replace(/[^0-9.]/g,'')).trim() + this.inputNoTaxAmount = Number(e.target.value) + this.calculateContractAmount() }, /** * 计算未税金额 @@ -593,6 +616,17 @@ export default { }) } }, + /** + * 计算合同总金额 + */ + calculateContractAmount() { + if (!this.rateNum && !this.inputNoTaxAmount) { + return + } + let contractNum = this.inputNoTaxAmount * (1 + this.rateNum) + contractNum = contractNum.toFixed(2) + this.form.setFieldsValue({contractAmount: contractNum}) + }, /** * 应收金额输入 * @param value