<template>
<div v-if="mty.indexOf('fmt') !== -1">
  <el-form-item  :label="pattern.label" v-bind:error="tagValue[2].s1" label-position="left" label-width="150px">
    <c-input size="small" v-model="tagValue[0].s1" :placeholder="pattern.label" :maxlength="16" @blur="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1"></c-input>
  </el-form-item>
</div>
<div v-else>
  <el-form-item v-bind:error="tagValue[2].s1">
    <c-input size="small" v-model="tagValue[0].s1" :placeholder="pattern.label" :maxlength="16" @blur="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1"></c-input>
  </el-form-item>
</div>
</template>
<script>
export default {
  props: {
    tag: {
      type: String,
      default: ''
    },
    mty: {
      type: String,
      default: ''
    },
    pattern: {
      type: Object,
      default: () => {}
    }
  },
  data: function () {
    return {
      tagValue: [{
        s1: ''
      },
      '',
      {
        s1: ''
      }]
    }
  },
  created: function () {
    if (this.pattern.tagValue == undefined || JSON.stringify(this.pattern.tagValue) == '[{},null]') {
      this.pattern.tagValue = this.tagValue
    } else {
      this.tagValue = this.pattern.tagValue
    }
  },
  methods: {
    handleChange: function () {
      // 触发校验
       let obj = this.pattern.tagValue[0]
      let mval = ''
      mval = obj.s1
      this.pattern.tagValue[1] = mval   
      this.$emit('validate')
    }
  }
}
</script>