<template>
  <el-cascader
    :id="id" :class="{'highlight': highlight}" v-model="model" v-bind="$attrs"
    v-on="$listeners" v-bind:disabled="isDisable" :clearable="clearable">
    <slot></slot>
  </el-cascader>
</template>

<script>
export default {
  props: {
    value: {
      type: [String, Array, Number],
      default: undefined
    },
    disabled: {
      type: Boolean,
      default: false
    },
    clearable: {
      type: Boolean,
      default: true
    },
    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
    }
  }, 
  // methods: {
  //   handleClick: function (e) {
      // let ev = new Event("click", {"bubbles": true})
      // let node = e.target
      // while (node && node.parentElement) {
      //   if (node.classList.contains('el-form-item')) {
      //     break
      //   } else {
      //     node = node.parentElement
      //   }
      // }
      // node.setAttribute('selectid', this.id)
      // node.dispatchEvent(ev)
  //   }
  // }
}
</script>

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