<template>
<div>
  <c-row :gutter="20">
    <c-col :span="8">
      <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="Code" @change="handleChange" style="width:100%" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1">
          <el-option value="COUR">COUR</el-option>
          <el-option value="EMAL">EMAL</el-option>
          <el-option value="FACT">FACT</el-option>
          <el-option value="FAXT">FAXT</el-option>
          <el-option value="HOST">HOST</el-option>
          <el-option value="MAIL">MAIL</el-option>
          <el-option value="OTHR">OTHR</el-option>
        </c-select>
      </el-form-item>
    </c-col>
    <c-col :span="10">
      <el-form-item v-bind:error="tagValue[2].s2" :required="pattern.status=='M' || tagValue[1]?true:false">
        <el-input size="small" v-model="tagValue[0].s2" placeholder="File Name or Reference" :maxlength="65" @blur="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s2') !== -1">
          <template slot="prepend">/</template>
        </el-input>
      </el-form-item>
    </c-col>
    
  </c-row>
</div>
</template>
<script>
export default {
  props: {
    tag: {
      type: String,
      default: ''
    },
    pattern: {
      type: Object,
      default: () => {}
    },
    mty: {
      type: String,
      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 = ''
      mval = `${obj.s1}/${obj.s2}`
      this.pattern.tagValue[1] = mval   
      this.$emit('validate')
    }
  }
}
</script>