main.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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. :draggable="true"
  50. node-key="id"
  51. :props="{ label: 'name', children: 'sonDirectoryList' }"
  52. :expand-on-click-node="true"
  53. :default-expand-all="true"
  54. @node-click="onNodeClick"
  55. @node-drop="nodeDrop"
  56. :allow-drop="allowDrop"
  57. >
  58. <span
  59. class="custom-tree-node"
  60. slot-scope="{ node, data }"
  61. @contextmenu.prevent="onRightClick(data,$event)"
  62. @click.prevent="clicka"
  63. ref="trueNodeRef"
  64. >
  65. <el-popover
  66. style="position: fixed; z-index: 2000"
  67. width="130"
  68. ref="popoverRef"
  69. v-model="visible"
  70. @click.native="visible = false"
  71. v-if="data.id == rightData.id && fileType === 0 && !isPop"
  72. >
  73. <div>
  74. <el-link
  75. v-if="lcyStatus == 1 && isPower(current)"
  76. :underline="false"
  77. @click.native="setPower(data)"
  78. >更改权限
  79. </el-link></div
  80. >
  81. <div>
  82. <el-link
  83. v-if="lcyStatus != 1"
  84. :underline="false"
  85. @click.native="goTo('文档工作区', data)"
  86. >转到文档工作区
  87. </el-link></div
  88. >
  89. <div>
  90. <el-link
  91. v-if="lcyStatus != '2'"
  92. :underline="false"
  93. @click.native="goTo('文档归档区', data)"
  94. >转到文档归档区
  95. </el-link></div
  96. >
  97. <div>
  98. <el-link
  99. v-if="lcyStatus != '3'"
  100. :underline="false"
  101. @click.native="goTo('文档发布区', data)"
  102. >转到文档发布区
  103. </el-link></div
  104. >
  105. </el-popover>
  106. <ElementTreeLine
  107. :node="node"
  108. :showLabelLine="true"
  109. :indent="20"
  110. >
  111. <img src="../../../assets/wjj.png" />
  112. <span>{{ node.label }}</span>
  113. </ElementTreeLine>
  114. </span>
  115. </el-tree>
  116. </div>
  117. </div>
  118. <template v-slot:content>
  119. <FileTableList
  120. ref="tableRef"
  121. :parentData="current"
  122. :folderList="data"
  123. @parenOpen="openEdit"
  124. :fileType="fileType"
  125. :lcyStatus="lcyStatus"
  126. :isPop="isPop"
  127. :disabledTableList="disabledTableList"
  128. />
  129. </template>
  130. </ele-split-layout>
  131. </el-card>
  132. <!-- 编辑弹窗 -->
  133. <folder-edit @done="query" ref="editRef" :fileType="fileType" />
  134. <!-- 文件夹权限 -->
  135. <ele-modal
  136. width="50vw"
  137. :visible="powerVisible"
  138. @close="powerVisible = false"
  139. :close-on-click-modal="false"
  140. append-to-body
  141. >
  142. <Power @powerSave="powerSave" ref="PowerRef" :powerArr="powerArr" />
  143. </ele-modal>
  144. <!-- {{current?.id}} -->
  145. </div>
  146. </template>
  147. <script>
  148. //
  149. import FileTableList from '@/views/doc/components/file-table-list.vue';
  150. import folderEdit from '@/views/doc/components/folder-edit.vue';
  151. import {
  152. directoryDeleteAPI,
  153. getDocTreeListAPI,
  154. directoryUpdateAPi,
  155. validationPersonal,
  156. moveDirectory
  157. } from '@/api/doc-manage';
  158. import { mapGetters } from 'vuex';
  159. import Power from './power/index.vue';
  160. import { isPower } from '../util.js';
  161. import ElementTreeLine from 'element-tree-line';
  162. // css
  163. import 'element-tree-line/dist/style.scss';
  164. export default {
  165. components: { FileTableList, folderEdit, ElementTreeLine, Power },
  166. props: {
  167. fileType: '', //0:公共文档 1:个人文档 2:文档模板
  168. lcyStatus: '', //1:文档工作区 2:文档归档区 3:文档发布区 4:文档废止区
  169. isPop: {
  170. //是否弹出
  171. default: false
  172. },
  173. disabledTableList: {
  174. //已选择列表
  175. default: () => []
  176. }
  177. },
  178. data() {
  179. return {
  180. isPower,
  181. powerArr: [
  182. { name: 'add', label: '新建' },
  183. { name: 'revise', label: '修改' },
  184. { name: 'del', label: '删除' }
  185. ],
  186. visible: false,
  187. powerVisible: false,
  188. rightData: {},
  189. // 加载状态
  190. loading: true,
  191. // 列表数据
  192. data: [],
  193. institutionList: [],
  194. // 选中数据
  195. current: {},
  196. // 是否显示表单弹窗
  197. showFolderEditFlag: false,
  198. // 编辑回显数据
  199. editData: null,
  200. // 上级id
  201. parentId: null
  202. };
  203. },
  204. computed: {
  205. ...mapGetters(['user'])
  206. },
  207. created() {
  208. this.query();
  209. },
  210. mounted() {
  211. document.addEventListener('click', this.clicka);
  212. },
  213. destroyed() {
  214. document.removeEventListener('click', this.clicka);
  215. },
  216. methods: {
  217. /* 查询 */
  218. async query() {
  219. this.loading = true;
  220. let query = {
  221. type: this.fileType,
  222. currentUserId: this.user.info.userId
  223. };
  224. this.data = await getDocTreeListAPI(query);
  225. if (this.fileType == 1 && this.data.length == 0) {
  226. await validationPersonal();
  227. await this.query();
  228. }
  229. this.current = null;
  230. this.$nextTick(() => {
  231. if (this.$route.params.row) {
  232. this.$refs.tree.setCurrentKey(this.$route.params.row.id);
  233. this.onNodeClick(this.$route.params.row);
  234. } else {
  235. this.$refs.tree.setCurrentKey(this.data[0].id);
  236. this.onNodeClick(this.data[0]);
  237. }
  238. });
  239. this.loading = false;
  240. },
  241. /* 选择数据 */
  242. onNodeClick(row) {
  243. if (row) {
  244. this.current = row;
  245. this.$nextTick(() => {
  246. this.$refs.tableRef.reload();
  247. });
  248. } else {
  249. this.current = null;
  250. }
  251. },
  252. allowDrop(draggingNode, dropNode, type) {
  253. //拖拽限制
  254. return dropNode.parent.id == draggingNode.parent.id && type != 'inner';
  255. },
  256. clicka() {
  257. this.visible = false;
  258. },
  259. onRightClick(data,PointerEvent) {
  260. this.rightData = data;
  261. this.visible = true;
  262. this.$nextTick(() => {
  263. let y = PointerEvent.pageY;
  264. let x = PointerEvent.pageX+10;
  265. if (PointerEvent.screenY >= PointerEvent.view.innerHeight) {
  266. y -= 80;
  267. }
  268. this.$refs.popoverRef.$el.style.top = y+'px'
  269. this.$refs.popoverRef.$el.style.left = x+'px'
  270. });
  271. },
  272. setPower(data) {
  273. this.powerVisible = true;
  274. this.$nextTick(() => {
  275. this.$refs.PowerRef &&
  276. this.$refs.PowerRef.setTableList(data.userAuthority || []);
  277. });
  278. },
  279. //权限保存
  280. powerSave(tableList) {
  281. directoryUpdateAPi({
  282. id: this.current.id,
  283. userAuthority: tableList,
  284. authority: 1
  285. }).then((msg) => {
  286. this.powerVisible = false;
  287. this.query();
  288. });
  289. },
  290. goTo(name, row) {
  291. this.$router.push({
  292. name,
  293. params: {
  294. row
  295. }
  296. });
  297. },
  298. /* 显示编辑 */
  299. openEdit(type) {
  300. if (type == 'del') {
  301. this.remove();
  302. return;
  303. }
  304. this.$refs.editRef.open(
  305. type,
  306. JSON.parse(JSON.stringify(this.current)),
  307. this.data
  308. );
  309. },
  310. /* 删除 */
  311. remove() {
  312. this.$confirm('确定要删除选中文件夹吗?', '提示', {
  313. type: 'warning'
  314. })
  315. .then(() => {
  316. const loading = this.$loading({ lock: true });
  317. directoryDeleteAPI([this.current.id])
  318. .then((msg) => {
  319. loading.close();
  320. this.$message.success('操作成功');
  321. this.query();
  322. })
  323. .catch((e) => {
  324. loading.close();
  325. });
  326. })
  327. .catch(() => {});
  328. },
  329. nodeDrop(to, form) {
  330. moveDirectory({
  331. targetId: form.data.id,
  332. replaceId: to.data.id
  333. });
  334. },
  335. getTableList() {
  336. return this.$refs.tableRef.getTableList();
  337. }
  338. }
  339. };
  340. </script>
  341. <style lang="scss" scoped>
  342. .sys-organization-list {
  343. height: calc(100vh - 180px);
  344. box-sizing: border-box;
  345. border-width: 1px;
  346. border-style: solid;
  347. overflow: auto;
  348. }
  349. .sys-organization-list :deep(.el-tree-node__content) {
  350. height: 25px;
  351. & > .el-tree-node__expand-icon {
  352. margin-left: 10px;
  353. }
  354. }
  355. .custom-tree-node {
  356. display: flex;
  357. align-items: center;
  358. }
  359. :deep(.el-popover) {
  360. min-width: 50px;
  361. position: fixed;
  362. background: #409EFF;
  363. }
  364. :deep(.el-link--inner) {
  365. padding: 3px 0;
  366. }
  367. :deep(.el-link.el-link--default) {
  368. color:#fff
  369. }
  370. // :deep(.element-tree-node-line-hor) {
  371. // border-bottom: 1px solid #dcdfe6;
  372. // }
  373. // :deep(.element-tree-node-line-ver) {
  374. // border-left: 1px solid #dcdfe6;
  375. // }
  376. </style>
  377. <style lang="scss">
  378. .el-tree
  379. > .el-tree-node
  380. > .el-tree-node__content:nth-of-type(1)
  381. .element-tree-node-line-hor {
  382. border: none;
  383. }
  384. .el-tree
  385. > .el-tree-node
  386. > .el-tree-node__content:nth-of-type(1)
  387. .element-tree-node-line-ver {
  388. border: none;
  389. }
  390. </style>