externalFiles.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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="tableData"
  30. :toolbars="listConfig.toolbars"
  31. :search-form="listConfig.searchForm"
  32. :pk-key="pkKey"
  33. :columns="listConfig.columns"
  34. :loading="loading"
  35. @sort-change="handleSortChange"
  36. @action-event="handleAction">
  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: '技术类' },
  71. { id: '1', label: '管理类' },
  72. { id: '2', label: '参考文献' },
  73. { id: '3', label: '设备说明资料' },
  74. { id: '4', label: '其它' }
  75. ],
  76. filterText: '',
  77. defaultProps: {
  78. children: 'children',
  79. label: 'label'
  80. },
  81. pkKey: 'id', // 主键 如果主键不是pk需要传主键
  82. tableData: [],
  83. listTreeData: [],
  84. listConfig: {
  85. // 工具栏
  86. toolbars: [
  87. { key: 'search' }
  88. ],
  89. // 查询条件
  90. searchForm: {
  91. forms: [
  92. { prop: 'fileCode', label: '文件编号' },
  93. { prop: 'fileName', label: '文件名称' },
  94. // { prop: 'deptName', label: '部门' },
  95. ]
  96. },
  97. // 表格字段配置
  98. columns: [
  99. // { prop: 'zi_duan_yi_', label: '部门' },
  100. { prop: 'wen_jian_bian_hao', label: '文件编号', sortable: 'custom', width: 150 },
  101. { prop: 'wen_jian_ming_che', label: '文件名称' },
  102. { prop: 'ban_ben_hao_', label: '版本号', width: 150 },
  103. { prop: 'fa_bu_ri_qi_', label: '发布日期', width: 150, sortable: 'custom' },
  104. { prop: 'wen_jian_id_', label: '查阅', slotName: "wenjinachayue" }
  105. ]
  106. },
  107. listOptions: {
  108. border: true,
  109. stripe: true
  110. },
  111. pagination: {},
  112. sorts: {},
  113. // testData: [{
  114. // zi_duan_yi_: '1',
  115. // wen_jian_bian_hao: '2',
  116. // wen_jian_ming_che: '3',
  117. // ban_ben_hao_: '4',
  118. // fa_bu_ri_qi_: '5',
  119. // wen_jian_id_: '880481571788816384'
  120. // }]
  121. }
  122. },
  123. mounted() {
  124. // this.loadNode()
  125. },
  126. methods: {
  127. filterNode(value, data) {
  128. if (!value) return true;
  129. return data.label.indexOf(value) !== -1;
  130. },
  131. loadNode() {
  132. this.loading = true
  133. },
  134. refreshData() {
  135. this.tableData = []
  136. this.getDatas(this.getSearcFormData())
  137. },
  138. handleNodeClick(data) {
  139. this.oldorgId = data
  140. this.show = 'detail'
  141. if (this.oldorgId == data.id) {
  142. return
  143. } else {
  144. this.getDatas({
  145. fileType: this.typeData[data.id].label,
  146. sorts: { 'wen_jian_bian_hao': 'desc' }
  147. })
  148. }
  149. },
  150. /**
  151. * 获取格式化参数
  152. */
  153. getSearcFormData() {
  154. const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
  155. params['fileType'] = this.typeData[this.oldorgId.id].label
  156. params['sorts'] = this.sorts
  157. return params
  158. },
  159. /**
  160. * 处理按钮事件
  161. */
  162. handleAction(command, position, selection, data) {
  163. switch (command) {
  164. case 'search':// 查询
  165. this.refreshData()
  166. break
  167. default:
  168. break
  169. }
  170. },
  171. /**
  172. * 处理排序
  173. */
  174. handleSortChange(sort) {
  175. ActionUtils.setSorts(this.sorts, sort)
  176. this.getDatas(this.getSearcFormData())
  177. },
  178. getDatas(sorts) {
  179. this.tableData = []
  180. let wheres = ''
  181. if (sorts.fileCode) {
  182. wheres = wheres + ` and wen_jian_bian_hao like '%${sorts.fileCode}%'`
  183. }
  184. if (sorts.fileType) {
  185. wheres = wheres + ` and wai_bu_wen_jian_l = '${sorts.fileType}'`
  186. }
  187. if (sorts.fileName) {
  188. wheres = wheres + ` and wen_jian_ming_che like '%${sorts.fileName}%'`
  189. }
  190. if (sorts.sorts) {
  191. if (JSON.stringify(sorts.sorts) !== "{}") {
  192. wheres = wheres + ` order by ${Object.keys(sorts.sorts)} ${Object.values(sorts.sorts)}`
  193. }
  194. }
  195. let sql = `select *FROM t_wjgl WHERE wen_jian_zhuang_t = '已发放' AND yi_gai_zuo_fei_='否' ${wheres} `
  196. curdPost('sql', sql).then(res => {
  197. this.tableData = res.variables.data
  198. }).catch(res => {
  199. this.loading = false
  200. this.tableData = []
  201. })
  202. },
  203. },
  204. watch: {
  205. filterText(val) {
  206. this.$refs.tree.filter(val);
  207. }
  208. },
  209. }
  210. </script>
  211. <style lang="less" scoped>
  212. .box {
  213. width: 210px;
  214. }
  215. .title {
  216. font-size: 14px;
  217. margin: 21px 5px 5px;
  218. padding: 0;
  219. }
  220. .treeDiv {
  221. height: 800px;
  222. overflow-y: auto;
  223. }
  224. /deep/ .el-tree-node__content {
  225. display: block;
  226. }
  227. </style>