Refactor duplicated variables

This commit is contained in:
benguozakinci@gmail.com 2021-07-02 15:05:25 +03:00
parent 165f857849
commit 8f27089cb0

View File

@ -34,7 +34,8 @@
'.,', '.,',
',.', ',.',
',,' ',,'
] ],
splice_value: null
} }
}, },
@ -46,13 +47,11 @@
this.form.sale_price = oldVal; this.form.sale_price = oldVal;
} }
let splice_value;
if (newVal.search('^(?=.*?[0-9])[0-9.,]+$') == 0) { if (newVal.search('^(?=.*?[0-9])[0-9.,]+$') == 0) {
for (let item of this.regex_condition) { for (let item of this.regex_condition) {
if (this.form.sale_price.includes(item)) { if (this.form.sale_price.includes(item)) {
splice_value = this.form.sale_price.replace(item, ''); this.splice_value = this.form.sale_price.replace(item, '');
this.form.sale_price = splice_value; this.form.sale_price = this.splice_value;
} }
} }
} }
@ -63,13 +62,11 @@
this.form.purchase_price = oldVal; this.form.purchase_price = oldVal;
} }
let splice_value;
if (newVal.search('^(?=.*?[0-9])[0-9.,]+$') == 0) { if (newVal.search('^(?=.*?[0-9])[0-9.,]+$') == 0) {
for (let item of this.regex_condition) { for (let item of this.regex_condition) {
if (this.form.purchase_price.includes(item)) { if (this.form.purchase_price.includes(item)) {
splice_value = this.form.purchase_price.replace(item, ''); this.splice_value = this.form.purchase_price.replace(item, '');
this.form.purchase_price = splice_value; this.form.purchase_price = this.splice_value;
} }
} }
} }