plm前端
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.

425 lines
12 KiB

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