From dec15afcc3eaf577256f3efcf2bcdfc9d11307a4 Mon Sep 17 00:00:00 2001 From: A1Gard Date: Mon, 24 Jun 2024 04:39:41 +0330 Subject: [PATCH] fixed currency input bug --- resources/js/components/CurrencyInput.vue | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/resources/js/components/CurrencyInput.vue b/resources/js/components/CurrencyInput.vue index d0895ec..f4da167 100644 --- a/resources/js/components/CurrencyInput.vue +++ b/resources/js/components/CurrencyInput.vue @@ -73,6 +73,7 @@ export default { }, mounted() { + if (this.modelValue !== 'nop') { if (typeof this.modelValue == 'number') { @@ -94,9 +95,9 @@ export default { computed: { noComma: function () { const n = uncommafy(this.val); - if (this.modelValue != null) { - this.$emit('update:modelValue', n); - } + // if (this.modelValue != 'nop') { + // this.$emit('update:modelValue', n); + // } return n; }, getClass: function () { @@ -109,10 +110,18 @@ export default { methods: { keyup: function () { this.val = commafy(this.val); + this.$emit('update:modelValue', this.noComma); if (typeof this.update === 'function') { this.update(this.updateKey, parseInt(this.noComma)); } }, + }, + watch: { + val(newValue) { + if (this.modelValue !== 'nop') { + this.$emit('update:modelValue', uncommafy(newValue)); + } + } } }