update code

main
lijun 2024-09-16 11:11:45 +08:00
parent 3c24f82b78
commit 2826f4189e
2 changed files with 29 additions and 19 deletions

View File

@ -59,12 +59,12 @@
<el-table-column label="系统延迟时间" align="left" prop="system_delay" /> <el-table-column label="系统延迟时间" align="left" prop="system_delay" />
</el-table> </el-table>
<div class="print-page"></div> <div class="print-page"></div>
<el-row class="report-chart1" style="margin-top:20px;"> <el-row class="report-chart1" style="margin-top:20px;" :key="info.elPrint" :style="info.isPrint?'width:18cm;':''">
<el-col :span="12"> <el-col :span="info.isPrint ? 24 : 12">
<charts :id="'reportChart1-' + idx" width="100%" height="400px" <charts :id="'reportChart1-' + idx" width="100%" height="400px"
:render="opt => renderChart1(it, 'roc')"></charts> :render="opt => renderChart1(it, 'roc')"></charts>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="info.isPrint ? 24 : 12">
<charts :id="'reportChart2-' + idx" width="100%" height="400px" <charts :id="'reportChart2-' + idx" width="100%" height="400px"
:render="opt => renderChart1(it, 'rp')"></charts> :render="opt => renderChart1(it, 'rp')"></charts>
</el-col> </el-col>
@ -129,23 +129,25 @@ const info = reactive({
extra_evaluation_type: '', extra_evaluation_type: '',
tasks: [], tasks: [],
reportType: '', reportType: '',
robustness: [] robustness: [],
isPrint: false,
elPrint: 0,
}) })
const doExport=async () => { const doExport = async () => {
try{ try {
let dom=document.querySelector("#print_simulation_report_desc"); let dom = document.querySelector("#print_simulation_report_desc");
const canvas = await html2canvas(dom,{ const canvas = await html2canvas(dom, {
allowTaint: true, allowTaint: true,
useCORS: true, useCORS: true,
}); });
const img = canvas.toDataURL('image/png'); const img = canvas.toDataURL('image/png');
const link = document.createElement('a'); const link = document.createElement('a');
link.href = img; link.href = img;
link.setAttribute('download', info.report.report_name+ useDateFormat(new Date(),"YYYYMMDDHHmmss").value+'.png'); link.setAttribute('download', info.report.report_name + useDateFormat(new Date(), "YYYYMMDDHHmmss").value + '.png');
link.click(); link.click();
}catch(e){ } catch (e) {
ElMessage.error("导出图片失败!"); ElMessage.error("导出图片失败!");
console.error("导出图片失败!",e); console.error("导出图片失败!", e);
} }
} }
function goBack() { function goBack() {
@ -153,9 +155,16 @@ function goBack() {
} }
function doPrint() { function doPrint() {
document.querySelector("html").classList.add("report-print"); document.querySelector("html").classList.add("report-print");
window.print(); info.isPrint = true;
document.querySelector("html").classList.remove("report-print"); info.elPrint++;
setTimeout(() => {
window.print();
document.querySelector("html").classList.remove("report-print");
info.isPrint = false;
info.elPrint++;
}, 800);
} }
const doDelete = () => { const doDelete = () => {
let id = route.query.id; let id = route.query.id;
ElMessageBox.confirm("确认删除?", "警告", { ElMessageBox.confirm("确认删除?", "警告", {
@ -332,9 +341,10 @@ html.report-print {
.simulation-report-desc { .simulation-report-desc {
.el-scrollbar__view{ .el-scrollbar__view {
vertical-align: unset !important; vertical-align: unset !important;
} }
.el-table { .el-table {
table { table {
width: unset !important; width: unset !important;