externalFiles.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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="输入关键字进行过滤" v-model="filterText">
  8. </el-input>
  9. <div class="treeDiv">
  10. <el-tree ref="tree" :data="typeData" :props="defaultProps" @node-click="handleNodeClick"
  11. :filter-node-method="filterNode"></el-tree>
  12. </div>
  13. </div>
  14. <ibps-container :margin-left="width + 'px'" class="page">
  15. <el-alert v-if="!show" :closable="false" title="请选择左边菜单右键进行操作!" type="warning" show-icon
  16. style="height:50px;" />
  17. <template v-else>
  18. <ibps-crud key="istree" ref="crud" :data="tableData" :toolbars="listConfig.toolbars"
  19. :search-form="listConfig.searchForm" :pk-key="pkKey" :columns="listConfig.columns"
  20. :loading="loading" @action-event="handleAction">
  21. <template slot="wenjinachayue" slot-scope="scope">
  22. <ibps-attachment :value="scope.row.wen_jian_id_" readonly allow-download
  23. :download="false" />
  24. </template>
  25. </ibps-crud>
  26. </template>
  27. </ibps-container>
  28. </div>
  29. </ibps-layout>
  30. </template>
  31. <script>
  32. import ActionUtils from '@/utils/action'
  33. import { getFileType, getFileByUserId } from '@/api/permission/file'
  34. import IbpsAttachment from '@/business/platform/file/attachment/selector'
  35. export default {
  36. components: {
  37. 'ibps-attachment': IbpsAttachment
  38. },
  39. data() {
  40. return {
  41. show: '',
  42. rightsArr: ['join', 'delete'],
  43. rowHandle: true,
  44. width: 230,
  45. orgId: '',
  46. oldorgId: '',
  47. orgName: '',
  48. loading: false,
  49. typeData: [
  50. { id: '0', label: '技术类' },
  51. { id: '1', label: '管理类' },
  52. { id: '2', label: '参考文献' },
  53. { id: '3', label: '设备说明资料' },
  54. { id: '4', label: '其它' }
  55. ],
  56. filterText: '',
  57. defaultProps: {
  58. children: 'children',
  59. label: 'label'
  60. },
  61. pkKey: 'id', // 主键 如果主键不是pk需要传主键
  62. loading: false,
  63. tableData: [],
  64. listTreeData: [],
  65. listConfig: {
  66. // 工具栏
  67. toolbars: [
  68. { key: 'search' }
  69. ],
  70. // 查询条件
  71. searchForm: {
  72. forms: [
  73. { prop: 'fileCode', label: '文件编号' },
  74. { prop: 'fileName', label: '文件名称' },
  75. // { prop: 'deptName', label: '部门' },
  76. ]
  77. },
  78. // 表格字段配置
  79. columns: [
  80. // { prop: 'zi_duan_yi_', label: '部门' },
  81. { prop: 'wen_jian_bian_hao', label: '文件编号' },
  82. { prop: 'wen_jian_ming_che', label: '文件名称' },
  83. { prop: 'ban_ben_hao_', label: '版本号' },
  84. { prop: 'fa_bu_ri_qi_', label: '发布日期' },
  85. { prop: 'wen_jian_id_', label: '查阅', slotName: "wenjinachayue" }
  86. ]
  87. },
  88. listOptions: {
  89. border: true,
  90. stripe: true
  91. },
  92. pagination: {},
  93. sorts: {},
  94. // testData: [{
  95. // zi_duan_yi_: '1',
  96. // wen_jian_bian_hao: '2',
  97. // wen_jian_ming_che: '3',
  98. // ban_ben_hao_: '4',
  99. // fa_bu_ri_qi_: '5',
  100. // wen_jian_id_: '880481571788816384'
  101. // }]
  102. }
  103. },
  104. mounted() {
  105. // this.loadNode()
  106. },
  107. methods: {
  108. filterNode(value, data) {
  109. if (!value) return true;
  110. return data.label.indexOf(value) !== -1;
  111. },
  112. loadNode() {
  113. this.loading = true
  114. // getFileType("外部文件").then(res => {
  115. // this.loading = false
  116. // for (let i in res.variables.data) {
  117. // let data = {}
  118. // data["id"] = i
  119. // data["label"] = res.variables.data[i]
  120. // this.typeData.push(data)
  121. // }
  122. // }).catch(res => {
  123. // this.loading = false
  124. // })
  125. },
  126. refreshData() {
  127. this.tableData = []
  128. getFileByUserId(this.getSearcFormData()).then(res => {
  129. this.tableData = res.variables.data
  130. }).catch(res => {
  131. this.loading = false
  132. this.tableData = []
  133. })
  134. },
  135. handleNodeClick(data) {
  136. this.show = 'detail'
  137. if (this.oldorgId == data.id) {
  138. return
  139. } else {
  140. getFileByUserId({
  141. deptName: "",
  142. fileCode: "",
  143. fileName: "",
  144. fileType: data.label,
  145. userId: this.$store.getters.userInfo.employee.id
  146. }).then(res => {
  147. this.oldorgId = data.id
  148. this.tableData = res.variables.data
  149. }).catch(res => {
  150. this.loading = false
  151. this.tableData = []
  152. })
  153. }
  154. },
  155. /**
  156. * 获取格式化参数
  157. */
  158. getSearcFormData() {
  159. const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
  160. params['fileType'] = this.typeData[this.oldorgId].label
  161. params['userId'] = this.$store.getters.userInfo.employee.id
  162. return params
  163. },
  164. /**
  165. * 处理按钮事件
  166. */
  167. handleAction(command, position, selection, data) {
  168. switch (command) {
  169. case 'search':// 查询
  170. this.refreshData()
  171. break
  172. default:
  173. break
  174. }
  175. },
  176. },
  177. watch: {
  178. filterText(val) {
  179. this.$refs.tree.filter(val);
  180. }
  181. },
  182. }
  183. </script>
  184. <style lang="less" scoped>
  185. .box {
  186. width: 210px;
  187. }
  188. .title {
  189. font-size: 14px;
  190. margin: 21px 5px 5px;
  191. padding: 0;
  192. }
  193. .treeDiv {
  194. height: 800px;
  195. overflow-y: auto;
  196. }
  197. /deep/ .el-tree-node__content {
  198. display: block;
  199. }
  200. </style>