index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <el-dialog
  3. title="工艺文件"
  4. :visible.sync="visible"
  5. v-if="visible"
  6. :before-close="handleClose"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="80%"
  11. >
  12. <div>
  13. <el-card shadow="never" v-loading="loading">
  14. <ele-split-layout
  15. width="240px"
  16. allow-collapse
  17. :right-style="{ overflow: 'hidden' }"
  18. >
  19. <div>
  20. <div class="ele-border-lighter sys-organization-list">
  21. <el-tree
  22. ref="treeRef"
  23. :data="fileTreeList"
  24. highlight-current
  25. :draggable="true"
  26. node-key="id"
  27. :props="{ label: 'name', children: 'sonDirectoryList' }"
  28. :expand-on-click-node="false"
  29. :default-expand-all="true"
  30. @node-click="onNodeClick"
  31. :allow-drop="allowDrop"
  32. >
  33. <span class="custom-tree-node" slot-scope="{ node, data }">
  34. <div class="tree_lab">
  35. <img src="@/assets/wjj.png" />
  36. <span>{{ node.label }}</span></div
  37. >
  38. </span>
  39. </el-tree>
  40. </div>
  41. </div>
  42. <template v-slot:content>
  43. <!-- 数据表格 -->
  44. <ele-pro-table
  45. ref="table"
  46. :columns="columns"
  47. :datasource="datasource"
  48. :initLoad="false"
  49. height="calc(60vh)"
  50. tool-class="ele-toolbar-form"
  51. :needPage="false"
  52. row-key="id"
  53. :selection.sync="selection"
  54. highlight-current-row
  55. >
  56. </ele-pro-table>
  57. </template>
  58. </ele-split-layout>
  59. </el-card>
  60. </div>
  61. <div slot="footer">
  62. <el-button type="primary" @click="handleSave"> 选择 </el-button>
  63. <el-button @click="handleClose"> 取消 </el-button>
  64. </div>
  65. </el-dialog>
  66. </template>
  67. <script>
  68. import { getDocTreeListAPI, filePageAPI } from '@/api/material/file';
  69. import { mapGetters } from 'vuex';
  70. export default {
  71. components: {},
  72. mixins: [],
  73. data() {
  74. return {
  75. // 加载状态
  76. loading: false,
  77. // 表格选中数据
  78. selection: [],
  79. visible: true,
  80. fileTreeList: [],
  81. fileType: 0, //0:公共文档 1:个人文档 2:文档模板
  82. parentData: {},
  83. // 表格列配置
  84. columns: [
  85. {
  86. width: 45,
  87. type: 'selection',
  88. columnKey: 'selection',
  89. align: 'center'
  90. },
  91. {
  92. label: '编码',
  93. prop: 'code',
  94. width: 180,
  95. align: 'center',
  96. showOverflowTooltip: true
  97. },
  98. {
  99. prop: 'name',
  100. label: '文档名称',
  101. align: 'center',
  102. slot: 'name',
  103. showOverflowTooltip: true,
  104. minWidth: 200
  105. },
  106. {
  107. prop: 'storagePath',
  108. label: '文件名称',
  109. align: 'center',
  110. showOverflowTooltip: true,
  111. minWidth: 200,
  112. formatter: (_row, _column, cellValue) => {
  113. return cellValue[0]?.name;
  114. }
  115. },
  116. {
  117. prop: 'version',
  118. label: '版本',
  119. align: 'center',
  120. showOverflowTooltip: true,
  121. minWidth: 100
  122. },
  123. {
  124. prop: 'checkOutUserName',
  125. label: '检出人',
  126. align: 'center',
  127. showOverflowTooltip: true,
  128. minWidth: 100
  129. },
  130. {
  131. prop: 'checkOutStatus',
  132. label: '检出状态',
  133. align: 'center',
  134. showOverflowTooltip: true,
  135. minWidth: 100,
  136. formatter: (_row, _column, cellValue) => {
  137. return cellValue == 1 ? '已检出' : '';
  138. }
  139. },
  140. {
  141. prop: 'checkOutTime',
  142. label: '检出时间',
  143. align: 'center',
  144. showOverflowTooltip: true,
  145. minWidth: 160
  146. },
  147. {
  148. prop: 'createUserName',
  149. label: '创建人',
  150. align: 'center',
  151. showOverflowTooltip: true,
  152. minWidth: 100
  153. },
  154. {
  155. prop: 'createTime',
  156. label: '创建时间',
  157. align: 'center',
  158. showOverflowTooltip: true,
  159. minWidth: 160
  160. },
  161. {
  162. prop: 'updateUserName',
  163. label: '修改人',
  164. align: 'center',
  165. showOverflowTooltip: true,
  166. minWidth: 100
  167. },
  168. {
  169. prop: 'updateTime',
  170. label: '修改时间',
  171. align: 'center',
  172. showOverflowTooltip: true,
  173. minWidth: 160
  174. },
  175. {
  176. prop: 'sizeUnit',
  177. label: '文档大小',
  178. align: 'center',
  179. showOverflowTooltip: true,
  180. minWidth: 100
  181. }
  182. ]
  183. };
  184. },
  185. computed: {
  186. ...mapGetters(['user'])
  187. },
  188. mounted() {
  189. this.query();
  190. },
  191. methods: {
  192. query() {
  193. this.loading = true;
  194. let query = {
  195. type: this.fileType,
  196. currentUserId: this.user.info.userId
  197. };
  198. getDocTreeListAPI(query).then((res) => {
  199. this.fileTreeList = res;
  200. if (res.length > 0) {
  201. this.$nextTick(() => {
  202. this.parentData = res[0];
  203. this.$refs.treeRef.setCurrentKey(res[0].id);
  204. this.reload();
  205. });
  206. }
  207. });
  208. this.loading = false;
  209. },
  210. datasource({ page, limit, where }) {
  211. return filePageAPI({
  212. ...where,
  213. pageNum: page,
  214. size: limit,
  215. directoryId: this.parentData?.id,
  216. lcyStatus: 1,
  217. fileType: 0
  218. });
  219. },
  220. /* 刷新表格 */
  221. reload() {
  222. this.$refs.table.reload({
  223. pageNum: 1
  224. });
  225. },
  226. allowDrop(draggingNode, dropNode, type) {
  227. //拖拽限制
  228. return dropNode.parent.id == draggingNode.parent.id && type != 'inner';
  229. },
  230. /* 选择数据 */
  231. onNodeClick(row) {
  232. if (row) {
  233. this.parentData = row;
  234. this.$nextTick(() => {
  235. this.reload();
  236. });
  237. }
  238. },
  239. handleClose() {
  240. this.$emit('close', false);
  241. },
  242. handleSave() {
  243. if(this.selection.length == 0) return this.$message.warning('请选择一条数据')
  244. this.$emit('close', JSON.parse(JSON.stringify(this.selection)));
  245. },
  246. /* 表格操作按钮事件 */
  247. handleOperation(type, data) {
  248. switch (type) {
  249. case 'checkOut':
  250. this.checkOut(data);
  251. break;
  252. case 'checkIn':
  253. this.checkIn(data);
  254. break;
  255. default:
  256. break;
  257. }
  258. },
  259. // 检出文档
  260. checkOut(row) {
  261. let query = {
  262. id: row.id,
  263. userId: this.user.info.userId
  264. };
  265. checkOutAPI(query).then((res) => {
  266. this.$message({
  267. type: 'success',
  268. message: res.msg,
  269. duration: 1000
  270. });
  271. this.reload();
  272. });
  273. },
  274. // 归还文档
  275. checkIn(row) {
  276. let query = {
  277. id: row.id,
  278. userId: this.user.info
  279. }
  280. }
  281. }
  282. };
  283. </script>
  284. <style lang="scss" scoped>
  285. .sys-organization-list {
  286. height: calc(100vh - 264px);
  287. box-sizing: border-box;
  288. border-width: 1px;
  289. border-style: solid;
  290. overflow: auto;
  291. }
  292. .tree_lab {
  293. display: flex;
  294. align-items: center;
  295. img {
  296. width: 20px;
  297. height: 20px;
  298. }
  299. }
  300. </style>