Skip to content

Commit

Permalink
Update form-input-number.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghangt authored Jun 1, 2024
1 parent 5ee6b74 commit d95d7fe
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/ma-form/formItem/form-input-number.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ const props = defineProps({
const formModel = inject('formModel')
const getColumnService= inject('getColumnService')
const columns = inject('columns')
const rv = async (ev, value = undefined) => await runEvent(props.component, ev, { formModel, getColumnService, columns }, value)
const index = props.customField ?? props.component.dataIndex
const value = ref(toNumber(get(formModel.value, index)))

const rv = async (ev, value = undefined) => {
if(ev === 'onChange') set(formModel.value, index, value)
await runEvent(props.component, ev, { formModel, getColumnService, columns }, value)
}

watch( () => get(formModel.value, index), vl => value.value = toNumber(vl))
watch( () => value.value, v => {
if (isNaN(v)) v = undefined
Expand All @@ -79,4 +83,4 @@ watch( () => value.value, v => {

rv('onCreated')
onMounted(() => rv('onMounted'))
</script>
</script>

0 comments on commit d95d7fe

Please sign in to comment.