<template>
<div>
  <el-row :gutter="20">
    <el-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="Applicable Rules" style="width: 100%" @change="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1">
          <el-option label="UCPURR LATEST VERSION" value="UCPURR LATEST VERSION"></el-option>
          <el-option label="UCP LATEST VERSION" value="UCP LATEST VERSION"></el-option>
          <el-option label="EUCP LATEST VERSION" value="EUCP LATEST VERSION"></el-option>
          <el-option label="EUCPURR LATEST VERSION" value="EUCPURR LATEST VERSION"></el-option>
          <el-option label="ISP LATEST VERSION" value="ISP LATEST VERSION"></el-option>
          <el-option label="OTHR" value="OTHR"></el-option>
        </c-select>
      </el-form-item>
    </el-col>
    <!-- <el-col :span="12">
      <el-form-item v-bind:error="tagValue[2].s2">
        <c-input size="small" v-model="tagValue[0].s2" placeholder="Narrative" @blur="handleChange" :maxlength="30" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s2') !== -1"></c-input>
      </el-form-item>
    </el-col> -->
  </el-row>
</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}`
      if(obj.s2)
          mval =mval + '/' + obj.s2
      this.pattern.tagValue[1] = mval  
      this.$emit('validate')
    }
  }
}
</script>