<template>
<div v-if="mty== 'fmt101' || mty == 'fmt102'  || mty == 'fmt104'"> 
  <c-row :gutter="20">
    <c-col :span="12">
      <el-form-item v-bind:error="tagValue[2].s1" :required="pattern.status=='M' || tagValue[1]?true:false">
        <c-select size="small" v-model="tagValue[0].s1" placeholder="Instruction Code" style="width: 100%" @change="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1">
          <el-option label="CHQB-Cheque" value="CHQB"></el-option>
          <el-option label="CORT-Corporate Trade" value="CORT"></el-option>
          <el-option label="HOLD-Hold" value="HOLD"></el-option>
          <el-option label="INTC-Intra-Company Payment" value="INTC"></el-option>
          <el-option label="PHOB-Phone Beneficiary" value="PHOB"></el-option>
          <el-option label="PHOI-Phone Intermediary" value="PHOI"></el-option>
          <el-option label="PHON-Telephone" value="PHON"></el-option>
          <el-option label="REPA-Related Payment" value="REPA"></el-option>
          <el-option label="SDVA-Same Day Value" value="SDVA"></el-option>
          <el-option label="TELB-Telecommunication" value="TELB"></el-option>
          <el-option label="TELE-Telecommunication" value="TELE"></el-option>
          <el-option label="TELI-Telecommunication" value="TELI"></el-option>
        </c-select>
      </el-form-item>
    </c-col>
    <!-- <c-col :span="12">
      <el-form-item v-bind:error="tagValue[2].s2">
        <c-input size="small" v-model="tagValue[0].s2" placeholder="Additional Information" @blur="handleChange" :maxlength="30" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s2') !== -1"></c-input>
      </el-form-item>
    </c-col> -->
  </c-row>
</div>
<div v-else>
   <c-row :gutter="20">
    <c-col :span="12">
      <el-form-item v-bind:error="tagValue[2].s1" :required="pattern.status=='M' || tagValue[1]?true:false">
        <c-select size="small" v-model="tagValue[0].s1" placeholder="Instruction Code" style="width: 100%" @change="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1">
          <el-option label="CHQB-Cheque" value="CHQB"></el-option>
          <el-option label="CORT-Corporate Trade" value="CORT"></el-option>
          <el-option label="HOLD-Hold" value="HOLD"></el-option>
          <el-option label="INTC-Intra-Company Payment" value="INTC"></el-option>
          <el-option label="PHOB-Phone Beneficiary" value="PHOB"></el-option>
          <el-option label="PHOI-Phone Intermediary" value="PHOI"></el-option>
          <el-option label="PHON-Telephone" value="PHON"></el-option>
          <el-option label="REPA-Related Payment" value="REPA"></el-option>
          <el-option label="SDVA-Same Day Value" value="SDVA"></el-option>
          <el-option label="TELB-Telecommunication" value="TELB"></el-option>
          <el-option label="TELE-Telecommunication" value="TELE"></el-option>
          <el-option label="TELI-Telecommunication" value="TELI"></el-option>
        </c-select>
      </el-form-item>
    </c-col>
     <c-col :span="12">
      <el-form-item v-bind:error="tagValue[2].s2">
        <c-input size="small" v-model="tagValue[0].s2" placeholder="Additional Information" @blur="handleChange" :maxlength="30" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s2') !== -1"></c-input>
      </el-form-item>
    </c-col>
   </c-row>
</div>
</template>
<script>
export default {
  props: {
    tag: {
      type: String,
      default: ''
    },
      mty: {
      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}`
      if(obj.s2)
          mval =mval + '/' + obj.s2
      this.pattern.tagValue[1] = mval  
      this.$emit('validate')
    }
  }
}
</script>