|
@@ -95,6 +95,7 @@ import qs from 'qs'
|
|
|
import {
|
|
|
getToken
|
|
|
} from '@/utils/auth'
|
|
|
+import load from '@/utils/loading'
|
|
|
export default {
|
|
|
name: "tbaseInfo",
|
|
|
props: ['teamid'],
|
|
@@ -179,23 +180,35 @@ export default {
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
|
+ load.startLoading()
|
|
|
axios(options).then(res => {
|
|
|
let blob = new Blob([res.data], {
|
|
|
// type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
|
|
|
type: 'application/vnd.ms-excel;charset=utf-8'
|
|
|
//word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
|
|
|
})
|
|
|
- let objectUrl = URL.createObjectURL(blob)
|
|
|
- let link = document.createElement("a")
|
|
|
- let nowTime = new Date()
|
|
|
- let ymd = nowTime.getFullYear() + '' + (nowTime.getMonth() + 1) + '' + nowTime.getDate() + '' +
|
|
|
- nowTime.getHours() +
|
|
|
- '' + nowTime.getMinutes()
|
|
|
- let fname = this.$route.query.id + '-' + ymd + '发放清单' //下载文件的名字
|
|
|
- link.href = objectUrl
|
|
|
- link.setAttribute("download", fname)
|
|
|
- document.body.appendChild(link)
|
|
|
- link.click()
|
|
|
+ let text = (new Response(blob)).text()
|
|
|
+ text.then(res => {
|
|
|
+ // 判断是否报错
|
|
|
+ if(res.indexOf('code') != -1) {
|
|
|
+ let json = JSON.parse(res)
|
|
|
+ this.$message.error(json.msg)
|
|
|
+ } else {
|
|
|
+ let objectUrl = URL.createObjectURL(blob)
|
|
|
+ let link = document.createElement("a")
|
|
|
+ let nowTime = new Date()
|
|
|
+ let ymd = nowTime.getFullYear() + '' + (nowTime.getMonth() + 1) + '' + nowTime.getDate() + '' +
|
|
|
+ nowTime.getHours() +
|
|
|
+ '' + nowTime.getMinutes()
|
|
|
+ let fname = this.$route.query.id + '-' + ymd + '发放清单' //下载文件的名字
|
|
|
+ link.href = objectUrl
|
|
|
+ link.setAttribute("download", fname)
|
|
|
+ document.body.appendChild(link)
|
|
|
+ link.click()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ load.endLoading();
|
|
|
+
|
|
|
})
|
|
|
}).catch(() => { })
|
|
|
|
|
@@ -219,23 +232,35 @@ export default {
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
|
+ load.startLoading()
|
|
|
axios(options).then(res => {
|
|
|
let blob = new Blob([res.data], {
|
|
|
// type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
|
|
|
type: 'application/vnd.ms-excel;charset=utf-8'
|
|
|
//word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
|
|
|
})
|
|
|
- let objectUrl = URL.createObjectURL(blob)
|
|
|
- let link = document.createElement("a")
|
|
|
- let nowTime = new Date()
|
|
|
- let ymd = nowTime.getFullYear() + '' + (nowTime.getMonth() + 1) + '' + nowTime.getDate() + '' +
|
|
|
- nowTime.getHours() +
|
|
|
- '' + nowTime.getMinutes()
|
|
|
- let fname = this.$route.query.id + '-' + ymd + '分发清单' //下载文件的名字
|
|
|
- link.href = objectUrl
|
|
|
- link.setAttribute("download", fname)
|
|
|
- document.body.appendChild(link)
|
|
|
- link.click()
|
|
|
+ let text = (new Response(blob)).text()
|
|
|
+ text.then(res => {
|
|
|
+ // 判断是否报错
|
|
|
+ if(res.indexOf('code') != -1) {
|
|
|
+ let json = JSON.parse(res)
|
|
|
+ this.$message.error(json.msg)
|
|
|
+ } else {
|
|
|
+ let objectUrl = URL.createObjectURL(blob)
|
|
|
+ let link = document.createElement("a")
|
|
|
+ let nowTime = new Date()
|
|
|
+ let ymd = nowTime.getFullYear() + '' + (nowTime.getMonth() + 1) + '' + nowTime.getDate() + '' +
|
|
|
+ nowTime.getHours() +
|
|
|
+ '' + nowTime.getMinutes()
|
|
|
+ let fname = this.$route.query.id + '-' + ymd + '分发清单' //下载文件的名字
|
|
|
+ link.href = objectUrl
|
|
|
+ link.setAttribute("download", fname)
|
|
|
+ document.body.appendChild(link)
|
|
|
+ link.click()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ load.endLoading();
|
|
|
+
|
|
|
})
|
|
|
}).catch(() => { })
|
|
|
}
|