From a67558c968d0d5b1ed968933590b959508da5e29 Mon Sep 17 00:00:00 2001 From: kun <1422840143@qq.com> Date: Thu, 30 May 2024 20:53:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20BUG=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../progressManagementAg/ganttChart.vue | 30 +- .../projectganttChart copy.vue | 2278 +++++++++++++++++ .../projectganttChart.vue | 66 +- 3 files changed, 2338 insertions(+), 36 deletions(-) create mode 100644 src/views/projectFront/progressManagementAg/projectganttChart copy.vue diff --git a/src/views/projectFront/progressManagementAg/ganttChart.vue b/src/views/projectFront/progressManagementAg/ganttChart.vue index d907da72..2793e9c8 100644 --- a/src/views/projectFront/progressManagementAg/ganttChart.vue +++ b/src/views/projectFront/progressManagementAg/ganttChart.vue @@ -942,6 +942,7 @@ import { } from "@/assets/js/api/progressManagement"; import { getQualityRegionListApi } from "@/assets/js/api/quality.js"; import { selectHierarchyEnterpriseListApi } from "@/assets/js/api/laborPerson"; +import moment from "moment"; export default { data() { return { @@ -1030,8 +1031,19 @@ export default { mapDates(this.projects); dates = dates.map((date) => date.slice(0, 7)).sort(); dates = [...new Set(dates)]; - console.log("dateList----", dates); - return dates; + // 计算两个日期之间相差的月数 + let startDate = moment(dates[0]); + let endDate = moment(dates[dates.length - 1]); + if (dates.length > 0) { + let countArr = [dates[0]]; + const months = endDate.diff(startDate, "months"); + for (let i = 0; i < months; i++) { + countArr.push(startDate.add(1, "month").format("YYYY-MM")); + } + return countArr; + } else { + return dates; + } }, }, watch: { @@ -1071,8 +1083,6 @@ export default { } return item.milestoneTime == dateEntiry; }); - console.log(dateEntiry,123456) - console.log(index) return index != -1 ? true : false; }, selectChange(val) { @@ -1357,7 +1367,7 @@ export default { if (count === 28) { days.push({ num: 28, date: date + "-28" }); } else if (count === 30) { - days.push({ num: 30, date: date + "-30" }); + // days.push({ num: 30, date: date + "-30" }); } return days; })(); @@ -1715,7 +1725,7 @@ export default { width: 200px; position: relative; background: #e2ebff; - z-index: 10; + z-index: 30; } .fixed_1 { @@ -1756,15 +1766,15 @@ export default { // flex: 1; width: 26px; position: relative; - text-align: right; + text-align: left; .tip-show { position: absolute; top: -20px; - left: 0; + left: 0px; display: flex; flex-direction: column; // align-items: center; - // justify-content: center; + align-items: flex-end; img { width: 20px; height: 20px; @@ -1850,7 +1860,7 @@ export default { width: 200px; position: relative; background: #092945; - z-index: 10; + z-index: 30; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; diff --git a/src/views/projectFront/progressManagementAg/projectganttChart copy.vue b/src/views/projectFront/progressManagementAg/projectganttChart copy.vue new file mode 100644 index 00000000..689b2ec5 --- /dev/null +++ b/src/views/projectFront/progressManagementAg/projectganttChart copy.vue @@ -0,0 +1,2278 @@ + + + + + diff --git a/src/views/projectFront/progressManagementAg/projectganttChart.vue b/src/views/projectFront/progressManagementAg/projectganttChart.vue index 8f4fda00..2c520341 100644 --- a/src/views/projectFront/progressManagementAg/projectganttChart.vue +++ b/src/views/projectFront/progressManagementAg/projectganttChart.vue @@ -1206,8 +1206,16 @@ export default { mapDates(this.projects); dates = dates.map((date) => date.slice(0, 7)).sort(); dates = [...new Set(dates)]; - console.log("dateList----", dates); - return dates; + // 计算两个日期之间相差的月数 + let startDate = moment(dates[0]); + let endDate = moment(dates[dates.length - 1]); + let countArr = [dates[0]]; + const months = endDate.diff(startDate, "months"); + for(let i = 0; i < months; i++) { + countArr.push(startDate.add(1, 'month').format('YYYY-MM')) + } + console.log("dateList----", countArr); + return countArr; }, }, watch: { @@ -1226,18 +1234,19 @@ export default { let offsetLeft = obj.width.substring(0, obj.width.indexOf("px")) / sum; // console.log(obj.width.substring(0,obj.width.indexOf('px')),777888) // console.log(offsetLeft,777888) - if (sum > 8) { - return index == sum - 4 || - index == sum - 3 || - index == sum - 2 || - index == sum - 1 - ? offsetLeft * (index + 1) + offsetLeft - : offsetLeft * (index + 1) + offsetLeft + 10; - } else { - return index == sum - 3 || index == sum - 2 || index == sum - 1 - ? offsetLeft * (index + 1) + offsetLeft - : offsetLeft * (index + 1) + offsetLeft + 10; - } + // if (sum > 8) { + // return index == sum - 4 || + // index == sum - 3 || + // index == sum - 2 || + // index == sum - 1 + // ? offsetLeft * (index + 1) + offsetLeft + // : offsetLeft * (index + 1) + offsetLeft + 10; + // } else { + // return index == sum - 3 || index == sum - 2 || index == sum - 1 + // ? offsetLeft * (index + 1) + offsetLeft + // : offsetLeft * (index + 1) + offsetLeft + 10; + // } + return offsetLeft * (index + 1) }, isShowDate(obj, dayAfter) { // 获取当前日期 @@ -1499,17 +1508,17 @@ export default { let endRef = null; // 抹灰工程1-1-2022/09/03 - const a = !(startArr[2] % 2); + const a = true; console.log(a, ":!(startArr[2] % 2:"); if (a) { - const day = startArr[2] - 1; + const day = +startArr[2]; startArr[2] = day < 10 ? "0" + day : day; startDate = startArr.join("-"); } - const b = !(endArr[2] % 2); + const b = true; console.log(a, ":!(endArr[2] % 2):"); - if (!(endArr[2] % 2)) { - const day = endArr[2] - 1; + if (b) { + const day = +endArr[2]; endArr[2] = day < 10 ? "0" + day : day; finishDate = endArr.join("-"); } @@ -1590,11 +1599,11 @@ export default { let fulldate = date + (num < 10 ? "-0" + num : "-" + num); return { num, date: fulldate }; }) - .filter((item) => item.num % 2); + // .filter((item) => item.num % 2); if (count === 28) { days.push({ num: 28, date: date + "-28" }); } else if (count === 30) { - days.push({ num: 30, date: date + "-30" }); + // days.push({ num: 30, date: date + "-30" }); } return days; })(); @@ -1991,7 +2000,9 @@ export default { display: flex; .day { - flex: 1; + width: 26px; + text-align: left; + // flex: 1; position: relative; } } @@ -2011,7 +2022,8 @@ export default { } &:nth-child(n + 4) { - width: 400px; + // width: 400px; + width: max-content; } } } @@ -2063,7 +2075,7 @@ export default { width: 200px; position: relative; background: #092945; - z-index: 10; + z-index: 20; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; @@ -2100,7 +2112,8 @@ export default { .grid { position: relative; - flex: 1; + // flex: 1; + width: 25px; height: 100%; &:not(:last-child) { @@ -2122,7 +2135,8 @@ export default { } &:nth-child(n + 4) { - width: 400px; + // width: 400px; + width: max-content; } }