阅行客电子档案
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.

126 lines
3.5 KiB

2 years ago
3 months ago
2 years ago
3 months ago
2 years ago
3 months ago
2 years ago
3 months ago
2 years ago
3 months ago
2 years ago
3 months ago
2 years ago
3 months ago
2 years ago
3 months ago
2 years ago
3 months ago
2 years ago
3 months ago
2 years ago
3 months ago
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="keyId" :expand-on-click-node="false" highlight-current default-expand-all @node-click="handleNodeClick">
  8. <span slot-scope="{ node, data }" class="custom-tree-node">
  9. <span v-if="data.isType === 1 " class="iconFolder">
  10. {{ data.label }}
  11. </span>
  12. <span v-if="data.isType === 2" class="iconFile">
  13. {{ data.label }}
  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. import { mapGetters } from 'vuex'
  24. export default {
  25. name: 'PrearchiveTree',
  26. components: { },
  27. cruds() {
  28. return [
  29. CRUD({
  30. title: '预归档库', url: 'api/document/menu_perpare',
  31. crudMethod: { },
  32. optShow: {
  33. add: false,
  34. edit: false,
  35. del: false,
  36. download: true,
  37. group: false,
  38. reset: true
  39. }
  40. })
  41. ]
  42. },
  43. mixins: [presenter(), header(), preLibraryCrud],
  44. data() {
  45. return {
  46. permission: {
  47. add: ['admin', 'prearchiveLibrary:add'],
  48. edit: ['admin', 'prearchiveLibrary:edit'],
  49. del: ['admin', 'prearchiveLibrary:del'],
  50. sort: ['admin', 'prearchiveLibrary:sort']
  51. },
  52. defaultProps: {
  53. children: 'children',
  54. label: 'cnName'
  55. }
  56. }
  57. },
  58. computed: {
  59. ...mapGetters([
  60. 'user'
  61. ])
  62. },
  63. created() {
  64. },
  65. methods: {
  66. [CRUD.HOOK.beforeRefresh](crud) {
  67. this.crud.query.page = null
  68. this.crud.query.size = null
  69. this.crud.query.fondsId = this.user.fonds.id
  70. const ids = this.user.roles.map(item => { return item.id })
  71. this.crud.query.roleIds = ids.join(',')
  72. },
  73. [CRUD.HOOK.afterRefresh]() {
  74. this.crud.data = this.crud.data.map((item, index) => {
  75. const newItem = {
  76. ...item.fonds,
  77. keyId: item.fonds.fonds_id,
  78. isType: 1,
  79. label: item.fonds.fonds_name,
  80. children: item.document.map((doc, childIndex) => {
  81. // 生成唯一的子节点 id
  82. const uniqueChildId = `${item.fonds.fonds_id}_${doc.id}_${childIndex}`
  83. return {
  84. ...doc,
  85. keyId: uniqueChildId,
  86. fondsId: item.fonds.fonds_id,
  87. fondsNo: item.fonds.fonds_no,
  88. label: doc.cnName
  89. }
  90. })
  91. }
  92. return newItem
  93. })
  94. this.$nextTick(() => {
  95. if (this.crud.data.length > 0 && this.crud.data[0].children && this.crud.data[0].children.length > 0) {
  96. const targetNode = this.crud.data[0].children[0]
  97. const node = this.$refs.tree.getNode(targetNode.keyId)
  98. if (node) {
  99. this.$refs.tree.setCurrentKey(targetNode.keyId)
  100. this.handleNodeClick(node.data)
  101. }
  102. }
  103. })
  104. },
  105. // 选中门类后
  106. handleNodeClick(val) {
  107. console.log('val', val)
  108. if (val) {
  109. this.$emit('nodeClick', val)
  110. }
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang='scss' scoped>
  116. [data-theme=dark] .elect-cont-left .container-left {
  117. min-height: calc(100vh - 158px);
  118. }
  119. .tree-scroll{
  120. font-size: 14px;
  121. }
  122. </style>