<!-- 机构选择下拉框 -->
<template>
  <el-cascader style="width: 100%" ref="tree"
               :props="{value:'id',label:'name',checkStrictly:checkStrictly,emitPath:emitPath}" :value="value || ''"
               @input="updateValue" filterable :options="data" clearable></el-cascader>
</template>

<script>
export default {
  props: {
    // 选中的数据(v-model)
    value: [Number, String],
    // 提示信息
    placeholder: {
      type: String,
      default: '请选择'
    },
    checkStrictly: {
      type: Boolean,
      default: true
    },
    emitPath: {
      type: Boolean,
      default: false
    },
    // 机构数据
    data: Array
  },
  methods: {
    /* 更新选中数据 */
    updateValue(value, node) {
      this.$emit('input', value);
      let nodesInfo = []
      nodesInfo = this.$refs['tree'].getCheckedNodes()
      nodesInfo.push(value)
      this.$emit('checkedKeys', nodesInfo)
    },
  }
};
</script>
