Browse Source

甘特图展开收起功能问题修复

fujunwen 4 years ago
parent
commit
253ed00b47

+ 16 - 12
src/utils/ganttChart/GanttChart_day.js

@@ -499,20 +499,24 @@ GanttChartDay.prototype.drawTasks = function() {
                         tempTaskContainerEl.setZIndex(1)
                         tempTaskContainerEl._pdata = taskP
                         tempTaskContainerEl.on('mouseenter', (ev) => {
-                            tempTaskContainerEl.attr({ fill: '#F5F6F7' })
-                            tempTaskContainerEl._pdata.tasks.forEach((_tempTask) => {
-                                if (_tempTask._rectEl) {
-                                    _tempTask._rectEl.setZIndex(5)
-                                }
-                            })
+                            if (taskP.parentNode.open) {
+                                tempTaskContainerEl.attr({ fill: '#F5F6F7' })
+                                tempTaskContainerEl._pdata.tasks.forEach((_tempTask) => {
+                                    if (_tempTask._rectEl) {
+                                        _tempTask._rectEl.setZIndex(5)
+                                    }
+                                })
+                            }
                         })
                         tempTaskContainerEl.on('mouseleave', (ev) => {
-                            tempTaskContainerEl.attr({ fill: '#fff' })
-                            tempTaskContainerEl._pdata.tasks.forEach((_tempTask) => {
-                                if (_tempTask._rectEl) {
-                                    _tempTask._rectEl.setZIndex(5)
-                                }
-                            })
+                            if (taskP.parentNode.open) {
+                                tempTaskContainerEl.attr({ fill: '#fff' })
+                                tempTaskContainerEl._pdata.tasks.forEach((_tempTask) => {
+                                    if (_tempTask._rectEl) {
+                                        _tempTask._rectEl.setZIndex(5)
+                                    }
+                                })
+                            }
                         })
                         taskP._containerEl = tempTaskContainerEl
                     }

+ 20 - 16
src/utils/ganttChart/GanttChart_month.js

@@ -357,10 +357,10 @@ GanttChartMonth.prototype.handleClick = function(task, flag, ev) {
         // document.getElementById('detailTaskStatus').textContent = task._pdata.status
         // document.getElementById('detailTaskStartDate').textContent = task._pdata.startDate
         // document.getElementById('detailTaskEndDate').textContent = task._pdata.endDate
-        console.log('show:', task)
+        // console.log('show:', task)
     } else if (flag === 'leave') {
         // detailDiv.style.display = 'none'
-        console.log('hide:', task)
+        // console.log('hide:', task)
     } else {
         this.callback(task)
         console.log('click:', task)
@@ -507,20 +507,24 @@ GanttChartMonth.prototype.drawTasks = function() {
                         tempTaskContainerEl.setZIndex(1)
                         tempTaskContainerEl._pdata = taskP
                         tempTaskContainerEl.on('mouseenter', (ev) => {
-                            tempTaskContainerEl.attr({ fill: '#F5F6F7' })
-                            tempTaskContainerEl._pdata.tasks.forEach((_tempTask) => {
-                                if (_tempTask._rectEl) {
-                                    _tempTask._rectEl.setZIndex(5)
-                                }
-                            })
+                            if (taskP.parentNode.open) {
+                                tempTaskContainerEl.attr({ fill: '#F5F6F7' })
+                                tempTaskContainerEl._pdata.tasks.forEach((_tempTask) => {
+                                    if (_tempTask._rectEl) {
+                                        _tempTask._rectEl.setZIndex(5)
+                                    }
+                                })
+                            }
                         })
                         tempTaskContainerEl.on('mouseleave', (ev) => {
-                            tempTaskContainerEl.attr({ fill: '#fff' })
-                            tempTaskContainerEl._pdata.tasks.forEach((_tempTask) => {
-                                if (_tempTask._rectEl) {
-                                    _tempTask._rectEl.setZIndex(5)
-                                }
-                            })
+                            if (taskP.parentNode.open) {
+                                tempTaskContainerEl.attr({ fill: '#fff' })
+                                tempTaskContainerEl._pdata.tasks.forEach((_tempTask) => {
+                                    if (_tempTask._rectEl) {
+                                        _tempTask._rectEl.setZIndex(5)
+                                    }
+                                })
+                            }
                         })
                         taskP._containerEl = tempTaskContainerEl
                     }
@@ -546,10 +550,10 @@ GanttChartMonth.prototype.drawTasks = function() {
                             rectEl._pdata = _taskItem
                             _taskItem._rectEl = rectEl
                             rectEl.on('mouseover', (ev) => {
-                                this.handleClick(ev.target, 'enter', ev)
+                                // this.handleClick(ev.target, 'enter', ev)
                             })
                             rectEl.on('mouseleave', (ev) => {
-                                this.handleClick(ev.target, 'leave', ev)
+                                // this.handleClick(ev.target, 'leave', ev)
                             })
                             rectEl.on('click', (ev) => {
                                 this.handleClick(ev.target, 'click', ev)

+ 5 - 2
src/views/analysis/GanttChart.vue

@@ -356,18 +356,21 @@ export default {
           this.treeData = newData;
 
           let taskData = _.map(_.cloneDeep(newData), item => {
-            return {
+            let parentNode = {
               id: item.id,
               type: item.name,
               open: item.open,
+            };
+            return Object.assign(parentNode, {
               dataList: _.map(item.children, _item => {
                 return {
+                  parentNode,
                   id: _item.id,
                   title: _item.name,
                   tasks: _item.originData
                 };
               })
-            };
+            })
           });
           console.log("taskData", taskData);
           if (!window.gc) {