diff --git a/src/components/04_product-service/PriceDataComponent.vue b/src/components/04_product-service/PriceDataComponent.vue index e08573f6..b45549d0 100644 --- a/src/components/04_product-service/PriceDataComponent.vue +++ b/src/components/04_product-service/PriceDataComponent.vue @@ -10,9 +10,13 @@ const price = defineModel('price'); const vatIncluded = defineModel('vatIncluded'); const calcVat = defineModel('calcVat'); -const price4Show = ref(''); -const agentPrice4Show = ref(''); -const serviceCharge4Show = ref(''); +const price4Show = ref(commaInput(price.value?.toString() || '0')); +const agentPrice4Show = ref( + commaInput(agentPrice.value?.toString() || '0'), +); +const serviceCharge4Show = ref( + commaInput(serviceCharge.value?.toString() || '0'), +); const column = [ { @@ -194,17 +198,21 @@ withDefaults( :borderless="readonly" hide-bottom-space input-class="text-right" - debounce="500" - :model-value="commaInput(price?.toString() || '0')" + :model-value="price4Show" + @blur=" + () => { + price = Number(price4Show.replace(/,/g, '')); + if (price % 1 === 0) { + const [, dec] = price4Show.split('.'); + if (!dec) { + price4Show += '.00'; + } + } + } + " @update:model-value=" (v) => { - if (typeof v === 'string') price4Show = commaInput(v); - const x = parseFloat( - price4Show && typeof price4Show === 'string' - ? price4Show.replace(/,/g, '') - : '', - ); - price = x; + price4Show = commaInput(v?.toString() || '0', 'string'); } " /> @@ -218,17 +226,24 @@ withDefaults( :borderless="readonly" hide-bottom-space input-class="text-right" - debounce="500" - :model-value="commaInput(agentPrice?.toString() || '0')" + :model-value="agentPrice4Show" + @blur=" + () => { + agentPrice = Number(agentPrice4Show.replace(/,/g, '')); + if (agentPrice % 1 === 0) { + const [, dec] = agentPrice4Show.split('.'); + if (!dec) { + agentPrice4Show += '.00'; + } + } + } + " @update:model-value=" (v) => { - if (typeof v === 'string') agentPrice4Show = commaInput(v); - const x = parseFloat( - agentPrice4Show && typeof agentPrice4Show === 'string' - ? agentPrice4Show.replace(/,/g, '') - : '', + agentPrice4Show = commaInput( + v?.toString() || '0', + 'string', ); - agentPrice = x; } " /> @@ -242,19 +257,26 @@ withDefaults( :borderless="readonly" input-class="text-right" hide-bottom-space - debounce="500" - :model-value="commaInput(serviceCharge?.toString() || '0')" + :model-value="serviceCharge4Show" + @blur=" + () => { + serviceCharge = Number( + serviceCharge4Show.replace(/,/g, ''), + ); + if (serviceCharge % 1 === 0) { + const [, dec] = serviceCharge4Show.split('.'); + if (!dec) { + serviceCharge4Show += '.00'; + } + } + } + " @update:model-value=" (v) => { - if (typeof v === 'string') - serviceCharge4Show = commaInput(v); - const x = parseFloat( - serviceCharge4Show && - typeof serviceCharge4Show === 'string' - ? serviceCharge4Show.replace(/,/g, '') - : '', + serviceCharge4Show = commaInput( + v?.toString() || '0', + 'string', ); - serviceCharge = x; } " /> diff --git a/src/components/05_quotation/ProductItem.vue b/src/components/05_quotation/ProductItem.vue index 71f59f38..ac0f0949 100644 --- a/src/components/05_quotation/ProductItem.vue +++ b/src/components/05_quotation/ProductItem.vue @@ -394,22 +394,30 @@ watch( outlined input-class="text-right" style="width: 90px" - debounce="500" :model-value=" - commaInput(props.row.discount.toString() || '0') + discount4Show[props.rowIndex] || + commaInput(props.row.discount?.toString() || '0') + " + @blur=" + () => { + props.row.discount = Number( + discount4Show[props.rowIndex].replace(/,/g, ''), + ); + if (props.row.discount % 1 === 0) { + const [, dec] = + discount4Show[props.rowIndex].split('.'); + if (!dec) { + discount4Show[props.rowIndex] += '.00'; + } + } + } " @update:model-value=" (v) => { - if (typeof v === 'string') - discount4Show[props.rowIndex] = commaInput(v); - const x = parseFloat( - discount4Show[props.rowIndex] && - typeof discount4Show[props.rowIndex] === 'string' - ? discount4Show[props.rowIndex].replace(/,/g, '') - : '', + discount4Show[props.rowIndex] = commaInput( + v?.toString() || '0', + 'string', ); - props.row.discount = x; - $emit('updateTable', props.row); } " /> diff --git a/src/components/05_quotation/TableQuotation.vue b/src/components/05_quotation/TableQuotation.vue index 395f0e81..014f5bce 100644 --- a/src/components/05_quotation/TableQuotation.vue +++ b/src/components/05_quotation/TableQuotation.vue @@ -2,7 +2,7 @@ import { QTableProps } from 'quasar'; import { dateFormat } from 'src/utils/datetime'; -import { formatNumberDecimal, commaInput } from 'stores/utils'; +import { formatNumberDecimal } from 'stores/utils'; import BadgeComponent from 'components/BadgeComponent.vue'; import KebabAction from 'components/shared/KebabAction.vue'; diff --git a/src/pages/03_customer-management/components/employer/EmployerFormAbout.vue b/src/pages/03_customer-management/components/employer/EmployerFormAbout.vue index 63be0fa0..7a16446c 100644 --- a/src/pages/03_customer-management/components/employer/EmployerFormAbout.vue +++ b/src/pages/03_customer-management/components/employer/EmployerFormAbout.vue @@ -1,7 +1,11 @@