<template>
	<uni-easyinput :inputBorder="false" class="w-form-input" v-if="!readonly" type="digit" v-model="_value" :placeholder="formProps.placeholder || '请输入数值'"/>
	<text class="w-form-input-rv" v-else>{{_value}}</text>
</template>

<script setup>
	import {computed} from 'vue'
	import {parseNumber} from '@/utils/tool.js'
	
	const props = defineProps({
		formProps: {
			type: Object,
			default: () => {
				return {}
			}
		},
		modelValue: Number | String,
		readonly: Boolean
	})
	
	const _value = computed({
		get() {
			return parseNumber(props.modelValue, props.formProps.precision)
		},
		set(val) {
			emits('update:modelValue', parseNumber(val, props.formProps.precision))
		}
	})
	
	const emits = defineEmits(['update:modelValue'])

</script>

<style>
</style>