externalFiles.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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="selectListData"
  29. :toolbars="listConfig.toolbars"
  30. :search-form="listConfig.searchForm"
  31. :pk-key="pkKey"
  32. :columns="listConfig.columns"
  33. :loading="loading"
  34. @sort-change="handleSortChange"
  35. @action-event="handleAction"
  36. @pagination-change="handlePaginationChange">
  37. <template slot="wenjinachayue"
  38. slot-scope="scope">
  39. <ibps-attachment :value="scope.row.wen_jian_id_"
  40. readonly
  41. allow-download
  42. :download="false" />
  43. </template>
  44. </ibps-crud>
  45. </template>
  46. </ibps-container>
  47. </div>
  48. </ibps-layout>
  49. </template>
  50. <script>
  51. import ActionUtils from '@/utils/action'
  52. import { getFileType, getFileByUserId } from '@/api/permission/file'
  53. import IbpsAttachment from '@/business/platform/file/attachment/selector'
  54. import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
  55. export default {
  56. components: {
  57. 'ibps-attachment': IbpsAttachment
  58. },
  59. data() {
  60. return {
  61. show: '',
  62. rightsArr: ['join', 'delete'],
  63. rowHandle: true,
  64. width: 230,
  65. orgId: '',
  66. oldorgId: '',
  67. orgName: '',
  68. loading: false,
  69. typeData: [
  70. { id: '0', label: 'CNAS相关文件' },
  71. { id: '1', label: 'CMA相关文件' },
  72. { id: '2', label: '法律法规' },
  73. { id: '3', label: '检测标准' },
  74. { id: '4', label: '设备说明书' },
  75. { id: '5', label: '试剂耗材说明书' },
  76. { id: '6', label: '标准物质证书' },
  77. { id: '7', label: '参考技术文献(受限)' },
  78. { id: '8', label: '客户技术资料(受限)' },
  79. ],
  80. filterText: '',
  81. defaultProps: {
  82. children: 'children',
  83. label: 'label'
  84. },
  85. pkKey: 'id', // 主键 如果主键不是pk需要传主键
  86. loading: false,
  87. selectListData: [],
  88. listTreeData: [],
  89. bianlistData: {
  90. dataResult: [],
  91. pageResult: {
  92. limit: 0,
  93. page: 0,
  94. totalCount: 0,
  95. totalPages: 0
  96. }
  97. },
  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: 150 },
  115. { prop: 'wen_jian_ming_che', label: '文件名称', width: 400 },
  116. { prop: 'ban_ben_hao_', label: '版本号', sortable: 'custom', width: 100 },
  117. { prop: 'fa_bu_ri_qi_', label: '发放日期', sortable: 'custom', width: 100 },
  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. getDatas(sorts) {
  151. this.listData = []
  152. let wheres = ''
  153. let sql = ''
  154. if (sorts.fileCode) {
  155. wheres = wheres + ` and wj.wen_jian_bian_hao like '%${sorts.fileCode}%'`
  156. }
  157. if (sorts.fileType) {
  158. wheres = wheres + ` and wj.wai_bu_wen_jian_l = '${sorts.fileType}'`
  159. }
  160. if (sorts.fileName) {
  161. wheres = wheres + ` and wj.wen_jian_ming_che like '%${sorts.fileName}%'`
  162. }
  163. if (sorts.sorts) {
  164. if (JSON.stringify(sorts.sorts) !== "{}") {
  165. wheres = wheres + ` order by ${Object.keys(sorts.sorts)} ${Object.values(sorts.sorts)}`
  166. }
  167. }
  168. if (sorts.fileType == '参考技术文献(受限)' || sorts.fileType == '客户技术资料(受限)') {
  169. 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
  170. LEFT JOIN t_wjgl wj ON qx.wen_jian_id_=wj.id_ WHERE qx.yong_hu_id_='${sorts.userId}' ${wheres}`
  171. } else {
  172. sql = `select wj.* FROM t_wjgl wj WHERE wj.wen_jian_zhuang_t = '已发放' AND wj.yi_gai_zuo_fei_ = '否' ${wheres}`
  173. }
  174. // 重复发放的文件,在权限表会存在重复的文件信息
  175. curdPost('sql', sql).then(res => {
  176. let tableDatas = res.variables.data
  177. this.selectListData = JSON.parse(JSON.stringify(tableDatas))
  178. let filterDatas = []
  179. this.bianlistData.pageResult.totalCount = tableDatas.length
  180. this.bianlistData.pageResult.totalPages = Math.ceil(tableDatas.length / this.pagination.limit)
  181. this.bianlistData.pageResult.limit = this.pagination.limit
  182. this.bianlistData.pageResult.page = this.pagination.page
  183. if (this.pagination.limit > tableDatas.length) {
  184. filterDatas = JSON.parse(JSON.stringify(tableDatas))
  185. } else {
  186. for (let index = 0; index < 20; index++) {
  187. filterDatas.push(tableDatas[index])
  188. }
  189. }
  190. this.bianlistData.dataResult = filterDatas
  191. ActionUtils.handleListData(this, this.bianlistData)
  192. }).catch(res => {
  193. this.loading = false
  194. this.listData = []
  195. })
  196. },
  197. refreshData() {
  198. this.listData = []
  199. this.getDatas(this.getSearcFormData())
  200. },
  201. /**
  202. * 处理排序
  203. */
  204. handleSortChange(sort) {
  205. ActionUtils.setSorts(this.sorts, sort)
  206. this.getDatas(this.getSearcFormData())
  207. },
  208. handleNodeClick(data) {
  209. this.oldorgId = data
  210. this.show = 'detail'
  211. ActionUtils.setPagination(this.pagination, { limit: 20, page: 1 })
  212. if (this.oldorgId == data.id) {
  213. return
  214. } else {
  215. this.getDatas({
  216. fileType: this.typeData[data.id].label,
  217. userId: this.$store.getters.userInfo.employee.id,
  218. sorts: { 'wen_jian_bian_hao': 'desc' }
  219. })
  220. }
  221. },
  222. /**
  223. * 获取格式化参数
  224. */
  225. getSearcFormData() {
  226. const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
  227. params['fileType'] = this.typeData[this.oldorgId.id].label
  228. params['userId'] = this.$store.getters.userInfo.employee.id
  229. params['sorts'] = this.sorts
  230. return params
  231. },
  232. // 处理分页事件
  233. handlePaginationChange(page) {
  234. ActionUtils.setPagination(this.pagination, page)
  235. this.bianlistData.pageResult.limit = page.limit
  236. this.bianlistData.pageResult.page = page.page
  237. let filterDatas = []
  238. if (this.selectListData.length >= (page.limit * page.page)) {
  239. for (let index = (page.limit * page.page) - page.limit; index < (page.limit * page.page); index++) {
  240. filterDatas.push(this.selectListData[index])
  241. }
  242. this.bianlistData.dataResult = JSON.parse(JSON.stringify(filterDatas))
  243. } else {
  244. for (let index = (page.limit * page.page) - page.limit; index < this.selectListData.length; index++) {
  245. filterDatas.push(this.selectListData[index])
  246. }
  247. this.bianlistData.dataResult = JSON.parse(JSON.stringify(filterDatas))
  248. }
  249. ActionUtils.handleListData(this, this.bianlistData)
  250. },
  251. /**
  252. * 处理按钮事件
  253. */
  254. handleAction(command, position, selection, data) {
  255. switch (command) {
  256. case 'search':// 查询
  257. this.refreshData()
  258. break
  259. default:
  260. break
  261. }
  262. },
  263. },
  264. watch: {
  265. filterText(val) {
  266. this.$refs.tree.filter(val);
  267. }
  268. },
  269. }
  270. </script>
  271. <style lang="less" scoped>
  272. .box {
  273. width: 230px;
  274. }
  275. .title {
  276. font-size: 14px;
  277. margin: 21px 5px 5px;
  278. padding: 0;
  279. }
  280. /deep/ .el-tree-node__content {
  281. display: block;
  282. }
  283. </style>