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,
|
||||
} from 'stores/utils';
|
||||
import { onMounted, watch } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import ThaiBahtText from 'thai-baht-text';
|
||||
|
||||
|
|
@ -18,9 +18,11 @@ const jobPosition = defineModel<string>('jobPosition');
|
|||
const jobDescription = defineModel<string>('jobDescription');
|
||||
const payDate = defineModel<string>('payDate');
|
||||
const payDateEN = defineModel<string>('payDateEn');
|
||||
const wageRate = defineModel<string>('wageRate');
|
||||
const wageRate = defineModel<string | number>('wageRate');
|
||||
const wageRateText = defineModel<string>('wageRateText', { default: '0' });
|
||||
|
||||
const rate = ref<string>(wageRate.value?.toString() || '0');
|
||||
|
||||
const wageRate4Show = ref('');
|
||||
const typeBusinessOption = ref([]);
|
||||
const typeBusinessENOption = ref([]);
|
||||
|
|
@ -37,7 +39,6 @@ defineProps<{
|
|||
}>();
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
const resultOption = await fetch('/option/option.json');
|
||||
rawOption.value = await resultOption.json();
|
||||
typeBusinessENOption.value = rawOption.value.eng.businessType;
|
||||
|
|
@ -67,13 +68,12 @@ watch([typeBusinessOption, typeBusinessENOption], () => {
|
|||
});
|
||||
|
||||
watch(
|
||||
() => wageRate.value,
|
||||
() => rate.value,
|
||||
(newValue) => {
|
||||
console.log(newValue);
|
||||
if (newValue !== undefined) {
|
||||
if (newValue !== undefined && typeof newValue === 'string') {
|
||||
const numericValue = newValue.replace(/,/g, '');
|
||||
|
||||
wageRateText.value = ThaiBahtText(numericValue);
|
||||
wageRate.value = parseFloat(numericValue);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
@ -317,11 +317,12 @@ let jobPositionENFilter = selectFilterOptionRefMod(
|
|||
hide-bottom-space
|
||||
class="col-md-3 col-6"
|
||||
:label="$t('customer.form.payRate')"
|
||||
:model-value="wageRate?.toString()"
|
||||
:model-value="rate?.toString()"
|
||||
@update:model-value="
|
||||
(v) => {
|
||||
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