fix: comma input behavior
This commit is contained in:
parent
61501dba8d
commit
889d4afbf5
6 changed files with 113 additions and 50 deletions
|
|
@ -10,9 +10,13 @@ const price = defineModel<number>('price');
|
|||
const vatIncluded = defineModel<boolean>('vatIncluded');
|
||||
const calcVat = defineModel<boolean>('calcVat');
|
||||
|
||||
const price4Show = ref('');
|
||||
const agentPrice4Show = ref('');
|
||||
const serviceCharge4Show = ref('');
|
||||
const price4Show = ref<string>(commaInput(price.value?.toString() || '0'));
|
||||
const agentPrice4Show = ref<string>(
|
||||
commaInput(agentPrice.value?.toString() || '0'),
|
||||
);
|
||||
const serviceCharge4Show = ref<string>(
|
||||
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;
|
||||
}
|
||||
"
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
"
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue