<template>
  <el-date-picker :id="id" :class="{'highlight': highlight}" v-model="model" v-bind="attrs" v-on="$listeners" v-bind:disabled="isDisable" :value-format="valueFormat" :format="format"></el-date-picker>
</template>

<script>
export default {
  props: {
    value: {
      default: ''
    },
    disabled: {
      type: Boolean,
      default: false
    },
    valueFormat: {
      type: String,
      default: 'yyyyMMdd'
    },
    format: {
      type: String,
      default: 'yyyy-MM-dd'
    },
    id: {
      type: String,
      default: undefined
    }
  },
  computed: {
    model: {
      get () {
        return this.value
      },
      set (newVal) {
        this.$emit('input', newVal)
      }
    },
    mode () {
      return this.$store.state.Status.mode
    },
    isDisable: {
      get () {
        return this.mode === 'display' || this.disabled
      }
    },
    highlight () {
      return this.$store.state.Status.highlights.indexOf(this.id) !== -1
    },
    attrs(){
      if(this.mode === 'display' || this.disabled)
      {
        let {placeholder,...rest} = this.$attrs
        return rest
      }
      return this.$attrs
    }
  }
}
</script>

<style>
.el-input.highlight .el-input__inner{
  border-color: red;
}
</style>