Bläddra i källkod

任务视图/项目视图单双击事件触发方式修改

yanshichao 1 år sedan
förälder
incheckning
ed15ccdd70
2 ändrade filer med 64 tillägg och 30 borttagningar
  1. 40 22
      src/views/task/projectView.vue
  2. 24 8
      src/views/task/view.vue

+ 40 - 22
src/views/task/projectView.vue

@@ -75,8 +75,6 @@
       @cell-mouse-enter="cellMouseEnter"
       @cell-mouse-leave="cellMouseLeave"
       :cell-style="cellStyle"
-      @cell-click="cellClick"
-      @cell-dblclick="cellDbClick"
       @row-click="rowClick"
       height="calc(100vh - 110px)"
       row-key="id"
@@ -292,6 +290,10 @@ export default {
       tableData: [],
       page: 0,
       total: 0,
+
+      clickCount: 0,
+      timer: null,
+
       open: false,
       form: {},
       feedbacks: [],
@@ -434,31 +436,47 @@ export default {
       this.open = true
     },
     rowClick(row, column, event) {
-      if (column.property != "taskName") {
-        return
-      }
-      if (row.status === '6' && row.auditUserId === this.userId) {
-        getTask(row.id).then(res => {
-          if (res.data.ancestorsTask && res.data.ancestorsTask.length === 0) {
-            this.detailForm = res.data;
-            this.auditForm = {
-              taskId: row.id,
-              auditResult: undefined,
-              value: undefined,
-              auditOpinion: undefined
+      if (column.property === "taskName") {
+        if (row.status === '6' && row.auditUserId === this.userId) {
+          getTask(row.id).then(res => {
+            if (res.data.ancestorsTask && res.data.ancestorsTask.length === 0) {
+              this.detailForm = res.data;
+              this.auditForm = {
+                taskId: row.id,
+                auditResult: undefined,
+                value: undefined,
+                auditOpinion: undefined
+              }
+              this.auditOpen = true;
+            } else {
+              this.detailForm = res.data
+              this.openDetail = true
             }
-            this.auditOpen = true;
-          } else {
+          })
+        } else {
+          getTask(row.id).then(res => {
             this.detailForm = res.data
             this.openDetail = true
-          }
-        })
+          })
+        }
+      }
+
+      this.clickCount++;
+      // 判断点击次数,如果是首次点击,则启动延时器
+      if (this.clickCount === 1) {
+        this.timer = setTimeout(() => {
+          // 执行单击操作
+          this.cellClick(row, column);
+          this.clickCount = 0
+        }, 300); // 设置延时时间,单位为毫秒
       } else {
-        getTask(row.id).then(res => {
-          this.detailForm = res.data
-          this.openDetail = true
-        })
+        // 如果点击次数大于1,则说明是双击操作,清除延时器,并执行双击操作
+        clearTimeout(this.timer);
+        this.cellDbClick(row, column);
+        this.clickCount = 0
       }
+
+
     },
     feedbackTypeChange(val) {
       if (val === '2') {

+ 24 - 8
src/views/task/view.vue

@@ -74,8 +74,6 @@
       @cell-mouse-enter="cellMouseEnter"
       @cell-mouse-leave="cellMouseLeave"
       :cell-style="cellStyle"
-      @cell-click="cellClick"
-      @cell-dblclick="cellDbClick"
       @row-click="rowClick"
       height="calc(100vh - 120px)"
       border>
@@ -411,6 +409,9 @@ export default {
       tableHeaders: [],
       tableData: [],
 
+      clickCount: 0,
+      timer: null,
+
       open: false,
       form: {},
       feedbacks: [],
@@ -549,13 +550,28 @@ export default {
       this.open = true
     },
     rowClick(row, column, event) {
-      if (column.property != "taskName") {
-        return
+      if (column.property == "taskName") {
+        getTask(row.id).then(res => {
+          this.detailForm = res.data
+          this.openDetail = true
+        })
       }
-      getTask(row.id).then(res => {
-        this.detailForm = res.data
-        this.openDetail = true
-      })
+
+      this.clickCount++;
+      // 判断点击次数,如果是首次点击,则启动延时器
+      if (this.clickCount === 1) {
+        this.timer = setTimeout(() => {
+          // 执行单击操作
+          this.cellClick(row, column);
+          this.clickCount = 0
+        }, 300); // 设置延时时间,单位为毫秒
+      } else {
+        // 如果点击次数大于1,则说明是双击操作,清除延时器,并执行双击操作
+        clearTimeout(this.timer);
+        this.cellDbClick(row, column);
+        this.clickCount = 0
+      }
+
     },
 
     feedbackTypeChange(val) {