Bladeren bron

甘特图增加点击事件

QuYueTing 1 maand geleden
bovenliggende
commit
5c0a5951b2

+ 78 - 7
fhKeeper/formulahousekeeper/timesheet/src/views/project/gantt.vue

@@ -1,9 +1,16 @@
 {{ src/components/Gantt.vue }}
 <template>
-    
-  <div ref="gantt">
-
+  <div ref="ganttContainer">
   </div>
+    <!-- 任务详情信息弹出框 -->
+    <!-- <el-dialog :class="addForm.id==null?'':'jm'" :title="title" v-if="taskFormVisible" :visible.sync="taskFormVisible" 
+      :close-on-click-modal="false" customClass="customWidth" width="840px" :top="'6vh'">
+          <taskComponent ref="thskComponents" :integrationTask="integrationTask" :showOrNot="showOrNot" @closeBounced="closeBounced"></taskComponent>
+          <div slot="title" v-if="addForm.parentTid != null">
+              <el-page-header  @back="backToParentTask" :title="$t('parenttask')" :content="addForm.parentTname"></el-page-header>
+          </div>
+      </el-dialog> -->
+  
 </template>
 
 <script>
@@ -22,7 +29,20 @@ export default {
       }
     },
     stafforpro: '',
-    valueDate:[]
+    valueDate:[],
+  },
+  data() {
+    return {
+      containerRect:null,
+      taskFormVisible: false,
+      addForm:null,
+      addLoading: false,
+      title: this.$t('createtask '),
+      commentList:[],
+      showOrNot: false,
+      integrationTask:null,
+      taskComponentFlg: false,
+    };
   },
   created:function(){
     // gantt.clearAll()
@@ -30,7 +50,38 @@ export default {
   },
  
   methods: {
-      
+    handleEmptyClick(event) {
+      const x = event.clientX - this.containerRect.left;
+      const y = event.clientY - this.containerRect.top;
+
+      // 获取点击位置对应的时间轴日期
+      const date = gantt.dateFromPos(x);
+      console.log(date);
+
+      // this.addTask();
+    },
+    addTask() {
+        this.taskFormVisible = true;
+        // this.addForm = {projectId: stage.projectId, groupId: stage.groupId, stagesId: stage.id, taskLevel:0, planHours: 8, taskType: 0};
+        this.addForm = {projectId: '', groupId: '', stagesId: '', taskLevel:0, planHours: 8, taskType: 0};
+        this.addLoading = false;
+        this.title=this.$t('createtask ');
+        this.commentList = [];
+        this.showOrNot = true
+
+        let obj = {
+            create: true,
+            addForm: this.addForm,
+            executorListFront: [{executorId:null, planHours:8}],
+            stage: this.addForm,
+            integrationTaskNingwai: this.integrationTaskNingwai,
+            taskVue: true,         
+            meetingId: this.addForm.meetingId
+        }
+        this.integrationTask = obj
+
+        this.taskComponentFlg = true
+    },
   },
   mounted: function () {
     gantt.clearAll()
@@ -87,7 +138,7 @@ export default {
     // gantt.config.autosize = true;
     // gantt.config.duration_unit = "hour";
     gantt.config.fit_tasks = true;
-      gantt.config.drag_move = false;
+    gantt.config.drag_move = false;
     gantt.config.xml_date = "%Y-%m-%d";
     gantt.config.columns=[
         {name:"text",label:(this.stafforpro == this.$t('anRenYuanChaKan') ? this.$t('lable.name') : this.$t('headerTop.projectName')), align: "left", tree:true},
@@ -188,6 +239,15 @@ export default {
     //   },
 
     // }
+    // 给每行增加双击事件 ,亲测事件会重复注册,用这个方法拦截一下
+    if (this.onTaskDblClick) gantt.detachEvent(this.onTaskDblClick);
+    // 双击bar任务事件(单击会有问题,点击展开时也会触发)
+    this.onTaskDblClick = gantt.attachEvent("onTaskDblClick", (id, e) => {
+      console.log('=====在这里,开始显示任务弹窗编辑任务===id=='+id+", e="+e);
+        this.$emit('rowDbClick',id)
+        return true;
+    }, { id: 'onTaskDblClick' })
+
     gantt.ext.tooltips.attach({
       selector: '.gantt_grid [' + gantt.config.task_attribute + ']',
       onmouseenter: (event,node) => {
@@ -212,8 +272,18 @@ export default {
       // },
       global: true
     })
+
+    // 绑定空白点击事件
+    gantt.attachEvent("onEmptyClick", (event) => {
+      this.handleEmptyClick(event);
+      return true; // 阻止默认行为
+    });
+    
     
-    gantt.init(this.$refs.gantt);
+    gantt.init(this.$refs.ganttContainer);
+    console.log('===初始化Init gantt===');
+    console.log(this.$refs.ganttContainer)
+    this.containerRect = this.$refs.ganttContainer.getBoundingClientRect();
     // this.$props.tasks.data[31].render = "split"
     gantt.parse(this.$props.tasks);
     
@@ -226,6 +296,7 @@ export default {
     // console.log("props",gantt);
   }
 }
+
 </script>
  
 <style>

+ 4 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -1823,7 +1823,7 @@
             </div>
             <div style="float: right; vertical-align: middle;height:32px">
               <el-link
-              type="primary"
+              type="primary" v-loading="remindering"
               @click="changeReminder()"
               >{{ $t('bianGengTiXing') }}</el-link
               >
@@ -2303,6 +2303,7 @@
         },
         data() {
             return {
+                remindering: false,
                 onlyHaveAttendance: false,
                 notFullData:[],
                 notFullOriginList:[],
@@ -8903,7 +8904,9 @@
                     parameter.createDate=item.createDate,
                     parameter.userId=item.userId
                 }
+                this.remindering = true;
                 this.http.post('/report/changeReminder',parameter,res => {
+                    this.remindering = false;
                     if(res.code == 'ok'){
                         this.$message({
                             message: res.msg,