externalFiles.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <ibps-layout ref="layout">
  3. <!-- 外部 -->
  4. <div slot="west">
  5. <div class="box">
  6. <p class="title">文件类型</p>
  7. <el-input placeholder="输入关键字进行过滤"
  8. v-model="filterText">
  9. </el-input>
  10. <div class="treeDiv">
  11. <el-tree ref="tree"
  12. :data="typeData"
  13. :props="defaultProps"
  14. @node-click="handleNodeClick"
  15. :filter-node-method="filterNode"></el-tree>
  16. </div>
  17. </div>
  18. <ibps-container :margin-left="width + 'px'"
  19. class="page">
  20. <el-alert v-if="!show"
  21. :closable="false"
  22. title="请选择左边菜单右键进行操作!"
  23. type="warning"
  24. show-icon
  25. style="height:50px;" />
  26. <template v-else>
  27. <ibps-crud key="istree"
  28. ref="crud"
  29. :data="listData"
  30. :toolbars="listConfig.toolbars"
  31. :search-form="listConfig.searchForm"
  32. :pk-key="pkKey"
  33. :columns="listConfig.columns"
  34. :loading="loading"
  35. :pagination="pagination"
  36. @sort-change="handleSortChange"
  37. @action-event="handleAction"
  38. @pagination-change="handlePaginationChange">
  39. <template slot="wenjinachayue"
  40. slot-scope="scope">
  41. <ibps-attachment :value="scope.row.wen_jian_id_"
  42. readonly
  43. allow-download
  44. :download="false" />
  45. </template>
  46. </ibps-crud>
  47. </template>
  48. </ibps-container>
  49. </div>
  50. </ibps-layout>
  51. </template>
  52. <script>
  53. import ActionUtils from '@/utils/action'
  54. import { getFileType, getFileByUserId } from '@/api/permission/file'
  55. import IbpsAttachment from '@/business/platform/file/attachment/selector'
  56. import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
  57. export default {
  58. components: {
  59. 'ibps-attachment': IbpsAttachment
  60. },
  61. data() {
  62. return {
  63. show: '',
  64. rightsArr: ['join', 'delete'],
  65. rowHandle: true,
  66. width: 230,
  67. orgId: '',
  68. oldorgId: '',
  69. orgName: '',
  70. loading: false,
  71. typeData: [
  72. { id: '0', label: '技术类' },
  73. { id: '1', label: '管理类' },
  74. { id: '2', label: '参考文献' },
  75. { id: '3', label: '设备说明资料' },
  76. { id: '4', label: '审查依据类' },
  77. { id: '5', label: '其它' }
  78. ],
  79. filterText: '',
  80. defaultProps: {
  81. children: 'children',
  82. label: 'label'
  83. },
  84. pkKey: 'id', // 主键 如果主键不是pk需要传主键
  85. listData: [],
  86. selectListData: [],
  87. bianlistData: {
  88. dataResult: [],
  89. pageResult: {
  90. limit: 0,
  91. page: 0,
  92. totalCount: 0,
  93. totalPages: 0
  94. }
  95. },
  96. listTreeData: [],
  97. listConfig: {
  98. // 工具栏
  99. toolbars: [
  100. { key: 'search' }
  101. ],
  102. // 查询条件
  103. searchForm: {
  104. forms: [
  105. { prop: 'fileCode', label: '文件编号' },
  106. { prop: 'fileName', label: '文件名称' },
  107. // { prop: 'deptName', label: '部门' },
  108. ]
  109. },
  110. // 表格字段配置
  111. columns: [
  112. // { prop: 'zi_duan_yi_', label: '部门' },
  113. { prop: 'wen_jian_bian_hao', label: '文件编号', sortable: 'custom', width: 150 },
  114. { prop: 'wen_jian_ming_che', label: '文件名称' },
  115. { prop: 'ban_ben_hao_', label: '版本号', width: 150 },
  116. { prop: 'fa_bu_ri_qi_', label: '发布日期', width: 150, sortable: 'custom' },
  117. { prop: 'wen_jian_id_', label: '查阅', slotName: "wenjinachayue" }
  118. ]
  119. },
  120. listOptions: {
  121. border: true,
  122. stripe: true
  123. },
  124. pagination: {
  125. limit: 20, page: 1
  126. },
  127. sorts: {},
  128. // testData: [{
  129. // zi_duan_yi_: '1',
  130. // wen_jian_bian_hao: '2',
  131. // wen_jian_ming_che: '3',
  132. // ban_ben_hao_: '4',
  133. // fa_bu_ri_qi_: '5',
  134. // wen_jian_id_: '880481571788816384'
  135. // }]
  136. }
  137. },
  138. mounted() {
  139. // this.loadNode()
  140. },
  141. methods: {
  142. filterNode(value, data) {
  143. if (!value) return true;
  144. return data.label.indexOf(value) !== -1;
  145. },
  146. loadNode() {
  147. this.loading = true
  148. },
  149. refreshData() {
  150. this.tableData = []
  151. this.getDatas(this.getSearcFormData())
  152. },
  153. handleNodeClick(data) {
  154. this.oldorgId = data
  155. this.show = 'detail'
  156. if (this.oldorgId == data.id) {
  157. return
  158. } else {
  159. this.getDatas({
  160. fileType: this.typeData[data.id].label,
  161. userId: this.$store.getters.userInfo.employee.id,
  162. sorts: { 'wen_jian_bian_hao': 'desc' }
  163. })
  164. }
  165. },
  166. /**
  167. * 获取格式化参数
  168. */
  169. getSearcFormData() {
  170. const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
  171. params['fileType'] = this.paramsTypeData[this.oldorgId.id].label
  172. params['userId'] = this.$store.getters.userInfo.employee.id
  173. params['sorts'] = this.sorts
  174. return params
  175. },
  176. /**
  177. * 处理按钮事件
  178. */
  179. handleAction(command, position, selection, data) {
  180. switch (command) {
  181. case 'search':// 查询
  182. this.refreshData()
  183. break
  184. default:
  185. break
  186. }
  187. },
  188. /**
  189. * 处理排序
  190. */
  191. handleSortChange(sort) {
  192. ActionUtils.setSorts(this.sorts, sort)
  193. this.getDatas(this.getSearcFormData())
  194. },
  195. // 处理分页事件
  196. handlePaginationChange(page) {
  197. ActionUtils.setPagination(this.pagination, page)
  198. this.bianlistData.pageResult.limit = page.limit
  199. this.bianlistData.pageResult.page = page.page
  200. let filterDatas = []
  201. if (this.selectListData.length >= (page.limit * page.page)) {
  202. for (let index = (page.limit * page.page) - page.limit; index < (page.limit * page.page); index++) {
  203. filterDatas.push(this.selectListData[index])
  204. }
  205. this.bianlistData.dataResult = JSON.parse(JSON.stringify(filterDatas))
  206. } else {
  207. for (let index = (page.limit * page.page) - page.limit; index < this.selectListData.length; index++) {
  208. filterDatas.push(this.selectListData[index])
  209. }
  210. this.bianlistData.dataResult = JSON.parse(JSON.stringify(filterDatas))
  211. }
  212. ActionUtils.handleListData(this, this.bianlistData)
  213. },
  214. getDatas(sorts) {
  215. let wheres = ''
  216. if (sorts.fileCode) {
  217. wheres = wheres + ` and wj.wen_jian_bian_hao like '%${sorts.fileCode}%'`
  218. }
  219. if (sorts.fileType) {
  220. wheres = wheres + ` and wj.wen_jian_lie_xing = '${sorts.fileType}'`
  221. }
  222. if (sorts.fileName) {
  223. wheres = wheres + ` and wj.wen_jian_ming_che like '%${sorts.fileName}%'`
  224. }
  225. if (sorts.sorts) {
  226. if (JSON.stringify(sorts.sorts) !== "{}") {
  227. wheres = wheres + ` order by ${Object.keys(sorts.sorts)} ${Object.values(sorts.sorts)}`
  228. }
  229. }
  230. // 重复发放的文件,在权限表会存在重复的文件信息
  231. let sql = `select wj.wen_jian_bian_hao,wj.wen_jian_ming_che,wj.ban_ben_hao_,qx.create_time_,wj.wen_jian_id_,qx.fa_bu_ri_qi_ FROM (
  232. SELECT *
  233. FROM t_wjcysqb t
  234. WHERE NOT EXISTS (
  235. SELECT 1
  236. FROM t_wjcysqb
  237. WHERE yong_hu_id_ = t.yong_hu_id_ AND wen_jian_id_ = t.wen_jian_id_
  238. AND create_time_ > t.create_time_
  239. )
  240. ) qx LEFT JOIN t_wjgl wj ON qx.wen_jian_id_=wj.id_ WHERE qx.shou_quan_='1' and qx.yong_hu_id_='${sorts.userId}' ${wheres}`
  241. curdPost('sql', sql).then(res => {
  242. let tableDatas = res.variables.data
  243. this.selectListData = JSON.parse(JSON.stringify(tableDatas))
  244. let filterDatas = []
  245. this.bianlistData.pageResult.totalCount = tableDatas.length
  246. this.bianlistData.pageResult.totalPages = Math.ceil(tableDatas.length / this.pagination.limit)
  247. this.bianlistData.pageResult.limit = this.pagination.limit
  248. this.bianlistData.pageResult.page = this.pagination.page
  249. if (this.pagination.limit > tableDatas.length) {
  250. filterDatas = JSON.parse(JSON.stringify(tableDatas))
  251. } else {
  252. for (let index = 0; index < 20; index++) {
  253. filterDatas.push(tableDatas[index])
  254. }
  255. }
  256. this.bianlistData.dataResult = filterDatas
  257. ActionUtils.handleListData(this, this.bianlistData)
  258. }).catch(res => {
  259. this.loading = false
  260. })
  261. },
  262. },
  263. watch: {
  264. filterText(val) {
  265. this.$refs.tree.filter(val);
  266. }
  267. },
  268. }
  269. </script>
  270. <style lang="less" scoped>
  271. .box {
  272. width: 210px;
  273. }
  274. .title {
  275. font-size: 14px;
  276. margin: 21px 5px 5px;
  277. padding: 0;
  278. }
  279. .treeDiv {
  280. height: 800px;
  281. overflow-y: auto;
  282. }
  283. /deep/ .el-tree-node__content {
  284. display: block;
  285. }
  286. </style>