Procházet zdrojové kódy

提交没来的工作计划需求第五点

Lijy před 2 dny
rodič
revize
c28ecdd5a9

+ 18 - 3
fhKeeper/formulahousekeeper/timesheet_mld/src/components/taskComponent.vue

@@ -1195,7 +1195,7 @@ export default {
             this.mileageCup = false
             this.addFormVisible = true;
             this.curProjectId = obj.stage.projectId;
-            const startDates = obj.addForm.startDate ? obj.addForm.startDate + '08:00:00' : ''
+            const startDates = obj.addForm.startDate ? obj.addForm.startDate + ' 08:00:00' : ''
             this.addForm = {
                 projectId: obj.stage.projectId, 
                 groupId: obj.stage.groupId, 
@@ -1933,16 +1933,31 @@ export default {
                                 message: this.$t('message.submittedSuccessfully'),
                                 type: "success"
                             });
-                            
                             if (this.addForm.parentTid == null) {
                                 let obj = {
                                     submitInsert: true,
                                     showOrNot: this.showOrNot
                                 }
+                                // if(!addFormData.id) {
+                                //     obj.dateList = [addFormData.startDate, addFormData.endDate]
+                                // }
+                                if(!addFormData.id) {
+                                    localStorage.setItem('ganttChartTaskId', JSON.stringify(res.data || []))
+                                }
                                 this.$emit('closeBounced', obj)
                             } else {
                                 // this.backToParentTask();
-                                this.$emit('closeBounced', {backToParentTaskSub: true})
+                                // if(!addFormData.id) {
+                                //     this.$emit('closeBounced', {
+                                //         backToParentTaskSub: true,
+                                //         dateList: [addFormData.startDate, addFormData.endDate]
+                                //     })
+                                // } else {
+                                    if(!addFormData.id) {
+                                        localStorage.setItem('ganttChartTaskId', JSON.stringify(res.data || []))
+                                    }
+                                    this.$emit('closeBounced', {backToParentTaskSub: true})
+                                // }
                             }
                         } else {
                             this.$message({

+ 30 - 0
fhKeeper/formulahousekeeper/timesheet_mld/src/views/project/gantt.vue

@@ -169,6 +169,25 @@ export default {
         this.addTask(row)
       }
     },
+    // 定位数据
+    focusAndSelectTaskFull(taskId) {
+      if (gantt.isTaskExists(taskId)) {
+        var task = gantt.getTask(taskId);
+        gantt.showTask(taskId);
+        gantt.selectTask(taskId);
+
+        // 检查日期有效性
+        if (!(task.start_date instanceof Date) || !(task.end_date instanceof Date)) {
+          console.error("Invalid date format in task:", task);
+          return;
+        }
+
+        var midTime = (task.start_date.getTime() + task.end_date.getTime()) / 2;
+        var midDate = new Date(midTime);
+
+        gantt.scrollTo(gantt.posFromDate(midDate) - 200, gantt.getScrollState().y);
+      }
+    }
   },
   mounted: function () {
     const userInfo = JSON.parse(sessionStorage.getItem("user"));
@@ -444,6 +463,17 @@ export default {
     gantt.init(this.$refs.ganttContainer);
     this.containerRect = this.$refs.ganttContainer.getBoundingClientRect();
     gantt.parse(this.$props.tasks);
+
+    setTimeout(() => {
+      // gantt.showTask('任务_2636_2339');
+      // gantt.selectTask('任务_2636_2339');
+      const list = JSON.parse(localStorage.getItem('ganttChartTaskId') || '[]')
+      if(list[0]) {
+        this.focusAndSelectTaskFull(list[0])
+      }
+
+      localStorage.removeItem('ganttChartTaskId')
+    }, 1000)
   }
 }
 

+ 17 - 0
fhKeeper/formulahousekeeper/timesheet_mld/src/views/project/project_gantt.vue

@@ -248,6 +248,9 @@ export default {
     this.isDataLoaded = true
 
     this.getTaskTypeList()
+
+    console.log('<===== 开始执行咯')
+    localStorage.removeItem('ganttChartTaskId')
   },
   methods: {
     getTaskTypeList() {
@@ -270,9 +273,23 @@ export default {
     },
     closeBounced(obj) {
       if(obj.submitInsert) {
+        if(obj.dateList && obj.dateList.length > 0) {
+          const formattedDates = obj.dateList.map(dateString => this.formatDate(dateString));
+          const one = formattedDates[0]
+          const two = formattedDates[1]
+          this.valueDate = [one, two]
+        }
         this.dateupdata()
       }
     },
+    formatDate(dateString) {
+      const date = new Date(dateString);
+      const year = date.getFullYear();
+      const month = String(date.getMonth() + 1).padStart(2, '0');
+      const day = String(date.getDate()).padStart(2, '0');
+      return `${year}-${month}-${day}`;
+    },
+
     selectCal(obj) {
       if(obj.distinction == '1') {
           this.valuex = obj.id