You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

421 lines
12 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="mod-oss">
  3. <el-form :inline="true" :model="dataForm">
  4. <el-form-item>
  5. <el-input v-model="dataForm.fileName"></el-input>
  6. </el-form-item>
  7. <el-form-item>
  8. <el-button type="primary" @click="getDataList()"> {{ buttons.search || '查询' }}</el-button>
  9. </el-form-item>
  10. <el-form-item>
  11. <el-button type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">
  12. {{ buttons.deleteList || '批量删除' }}
  13. </el-button>
  14. </el-form-item>
  15. <el-form-item>
  16. <download-excel
  17. :fields="fields()"
  18. :data="exportData"
  19. type="xls"
  20. :name="exportName"
  21. :footer="exportFooter"
  22. :defaultValue="exportDefaultValue"
  23. :fetch="createExportData"
  24. :before-generate="startDownload"
  25. :before-finish="finishDownload"
  26. worksheet="导出信息"
  27. class="el-button el-button--primary el-button--medium">
  28. {{ buttons.download || '导出' }}
  29. </download-excel>
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="primary" @click="openMenuList()">{{ buttons.upload || '上传' }}<i
  33. class="el-icon-upload el-icon--right"></i></el-button>
  34. </el-form-item>
  35. </el-form>
  36. <el-table
  37. :data="dataList"
  38. border
  39. :height="tableHeight"
  40. v-loading="dataListLoading"
  41. @selection-change="selectionChangeHandle"
  42. style="width: 100%;">
  43. <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
  44. <el-table-column
  45. v-for="(item,index) in columnList"
  46. :key="index"
  47. :prop="item.columnProp"
  48. header-align="center"
  49. :align="item.align"
  50. :label="item.columnLabel">
  51. </el-table-column>
  52. <el-table-column
  53. fixed="right"
  54. header-align="center"
  55. align="center"
  56. width="150"
  57. label="操作">
  58. <template slot-scope="scope">
  59. <a type="text" size="small" @click="deleteHandle(scope.row.id)">{{ buttons.delete || '删除' }}</a>
  60. <a @click="fileDownload(scope.row)">下载</a>
  61. <a v-if="isAuth('sys:oss:all')" type="text" size="small" @click="helpFileList(scope.row.orderRef1)">
  62. {{ buttons.helpFileList || '帮助文档' }}</a>
  63. </template>
  64. </el-table-column>
  65. </el-table>
  66. <el-pagination
  67. @size-change="sizeChangeHandle"
  68. @current-change="currentChangeHandle"
  69. :current-page="pageIndex"
  70. :page-sizes="[20, 50, 100 , 200, 500]"
  71. :page-size="pageSize"
  72. :total="totalPage"
  73. layout="total, sizes, prev, pager, next, jumper">
  74. </el-pagination>
  75. <FileList ref="helpFileList" v-if="helpFileVisible"></FileList>
  76. <FileMenu ref="fileMenuList"></FileMenu>
  77. </div>
  78. </template>
  79. <script>
  80. import FileList from '../common/file-list'
  81. import FileMenu from './file-menu.vue'
  82. import axios from "axios";
  83. import Vue from "vue";
  84. import {
  85. searchFunctionButtonList,
  86. } from "@/api/sysLanguage.js"
  87. export default {
  88. data() {
  89. return {
  90. uploadShow: false,
  91. fileMenuVisible: false,
  92. tableHeight: 0,
  93. helpFileVisible: false,
  94. dataForm: {
  95. fileName: ''
  96. },
  97. buttons: {
  98. download: '导出',
  99. search: '查询',
  100. cz: '操作',
  101. upload: '上传',
  102. delete: '删除',
  103. fileDownload: '下载',
  104. deleteList: '批量删除',
  105. helpFileList: '帮助文档',
  106. },
  107. dataList: [],
  108. pageIndex: 1,
  109. pageSize: 20,
  110. totalPage: 0,
  111. dataListLoading: false,
  112. dataListSelections: [],
  113. configVisible: false,
  114. uploadVisible: false,
  115. columnList: [
  116. {
  117. tableId: this.$route.meta.menuId + "OSSHELP",
  118. tableName: "OSSHELP",
  119. columnProp: "fileName",
  120. columnLabel: "文件名",
  121. columnHidden: false,
  122. columnImage: false,
  123. columnSortable: false,
  124. columnWidth: null,
  125. format: null,
  126. functionId: this.$route.meta.menuId,
  127. sortLv: 0,
  128. status: true,
  129. fixed: '',
  130. serialNumber: null,
  131. columnType: null,
  132. align: 'center'
  133. },
  134. {
  135. tableId: this.$route.meta.menuId + "OSSHELP",
  136. tableName: "OSSHELP",
  137. columnProp: "orderInfo",
  138. columnLabel: "功能名称",
  139. columnHidden: false,
  140. columnImage: false,
  141. columnSortable: false,
  142. columnWidth: null,
  143. format: null,
  144. functionId: this.$route.meta.menuId,
  145. sortLv: 0,
  146. status: true,
  147. fixed: '',
  148. serialNumber: null,
  149. columnType: null,
  150. align: 'center'
  151. },
  152. {
  153. tableId: this.$route.meta.menuId + "OSSHELP",
  154. tableName: "OSSHELP",
  155. columnProp: "orderRef1",
  156. columnLabel: "功能编码",
  157. columnHidden: false,
  158. columnImage: false,
  159. columnSortable: false,
  160. columnWidth: null,
  161. format: null,
  162. functionId: this.$route.meta.menuId,
  163. sortLv: 0,
  164. status: true,
  165. fixed: '',
  166. serialNumber: null,
  167. columnType: null,
  168. align: 'center'
  169. },
  170. {
  171. tableId: this.$route.meta.menuId + "OSSHELP",
  172. tableName: "OSSHELP",
  173. columnProp: "url",
  174. columnLabel: "URL地址",
  175. columnHidden: false,
  176. columnImage: false,
  177. columnSortable: false,
  178. columnWidth: null,
  179. format: null,
  180. functionId: this.$route.meta.menuId,
  181. sortLv: 0,
  182. status: true,
  183. fixed: '',
  184. serialNumber: null,
  185. columnType: null,
  186. align: 'center'
  187. },
  188. {
  189. tableId: this.$route.meta.menuId + "OSSHELP",
  190. tableName: "OSSHELP",
  191. columnProp: "createdBy",
  192. columnLabel: "创建人",
  193. columnHidden: false,
  194. columnImage: false,
  195. columnSortable: false,
  196. columnWidth: null,
  197. format: null,
  198. functionId: this.$route.meta.menuId,
  199. sortLv: 0,
  200. status: true,
  201. fixed: '',
  202. serialNumber: null,
  203. columnType: null,
  204. align: 'center'
  205. },
  206. {
  207. tableId: this.$route.meta.menuId + "OSSHELP",
  208. tableName: "OSSHELP",
  209. columnProp: "createDate",
  210. columnLabel: "创建时间",
  211. columnHidden: false,
  212. columnImage: false,
  213. columnSortable: false,
  214. columnWidth: null,
  215. format: null,
  216. functionId: this.$route.meta.menuId,
  217. sortLv: 0,
  218. status: true,
  219. fixed: '',
  220. serialNumber: null,
  221. columnType: null,
  222. align: 'center'
  223. },
  224. ],
  225. // 导出 start
  226. exportData: [],
  227. exportName: "帮助文件列表" + this.dayjs().format('YYYYMMDDHHmmss'),
  228. //exportHeader: ["帮助文件列表"],
  229. exportFooter: [],
  230. exportDefaultValue: "这一行这一列没有数据",
  231. // 导出 end
  232. }
  233. },
  234. components: {
  235. FileList,
  236. FileMenu
  237. },
  238. activated() {
  239. this.getDataList()
  240. },
  241. mounted() {
  242. this.$nextTick(() => {
  243. this.tableHeight = window.innerHeight - 166;
  244. })
  245. },
  246. methods: {
  247. // 获取button的词典
  248. getFunctionButtonList() {
  249. let queryButton = {
  250. functionId: this.$route.meta.menuId,
  251. tableId: '*',
  252. languageCode: this.$i18n.locale,
  253. objectType: 'button'
  254. }
  255. searchFunctionButtonList(queryButton).then(({data}) => {
  256. if (data.code == 0 && data.data) {
  257. this.buttons = data.data
  258. }
  259. })
  260. },
  261. // 打开上传功能列表
  262. openMenuList() {
  263. this.$nextTick(() => {
  264. this.$refs.fileMenuList.init()
  265. })
  266. },
  267. // 帮助文档列表
  268. helpFileList(val) {
  269. let fileMappingDto = {
  270. fileId: '',
  271. fileTypeCode: 1,
  272. orderRef1: val,
  273. orderRef2: '*',
  274. orderRef3: '*',
  275. }
  276. this.helpFileVisible = true;
  277. this.$nextTick(() => {
  278. this.$refs.helpFileList.init(fileMappingDto)
  279. })
  280. },
  281. // 文件下载
  282. fileDownload(row) {
  283. //'/proxyApi/ftp/file/downFtpFile/'
  284. axios.get('/proxyApi/ftp/file/downFtpFile/' + row.id, {
  285. responseType: 'blob',
  286. headers: {
  287. 'Content-Type': 'application/json',
  288. 'token': Vue.cookie.get('token')
  289. }
  290. }).then(({data}) => {
  291. // 不限制文件下载类型
  292. const blob = new Blob([data], {type: "application/octet-stream"})
  293. // 下载文件名称
  294. const fileName = row.fileName
  295. // a标签下载
  296. const linkNode = document.createElement('a')
  297. linkNode.download = fileName // a标签的download属性规定下载文件的名称
  298. linkNode.style.display = 'none'
  299. linkNode.href = URL.createObjectURL(blob) // 生成一个Blob URL
  300. // if(val == 'Y'){
  301. // this.pdfVisible = true
  302. // this.pdfUrl = linkNode.href
  303. // }else {
  304. document.body.appendChild(linkNode)
  305. linkNode.click() // 模拟在按钮上的一次鼠标单击
  306. URL.revokeObjectURL(linkNode.href) // 释放URL 对象
  307. document.body.removeChild(linkNode)
  308. // }
  309. })
  310. },
  311. downloadFile(fileName, data) {
  312. if (!data) {
  313. return;
  314. }
  315. let url = window.URL.createObjectURL(new Blob([data]));
  316. let link = document.createElement('a');
  317. link.style.display = 'none';
  318. link.href = url;
  319. link.setAttribute('download', fileName);
  320. document.body.appendChild(link);
  321. link.click();
  322. },
  323. // 获取数据列表
  324. getDataList() {
  325. this.dataListLoading = true
  326. this.$http({
  327. url: this.$http.adornUrl('/sys/oss/list'),
  328. method: 'get',
  329. params: this.$http.adornParams({
  330. 'page': this.pageIndex,
  331. 'fileTypeCode': 1,
  332. 'limit': this.pageSize,
  333. 'fileName': this.dataForm.fileName
  334. })
  335. }).then(({data}) => {
  336. if (data && data.code === 0) {
  337. this.dataList = data.page.list
  338. this.totalPage = data.page.totalCount
  339. } else {
  340. this.dataList = []
  341. this.totalPage = 0
  342. }
  343. this.dataListLoading = false
  344. })
  345. },
  346. // 每页数
  347. sizeChangeHandle(val) {
  348. this.pageSize = val
  349. this.pageIndex = 1
  350. this.getDataList()
  351. },
  352. // 当前页
  353. currentChangeHandle(val) {
  354. this.pageIndex = val
  355. this.getDataList()
  356. },
  357. // 多选
  358. selectionChangeHandle(val) {
  359. this.dataListSelections = val
  360. },
  361. // 删除
  362. deleteHandle(id) {
  363. var ids = id ? [id] : this.dataListSelections.map(item => {
  364. return item.id
  365. })
  366. this.$confirm(`确定进行删除操作?`, '提示', {
  367. confirmButtonText: '确定',
  368. cancelButtonText: '取消',
  369. type: 'warning'
  370. }).then(() => {
  371. this.$http({
  372. url: this.$http.adornUrl('/sys/oss/delete'),
  373. method: 'post',
  374. data: this.$http.adornData(ids, false)
  375. }).then(({data}) => {
  376. if (data && data.code === 0) {
  377. this.$message.success('操作成功')
  378. this.getDataList()
  379. } else {
  380. this.$message.error(data.msg)
  381. }
  382. })
  383. }).catch(() => {
  384. })
  385. },
  386. // 导出
  387. fields() {
  388. let json = "{"
  389. this.columnList.forEach((item, index) => {
  390. if (index == this.columnList.length - 1) {
  391. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  392. } else {
  393. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  394. }
  395. })
  396. json += "}"
  397. let s = eval("(" + json + ")")
  398. return s
  399. },
  400. createExportData() {
  401. // 点击导出按钮之后,开始导出数据之前的执行函数,返回值为需要下载的数据
  402. return this.dataList;
  403. },
  404. startDownload() {
  405. },
  406. finishDownload() {
  407. }
  408. },
  409. created() {
  410. this.getFunctionButtonList()
  411. }
  412. }
  413. </script>