<template>
<div v-if="mty == 'fmt194'">
  <el-form-item label="退汇应答" v-bind:error="tagValue[2].s1" :required="true"  label-position="left" label-width="150px">
    <c-select size="small" v-model="tagValue[0].s1" placeholder="" @change="handleChange" style="width: 100%">
      <el-option label="同意退汇" value="0"></el-option>
      <el-option label="不能退汇" value="1"></el-option>
    </c-select>
  </el-form-item>
</div>
<div v-else-if="mty == 'fmt196'">
  <el-form-item :label="pattern.label" v-bind:error="tagValue[2].s1" label-position="left" label-width="150px">
    <c-input-format size="small" v-model="tagValue[0].s1" :maxRows="6" :maxCols="35" :placeholder="pattern.label"
    @blur="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1">
    </c-input-format>
  </el-form-item>
</div>
<div v-else>
  <el-form-item v-bind:error="tagValue[2].s1">
    <c-input-format size="small" v-model="tagValue[0].s1" :maxRows="6" :maxCols="35" placeholder="Narrative"
    @blur="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1">
    </c-input-format>
  </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 () {
      if (this.mty == 'fmt194') {
        let obj = this.pattern.tagValue[0]
        let mval = obj.s1
        this.pattern.tagValue[1] = mval
      } else {
        let obj = this.pattern.tagValue[0]
        let mval = ''
        mval = obj.s1
        this.pattern.tagValue[1] = mval 
      }
      // 触发校验
      this.$emit('validate')
    }
  }
}
</script>