阅行客电子档案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
3.0 KiB

2 years ago
  1. <template>
  2. <div class="container-left">
  3. <span class="right-top-line" />
  4. <span class="left-bottom-line" />
  5. <!--门类树状结构-->
  6. <div class="tree-scroll">
  7. <el-tree ref="tree" v-loading="crud.loading" :data="crud.data" :props="defaultProps" node-key="id" :expand-on-click-node="false" highlight-current @node-click="handleNodeClick">
  8. <span slot-scope="{ node, data }" class="custom-tree-node">
  9. <span v-if="data.isType === 1 " class="iconFolder">
  10. {{ data.cnName }}
  11. </span>
  12. <span v-if="data.isType === 2" class="iconFile">
  13. {{ data.cnName }}
  14. </span>
  15. </span>
  16. </el-tree>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. import CRUD, { presenter, header } from '@crud/crud'
  22. import { preLibraryCrud } from './mixins/index'
  23. export default {
  24. name: 'PrearchiveTree',
  25. components: { },
  26. cruds() {
  27. return [
  28. CRUD({
  29. title: '预归档库', url: 'api/document/menu',
  30. crudMethod: { },
  31. optShow: {
  32. add: false,
  33. edit: false,
  34. del: false,
  35. download: true,
  36. group: false,
  37. reset: true
  38. }
  39. })
  40. ]
  41. },
  42. mixins: [presenter(), header(), preLibraryCrud],
  43. data() {
  44. return {
  45. permission: {
  46. add: ['admin', 'prearchiveLibrary:add'],
  47. edit: ['admin', 'prearchiveLibrary:edit'],
  48. del: ['admin', 'prearchiveLibrary:del'],
  49. sort: ['admin', 'prearchiveLibrary:sort']
  50. },
  51. defaultProps: {
  52. children: 'children',
  53. label: 'cnName'
  54. }
  55. }
  56. },
  57. computed: {
  58. },
  59. created() {
  60. },
  61. methods: {
  62. [CRUD.HOOK.beforeToAdd](crud, form, btn) {
  63. },
  64. [CRUD.HOOK.afterRefresh]() {
  65. this.crud.data = this.filterData(this.crud.data)
  66. this.$nextTick(() => {
  67. let currentKey
  68. if (this.crud.data[0].isType === 1) {
  69. currentKey = this.findNode(this.crud.data[0].children, (node) => {
  70. return node.isType !== 1
  71. })
  72. } else {
  73. currentKey = this.crud.data[0]
  74. }
  75. // 设置某个节点的当前选中状态
  76. this.$refs.tree.setCurrentKey(currentKey.id)
  77. this.$nextTick(() => {
  78. // 设置某个节点的父级展开
  79. const selectedKey = this.$refs.tree.getCurrentNode()
  80. if (this.$refs.tree.getNode(selectedKey) && this.$refs.tree.getNode(selectedKey).parent) {
  81. this.expandParents(this.$refs.tree.getNode(selectedKey).parent)
  82. }
  83. // 选中节点的门类详情
  84. this.handleNodeClick(selectedKey)
  85. })
  86. })
  87. },
  88. // 选中门类后
  89. handleNodeClick(val) {
  90. if (val) {
  91. this.$emit('nodeClick', val)
  92. }
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang='scss' scoped>
  98. [data-theme=dark] .elect-cont-left .container-left {
  99. min-height: calc(100vh - 158px);
  100. }
  101. .tree-scroll{
  102. font-size: 14px;
  103. }
  104. </style>