<template>
  <span v-if="mode === 'look'">{{ text || '-' }}</span>
  <el-input-number v-else v-model="text" :min="0" :disabled="disabled" />
</template>

<script setup lang="ts">
import { computed } from 'vue'

const emits = defineEmits(['update:modelValue'])
const props = defineProps({
  modelValue: {
    type: [String, Number],
    default: 1
  },
  formItem: {
    type: Object,
    default: () => {}
  },
  mode: {
    type: String,
    default: 'add'
  },
  disabled: {
    type: Boolean,
    default: false
  }
})

const text = computed({
  get() {
    return Number(props.modelValue)
  },
  set(val) {
    emits('update:modelValue', Number(val))
  }
})
</script>
