externalFiles.vue 9.9 KB

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