<template>
<div>
  <el-form-item v-bind:error="tagValue[2].s1">
    <c-select size="small" v-model="tagValue[0].s1" :placeholder="pattern.label" @change="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1">
      <el-option v-for="item in purpose" :label="item" :value="item" :key="item"></el-option>
    </c-select>
  </el-form-item>
</div>
</template>
<script>
export default {
  props: {
    tag: {
      type: String,
      default: ''
    },
    pattern: {
      type: Object,
      default: () => {}
    },
    mty: {
      type: String,
      default: ''
    }
  },
  data: function () {
    return {
      tagValue: [{
        s1: ''
      },
      '',
      {
        s1: ''
      }],
    }
  },
  computed: {
    purpose: function () {
      if (this.mty == 'mt300') {
        return ['AMND','CANC','DUPL','EXOP','NEWT']
      } else if (this.mty == 'mt306') {
        return ['AMND','CANC','NEWT']
      } else if (this.mty == 'mt320' || this.mty == '360' || this.mty == '620') {
        return ['AMND','CANC','DUPL','NEWT']
      } else {
        return ['ACNF','ADVI','ISSU']
      }
    }
  },
  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>