diff --git a/src/api/cost/cost.js b/src/api/cost/cost.js index 6251b0d..05b0759 100644 --- a/src/api/cost/cost.js +++ b/src/api/cost/cost.js @@ -107,11 +107,6 @@ export const getUnitListByProjetctIds = (params) => { }) } - - - - - // 费用维修审核-提交 export function auditSltApi(data) { return request({ @@ -121,7 +116,15 @@ export function auditSltApi(data) { }) } - +// 导出 +export function exportLeaseAll(data) { + return request({ + url: 'material/sltAgreementInfo/exportLeaseAll', + method: 'post', + responseType: 'blob', + data + }) +} diff --git a/src/main.js b/src/main.js index 693feaf..470d47b 100644 --- a/src/main.js +++ b/src/main.js @@ -13,7 +13,7 @@ import router from './router' import directive from './directive' // directive import VueDOMPurifyHTML from 'vue-dompurify-html' import plugins from './plugins' // plugins -import { download, downloadJson } from '@/utils/request' +import { download, downloadJson,downloadZip } from '@/utils/request' import './assets/icons' // icon import './permission' // permission control @@ -63,6 +63,7 @@ Vue.prototype.selectDictLabel = selectDictLabel Vue.prototype.selectDictLabels = selectDictLabels Vue.prototype.download = download Vue.prototype.downloadJson = downloadJson +Vue.prototype.downloadZip = downloadZip Vue.prototype.handleTree = handleTree Vue.prototype.globalUrl = global_ Vue.prototype.indexContinuation = indexContinuation diff --git a/src/utils/request.js b/src/utils/request.js index fa7423a..1554bc9 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -270,4 +270,43 @@ export function downloadJson(url, params, filename, config) { downloadLoadingInstance.close() }) } + +// 通用下载方法 +export function downloadZip(url, params, filename, config) { + downloadLoadingInstance = Loading.service({ + text: '正在下载数据,请稍候', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)', + }) + return service + .post(url, params, { + transformRequest: [ + (params) => { + return params + }, + ], + headers: { 'Content-Type': 'application/json',encryptResponse: false }, + responseType: 'blob', + ...config, + }) + .then(async (data) => { + const isBlob = blobValidate(data) + if (isBlob) { + const blob = new Blob([data]) + saveAs(blob, filename) + } else { + const resText = await data.text() + const rspObj = JSON.parse(resText) + const errMsg = + errorCode[rspObj.code] || rspObj.msg || errorCode['default'] + Message.error(errMsg) + } + downloadLoadingInstance.close() + }) + .catch((r) => { + console.error(r) + Message.error('下载文件出现错误,请联系管理员!') + downloadLoadingInstance.close() + }) +} export default service diff --git a/src/views/cost/csotSettlement/costApplyList.vue b/src/views/cost/csotSettlement/costApplyList.vue index 2bdf5a0..70bf512 100644 --- a/src/views/cost/csotSettlement/costApplyList.vue +++ b/src/views/cost/csotSettlement/costApplyList.vue @@ -146,8 +146,8 @@