<template>
<div>
  <el-row :gutter="20">
    <el-col :span="5">
      <el-form-item v-bind:error="tagValue[2].s1" label-position="top" :required="pattern.status=='M' || tagValue[1]?true:false">
        <c-select size="small" v-model="tagValue[0].s1" placeholder="code" @change="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1">
          <el-option label="CLSTIME" value="CLSTIME"></el-option>
          <el-option label="RNCTIME" value="RNCTIME"></el-option>
          <el-option label="SNDTIME" value="SNDTIME"></el-option>
        </c-select>
      </el-form-item>
    </el-col>
    <el-col :span="7">
      <el-form-item  v-bind:error="tagValue[2].s2" label-position="top" :required="pattern.status=='M' || tagValue[1]?true:false">
        <el-time-picker v-model="tagValue[0].s2" format="HHmm" value-format="HHmm" placeholder="indication" style="width: 100%" @change="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s2') !== -1" size="small"></el-time-picker>
      </el-form-item>
    </el-col>
    <el-col :span="5">
       <el-form-item v-bind:error="tagValue[2].s3" label-position="top" :required="pattern.status=='M' || tagValue[1]?true:false">
        <c-select size="small" v-model="tagValue[0].s3" placeholder="sign" @change="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s3') !== -1">
          <el-option label="+" value="+"></el-option>
          <el-option label="-" value="-"></el-option>
        </c-select>
      </el-form-item>
    </el-col>
    <el-col :span="7">
      <el-form-item v-bind:error="tagValue[2].s4" label-position="top" :required="pattern.status=='M' || tagValue[1]?true:false">
        <el-time-picker v-model="tagValue[0].s4" format="HHmm" value-format="HHmm" style="width: 100%" placeholder="offset" size="small"
          :picker-options="{selectableRange:'00:00:00 - 13:59:00'}" @change="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s4') !== -1"></el-time-picker>
      </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: '',
        s3:'',
        s4:''
      },
      '',
      {
        s1: '',
        s2: '',
        s3:'',
        s4:''
      }]
    }
  },
  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 = ''
      if(obj.s1 || obj.s2  || obj.s3 || obj.s4) {
        mval = `/${obj.s1}/${obj.s2}${obj.s3}${obj.s4}`.replace(/:/g,'')
      }
      this.pattern.tagValue[1] = mval    
      this.$emit('validate')
    }
  }
}
</script>