合并分支 'fix_bug_first_stage' 到 'master'
Fix bug first stage 查看合并请求 laws-nio/laws-weilai!80
This commit is contained in:
@@ -134,7 +134,14 @@ export function downFile(url, parameter) {
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
export function downFilePost(url, parameter) {
|
||||
return axios({
|
||||
url: url,
|
||||
data: parameter,
|
||||
method: 'post',
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 下载文件
|
||||
* @param url 文件路径
|
||||
@@ -226,6 +233,85 @@ export function downloadFile(url, fileName, parameter, callback) {
|
||||
})
|
||||
}
|
||||
|
||||
export function downloadFilePost(url, fileName, parameter, callback) {
|
||||
let langCn = localStorage.language
|
||||
// 默认中文
|
||||
let isTrue
|
||||
if (langCn == 'en-us') {
|
||||
isTrue = true
|
||||
} else if (langCn == 'zh-cn') {
|
||||
isTrue = false
|
||||
}
|
||||
index.showDrawer({
|
||||
loading: true,
|
||||
isTrue: isTrue
|
||||
})
|
||||
return downFilePost(url, parameter).then((data) => {
|
||||
let fileReader = new FileReader()
|
||||
fileReader.onload = function(event) {
|
||||
try {
|
||||
let jsonData = JSON.parse(event.target.result)
|
||||
if (jsonData.message.includes('token')) {
|
||||
index.showDrawer({
|
||||
loading: false,
|
||||
isTrue: isTrue
|
||||
})
|
||||
Modal.error({
|
||||
title: '登录已过期',
|
||||
content: '很抱歉,登录已过期,请重新登录',
|
||||
okText: '重新登录',
|
||||
mask: false,
|
||||
onOk: () => {
|
||||
store.dispatch('Logout').then(() => {
|
||||
Vue.ls.remove(ACCESS_TOKEN)
|
||||
try {
|
||||
let path = window.document.location.pathname
|
||||
if (path != '/' && path.indexOf('/user/login') == -1) {
|
||||
window.location.reload()
|
||||
}
|
||||
} catch (e) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (!jsonData.success) {
|
||||
index.showDrawer({
|
||||
loading: false,
|
||||
isTrue: isTrue
|
||||
})
|
||||
Vue.prototype['$message'].warning(jsonData.message)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (!data || data.size === 0) {
|
||||
Vue.prototype['$message'].warning('文件下载失败')
|
||||
return
|
||||
}
|
||||
if (typeof window.navigator.msSaveBlob !== 'undefined') {
|
||||
window.navigator.msSaveBlob(new Blob([data]), fileName)
|
||||
} else {
|
||||
let url = window.URL.createObjectURL(new Blob([data]))
|
||||
let link = document.createElement('a')
|
||||
link.style.display = 'none'
|
||||
link.href = url
|
||||
link.setAttribute('download', fileName)
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link) //下载完成移除元素
|
||||
window.URL.revokeObjectURL(url) //释放掉blob对象
|
||||
}
|
||||
index.showDrawer({
|
||||
loading: false,
|
||||
isTrue: isTrue
|
||||
})
|
||||
callback && callback()
|
||||
}
|
||||
}
|
||||
fileReader.readAsText(data)
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 文件上传 用于富文本上传图片
|
||||
* @param url
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<a-drawer
|
||||
title="添加"
|
||||
:title="$t('add')"
|
||||
:maskClosable="false"
|
||||
:width="1000"
|
||||
placement="right"
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getAction, postAction, downloadFile, deleteAction } from '@/api/manage'
|
||||
import { getAction, postAction, downloadFile, deleteAction,downloadFilePost } from '@/api/manage'
|
||||
import store from '@/store/'
|
||||
|
||||
export default {
|
||||
@@ -214,9 +214,9 @@
|
||||
let query = {
|
||||
...this.queryParam,
|
||||
projectLibraryId: this.$route.query.id,
|
||||
ncrTrackVOList: JSON.stringify(this.content)
|
||||
ncrTrackVOList: this.content
|
||||
}
|
||||
downloadFile(this.url.exportData, this.$t('NonConformance') + '.xls', query, this.Deselect)
|
||||
downloadFilePost(this.url.exportData, this.$t('NonConformance') + '.xls', query, this.Deselect)
|
||||
},
|
||||
getList() {
|
||||
let query = {
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
:scroll="{x: 1000}"
|
||||
:data-source="dataList"
|
||||
:pagination="false"
|
||||
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
|
||||
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange,columnTitle:' ' }"
|
||||
:loading="loading">
|
||||
|
||||
</a-table>
|
||||
|
||||
@@ -182,7 +182,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getAction, postAction, downloadFile, deleteAction } from '@/api/manage'
|
||||
import { getAction, postAction, downloadFile, deleteAction ,downloadFilePost} from '@/api/manage'
|
||||
import PersonnelSelection from '@/components/PersonnelSelection/index'
|
||||
import store from '@/store/'
|
||||
|
||||
@@ -354,9 +354,9 @@
|
||||
handleExport() {
|
||||
let query = {
|
||||
...this.queryParam,
|
||||
ncrTrackVOList: JSON.stringify(this.content)
|
||||
ncrTrackVOList: this.content
|
||||
}
|
||||
downloadFile(this.url.exportData, this.$t('NonConformance') + '.xls', query, this.Deselect)
|
||||
downloadFilePost(this.url.exportData, this.$t('NonConformance') + '.xls', query, this.Deselect)
|
||||
},
|
||||
Deselect() {
|
||||
this.selectedRowKeys = []
|
||||
|
||||
Reference in New Issue
Block a user