NEZ-3174 feat:notebook导出pdf
This commit is contained in:
@@ -538,13 +538,13 @@ export default {
|
|||||||
if (window.navigator.msSaveOrOpenBlob) {
|
if (window.navigator.msSaveOrOpenBlob) {
|
||||||
// 兼容ie11
|
// 兼容ie11
|
||||||
const blobObject = new Blob([res.data])
|
const blobObject = new Blob([res.data])
|
||||||
window.navigator.msSaveOrOpenBlob(blobObject, this.obj.name)
|
window.navigator.msSaveOrOpenBlob(blobObject, this.obj.name + '.json')
|
||||||
} else {
|
} else {
|
||||||
const url = URL.createObjectURL(new Blob([res.data]))
|
const url = URL.createObjectURL(new Blob([res.data]))
|
||||||
const a = document.createElement('a')
|
const a = document.createElement('a')
|
||||||
document.body.appendChild(a) // 此处增加了将创建的添加到body当中
|
document.body.appendChild(a) // 此处增加了将创建的添加到body当中
|
||||||
a.href = url
|
a.href = url
|
||||||
a.download = this.obj.name
|
a.download = this.obj.name + '.json'
|
||||||
a.target = '_blank'
|
a.target = '_blank'
|
||||||
a.click()
|
a.click()
|
||||||
a.remove() // 将a标签移除
|
a.remove() // 将a标签移除
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import axios from 'axios'
|
||||||
import bus from '@/libs/bus'
|
import bus from '@/libs/bus'
|
||||||
|
|
||||||
function create (f) {
|
function create (f) {
|
||||||
@@ -145,34 +146,26 @@ export default {
|
|||||||
downloadSnapshot () {
|
downloadSnapshot () {
|
||||||
let total = 10
|
let total = 10
|
||||||
let loaded = 0
|
let loaded = 0
|
||||||
this.$get(`/visual/${this.api}/snapshot/download/` + this.tid, {}, {
|
axios.get(`/visual/${this.api}/snapshot/download/` + this.tid, {
|
||||||
|
responseType: 'blob',
|
||||||
onDownloadProgress: function (progressEvent) {
|
onDownloadProgress: function (progressEvent) {
|
||||||
// 处理原生进度事件
|
// 处理原生进度事件
|
||||||
total = progressEvent.total
|
total = progressEvent.total
|
||||||
loaded = progressEvent.loaded
|
loaded = progressEvent.loaded
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
const self = this
|
|
||||||
const fileName = this.showPanel.name
|
const fileName = this.showPanel.name
|
||||||
if (res.type == 'application/json') {
|
|
||||||
const reader = new FileReader() // 创建一个FileReader实例
|
|
||||||
reader.readAsText(res, 'utf-8') // 读取文件,结果用字符串形式表示
|
|
||||||
reader.onload = function () { // 读取完成后,**获取reader.result**
|
|
||||||
const { msg } = JSON.parse(reader.result)
|
|
||||||
self.$message.error(msg) // 弹出错误提示
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (loaded < total) {
|
if (loaded < total) {
|
||||||
this.$message.error(res.msg || res.error || res || this.$t('NetWork Error'))
|
this.$message.error(res.msg || res.error || this.$t('NetWork Error'))
|
||||||
|
this.prevent_opt.import = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (window.navigator.msSaveOrOpenBlob) {
|
if (window.navigator.msSaveOrOpenBlob) {
|
||||||
// 兼容ie11
|
// 兼容ie11
|
||||||
const blobObject = new Blob([res])
|
const blobObject = new Blob([res.data])
|
||||||
window.navigator.msSaveOrOpenBlob(blobObject, fileName + '.' + (this.showPanel.format || 'html'))
|
window.navigator.msSaveOrOpenBlob(blobObject, fileName + '.' + (this.showPanel.format || 'html'))
|
||||||
} else {
|
} else {
|
||||||
const blob = new Blob([res])
|
const blob = new Blob([res.data])
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
const href = window.URL.createObjectURL(blob) // 下载链接
|
const href = window.URL.createObjectURL(blob) // 下载链接
|
||||||
link.href = href
|
link.href = href
|
||||||
@@ -184,8 +177,20 @@ export default {
|
|||||||
}
|
}
|
||||||
this.prevent_opt.import = false
|
this.prevent_opt.import = false
|
||||||
this.$emit('update:snapshotVisible', false)
|
this.$emit('update:snapshotVisible', false)
|
||||||
}, (res) => {
|
}, error => {
|
||||||
this.$message.error(res.msg || res.error)
|
const $self = this
|
||||||
|
const reader = new FileReader()
|
||||||
|
reader.onload = function (event) {
|
||||||
|
const responseText = reader.result
|
||||||
|
const exception = JSON.parse(responseText)
|
||||||
|
if (exception.message) {
|
||||||
|
$self.$message.error(exception.message)
|
||||||
|
} else {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reader.readAsText(error.response.data)
|
||||||
|
this.prevent_opt.import = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 关闭定时器 取消任务
|
// 关闭定时器 取消任务
|
||||||
|
|||||||
@@ -201,6 +201,9 @@ export default {
|
|||||||
if (!this.isExportHtml) {
|
if (!this.isExportHtml) {
|
||||||
this.onScroll()
|
this.onScroll()
|
||||||
} else {
|
} else {
|
||||||
|
setTimeout(() => {
|
||||||
|
window.dataJson.AllChartDataload = true
|
||||||
|
}, 1000)
|
||||||
this.onScroll(999999)
|
this.onScroll(999999)
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user