赞
踩
- fileHandle(data, fileName) {
- let blob = new Blob([data], { type: 'application/zip' }//此处必须添加)
- let url = window.URL.createObjectURL(blob)
- const link = document.createElement('a') // 创建a标签
- link.href = url
- link.download = fileName // 重命名文件
- link.click()
- URL.revokeObjectURL(url) // 释放内存
- },
- DownloadFile(row) {
- let paymentId = row.cfbizPaymentEnrollment.ID
- let customerName = row.cfbizPaymentEnrollment.CUSTOMER_NAME
- doRestFileGet('service/payment/getAttachment?paymentId=' + paymentId + "&customerName=" + customerName,).then(result => {
- this.fileHandle(result.data, `${customerName}.zip`)
- })
- },
-
-
- // 请求
- export function doRestFileGet(url,params)
- {
- /* 自动添加sessionId */
- let sessionId = getToken();
- return service({
- url: url,
- method: 'get',
- responseType: 'blob', // 表明返回服务器返回的数据类型
- headers: {
- sessionId:sessionId,
- 'Content-Type': 'application/json; charset=UTF-8'
- },
- params:params
- }).catch(function (error) {
- console.log(error);
- });
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。