index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <ele-split-layout
  5. width="210px"
  6. allow-collapse
  7. :right-style="{ overflow: 'hidden' }"
  8. >
  9. <div>
  10. <!-- 操作按钮 -->
  11. <ele-toolbar class="ele-toolbar-actions">
  12. <div style="margin: 5px 0">
  13. <!-- <el-button
  14. size="small"
  15. type="primary"
  16. icon="el-icon-plus"
  17. class="ele-btn-icon"
  18. @click="openEdit()"
  19. >
  20. 添加
  21. </el-button>
  22. <el-button
  23. size="small"
  24. type="warning"
  25. icon="el-icon-edit"
  26. class="ele-btn-icon"
  27. :disabled="!current"
  28. @click="openEdit(current)"
  29. >
  30. 修改
  31. </el-button>
  32. <el-button
  33. size="small"
  34. type="danger"
  35. icon="el-icon-delete"
  36. class="ele-btn-icon"
  37. :disabled="!current"
  38. @click="remove"
  39. >
  40. 删除
  41. </el-button> -->
  42. </div>
  43. </ele-toolbar>
  44. <div class="ele-border-lighter sys-organization-list">
  45. <el-tree
  46. ref="tree"
  47. :data="data"
  48. highlight-current
  49. node-key="id"
  50. :props="{ label: 'name', children: 'sonDirectoryList' }"
  51. :expand-on-click-node="false"
  52. :default-expanded-keys="['0','1']"
  53. @node-click="onNodeClick"
  54. >
  55. <span class="custom-tree-node" slot-scope="{ node, data }">
  56. <!-- {{ data.type }} -->
  57. <img src="../../../assets/code1.png" v-if="data.type == 1" />
  58. <img src="../../../assets/code2.png" v-if="data.type == 2" />
  59. <img src="../../../assets/code3.png" v-if="data.type == 3" />
  60. <span>{{ node.label }}</span>
  61. </span>
  62. </el-tree>
  63. </div>
  64. </div>
  65. <template v-slot:content>
  66. <codeList
  67. :parentData="current"
  68. ref="tableRef1"
  69. v-if="current.type == 1"
  70. @done="done"
  71. ></codeList>
  72. <codeSegmentList
  73. :parentData="current"
  74. ref="tableRef2"
  75. v-if="current.type == 2"
  76. @done="done"
  77. ></codeSegmentList>
  78. <codeValueList
  79. :parentData="current"
  80. v-if="current.type == 3"
  81. @done="done"
  82. ref="tableRef3"
  83. ></codeValueList>
  84. </template>
  85. </ele-split-layout>
  86. </el-card>
  87. <!-- 编辑弹窗 -->
  88. <!-- <folder-edit @done="query" ref="editRef" :fileType="fileType" /> -->
  89. </div>
  90. </template>
  91. <script>
  92. // import fileTableList from '@/views/doc/components/file-table-list.vue';
  93. import codeList from './codeList.vue';
  94. import codeSegmentList from './codeSegmentList.vue';
  95. import codeValueList from './codeValueList.vue';
  96. import { selectTreeList } from '@/api/businessCode';
  97. // import { mapGetters } from 'vuex';
  98. export default {
  99. components: { codeList, codeSegmentList, codeValueList },
  100. data() {
  101. return {
  102. rightData: {},
  103. // 加载状态
  104. loading: true,
  105. // 列表数据
  106. data: [],
  107. institutionList: [],
  108. // 选中数据
  109. current: {},
  110. // 是否显示表单弹窗
  111. showFolderEditFlag: false,
  112. // 编辑回显数据
  113. editData: null,
  114. // 上级id
  115. parentId: null
  116. };
  117. },
  118. computed: {
  119. // ...mapGetters(['user'])
  120. },
  121. created() {
  122. this.query();
  123. },
  124. methods: {
  125. /* 查询 */
  126. async query(row) {
  127. this.loading = true;
  128. this.data = await selectTreeList();
  129. this.setTree(this.data);
  130. this.$nextTick(() => {
  131. if (row) {
  132. this.$refs.tree.setCurrentKey(row.id);
  133. this.onNodeClick(row);
  134. } else {
  135. this.$refs.tree.setCurrentKey(this.data[0].id);
  136. this.onNodeClick(this.data[0]);
  137. }
  138. });
  139. this.loading = false;
  140. },
  141. setTree(data) {
  142. data.forEach((item) => {
  143. if (item.codeManageVOList && item.codeManageVOList.length > 0) {
  144. item.sonDirectoryList = item.codeManageVOList;
  145. item.codeManageVOList.forEach((val) => {
  146. val['type'] = 3;
  147. });
  148. }
  149. if (item.sonDirectoryList && item.sonDirectoryList.length > 0) {
  150. this.setTree(item.sonDirectoryList);
  151. }
  152. });
  153. },
  154. /* 选择数据 */
  155. onNodeClick(row) {
  156. if (row) {
  157. this.current = row;
  158. this.$nextTick(() => {
  159. if (this.current.type == 1) {
  160. this.$refs.tableRef1.reload();
  161. }
  162. if (this.current.type == 2 && this.$refs.tableRef2) {
  163. this.$refs.tableRef2.reload();
  164. }
  165. if (this.current.type == 3 && this.$refs.tableRef3) {
  166. this.$refs.tableRef3.reload();
  167. }
  168. });
  169. } else {
  170. this.current = null;
  171. }
  172. },
  173. done(row) {
  174. this.query(row);
  175. },
  176. /* 显示编辑 */
  177. openEdit(type) {
  178. if (type == 'del') {
  179. this.remove();
  180. return;
  181. }
  182. this.$refs.editRef.open(
  183. type,
  184. JSON.parse(JSON.stringify(this.current)),
  185. this.data
  186. );
  187. },
  188. /* 删除 */
  189. remove() {
  190. this.$confirm('确定要删除选中文件夹吗?', '提示', {
  191. type: 'warning'
  192. })
  193. .then(() => {
  194. const loading = this.$loading({ lock: true });
  195. directoryDeleteAPI([this.current.id])
  196. .then((msg) => {
  197. loading.close();
  198. this.$message.success('操作成功');
  199. this.query();
  200. })
  201. .catch((e) => {
  202. loading.close();
  203. });
  204. })
  205. .catch(() => {});
  206. }
  207. }
  208. };
  209. </script>
  210. <style lang="scss" scoped>
  211. .sys-organization-list {
  212. height: calc(100vh - 180px);
  213. box-sizing: border-box;
  214. border-width: 1px;
  215. border-style: solid;
  216. overflow: auto;
  217. }
  218. .sys-organization-list :deep(.el-tree-node__content) {
  219. height: 40px;
  220. & > .el-tree-node__expand-icon {
  221. margin-left: 10px;
  222. }
  223. }
  224. .custom-tree-node {
  225. display: flex;
  226. align-items: center;
  227. img {
  228. width: 20px;
  229. height: 20px;
  230. margin-right: 2px;
  231. }
  232. }
  233. :deep(.el-popover) {
  234. min-width: 50px;
  235. }
  236. :deep(.ele-split-panel-side .ele-table-tool-default) {
  237. display: none;
  238. }
  239. </style>
  240. <style>
  241. .el-input.is-disabled .el-input__inner {
  242. color: #606266;
  243. }
  244. </style>