Merge branch 'dev-3.2' of https://git.mesalab.cn/nezha/nezha-fronted into dev-3.3

# Conflicts:
#	nezha-fronted/src/components/common/js/htmlToPdf.js
This commit is contained in:
zhangyu
2022-04-12 09:29:21 +08:00
3 changed files with 1424 additions and 696 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -13,8 +13,8 @@
"dependencies": {
"@johmun/vue-tags-input": "^2.1.0",
"@riophae/vue-treeselect": "^0.4.0",
"@svgdotjs/svg.js": "^3.0.16",
"@svgdotjs/svg.panzoom.js": "^2.1.1",
"@svgdotjs/svg.js": "3.0.16",
"@svgdotjs/svg.panzoom.js": "2.1.1",
"@topology/activity-diagram": "^0.3.0",
"@topology/chart-diagram": "^0.3.0",
"@topology/class-diagram": "^0.3.0",

View File

@@ -41,6 +41,9 @@
<el-dropdown-item v-has="'main_edit'">
<div id="chart-temp-sync" @click="chartBySync"><i class="nz-icon nz-icon-sync"></i>{{ $t('overall.syncChart') }}</div>
</el-dropdown-item>
<el-dropdown-item v-has="'main_edit'">
<div id="chart-htmltopdf" @click="htmlToPdf"><i class="nz-icon nz-icon-download1"></i>{{ $t('overall.downloadToPdf') }}</div>
</el-dropdown-item>
</template>
</top-tool-more-options>
</div>
@@ -72,6 +75,9 @@
<el-dropdown-item v-has="'main_edit'">
<div id="chart-temp-sync" @click="chartBySync"><i class="nz-icon nz-icon-sync"></i>{{ $t('overall.syncChart') }}</div>
</el-dropdown-item>
<el-dropdown-item v-has="'main_edit'">
<div id="chart-htmltopdf" @click="htmlToPdf"><i class="nz-icon nz-icon-download1"></i>{{ $t('overall.downloadToPdf') }}</div>
</el-dropdown-item>
</template>
</top-tool-more-options>
</div>
@@ -146,9 +152,10 @@ import chartTempBox from '@/components/common/rightBox/chartTempBox'
import topToolMoreOptions from '@/components/common/popBox/topToolMoreOptions'
import detailViewRightMixin from '@/components/common/mixin/detailViewRightMixin'
import { randomcolor } from '@/components/common/js/radomcolor/randomcolor'
import htmlToPdfMixin from '@/components/common/mixin/htmlToPdfMixin'
export default {
name: 'panelTabNew',
mixins: [subDataListMixin, detailViewRightMixin],
mixins: [subDataListMixin, detailViewRightMixin, htmlToPdfMixin],
props: {
from: String,
obj: Object,
@@ -172,6 +179,7 @@ export default {
data () {
return {
fromRoute,
pdfId: 'pdfDom',
panelTabLoading: false,
showTopBtn: false, // top按钮
visible: false,
@@ -724,6 +732,42 @@ export default {
if (type === 'duplicate') {
this.editChart(chartInfo, true)
}
},
htmlToPdf () {
const dom = document.getElementsByClassName(this.pdfId)[0]
if (dom) {
// dom = dom.getElementsByClassName('vue-grid-layout')[0]
this.scrollbarWrap.scrollTop = this.scrollbarWrap.scrollHeight
this.$refs.chartList.onScroll(this.scrollbarWrap.scrollTop)
let flag = true
this.showScreenLoading(true)
let timer = setInterval(() => {
flag = true
this.$refs.chartList.copyDataList.forEach(chart => {
if (chart.type !== 'group') {
flag = flag && chart.loaded
} else if (chart.collapse) {
chart.children.forEach(groupChart => {
flag = flag && groupChart.loaded
})
}
})
if (flag) {
clearInterval(timer)
timer = null
setTimeout(() => {
document.body.style.height = 'auto'
// document.getElementsByTagName('html')[0].style.overflow = 'visible'
const position = dom.getBoundingClientRect()
console.log(position)
this.getPdf(dom, -1 * position.left, -1 * position.top)
// this.getPdf(dom, 0, 0)
}, 2000)
}
}, 200)
} else {
this.showScreenLoading(false)
}
}
},
mounted () {