department.vue 966 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <div class="w-full sm:w-[28rem] min-h-[30rem] bg-white">
  3. <el-tree :data="departments" :props="{ label: 'department_name', value: 'id'}" @node-click="clickDepartment" class="p-5" :expand-on-click-node="false" :highlight-current="true"/>
  4. </div>
  5. </template>
  6. <script lang="ts" setup>
  7. import { onMounted, ref } from 'vue'
  8. import http from '/admin/support/http'
  9. const props = defineProps({
  10. modelValue: {
  11. type: Number,
  12. default: 0
  13. }
  14. })
  15. const departments = ref()
  16. onMounted(() => {
  17. http.get('permissions/departments').then(r => {
  18. departments.value = r.data.data
  19. })
  20. })
  21. const emits = defineEmits(['update:modelValue', 'searchDepartmentUsers'])
  22. const clickDepartment = (node) => {
  23. emits('update:modelValue', node.id)
  24. emits('searchDepartmentUsers')
  25. }
  26. </script>
  27. <style scoped lang="scss">
  28. :deep(.el-tree .el-tree-node) {
  29. @apply p-0.5
  30. }
  31. :deep(.el-tree .el-tree-node .el-tree-node__content) {
  32. @apply h-8 rounded
  33. }
  34. </style>