externalFiles.vue 6.7 KB

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