Display and accept SuperAdmin money amounts in tomans.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { fromGroupedInput, toGroupedDisplay } from '@/utils/money'
|
||||
import {
|
||||
fromGroupedInput,
|
||||
rialToToman,
|
||||
toGroupedDisplay,
|
||||
tomanToRial,
|
||||
} from '@/utils/money'
|
||||
|
||||
/**
|
||||
* Money field bound to **rial** storage values (API/DB).
|
||||
* User types and sees **toman** (÷10 / ×10 at the edges).
|
||||
*/
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
value: number | null | undefined
|
||||
@@ -22,10 +31,11 @@ const emit = defineEmits<{
|
||||
(e: 'update:value', value: number): void
|
||||
}>()
|
||||
|
||||
const display = computed(() => toGroupedDisplay(props.value ?? 0))
|
||||
const display = computed(() => toGroupedDisplay(rialToToman(props.value ?? 0)))
|
||||
|
||||
function onInput(raw: string | number) {
|
||||
emit('update:value', fromGroupedInput(String(raw ?? ''), props.allowNegative))
|
||||
const toman = fromGroupedInput(String(raw ?? ''), props.allowNegative)
|
||||
emit('update:value', tomanToRial(toman))
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user