1
0
Quellcode durchsuchen

拖拽page 判断标引是否影响需要清除

tangning vor 9 Stunden
Ursprung
Commit
c2c2a6060d
1 geänderte Dateien mit 15 neuen und 8 gelöschten Zeilen
  1. 15 8
      src/view/case/photos/canvas-photo-editor.js

+ 15 - 8
src/view/case/photos/canvas-photo-editor.js

@@ -299,10 +299,12 @@ export class CanvasPhotoEditor {
     const rect = this.canvas.getBoundingClientRect()
     const mouseX = (e.clientX - rect.left - this.drawOffsetX) / this.scale
     const mouseY = (e.clientY - rect.top - this.drawOffsetY) / this.scale
-    if (this.dragPageData.drawing && this.indexingLineList.length) {
-      await this.clearLineThrottle()
-      return
-    }
+    console.log('pageIndex', this.dragPageData.movedIndex, this.indexingLineList.length)
+    // if (this.dragPageData.drawing && this.indexingLineList.length) {
+    //   let check = await this.clearLineThrottle()
+    //   console.log('pageIndexcheck', check)
+    //   return
+    // }
     if (this.indexing && drawing) {
       const PhotoIndex = this.getPhotoPositionInPage(e)
       console.log('PhotoIndex', PhotoIndex, this.tempArrow)
@@ -335,9 +337,10 @@ export class CanvasPhotoEditor {
   // 先把节流函数定义在外面(关键!)
   clearLineThrottle = throttle(async () => {
     if (this.indexingLineList.length) {
-      await this.checkIndexing('修改页面排序将会清除所有标引是否继续?')
+      return await this.checkIndexing('修改页面排序将会清除所有标引是否继续?')
       this.drawAllPages()
     }
+    return false
   }, 1000, { leading: true, trailing: false })
 
   async handleMouseUp(e) {
@@ -345,7 +348,7 @@ export class CanvasPhotoEditor {
     this.canvas.style.cursor = 'grab'
     if (this.dragPageData.drawing && this.dragPageData.index != this.dragPageData.movedIndex) {//鼠标释放左键时,移动页面到指定位置)
       // 末尾必须加分号!!!
-      console.log('handleMouseUpdragPageData', this.dragPageData)
+      let check = await this.checkIndexing('修改页面排序将会清除所有标引是否继续?')
       let newPagelist = this.moveItem(this.pages, this.dragPageData.index, this.dragPageData.movedIndex)
       this.pages = newPagelist;
       this.dragPageData.drawing = false//退出page编辑模式
@@ -1897,10 +1900,14 @@ export class CanvasPhotoEditor {
     }
   }
   async checkIndexing(mes = '此操作将会清除所有标引是否继续?') {
+    let selectIndexPage = this.dragPageData.drawing?Math.min(this.dragPageData.index,this.dragPageData.movedIndex):this.selectedPageIndex//拖拽模式判断是否有标引
     let newList = this.indexingLineList.filter(ele =>{
-      return ele.indexingList.some(item => item.pageIndex > this.selectedPageIndex-1)
+      return ele.indexingList.some(item => item.pageIndex > selectIndexPage-1)
     })
-    console.log(this.indexingLineList,'this.indexingLineList', newList, this.selectedPageIndex)
+    if(this.dragPageData.drawing && newList.length){
+      this.dragPageData.drawing = false;
+    }
+    console.log(this.indexingLineList,'this.indexingLineList', newList, selectIndexPage, this.selectedPageIndex, this.dragPageData)
     let length = this.selectedPageIndex==-1?this.indexingLineList.length:newList.length;
     // try {
     if (length && await ElMessageBox.confirm(mes, '提示')) {