fix: comma input behavior

This commit is contained in:
puriphatt 2024-12-25 15:47:25 +07:00
parent 61501dba8d
commit 889d4afbf5
6 changed files with 113 additions and 50 deletions

View file

@ -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);
}
"
/>

View file

@ -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';