<template>
<div>
  <el-form-item v-bind:error="tagValue[2].s1" label-position="top">
    <c-select size="small" v-model="tagValue[0].s1" @change="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1">
      <el-option label="IRREVOCABLE" value="IRREVOCABLE"></el-option>
      <el-option label="IRREVOC TRANS STANDBY" value="IRREVOC TRANS STANDBY"></el-option>
      <el-option label="IRREVOCABLE STANDBY" value="IRREVOCABLE STANDBY"></el-option>
      <el-option label="IRREVOC TRANS STANDBY" value="IRREVOC TRANS STANDBY"></el-option>
    </c-select>
  </el-form-item>
  <el-form-item v-bind:error="tagValue[2].s2" label-position="top">
    <c-select size="small" v-model="tagValue[0].s2"  @change="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s2') !== -1">
      <el-option label="ADDING OUR CONFIRMATION" value="ADDING OUR CONFIRMATION"></el-option>
      <el-option label="WITHOUT OUR CONFIRMATION" value="WITHOUT OUR CONFIRMATION"></el-option>
    </c-select>
  </el-form-item>
</div>
</template>
<script>
export default {
  props: {
    tag: {
      type: String,
      default: ''
    },
    pattern: {
      type: Object,
      default: () => {}
    }
  },
  data: function () {
    return {
      tagValue: [{
        s1: '',
        s2: ''
      },
      '',
      {
        s1: '',
        s2: ''
      }]
    }
  },
  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 = `${obj.s1}\r\n${obj.s2}`
      this.pattern.tagValue[1] = mval 
      this.$emit('validate')
    }
  }
}
</script>