0525bugFixed

This commit is contained in:
shijing 2022-05-25 16:40:48 +08:00
parent 274503442f
commit be095ce94f
1 changed files with 263 additions and 250 deletions

View File

@ -133,7 +133,7 @@
<el-row v-show="hasPicture"> <el-row v-show="hasPicture">
<el-form-item label="图表"> <el-form-item label="图表">
<div> <div>
<img id="canvasImg" :src="img" style="width:500px;height: 300px;position: absolute;top: -1000px;"> <img id="canvasImg" :src="img" alt="tupian">
<div style="position: relative;display: flex;flex-direction: column; <div style="position: relative;display: flex;flex-direction: column;
border: 1px solid #DCDFE6;"> border: 1px solid #DCDFE6;">
<canvas id="canvas" width="500" height="300"> <canvas id="canvas" width="500" height="300">
@ -170,6 +170,7 @@
<script> <script>
import {upFile} from "@/api/file"; import {upFile} from "@/api/file";
let preDrawAry = []; let preDrawAry = [];
export default { export default {
name: "index", name: "index",
@ -178,7 +179,8 @@
type: Array, type: Array,
default: () => { default: () => {
return [] return []
}} , }
},
formID: { formID: {
type: Number, type: Number,
default: 0 default: 0
@ -244,11 +246,11 @@
if (imag.length > 0) { if (imag.length > 0) {
that.img = new Image(); that.img = new Image();
that.img.crossOrigin = 'anonymous'; that.img.crossOrigin = 'anonymous';
let value = imag[0].field_value?imag[0].field_value:imag[0].draw_template; let value = imag[0].field_value!==null ? imag[0].field_value : imag[0].draw_template;
that.img = value; that.img =process.env.VUE_APP_BASE_API.replace('/api','')+ value;
setTimeout(function () { setTimeout(function () {
that.canvasInit(); that.canvasInit();
},500); }, 1000);
} }
}, },
data() { data() {
@ -434,10 +436,10 @@
}, },
//画布添加背景模板图 //画布添加背景模板图
draw() { draw() {
debugger;
this.ctx = document.getElementById('canvas').getContext('2d');
let canvasImg = document.getElementById("canvasImg"); let canvasImg = document.getElementById("canvasImg");
canvasImg.setAttribute("crossOrigin",'anonymous'); // canvasImg.setAttribute("crossOrigin", 'anonymous');
// canvasImg.style.width = '500px';
// canvasImg.style.height = '300px';
this.ctx.drawImage(canvasImg, 0, 0, 500, 300); this.ctx.drawImage(canvasImg, 0, 0, 500, 300);
}, },
// 叉号 // 叉号
@ -757,6 +759,7 @@
margin-right: 10px; margin-right: 10px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.hide { .hide {
display: none; display: none;
} }
@ -795,11 +798,13 @@
#res { #res {
display: inline-block; display: inline-block;
} }
.helpText { .helpText {
position: absolute; position: absolute;
top: 40px; top: 40px;
left: 100px; left: 100px;
} }
.adoptTip { .adoptTip {
position: absolute; position: absolute;
top: 38px; top: 38px;
@ -807,6 +812,7 @@
font-size: 12px; font-size: 12px;
color: #46ce7a; color: #46ce7a;
} }
.failTip { .failTip {
position: absolute; position: absolute;
top: 38px; top: 38px;
@ -814,4 +820,11 @@
font-size: 12px; font-size: 12px;
color: #ff0000; color: #ff0000;
} }
#canvasImg{
width:500px;
height: 300px;
position: absolute;
left: 50%;
transform: translateX(-50%)
}
</style> </style>