|
|
@@ -109,7 +109,6 @@ export class CanvasPhotoEditor {
|
|
|
get pages() { return this._pages }
|
|
|
set pages(newPages) {
|
|
|
const oldPages = this._pages; // ✅ 这就是旧值!
|
|
|
- console.log('saveHistory', this._pages, newPages)
|
|
|
// const isSave = this._pages.length !== newPages.length?true:!this._pages.some((ele, index) => this.isArrayEqual(ele.list, newPages[index].list))
|
|
|
this._pages = [...newPages]
|
|
|
this.resizeCanvas()
|
|
|
@@ -119,7 +118,6 @@ export class CanvasPhotoEditor {
|
|
|
// --- 数据 getter/setter ---
|
|
|
get selectedPageItem() { return this._selectedPageItem }
|
|
|
set selectedPageItem(newItem) {
|
|
|
- console.log('selectedPageItem', newItem)
|
|
|
this._selectedPageItem = { ...newItem }
|
|
|
this.updata({
|
|
|
selectedPageItem: this._selectedPageItem,
|
|
|
@@ -201,7 +199,6 @@ export class CanvasPhotoEditor {
|
|
|
|
|
|
// --- 核心:拖拽仅改坐标,不重绘 ---
|
|
|
async handleMouseDown(e) {
|
|
|
- console.log('handleMouseDown', e.button, this.tempArrow)
|
|
|
if (e.button === 2 && this.indexing) { // 右键
|
|
|
//结束标引
|
|
|
this.clearIndexing()
|
|
|
@@ -273,7 +270,6 @@ export class CanvasPhotoEditor {
|
|
|
return
|
|
|
}
|
|
|
const pageIndex = this.getPageIndexByClick(e)
|
|
|
- console.log('getPageIndexByClick', pageIndex, this.pages[pageIndex])
|
|
|
|
|
|
if (!this.show && pageIndex > -1 && this.setImgTitle.titleIndex > -1 && this.pages[pageIndex].list && this.pages[pageIndex].list[this.setImgTitle.titleIndex]) {//点击标题进行修改标题名称
|
|
|
let item = this.pages[pageIndex].item[this.setImgTitle.titleIndex]
|
|
|
@@ -339,7 +335,6 @@ export class CanvasPhotoEditor {
|
|
|
this.lastDrawOffsetX = this.drawOffsetX
|
|
|
this.lastDrawOffsetY = this.drawOffsetY
|
|
|
this.canvas.style.cursor = 'grabbing'
|
|
|
- console.log('pageIndex', this.pages, this._selectedPageItem, this.selectedPageItem, pageIndex)
|
|
|
this.drawAllPages()
|
|
|
}
|
|
|
|
|
|
@@ -412,7 +407,6 @@ export class CanvasPhotoEditor {
|
|
|
// 松开鼠标后仅重绘一次,确认最终位置
|
|
|
// this.drawDragPreview()
|
|
|
// 选中页面(仅点击时重绘一次)
|
|
|
- console.log('pageIndex', this.indexing, this.indexingNum)
|
|
|
}
|
|
|
moveItem(arr, fromIndex, toIndex) {
|
|
|
let newtoIndex = fromIndex < toIndex ? toIndex - 1 : toIndex;
|
|
|
@@ -422,7 +416,6 @@ export class CanvasPhotoEditor {
|
|
|
return newArr
|
|
|
}
|
|
|
handleMouseLeave() {
|
|
|
- console.log('handleMouseLeave', this.isDragging)
|
|
|
this.isDragging = false
|
|
|
this.dragPageData.drawing = false
|
|
|
this.dragPageData.movedIndex = 0
|
|
|
@@ -456,7 +449,6 @@ export class CanvasPhotoEditor {
|
|
|
const mouseX = (e.clientX - rect.left - this.drawOffsetX) / this.scale
|
|
|
const mouseY = (e.clientY - rect.top - this.drawOffsetY) / this.scale
|
|
|
const PhotoIndex = this.getPhotoPositionInPage(e)
|
|
|
- console.log('indexingLineList', this.indexingLineList)
|
|
|
if (PhotoIndex.itemIndex == -1) {
|
|
|
ElMessage.error("请选中对应的图片进行标引操作!");
|
|
|
return
|
|
|
@@ -468,7 +460,6 @@ export class CanvasPhotoEditor {
|
|
|
this.indexingStartY = mouseY
|
|
|
this.tempArrow.start = { ...PhotoIndex, x: mouseX, y: mouseY }
|
|
|
this.tempArrow.drawing = true;
|
|
|
- console.log('indexing', this.indexing, PhotoIndex, mouseX, mouseY)
|
|
|
}
|
|
|
/**
|
|
|
* 结束标引操作,计算鼠标在画布上的相对坐标并保存起始位置
|
|
|
@@ -481,12 +472,10 @@ export class CanvasPhotoEditor {
|
|
|
return
|
|
|
}
|
|
|
const oldPhotoIndex = this.indexingList[0]
|
|
|
- console.log('oldPhotoIndex', oldPhotoIndex, this.indexingList)
|
|
|
if (oldPhotoIndex.pageIndex == PhotoIndex.pageIndex && oldPhotoIndex.itemIndex == PhotoIndex.itemIndex) {
|
|
|
ElMessage.error("标引开始和结束图片不能相同!");
|
|
|
return
|
|
|
}
|
|
|
- console.log('indexing1111', this.indexing, oldPhotoIndex.pageIndex - PhotoIndex.pageIndex)
|
|
|
if (Math.abs(oldPhotoIndex.pageIndex - PhotoIndex.pageIndex) > 1) {
|
|
|
ElMessage.error("标引不支持跨页面!");
|
|
|
return
|
|
|
@@ -496,7 +485,6 @@ export class CanvasPhotoEditor {
|
|
|
const mouseX = (e.clientX - rect.left - this.drawOffsetX) / this.scale
|
|
|
const mouseY = (e.clientY - rect.top - this.drawOffsetY) / this.scale
|
|
|
let coordinate = this.pages[PhotoIndex.pageIndex].coordinate[PhotoIndex.itemIndex]
|
|
|
- console.log('coordinate', coordinate, PhotoIndex, oldPhotoIndex)
|
|
|
this.indexingEndX = mouseX
|
|
|
this.indexingEndY = mouseY
|
|
|
let startInfo = this.indexingList[0]
|
|
|
@@ -1805,7 +1793,6 @@ resizePageAndReflow(pages, pageIndex, itemValue) {
|
|
|
|
|
|
// 页面全局偏移(核心修正)
|
|
|
// const pageOffsetX = pageIndex * ((pageWith + 30) * perSheet); + this.pageMargin
|
|
|
- console.log(pageOffsetX, pageIndex, perSheet, this.pageWidth, 'pageOffsetX')
|
|
|
// 绘制连线
|
|
|
ctx.beginPath();
|
|
|
let last = points[points.length - 1];
|
|
|
@@ -1813,7 +1800,6 @@ resizePageAndReflow(pages, pageIndex, itemValue) {
|
|
|
const newcoordinateX = coordinate.x - (newcoorindex*this.pageMargin) - pageOffsetX;
|
|
|
points.forEach((p, i) => {
|
|
|
const newindex = (Math.round(p.x / this.pageWidth)) - (pageIndex*perSheet);
|
|
|
- console.log(newindex, 'newindex')
|
|
|
const itemOffsetX = newindex>0?newindex*this.pageMargin:0;
|
|
|
// p.x = p.x - pageOffsetX;
|
|
|
const x = p.x - pageOffsetX - itemOffsetX;
|
|
|
@@ -1826,7 +1812,6 @@ resizePageAndReflow(pages, pageIndex, itemValue) {
|
|
|
}
|
|
|
i === 0 ? ctx.moveTo(x, y) : ctx.lineTo(x, y);
|
|
|
});
|
|
|
- console.log(...points, 'pageOffsetX1', pageOffsetX)
|
|
|
ctx.stroke();
|
|
|
// T型端线(只在终点页画)
|
|
|
// if (currentIsEnd) {
|
|
|
@@ -1842,10 +1827,7 @@ resizePageAndReflow(pages, pageIndex, itemValue) {
|
|
|
ctx.lineTo(last.x, coordinate.y + coordinate.height);
|
|
|
}
|
|
|
ctx.stroke();
|
|
|
- }else{
|
|
|
- console.log(currentEnd, currentStart,'pageIndex', pageIndex, 'perSheet', perSheet)
|
|
|
}
|
|
|
-
|
|
|
ctx.restore();
|
|
|
});
|
|
|
}
|
|
|
@@ -1883,7 +1865,6 @@ resizePageAndReflow(pages, pageIndex, itemValue) {
|
|
|
this.exportPagesAsImages(paperType, name);
|
|
|
}
|
|
|
// this.drawAllPages();
|
|
|
- console.log('正在导出1');
|
|
|
}
|
|
|
async checkIndexing(mes = '此操作将会清除所有标引是否继续?', type = false) {
|
|
|
let selectIndexPage = this.dragPageData.drawing?Math.min(this.dragPageData.index,this.dragPageData.movedIndex):this.selectedPageIndex//拖拽模式判断是否有标引
|
|
|
@@ -1893,7 +1874,6 @@ resizePageAndReflow(pages, pageIndex, itemValue) {
|
|
|
if(this.dragPageData.drawing && newList.length){
|
|
|
this.dragPageData.drawing = false;
|
|
|
}
|
|
|
- console.log(type,this.selectedPageIndex,newList, this.indexingLineList, this.dragPageData.drawing)
|
|
|
let length = this.selectedPageIndex==-1?this.indexingLineList.length:newList.length;
|
|
|
// try {
|
|
|
if (length && await ElMessageBox.confirm(mes, '提示')) {
|