fix: product decimal
This commit is contained in:
parent
ef49f374cd
commit
401dbab1ca
2 changed files with 45 additions and 7 deletions
|
|
@ -1,9 +1,16 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { commaInput } from 'stores/utils';
|
||||||
|
|
||||||
const serviceCharge = defineModel<number>('serviceCharge');
|
const serviceCharge = defineModel<number>('serviceCharge');
|
||||||
const agentPrice = defineModel<number>('agentPrice');
|
const agentPrice = defineModel<number>('agentPrice');
|
||||||
const price = defineModel<number>('price');
|
const price = defineModel<number>('price');
|
||||||
const vatIncluded = defineModel<boolean>('vatIncluded');
|
const vatIncluded = defineModel<boolean>('vatIncluded');
|
||||||
|
|
||||||
|
const price4Show = ref('');
|
||||||
|
const agentPrice4Show = ref('');
|
||||||
|
const serviceCharge4Show = ref('');
|
||||||
|
|
||||||
withDefaults(
|
withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
dense?: boolean;
|
dense?: boolean;
|
||||||
|
|
@ -83,9 +90,19 @@ withDefaults(
|
||||||
:borderless="readonly"
|
:borderless="readonly"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
class="col-4"
|
class="col-4"
|
||||||
type="number"
|
|
||||||
:label="$t('productService.product.salePrice')"
|
:label="$t('productService.product.salePrice')"
|
||||||
v-model="price"
|
:model-value="commaInput(price?.toString() || '0')"
|
||||||
|
@update:model-value="
|
||||||
|
(v) => {
|
||||||
|
if (typeof v === 'string') price4Show = commaInput(v);
|
||||||
|
const x = parseInt(
|
||||||
|
price4Show && typeof price4Show === 'string'
|
||||||
|
? price4Show.replace(/,/g, '')
|
||||||
|
: '',
|
||||||
|
);
|
||||||
|
price = x;
|
||||||
|
}
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
|
|
@ -98,9 +115,19 @@ withDefaults(
|
||||||
:borderless="readonly"
|
:borderless="readonly"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
class="col-4"
|
class="col-4"
|
||||||
type="number"
|
|
||||||
:label="$t('productService.product.agentPrice')"
|
:label="$t('productService.product.agentPrice')"
|
||||||
v-model="agentPrice"
|
:model-value="commaInput(agentPrice?.toString() || '0')"
|
||||||
|
@update:model-value="
|
||||||
|
(v) => {
|
||||||
|
if (typeof v === 'string') agentPrice4Show = commaInput(v);
|
||||||
|
const x = parseInt(
|
||||||
|
agentPrice4Show && typeof agentPrice4Show === 'string'
|
||||||
|
? agentPrice4Show.replace(/,/g, '')
|
||||||
|
: '',
|
||||||
|
);
|
||||||
|
agentPrice = x;
|
||||||
|
}
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
|
|
@ -113,9 +140,19 @@ withDefaults(
|
||||||
:borderless="readonly"
|
:borderless="readonly"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
class="col-4"
|
class="col-4"
|
||||||
type="number"
|
|
||||||
:label="$t('productService.product.processingPrice')"
|
:label="$t('productService.product.processingPrice')"
|
||||||
v-model="serviceCharge"
|
:model-value="commaInput(serviceCharge?.toString() || '0')"
|
||||||
|
@update:model-value="
|
||||||
|
(v) => {
|
||||||
|
if (typeof v === 'string') serviceCharge4Show = commaInput(v);
|
||||||
|
const x = parseInt(
|
||||||
|
serviceCharge4Show && typeof serviceCharge4Show === 'string'
|
||||||
|
? serviceCharge4Show.replace(/,/g, '')
|
||||||
|
: '',
|
||||||
|
);
|
||||||
|
serviceCharge = x;
|
||||||
|
}
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -416,7 +416,8 @@ export async function waitAll<T extends Promise<any>[]>(arr: T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function commaInput(text: string): string {
|
export function commaInput(text: string): string {
|
||||||
if (typeof text !== 'string') return '';
|
if (typeof text !== 'string') return '0';
|
||||||
|
if (!text) return '0';
|
||||||
const num = text.replace(/,/gi, '');
|
const num = text.replace(/,/gi, '');
|
||||||
const numF = num.split(/(?=(?:\d{3})+$)/).join(',');
|
const numF = num.split(/(?=(?:\d{3})+$)/).join(',');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue