<template>
  <div>
    <treeselect v-model="deptId" :options="deptOptions" :show-count="true" placeholder="请选择隶属海关" :disabled="disabled" />
  </div>
</template>

<script>
import Treeselect from '@riophae/vue-treeselect';
import '@riophae/vue-treeselect/dist/vue-treeselect.css';
export default {
  name: 'dselect',
  components: {
    Treeselect
  },
  props: {
    value: {},
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      deptId: this.value,
      deptOptions: []
    };
  },
  watch: {
    value(val) {
      this.deptId = val;
    },
    // 根据名称筛选部门树
    deptId(val) {
      this.$emit('input', this.deptId);
    }
  },
  mounted() {
    //部门列表
    this.ajax({ url: '/system/user/deptTree' }).then(response => {
      this.deptOptions = response.data;
    });
  },
  methods: {}
};
</script>
