|
|
@@ -6,11 +6,12 @@
|
|
|
<img v-if="paperImgUrl" :src="paperImgUrl" >
|
|
|
</div>
|
|
|
<div class="no_paper_url" v-if="paperImgUrl==''">
|
|
|
+ <div>暂无答题卡</div>
|
|
|
<!-- 暂无答题卡 -->
|
|
|
<!-- 请先制作模版 -->
|
|
|
</div>
|
|
|
<div v-if="showContextMenu" class="custom_context_menu" :style="{ top: contextMenuY + 'px', left: contextMenuX + 'px' }" @click="hideContextMenu">
|
|
|
- <div class="menu_item" @click="handleMenuAction('download')">图片另存为(放大后点另存可提高图片分率)</div>
|
|
|
+ <div class="menu_item" @click="handleMenuAction('download')">图片另存为</div>
|
|
|
<div class="menu_item" @click="handleMenuAction('fitScreen')">适合屏幕</div>
|
|
|
<div class="menu_item" @click="handleMenuAction('zoomIn')">放大(向上滚轮)</div>
|
|
|
<div class="menu_item" @click="handleMenuAction('zoomOut')">缩小(向下滚轮)</div>
|
|
|
@@ -211,11 +212,11 @@ export default {
|
|
|
deep: true // 如果需要深度监听数组内部对象的变化
|
|
|
},//边框数据
|
|
|
|
|
|
- currentId()
|
|
|
- {
|
|
|
- // console.log("当前选中项的id变化了",this.currentId);
|
|
|
- this.drawImage();//更新边框数据并重新绘制
|
|
|
- },
|
|
|
+ // currentId()
|
|
|
+ // {
|
|
|
+ // // console.log("当前选中项的id变化了",this.currentId);
|
|
|
+ // this.drawImage();//更新边框数据并重新绘制
|
|
|
+ // },
|
|
|
|
|
|
|
|
|
},
|
|
|
@@ -371,7 +372,6 @@ export default {
|
|
|
|
|
|
// 在canvas上按当前显示尺寸绘制所有试卷图片
|
|
|
exportCtx.drawImage(this.image, 0, 0, this.paperImgInfo.width, this.paperImgInfo.height);
|
|
|
-
|
|
|
// 重新绘制标注信息到导出canvas上(按原始图片尺寸)
|
|
|
this.DrawDataInfoCommon(exportCtx,1,1);//导出按原试卷尺寸
|
|
|
|
|
|
@@ -669,10 +669,10 @@ export default {
|
|
|
console.log("打印当前的批阅块数组",blockList);
|
|
|
const drawLineData=JSON.parse(item.drawLineData);
|
|
|
console.log("打印drawLineData",drawLineData);
|
|
|
-
|
|
|
if(blockList.length>0)
|
|
|
{
|
|
|
//跨页的
|
|
|
+ let jh=0;//打印需要减去的高度 跨页的
|
|
|
blockList.forEach((blockItem,index) => {
|
|
|
console.log("打印blockItem",blockItem);
|
|
|
if(blockItem.page==this.currentPage)
|
|
|
@@ -685,7 +685,7 @@ export default {
|
|
|
let drawItem=drawlineItem;
|
|
|
if(findIndex==index)
|
|
|
{
|
|
|
- drawItem=this.FindTargetObj(drawlineItem,blockList);
|
|
|
+ // drawItem=this.FindTargetObj(drawlineItem,blockList);
|
|
|
blockPoint=blockList[findIndex];
|
|
|
|
|
|
|
|
|
@@ -723,9 +723,9 @@ export default {
|
|
|
console.log("打印blockList",blockList);
|
|
|
const coords = {
|
|
|
x: this.GetInteger(drawItem.x * zoomScale + offsetX),
|
|
|
- y: this.GetInteger(drawItem.y * zoomScale + offsetY - jHeight * zoomScale),
|
|
|
+ y: this.GetInteger(drawItem.y * zoomScale + offsetY - jh * zoomScale),
|
|
|
endX: this.GetInteger(drawItem.endX * zoomScale + offsetX),
|
|
|
- endY: this.GetInteger(drawItem.endY * zoomScale + offsetY - jHeight * zoomScale)
|
|
|
+ endY: this.GetInteger(drawItem.endY * zoomScale + offsetY - jh * zoomScale)
|
|
|
};
|
|
|
this.DrawHorizontalLine(coords.x, coords.y, coords.endX, coords.endY,ctx);
|
|
|
break;
|
|
|
@@ -735,9 +735,9 @@ export default {
|
|
|
// 绘制波浪线
|
|
|
const coords = {
|
|
|
startX: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
|
|
|
- startY: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2)),
|
|
|
+ startY: parseFloat(((drawItem.y-jh) * zoomScale + offsetY).toFixed(2)),
|
|
|
endX: parseFloat((drawItem.endX * zoomScale + offsetX).toFixed(2)),
|
|
|
- endY: parseFloat((drawItem.endY * zoomScale + offsetY).toFixed(2))
|
|
|
+ endY: parseFloat(((drawItem.endY-jh) * zoomScale + offsetY).toFixed(2))
|
|
|
};
|
|
|
this.DrawWaveLine(coords.startX, coords.startY, coords.endX, coords.endY,ctx);
|
|
|
break;
|
|
|
@@ -757,7 +757,25 @@ export default {
|
|
|
this.DrawText(coords.x, coords.y, drawItem.text,ctx);
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
+ case 6:
|
|
|
+ {
|
|
|
+ // 绘制对号
|
|
|
+ const coords = {
|
|
|
+ x: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
|
|
|
+ y: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2))
|
|
|
+ };
|
|
|
+ this.DrawText(coords.x, coords.y, '✔',ctx);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 7: {
|
|
|
+ // 绘制对号
|
|
|
+ const coords = {
|
|
|
+ x: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
|
|
|
+ y: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2))
|
|
|
+ };
|
|
|
+ this.DrawText(coords.x, coords.y, '✘',ctx);
|
|
|
+ break;
|
|
|
+ }
|
|
|
default:
|
|
|
console.warn('未知的绘图类型:', drawItem.drawType);
|
|
|
}
|
|
|
@@ -765,18 +783,18 @@ export default {
|
|
|
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
+ jh=jh+blockItem.h;
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ //非跨页的数据
|
|
|
for(const [index, drawItem] of drawLineData.entries()) {
|
|
|
console.log("打印drawItem",drawItem);
|
|
|
// 计算通用的缩放因子,避免重复计算
|
|
|
const zoomScale = zoomRate * scale;
|
|
|
const offsetX = blockPoint.x * zoomScale;
|
|
|
const offsetY = blockPoint.y * zoomScale;
|
|
|
-
|
|
|
// 扣分点 加分点 标记// 1:文字 (扣分留痕 显示扣分信息) 2:划线 3:波浪线 4:画笔 5:评语
|
|
|
switch(drawItem.drawType) {
|
|
|
case 1: {
|
|
|
@@ -839,6 +857,25 @@ export default {
|
|
|
this.DrawText(coords.x, coords.y, drawItem.text,ctx);
|
|
|
break;
|
|
|
}
|
|
|
+ case 6:
|
|
|
+ {
|
|
|
+ // 绘制对号
|
|
|
+ const coords = {
|
|
|
+ x: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
|
|
|
+ y: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2))
|
|
|
+ };
|
|
|
+ this.DrawText(coords.x, coords.y, '✔',ctx);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 7: {
|
|
|
+ // 绘制对号
|
|
|
+ const coords = {
|
|
|
+ x: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
|
|
|
+ y: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2))
|
|
|
+ };
|
|
|
+ this.DrawText(coords.x, coords.y, '✘',ctx);
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
default:
|
|
|
console.warn('未知的绘图类型:', drawItem.drawType);
|
|
|
@@ -846,82 +883,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- // for(const [index, drawItem] of drawLineData.entries()) {
|
|
|
- // console.log("打印drawItem",drawItem);
|
|
|
- // // 计算通用的缩放因子,避免重复计算
|
|
|
- // const zoomScale = zoomRate * scale;
|
|
|
- // const offsetX = blockPoint.x * zoomScale;
|
|
|
- // const offsetY = blockPoint.y * zoomScale;
|
|
|
-
|
|
|
- // // 扣分点 加分点 标记// 1:文字 (扣分留痕 显示扣分信息) 2:划线 3:波浪线 4:画笔 5:评语
|
|
|
- // switch(drawItem.drawType) {
|
|
|
- // case 1: {
|
|
|
- // // 文字类型(扣分点/加分点标记)
|
|
|
- // const fontSize = Math.max(12, 40 * zoomScale);
|
|
|
- // ctx.font = `${fontSize}px Arial`;
|
|
|
- // ctx.fillStyle = '#D81E06';
|
|
|
- // ctx.textAlign = 'center';
|
|
|
- // ctx.textBaseline = 'middle';
|
|
|
-
|
|
|
- // const x = drawItem.x * zoomScale + offsetX;
|
|
|
- // const y = drawItem.y * zoomScale + offsetY;
|
|
|
-
|
|
|
- // if(drawItem.type==='reduce') {
|
|
|
- // ctx.fillText('-'+drawItem.score, x, y);
|
|
|
- // } else if(drawItem.type==='bonus') {
|
|
|
- // ctx.fillText('+'+drawItem.score, x, y);
|
|
|
- // }
|
|
|
- // break;
|
|
|
- // }
|
|
|
-
|
|
|
- // case 2: {
|
|
|
- // // 绘制横线
|
|
|
- // console.log("打印需要减去的高度",jHeight);
|
|
|
- // jHeight=0;
|
|
|
- // console.log("打印blockList",blockList);
|
|
|
- // const coords = {
|
|
|
- // x: this.GetInteger(drawItem.x * zoomScale + offsetX),
|
|
|
- // y: this.GetInteger(drawItem.y * zoomScale + offsetY - jHeight * zoomScale),
|
|
|
- // endX: this.GetInteger(drawItem.endX * zoomScale + offsetX),
|
|
|
- // endY: this.GetInteger(drawItem.endY * zoomScale + offsetY - jHeight * zoomScale)
|
|
|
- // };
|
|
|
- // this.DrawHorizontalLine(coords.x, coords.y, coords.endX, coords.endY);
|
|
|
- // break;
|
|
|
- // }
|
|
|
-
|
|
|
- // case 3: {
|
|
|
- // // 绘制波浪线
|
|
|
- // const coords = {
|
|
|
- // startX: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
|
|
|
- // startY: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2)),
|
|
|
- // endX: parseFloat((drawItem.endX * zoomScale + offsetX).toFixed(2)),
|
|
|
- // endY: parseFloat((drawItem.endY * zoomScale + offsetY).toFixed(2))
|
|
|
- // };
|
|
|
- // this.DrawWaveLine(coords.startX, coords.startY, coords.endX, coords.endY);
|
|
|
- // break;
|
|
|
- // }
|
|
|
-
|
|
|
- // case 4:
|
|
|
- // // 绘制画笔数据
|
|
|
- // this.DrawPenLine(drawItem,blockPoint);
|
|
|
- // break;
|
|
|
-
|
|
|
- // case 5: {
|
|
|
- // // 绘制评语
|
|
|
- // const coords = {
|
|
|
- // x: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
|
|
|
- // y: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2))
|
|
|
- // };
|
|
|
- // this.DrawText(coords.x, coords.y, drawItem.text);
|
|
|
- // break;
|
|
|
- // }
|
|
|
-
|
|
|
- // default:
|
|
|
- // console.warn('未知的绘图类型:', drawItem.drawType);
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -1552,6 +1513,24 @@ export default {
|
|
|
this.DrawText(coords.x, coords.y, drawItem.text);
|
|
|
break;
|
|
|
}
|
|
|
+ case 6: {
|
|
|
+ // 绘制对号
|
|
|
+ const coords = {
|
|
|
+ x: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
|
|
|
+ y: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2))
|
|
|
+ };
|
|
|
+ this.DrawText(coords.x, coords.y, '✔');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 7: {
|
|
|
+ // 绘制错号
|
|
|
+ const coords = {
|
|
|
+ x: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
|
|
|
+ y: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2))
|
|
|
+ };
|
|
|
+ this.DrawText(coords.x, coords.y, '✘');
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
default:
|
|
|
console.warn('未知的绘图类型:', drawItem.drawType);
|
|
|
@@ -1609,20 +1588,20 @@ export default {
|
|
|
},
|
|
|
|
|
|
//画横线
|
|
|
- DrawHorizontalLine(x1,y1,x2,y2)
|
|
|
+ DrawHorizontalLine(x1,y1,x2,y2,ctx = null)
|
|
|
{
|
|
|
console.log("画横线起始坐标点",x1, y1, x2, y2);
|
|
|
- const canvas = this.$refs.paperCanvas;
|
|
|
- const ctx = canvas.getContext('2d');
|
|
|
- ctx.strokeStyle = 'red';//设置红色
|
|
|
- ctx.lineWidth = 2;//线条宽度
|
|
|
- ctx.beginPath();
|
|
|
- ctx.moveTo(x1, y1);
|
|
|
- ctx.lineTo(x2, y2);
|
|
|
- ctx.stroke();
|
|
|
+ // 如果没有传入上下文,则使用当前canvas的上下文
|
|
|
+ const canvasContext = ctx || this.$refs.paperCanvas.getContext('2d');
|
|
|
+ canvasContext.strokeStyle = 'red';//设置红色
|
|
|
+ canvasContext.lineWidth = 2;//线条宽度
|
|
|
+ canvasContext.beginPath();
|
|
|
+ canvasContext.moveTo(x1, y1);
|
|
|
+ canvasContext.lineTo(x2, y2);
|
|
|
+ canvasContext.stroke();
|
|
|
},
|
|
|
//画波浪线
|
|
|
- DrawWaveLine(startX, startY, endX, endY)
|
|
|
+ DrawWaveLine(startX, startY, endX, endY,ctx = null)
|
|
|
{
|
|
|
// console.log("画波浪线起始坐标点",startX, startY, endX, endY);
|
|
|
const amplitude = 2; // 波浪的宽度
|
|
|
@@ -1632,68 +1611,67 @@ export default {
|
|
|
const dy=endY-startY;
|
|
|
|
|
|
|
|
|
- // 开始绘制
|
|
|
- const canvas = this.$refs.paperCanvas;
|
|
|
- const ctx = canvas.getContext('2d');
|
|
|
- ctx.strokeStyle = 'red';//设置红色
|
|
|
- ctx.lineWidth = 2;//线条宽度
|
|
|
+ // 如果没有传入上下文,则使用当前canvas的上下文
|
|
|
+ const canvasContext = ctx || this.$refs.paperCanvas.getContext('2d');
|
|
|
+ canvasContext.strokeStyle = 'red';//设置红色
|
|
|
+ canvasContext.lineWidth = 2;//线条宽度
|
|
|
// 清除之前的线条
|
|
|
// ctx.clearRect(0, 0, this.canvasInfo.width, this.canvasInfo.height);
|
|
|
- ctx.beginPath();
|
|
|
- ctx.moveTo(startX, startY);//绘制第一个点
|
|
|
+ canvasContext.beginPath();
|
|
|
+ canvasContext.moveTo(startX, startY);//绘制第一个点
|
|
|
//绘制波浪
|
|
|
// 绘制波浪线
|
|
|
for (let x = startX; x <= endX; x += 1) {
|
|
|
const y = startY + dy * (x - startX) / dx + amplitude * Math.sin(frequency * (x - startX));
|
|
|
- ctx.lineTo(x, y);
|
|
|
+ canvasContext.lineTo(x, y);
|
|
|
}
|
|
|
// ctx.lineTo(endX, endY);//绘制最后一个点
|
|
|
// ctx.lineWidth = 2; // 设置线条宽度
|
|
|
- ctx.stroke();
|
|
|
+ canvasContext.stroke();
|
|
|
},
|
|
|
|
|
|
//绘制画笔数据
|
|
|
- DrawPenLine(data,blockPoint)
|
|
|
+ DrawPenLine(data,blockPoint,zoomRate,scale, ctx = null)
|
|
|
{
|
|
|
|
|
|
- let linelist=data.drawlineData;
|
|
|
+ console.log("打印绘制画笔数据",data);
|
|
|
+ let linelist=data.drawlineData;
|
|
|
if(linelist.length>0)
|
|
|
{
|
|
|
- const canvas = this.$refs.paperCanvas;
|
|
|
- const ctx = canvas.getContext('2d');
|
|
|
- ctx.strokeStyle = 'red';//设置红色
|
|
|
- ctx.lineWidth = 2;//线条宽度
|
|
|
+ // 如果没有传入上下文,则使用当前canvas的上下文
|
|
|
+ const canvasContext = ctx || this.$refs.paperCanvas.getContext('2d');
|
|
|
+ canvasContext.strokeStyle = 'red';//设置红色
|
|
|
+ canvasContext.lineWidth = 2;//线条宽度
|
|
|
// 开始绘制
|
|
|
- ctx.beginPath();
|
|
|
+ canvasContext.beginPath();
|
|
|
|
|
|
// 绘制路径
|
|
|
for (let i = 0; i < linelist.length; i++) {
|
|
|
if(blockPoint)
|
|
|
{
|
|
|
- let x=parseFloat(((linelist[i].x + blockPoint.x)* this.zoomRate * this.scale).toFixed(2));
|
|
|
- let y=parseFloat(((linelist[i].y + blockPoint.y)* this.zoomRate * this.scale).toFixed(2));
|
|
|
- ctx.lineTo(x, y);
|
|
|
+ let x=parseFloat(((linelist[i].x + blockPoint.x)* zoomRate * scale).toFixed(2));
|
|
|
+ let y=parseFloat(((linelist[i].y + blockPoint.y)* zoomRate * scale).toFixed(2));
|
|
|
+ canvasContext.lineTo(x, y);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- ctx.stroke();
|
|
|
- ctx.closePath();
|
|
|
+ canvasContext.stroke();
|
|
|
+ canvasContext.closePath();
|
|
|
}
|
|
|
},
|
|
|
|
|
|
//绘制文字
|
|
|
- DrawText(startX, startY, text)
|
|
|
+ DrawText(startX, startY, text , ctx = null)
|
|
|
{
|
|
|
- // 开始绘制
|
|
|
- const canvas = this.$refs.paperCanvas;
|
|
|
- const ctx = canvas.getContext('2d');
|
|
|
+ // 如果没有传入上下文,则使用当前canvas的上下文
|
|
|
+ const canvasContext = ctx || this.$refs.paperCanvas.getContext('2d');
|
|
|
// 设置字体样式
|
|
|
- ctx.font = '15px Arial';
|
|
|
- ctx.fillStyle = 'red';
|
|
|
- ctx.textAlign = 'left';
|
|
|
+ canvasContext.font = '15px Arial';
|
|
|
+ canvasContext.fillStyle = 'red';
|
|
|
+ canvasContext.textAlign = 'left';
|
|
|
// ctx.textBaseline = 'middle';
|
|
|
// 绘制文字
|
|
|
- ctx.fillText(text,startX, startY);
|
|
|
+ canvasContext.fillText(text,startX, startY);
|
|
|
},
|
|
|
|
|
|
//下载图片绘制
|
|
|
@@ -2103,6 +2081,8 @@ export default {
|
|
|
position: absolute;
|
|
|
cursor: pointer;
|
|
|
z-index: 9;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
img
|
|
|
{
|
|
|
width: 100%;
|