index.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <m-table
  3. v-loading="loading"
  4. row-key="uuid"
  5. :items="items"
  6. :headers="headers"
  7. :page-size="total"
  8. :page-current="1"
  9. :total="total"
  10. :expand-row-keys="expandRowKeys"
  11. lazy
  12. :load="load"
  13. :tree-props="{children: 'child'}"
  14. :default-sort="{ prop: 'sort', order: 'ascending' }"
  15. ></m-table>
  16. </template>
  17. <script>
  18. import {
  19. getOrganizationTree,
  20. drillEmployee
  21. } from '@/api/system'
  22. export default {
  23. name: 'organization-structure',
  24. data () {
  25. return {
  26. expandRowKeys: [],
  27. loading: false,
  28. items: [],
  29. total: 0,
  30. headers: [
  31. { label: '机构名称', prop: 'organizationName' }
  32. ]
  33. }
  34. },
  35. created () {
  36. this.init()
  37. },
  38. methods: {
  39. async init () {
  40. try {
  41. const { data } = await getOrganizationTree()
  42. this.expandRowKeys = [data.uuid]
  43. this.items = [
  44. data
  45. ]
  46. this.total = this.items.length
  47. } catch (error) {
  48. this.$message.error(error)
  49. }
  50. },
  51. async load (tree, treeNode, resolve) {
  52. try {
  53. const { data } = await drillEmployee({ deptName: tree.organizationName })
  54. resolve(data)
  55. } catch (error) {
  56. this.$message.error(error)
  57. }
  58. }
  59. }
  60. }
  61. </script>
  62. <style lang="scss" scoped>
  63. </style>