<template>
<div>
  <c-row :gutter="20">
    <c-col :span="8">
      <el-form-item v-bind:error="tagValue[2].s1">
        <c-date-picker size="small" v-model="tagValue[0].s1" format="yyMMdd" value-format="yyMMdd" style="width: 100%" @change="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1"></c-date-picker>
      </el-form-item>
    </c-col>
  </c-row>
</div>
</template>
<script>
export default {
  props: {
    tag: {
      type: String,
      default: ''
    },
    pattern: {
      type: Object,
      default: () => {}
    }
  },
  data: function () {
    return {
      tagValue: [{
        s1: '',
      },
      '',
      {
        s1: '',
      }],
    }
  },
  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}`.replace('/','')
      this.pattern.tagValue[1] = mval
      this.$emit('validate')
    }
  }
}
</script>