Merge branch 'dev-3.8' of https://git.mesalab.cn/nezha/nezha-fronted into dev-3.9
This commit is contained in:
@@ -525,6 +525,7 @@ export default {
|
|||||||
// 兼容ie11
|
// 兼容ie11
|
||||||
const blobObject = new Blob([csv])
|
const blobObject = new Blob([csv])
|
||||||
window.navigator.msSaveOrOpenBlob(blobObject, chart.name + '.csv')
|
window.navigator.msSaveOrOpenBlob(blobObject, chart.name + '.csv')
|
||||||
|
this.$message.success(this.$t('tip.downloadSuccess'))
|
||||||
} else {
|
} else {
|
||||||
const blob = new Blob([csv])
|
const blob = new Blob([csv])
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
@@ -535,11 +536,12 @@ export default {
|
|||||||
link.click() // 点击下载
|
link.click() // 点击下载
|
||||||
document.body.removeChild(link) // 下载完成移除元素
|
document.body.removeChild(link) // 下载完成移除元素
|
||||||
window.URL.revokeObjectURL(href) // 释放blob对象
|
window.URL.revokeObjectURL(href) // 释放blob对象
|
||||||
|
this.$message.success(this.$t('tip.downloadSuccess'))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
convertTimeSertesToCSV (chartInfo) {
|
convertTimeSertesToCSV (chartInfo) {
|
||||||
const data = this.series
|
const data = this.series
|
||||||
let csv = 'time,legend,value\n'
|
let csv = '"time","legend","value"\n'
|
||||||
data.forEach((item, index) => {
|
data.forEach((item, index) => {
|
||||||
item.data.forEach(value => {
|
item.data.forEach(value => {
|
||||||
let val = formatScientificNotation(value[1], this.$lodash.get(chartInfo, 'param.decimals', 2))
|
let val = formatScientificNotation(value[1], this.$lodash.get(chartInfo, 'param.decimals', 2))
|
||||||
@@ -550,13 +552,16 @@ export default {
|
|||||||
unit = chartDataFormat.getUnit(this.$lodash.get(chartInfo, 'unit', 2))
|
unit = chartDataFormat.getUnit(this.$lodash.get(chartInfo, 'unit', 2))
|
||||||
}
|
}
|
||||||
val = unit.compute(val, index, -1, chartInfo.param.decimals || 2)
|
val = unit.compute(val, index, -1, chartInfo.param.decimals || 2)
|
||||||
csv += `${this.momentTz(value[0] * 1000)},${this.legends[index].alias},${val}\n`
|
csv += `"${this.momentTz(value[0] * 1000)}",${this.yasuo(this.legends[index].alias)},"${val}"\n`
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return csv
|
return csv
|
||||||
},
|
},
|
||||||
|
yasuo (str) {
|
||||||
|
return JSON.stringify(str)
|
||||||
|
},
|
||||||
convertOtherToCSV (chartInfo) {
|
convertOtherToCSV (chartInfo) {
|
||||||
let csv = 'legend,value\n'
|
let csv = '"legend","value"\n'
|
||||||
let keyByData = ''
|
let keyByData = ''
|
||||||
let legend = 'legend'
|
let legend = 'legend'
|
||||||
switch (chartInfo.type) {
|
switch (chartInfo.type) {
|
||||||
@@ -611,18 +616,18 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$lodash.get(this, keyByData, []).forEach(item => {
|
this.$lodash.get(this, keyByData, []).forEach(item => {
|
||||||
csv += `${item[legend]},${item.showValue}\n`
|
csv += `${this.yasuo(item[legend])},"${item.showValue}"\n`
|
||||||
})
|
})
|
||||||
return csv
|
return csv
|
||||||
},
|
},
|
||||||
convertTableToCSV (chartInfo) {
|
convertTableToCSV (chartInfo) {
|
||||||
let csv = ''
|
let csv = ''
|
||||||
csv = this.columns.map(item => item.title).join(',')
|
csv = this.columns.map(item => JSON.stringify(item.title)).join(',')
|
||||||
csv += '\n'
|
csv += '\n'
|
||||||
this.oldTableData.forEach(item => {
|
this.oldTableData.forEach(item => {
|
||||||
let arr = []
|
let arr = []
|
||||||
this.columns.forEach(column => {
|
this.columns.forEach(column => {
|
||||||
arr.push(item.display[column.title + 'display'].display)
|
arr.push(`${this.yasuo(item.display[column.title + 'display'].display)}`)
|
||||||
})
|
})
|
||||||
arr = arr.join(',')
|
arr = arr.join(',')
|
||||||
csv += arr
|
csv += arr
|
||||||
|
|||||||
Reference in New Issue
Block a user