From af8fda0b3d6052282d46fdbea00cf4569ebaf7ca Mon Sep 17 00:00:00 2001 From: fengchenchen Date: Fri, 5 Aug 2022 10:48:59 +0800 Subject: [PATCH] =?UTF-8?q?[update]=20-=E7=A8=8E=E9=A2=9D+=E6=9C=AA?= =?UTF-8?q?=E7=A8=8E=E9=87=91=E9=A2=9D=3D=20=E6=80=BB=E9=A2=9D=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/ArriveModule.vue | 40 ++--------- .../modules/ConfirmModule.vue | 43 ++---------- .../modules/InvoicingModule.vue | 42 ++---------- .../modules/TaxOperateMixin.js | 68 +++++++++++++++++++ 4 files changed, 84 insertions(+), 109 deletions(-) create mode 100644 src/views/financialManagement/arriveAndInvoicing/modules/TaxOperateMixin.js diff --git a/src/views/financialManagement/arriveAndInvoicing/modules/ArriveModule.vue b/src/views/financialManagement/arriveAndInvoicing/modules/ArriveModule.vue index 39bef6d..4b11113 100644 --- a/src/views/financialManagement/arriveAndInvoicing/modules/ArriveModule.vue +++ b/src/views/financialManagement/arriveAndInvoicing/modules/ArriveModule.vue @@ -22,14 +22,14 @@ @@ -54,14 +54,15 @@ diff --git a/src/views/financialManagement/arriveAndInvoicing/modules/ConfirmModule.vue b/src/views/financialManagement/arriveAndInvoicing/modules/ConfirmModule.vue index 51816c9..9c23e27 100644 --- a/src/views/financialManagement/arriveAndInvoicing/modules/ConfirmModule.vue +++ b/src/views/financialManagement/arriveAndInvoicing/modules/ConfirmModule.vue @@ -23,14 +23,14 @@ @@ -55,15 +55,16 @@ diff --git a/src/views/financialManagement/arriveAndInvoicing/modules/InvoicingModule.vue b/src/views/financialManagement/arriveAndInvoicing/modules/InvoicingModule.vue index b2eaea3..af920b2 100644 --- a/src/views/financialManagement/arriveAndInvoicing/modules/InvoicingModule.vue +++ b/src/views/financialManagement/arriveAndInvoicing/modules/InvoicingModule.vue @@ -22,14 +22,14 @@ @@ -61,14 +61,15 @@ diff --git a/src/views/financialManagement/arriveAndInvoicing/modules/TaxOperateMixin.js b/src/views/financialManagement/arriveAndInvoicing/modules/TaxOperateMixin.js new file mode 100644 index 0000000..4a9fca7 --- /dev/null +++ b/src/views/financialManagement/arriveAndInvoicing/modules/TaxOperateMixin.js @@ -0,0 +1,68 @@ +/*换入税率操作的相关方法*/ + +import {money} from '../../../../utils/validate' + +export const TaxOperateMixin = { + data() { + return { + taxRate: 0.06, // 税率 + } + }, + + methods: { + /** + * 校验金额格式 + * @param rules + * @param value + * @param callback + * @param name --校验字段的名字 + * + */ + checkMoneyTemplate(rules, value, callback, name) { + if (value) { + if (money(value)) { + callback() + } + callback('请输入合法的金额数字,最多2位小数,10位整数') + } + callback(`请输入${name}`) + }, + // 总金额做相关的处理 + addZeroAmount(event) { + this.addZero(event) + let finalValue = event.target.value + // 计算未税金额和税额的值 + let obj = this.calcOtherNumber(finalValue) + // console.log(event.target.value ) + this.$nextTick(() => { + this.form.setFieldsValue(obj) + }) + }, + /** + * 税额\未税金额 失去焦点的事件 + * @param event --失去焦点的event ,存储当前input 的值 + * @param keyName -- 想互斥 数字 对应的key值 + * @param amountKeyName--当前dom 中 存储金额的字段的key值 + * + */ + addZeroTaxOrNo(event, keyName, amountKeyName) { + console.log('-----addZeroTaxOrNo---', event.target.value) + this.addZero(event) + let amount = this.form.getFieldValue(amountKeyName) + if(!amount) return + let finalValue = event.target.value + let otherVlaue = (amount - finalValue).toFixed(2) + this.$nextTick(() => { + this.form.setFieldsValue({[keyName]: otherVlaue}) + }) + + }, + // 通过金额 计算 税额、未税金额 + calcOtherNumber(amount) { + let noTaxAmount = (amount / (1 + this.taxRate)).toFixed(2) // 未税金额 + let tax = (amount - noTaxAmount).toFixed(2) // 税额 + return {noTaxAmount, tax} + }, + } + +}