forked from github/dataease
fix: 部分仪表板导出模板失败
This commit is contained in:
parent
1c551ae3cc
commit
6fe299c5c9
@ -266,35 +266,40 @@ export default {
|
|||||||
downloadToTemplate() {
|
downloadToTemplate() {
|
||||||
const _this = this
|
const _this = this
|
||||||
_this.dataLoading = true
|
_this.dataLoading = true
|
||||||
_this.findStaticSource(function(staticResource) {
|
try {
|
||||||
html2canvas(document.getElementById('canvasInfoTemp')).then(canvas => {
|
_this.findStaticSource(function(staticResource) {
|
||||||
_this.dataLoading = false
|
html2canvas(document.getElementById('canvasInfoTemp')).then(canvas => {
|
||||||
const snapshot = canvas.toDataURL('image/jpeg', 0.1) // 0.1是图片质量
|
_this.dataLoading = false
|
||||||
if (snapshot !== '') {
|
const snapshot = canvas.toDataURL('image/jpeg', 0.1) // 0.1是图片质量
|
||||||
_this.templateInfo = {
|
if (snapshot !== '') {
|
||||||
name: _this.$store.state.panel.panelInfo.name,
|
_this.templateInfo = {
|
||||||
templateType: 'self',
|
name: _this.$store.state.panel.panelInfo.name,
|
||||||
snapshot: snapshot,
|
templateType: 'self',
|
||||||
panelStyle: JSON.stringify(_this.canvasStyleData),
|
snapshot: snapshot,
|
||||||
panelData: JSON.stringify(_this.componentData),
|
panelStyle: JSON.stringify(_this.canvasStyleData),
|
||||||
dynamicData: JSON.stringify(_this.panelViewDetailsInfo),
|
panelData: JSON.stringify(_this.componentData),
|
||||||
staticResource: JSON.stringify(staticResource || {})
|
dynamicData: JSON.stringify(_this.panelViewDetailsInfo),
|
||||||
|
staticResource: JSON.stringify(staticResource || {})
|
||||||
|
}
|
||||||
|
const blob = new Blob([JSON.stringify(_this.templateInfo)], { type: '' })
|
||||||
|
FileSaver.saveAs(blob, _this.$store.state.panel.panelInfo.name + '-TEMPLATE.DET')
|
||||||
}
|
}
|
||||||
const blob = new Blob([JSON.stringify(_this.templateInfo)], { type: '' })
|
})
|
||||||
FileSaver.saveAs(blob, _this.$store.state.panel.panelInfo.name + '-TEMPLATE.DET')
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
_this.dataLoading = false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 解析静态文件
|
// 解析静态文件
|
||||||
findStaticSource(callBack) {
|
findStaticSource(callBack) {
|
||||||
const staticResource = []
|
const staticResource = []
|
||||||
// 系统背景文件
|
// 系统背景文件
|
||||||
if (this.canvasStyleData.panel.imageUrl && this.canvasStyleData.panel.imageUrl.indexOf('static-resource') > -1) {
|
if (typeof this.canvasStyleData.panel.imageUrl === 'string' && this.canvasStyleData.panel.imageUrl.indexOf('static-resource') > -1) {
|
||||||
staticResource.push(this.canvasStyleData.panel.imageUrl)
|
staticResource.push(this.canvasStyleData.panel.imageUrl)
|
||||||
}
|
}
|
||||||
this.componentData.forEach(item => {
|
this.componentData.forEach(item => {
|
||||||
if (item.commonBackground && item.commonBackground.outerImage && item.commonBackground.outerImage.indexOf('static-resource') > -1) {
|
if (typeof item.commonBackground.outerImage === 'string' && item.commonBackground.outerImage.indexOf('static-resource') > -1) {
|
||||||
staticResource.push(item.commonBackground.outerImage)
|
staticResource.push(item.commonBackground.outerImage)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -308,7 +313,9 @@ export default {
|
|||||||
callBack()
|
callBack()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
callBack()
|
setTimeout(() => {
|
||||||
|
callBack()
|
||||||
|
}, 0)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user