下载对账单表
2020-11-04 本文已影响0人
曹锦花
async refundDownStatement() {
let postData = {
batchNo: this.batchNo,
houseId: this.houseId,
keyword: this.searchInfo.keyword,
}
let res = await refundDownStatement(postData)
let blob = new Blob([res], {
type: 'application/pdf' // 后台返回 pdf 类型的文件,如果是其他文件,可以根据MIME表来选择对应的文件类型
})
let fileName = this.batchName +'对账单.xlsx'
if (window.navigator.msSaveOrOpenBlob) {
navigator.msSaveBlob(blob, fileName)
} else {
var link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = fileName
link.click()
//释放内存
window.URL.revokeObjectURL(link.href)
}
},
________________________________
// 下载对账单表
export function refundDownStatement (data) {
return requestPdf({
url: base_api_path + '/api/general/refund/downStatement',
method: 'get',
params: data
})
}
_____________________________
export const service = createService()
export const requestPdf = createRequestFunctionBypdf(service)
function createRequestFunctionBypdf (service) {
return function (config) {
const token = util.cookies.get('token') || ""
let baseURL = ''
// console.log('运行模式', process.env.NODE_ENV)
if (process.env.NODE_ENV === 'development') {
baseURL = '/localapi' + baseURL
}
const configDefault = {
headers: {
Authorization: token,
},
responseType:'blob',
timeout: 5000,
baseURL: baseURL || process.env.VUE_APP_API,
data: new FormData()
}
return service(Object.assign(configDefault, config))
}
}
导出结佣列表
export function exportBrokerageApply(data) {
return request({
url: base_api_path + "/api/general/brokerage/exportBrokerageApply",
method: "get",
responseType: "blob",
params: data,
});
}
_____________________________________
async exportBrokerageApply() {
let postData = {
startTime: this.searchInfo.value1 ? this.formatDate(this.searchInfo.value1[0]) : '',
endTime: this.searchInfo.value1 ? this.formatDate(this.searchInfo.value1[1]) : '',
houseId: this.searchInfo.houseId,
keyword: this.searchInfo.keyword,
status: this.searchInfo.status
}
let res = await exportBrokerageApply(postData)
let blob = new Blob([res], {
type: 'application/vnd.ms-excel' //可以根据MIME表来选择对应的文件类型
})
let fileName = '结佣报表.xlsx'
if (window.navigator.msSaveOrOpenBlob) {
navigator.msSaveBlob(blob, fileName)
} else {
var link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = fileName
link.click()
//释放内存
window.URL.revokeObjectURL(link.href)
}
},