<template>
  <div>
    <a-input
      v-model="modelValue"
      :placeholder="placeholder"
      :read-only="!isEdit(prop) || readOnly || disabled"
      @input="event => $emit('input', event.target.value)"
      @blur="event => $emit('blur', event.target.value)"
    />
  </div>
</template>

<script>
import { isEdit } from '@/components/hrhx/approval/utils/set-form-control'

export default {
  name: 'TInput',

  /**
   * input 输入框
   * @description 仅用于两票管理模块的 input 表单
   * @property {String} value v-model语法糖
   * @property {String} placeholder 提示信息
   * @property {String} prop 需要通过 isEdit 校验的字段
   * @author Matrix
   * @since 2022/09/02
   */
  props: {
    value: {
      type: [String, Number],
      required: false,
      default: ''
    },
    placeholder: {
      type: String,
      required: false,
      default: '请填写'
    },
    prop: {
      type: String,
      required: false,
      default: ''
    },
    readOnly: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      modelValue: ''
    }
  },
  watch: {
    value: {
      handler(val) {
        this.modelValue = val
      },
      immediate: true
    }
  },
  methods: {
    isEdit
  }
}
</script>

<style scoped></style>
