This commit is contained in:
jiangfuzhuang
2020-02-11 10:11:08 +08:00
parent ac32df04d7
commit 06506ad5d9
5 changed files with 109 additions and 4 deletions

View File

@@ -4,7 +4,7 @@ import { type } from './tool' // type判断传入值的类型比typeof更详
export default {
install(Vue) {
Vue.prototype.exportExcel_NPOI = function(param) {
console.log(ExcelDownLoad, param, 1111111111)
console.log(param, 1)
download(`${ExcelDownLoad}?param=${param}`)
}
Vue.prototype.CreateData = function(type, name, data, pageSize, pageList) {
@@ -272,6 +272,7 @@ export default {
}
function download(url) {
getBlob(url, function(blob, filename) {
console.log(blob, filename, 2)
saveAs(blob, filename)
})
}
@@ -283,14 +284,14 @@ function getBlob(url, cb) {
xhr.onload = function() {
if (xhr.status === 200) {
const name = xhr.getResponseHeader('content-disposition').split('=')[1]
var filename1 = decodeURIComponent(name)
cb(xhr.response, filename1)
var filename = decodeURIComponent(name)
cb(xhr.response, filename)
}
}
xhr.send()
}
function saveAs(blob, filename = '下载文件.xls') {
function saveAs(blob, filename) {
if (window.navigator.msSaveOrOpenBlob) {
navigator.msSaveBlob(blob, filename)
} else {