externalFiles.vue 6.3 KB

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