<!-- 业务组件 上门核销码 -->
<template>
  <div class="component_JDCancelCode">
    <van-field
      v-model="item.props[0].value"
      :name="item.label"
      :required="item.props[0].required"
      :disabled="item.props[0].disabled"
      :label="item.label"
      :placeholder="`请填写${item.label}`"
      :rules="rules(item.props[0], item.label)"
      clearable
    />
  </div>
</template>

<script>
export default {
  name: 'JDCancelCode',
  props: {
    item: {
      type: Object,
      required: true,
      default () {
        return {}
      }
    },
    // 校验规则
    rules: {
      type: Function,
      default: () => {
        return []
      }
    }
  },
  data () {
    return {
    }
  },
  watch: {
    'item.props': {
      handler () {
        this.item.componentFeedback[0].value = [{
          VisitCancelCode: this.item.props[0].value
        }]
      },
      deep: true,
      immediate: true
    },
    // 业务组件支持修改组件名称-H5应该没啥用
    'item.label': {
      handler () {
        this.item.componentFeedback[0].label = this.item.label
      },
      deep: true,
      immediate: true
    }
  }
}
</script>
