externalFiles.vue 6.9 KB

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