refactor: handle type number
This commit is contained in:
parent
2e941af305
commit
c948a533c7
1 changed files with 10 additions and 9 deletions
|
|
@ -5,7 +5,7 @@ import {
|
||||||
formatNumberDecimal,
|
formatNumberDecimal,
|
||||||
} from 'stores/utils';
|
} from 'stores/utils';
|
||||||
import { onMounted, watch } from 'vue';
|
import { onMounted, watch } from 'vue';
|
||||||
import { ref } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import ThaiBahtText from 'thai-baht-text';
|
import ThaiBahtText from 'thai-baht-text';
|
||||||
|
|
||||||
|
|
@ -18,9 +18,11 @@ const jobPosition = defineModel<string>('jobPosition');
|
||||||
const jobDescription = defineModel<string>('jobDescription');
|
const jobDescription = defineModel<string>('jobDescription');
|
||||||
const payDate = defineModel<string>('payDate');
|
const payDate = defineModel<string>('payDate');
|
||||||
const payDateEN = defineModel<string>('payDateEn');
|
const payDateEN = defineModel<string>('payDateEn');
|
||||||
const wageRate = defineModel<string>('wageRate');
|
const wageRate = defineModel<string | number>('wageRate');
|
||||||
const wageRateText = defineModel<string>('wageRateText', { default: '0' });
|
const wageRateText = defineModel<string>('wageRateText', { default: '0' });
|
||||||
|
|
||||||
|
const rate = ref<string>(wageRate.value?.toString() || '0');
|
||||||
|
|
||||||
const wageRate4Show = ref('');
|
const wageRate4Show = ref('');
|
||||||
const typeBusinessOption = ref([]);
|
const typeBusinessOption = ref([]);
|
||||||
const typeBusinessENOption = ref([]);
|
const typeBusinessENOption = ref([]);
|
||||||
|
|
@ -37,7 +39,6 @@ defineProps<{
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
||||||
const resultOption = await fetch('/option/option.json');
|
const resultOption = await fetch('/option/option.json');
|
||||||
rawOption.value = await resultOption.json();
|
rawOption.value = await resultOption.json();
|
||||||
typeBusinessENOption.value = rawOption.value.eng.businessType;
|
typeBusinessENOption.value = rawOption.value.eng.businessType;
|
||||||
|
|
@ -67,13 +68,12 @@ watch([typeBusinessOption, typeBusinessENOption], () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => wageRate.value,
|
() => rate.value,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
console.log(newValue);
|
if (newValue !== undefined && typeof newValue === 'string') {
|
||||||
if (newValue !== undefined) {
|
|
||||||
const numericValue = newValue.replace(/,/g, '');
|
const numericValue = newValue.replace(/,/g, '');
|
||||||
|
|
||||||
wageRateText.value = ThaiBahtText(numericValue);
|
wageRateText.value = ThaiBahtText(numericValue);
|
||||||
|
wageRate.value = parseFloat(numericValue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -317,11 +317,12 @@ let jobPositionENFilter = selectFilterOptionRefMod(
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
class="col-md-3 col-6"
|
class="col-md-3 col-6"
|
||||||
:label="$t('customer.form.payRate')"
|
:label="$t('customer.form.payRate')"
|
||||||
:model-value="wageRate?.toString()"
|
:model-value="rate?.toString()"
|
||||||
@update:model-value="
|
@update:model-value="
|
||||||
(v) => {
|
(v) => {
|
||||||
if (typeof v === 'string') {
|
if (typeof v === 'string') {
|
||||||
wageRate = commaInput(v, 'string');
|
console.log(v);
|
||||||
|
rate = commaInput(v, 'string');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue