hrms-mgt/src/components/CurruncyInput.vue

61 lines
1.2 KiB
Vue
Raw Normal View History

2023-08-21 15:14:45 +07:00
<template>
<q-input
ref="inputRef"
v-model="formattedValue"
:dense="dense"
2023-08-22 09:00:36 +07:00
:outlined="edit"
:class="
edit == true
? 'full-width inputgreen cursor-pointer'
: 'full-width cursor-pointer'
"
:readonly="!edit"
:borderless="!edit"
hide-bottom-space
2023-08-21 15:14:45 +07:00
>
2023-09-14 10:53:01 +07:00
<template v-for="slot in slots">
<slot :name="slot" />
2023-08-21 15:14:45 +07:00
</template>
</q-input>
</template>
<script setup lang="ts">
import { useCurrencyInput } from "vue-currency-input";
import { ref, useSlots, watch } from "vue";
const slots = ref<any>(useSlots());
const props = defineProps({
2023-10-19 13:47:54 +07:00
modelValue: {
type: Number,
default: undefined,
},
2023-08-21 15:14:45 +07:00
dense: {
type: Boolean,
2023-08-22 09:00:36 +07:00
default: true,
2023-08-21 15:14:45 +07:00
},
2023-08-22 09:00:36 +07:00
edit: {
2023-08-21 15:14:45 +07:00
type: Boolean,
},
});
const { inputRef, formattedValue, setValue } = useCurrencyInput({
2023-09-14 10:53:01 +07:00
locale: "th-TH",
currency: "THB",
currencyDisplay: "hidden" as any,
2023-08-21 15:14:45 +07:00
hideCurrencySymbolOnFocus: true,
hideGroupingSeparatorOnFocus: true,
hideNegligibleDecimalDigitsOnFocus: true,
autoDecimalDigits: false,
useGrouping: true,
accountingSign: false,
});
watch(
() => props.modelValue,
2023-09-14 10:53:01 +07:00
(value: any) => {
2023-08-21 15:14:45 +07:00
setValue(value);
}
);
</script>