DatePicker.vue 1.23 KB
Newer Older
liuxin committed
1
<template>
fukai committed
2
  <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>
liuxin committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16
</template>

<script>
export default {
  props: {
    value: {
      default: ''
    },
    disabled: {
      type: Boolean,
      default: false
    },
    valueFormat: {
      type: String,
zhengxiaokui committed
17
      default: 'yyyy-MM-dd'
liuxin committed
18 19 20 21 22 23 24
    },
    format: {
      type: String,
      default: 'yyyy-MM-dd'
    },
    id: {
      type: String,
fukai committed
25
      default: undefined
liuxin committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
    }
  },
  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
fukai committed
47 48 49 50 51 52 53 54
    },
    attrs(){
      if(this.mode === 'display' || this.disabled)
      {
        let {placeholder,...rest} = this.$attrs
        return rest
      }
      return this.$attrs
liuxin committed
55 56 57 58 59 60 61 62 63 64
    }
  }
}
</script>

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