<template>
    <el-input-number v-model="warningValue" :min="0" class="w-46px" :controls="false" @blur="inputBlur" />
</template>

<script setup>
import { ref, watch } from 'vue'
import { isNullES } from 'js-fast-way'

defineOptions({
    name: 'HcInputNumberNum',
})

//双向绑定
const modelValue = defineModel('modelValue', {
    type: [String, Number],
    default: '',
})

//监听数据改变
const warningValue = ref('')
watch(() => modelValue.value, (val) => {
    warningValue.value = isNullES(val) ? null : Number(val)
}, { deep: true, immediate:true })

//输入内容改变
const inputBlur = () => {
    const roundedValue = Math.round(warningValue.value * 100) / 100
    
    modelValue.value = roundedValue
 
    
    
}
</script>
