internalFiles.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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="paramsTypeData"
  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: '质量管理手册(QM)' },
  73. // { id: '1', label: '程序文件(QP)' },
  74. // { id: '2', label: '生物安全手册(SWAQ)' },
  75. // { id: '3', label: '行政管理制度(ZD)' },
  76. // { id: '4', label: '检测类(JC-SOP)' },
  77. // { id: '5', label: '仪器设备类(YQ-SOP)' },
  78. // { id: '6', label: '期间核查类(HC-SOP)' },
  79. // { id: '7', label: '环境设施类(HJ-SOP)' },
  80. // { id: '8', label: '[限] 技术管理类(ZQ-SOP)' },
  81. // { id: '9', label: '技术记录表(FQ)' },
  82. // { id: '10', label: '管理记录表(FQ)' }
  83. // ],
  84. paramsTypeData: [
  85. { id: '0', label: '质量管理手册(QM)' },
  86. { id: '1', label: '程序文件(QP)' },
  87. { id: '2', label: '生物安全手册(SWAQ)' },
  88. { id: '3', label: '行政管理制度(ZD)' },
  89. { id: '4', label: '检测类(JC-SOP)' },
  90. { id: '5', label: '仪器设备类(YQ-SOP)' },
  91. { id: '6', label: '期间核查类(HC-SOP)' },
  92. { id: '7', label: '环境设施类(HJ-SOP)' },
  93. { id: '8', label: '技术管理类(ZQ-SOP)' },
  94. { id: '9', label: '技术记录表(FQ)' },
  95. { id: '10', label: '管理记录表(FQ)' }
  96. ],
  97. filterText: '',
  98. defaultProps: {
  99. children: 'children',
  100. label: 'label'
  101. },
  102. pkKey: 'id', // 主键 如果主键不是pk需要传主键
  103. loading: false,
  104. listData: [],
  105. selectListData: [],
  106. bianlistData: {
  107. dataResult: [],
  108. pageResult: {
  109. limit: 0,
  110. page: 0,
  111. totalCount: 0,
  112. totalPages: 0
  113. }
  114. },
  115. listTreeData: [],
  116. listConfig: {
  117. // 工具栏
  118. toolbars: [
  119. { key: 'search' }
  120. ],
  121. // 查询条件
  122. searchForm: {
  123. forms: [
  124. { prop: 'fileCode', label: '文件编号' },
  125. { prop: 'fileName', label: '文件名称' },
  126. // { prop: 'deptName', label: '部门' },
  127. ]
  128. },
  129. // 表格字段配置
  130. columns: [
  131. // { prop: 'zi_duan_yi_', label: '部门' },
  132. { prop: 'wen_jian_bian_hao', label: '文件编号', sortable: 'custom', width: 150 },
  133. { prop: 'wen_jian_ming_che', label: '文件名称' },
  134. { prop: 'ban_ben_hao_', label: '版本号', width: 150 },
  135. { prop: 'fa_bu_ri_qi_', label: '发布日期', width: 150, sortable: 'custom' },
  136. { prop: 'wen_jian_id_', label: '查阅', slotName: "wenjinachayue" }
  137. ]
  138. },
  139. listOptions: {
  140. border: true,
  141. stripe: true
  142. },
  143. pagination: {
  144. limit: 20, page: 1
  145. },
  146. sorts: {},
  147. // testData: [{
  148. // zi_duan_yi_: '1',
  149. // wen_jian_bian_hao: '2',
  150. // wen_jian_ming_che: '3',
  151. // ban_ben_hao_: '4',
  152. // fa_bu_ri_qi_: '5',
  153. // wen_jian_id_: '880481571788816384'
  154. // }]
  155. }
  156. },
  157. mounted() {
  158. // this.loadNode()
  159. },
  160. methods: {
  161. filterNode(value, data) {
  162. if (!value) return true;
  163. return data.label.indexOf(value) !== -1;
  164. },
  165. loadNode() {
  166. this.loading = true
  167. },
  168. getDatas(sorts) {
  169. this.listData = []
  170. let wheres = ''
  171. if (sorts.fileCode) {
  172. wheres = wheres + ` and wj.wen_jian_bian_hao like '%${sorts.fileCode}%'`
  173. }
  174. if (sorts.fileType) {
  175. wheres = wheres + ` and wj.wen_jian_lie_xing = '${sorts.fileType}'`
  176. }
  177. if (sorts.fileName) {
  178. wheres = wheres + ` and wj.wen_jian_ming_che like '%${sorts.fileName}%'`
  179. }
  180. if (sorts.sorts) {
  181. if (JSON.stringify(sorts.sorts) !== "{}") {
  182. wheres = wheres + ` order by ${Object.keys(sorts.sorts)} ${Object.values(sorts.sorts)}`
  183. }
  184. }
  185. // 重复发放的文件,在权限表会存在重复的文件信息
  186. let sql = `select wj.wen_jian_bian_hao,wj.wen_jian_ming_che,wj.ban_ben_hao_,qx.create_time_,wj.wen_jian_id_ FROM (
  187. SELECT *
  188. FROM t_wjcysqb t
  189. WHERE NOT EXISTS (
  190. SELECT 1
  191. FROM t_wjcysqb
  192. WHERE yong_hu_id_ = t.yong_hu_id_ AND wen_jian_id_ = t.wen_jian_id_
  193. AND create_time_ > t.create_time_
  194. )
  195. ) 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}`
  196. curdPost('sql', sql).then(res => {
  197. let tableDatas = res.variables.data
  198. this.selectListData = JSON.parse(JSON.stringify(tableDatas))
  199. let filterDatas = []
  200. this.bianlistData.pageResult.totalCount = tableDatas.length
  201. this.bianlistData.pageResult.totalPages = Math.ceil(tableDatas.length / this.pagination.limit)
  202. this.bianlistData.pageResult.limit = this.pagination.limit
  203. this.bianlistData.pageResult.page = this.pagination.page
  204. if (this.pagination.limit > tableDatas.length) {
  205. filterDatas = JSON.parse(JSON.stringify(tableDatas))
  206. } else {
  207. for (let index = 0; index < 20; index++) {
  208. filterDatas.push(tableDatas[index])
  209. }
  210. }
  211. this.bianlistData.dataResult = filterDatas
  212. ActionUtils.handleListData(this, this.bianlistData)
  213. }).catch(res => {
  214. this.loading = false
  215. this.listData = []
  216. })
  217. },
  218. refreshData() {
  219. this.listData = []
  220. this.getDatas(this.getSearcFormData())
  221. },
  222. handleNodeClick(data) {
  223. this.oldorgId = data
  224. this.show = 'detail'
  225. if (this.oldorgId == data.id) {
  226. return
  227. } else {
  228. this.getDatas({
  229. fileType: this.paramsTypeData[data.id].label,
  230. userId: this.$store.getters.userInfo.employee.id,
  231. sorts: { 'wen_jian_bian_hao': 'desc' }
  232. })
  233. }
  234. },
  235. /**
  236. * 获取格式化参数
  237. */
  238. getSearcFormData() {
  239. const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
  240. params['fileType'] = this.paramsTypeData[this.oldorgId.id].label
  241. params['userId'] = this.$store.getters.userInfo.employee.id
  242. params['sorts'] = this.sorts
  243. return params
  244. },
  245. /**
  246. * 处理按钮事件
  247. */
  248. handleAction(command, position, selection, data) {
  249. switch (command) {
  250. case 'search':// 查询
  251. this.refreshData()
  252. break
  253. default:
  254. break
  255. }
  256. },
  257. /**
  258. * 处理排序
  259. */
  260. handleSortChange(sort) {
  261. ActionUtils.setSorts(this.sorts, sort)
  262. this.getDatas(this.getSearcFormData())
  263. },
  264. // 处理分页事件
  265. handlePaginationChange(page) {
  266. ActionUtils.setPagination(this.pagination, page)
  267. this.bianlistData.pageResult.limit = page.limit
  268. this.bianlistData.pageResult.page = page.page
  269. let filterDatas = []
  270. if (this.selectListData.length >= (page.limit * page.page)) {
  271. for (let index = (page.limit * page.page) - page.limit; index < (page.limit * page.page); index++) {
  272. filterDatas.push(this.selectListData[index])
  273. }
  274. this.bianlistData.dataResult = JSON.parse(JSON.stringify(filterDatas))
  275. } else {
  276. for (let index = (page.limit * page.page) - page.limit; index < this.selectListData.length; index++) {
  277. filterDatas.push(this.selectListData[index])
  278. }
  279. this.bianlistData.dataResult = JSON.parse(JSON.stringify(filterDatas))
  280. }
  281. ActionUtils.handleListData(this, this.bianlistData)
  282. },
  283. },
  284. watch: {
  285. filterText(val) {
  286. this.$refs.tree.filter(val);
  287. }
  288. },
  289. }
  290. </script>
  291. <style lang="less" scoped>
  292. .box {
  293. width: 230px;
  294. }
  295. .title {
  296. font-size: 14px;
  297. margin: 21px 5px 5px;
  298. padding: 0;
  299. }
  300. .treeDiv {
  301. height: 800px;
  302. overflow-y: auto;
  303. }
  304. /deep/ .el-tree-node__content {
  305. display: block;
  306. }
  307. </style>