externalFiles.vue 9.1 KB

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