From 923aad5fefb97ebe62b15db2d034793eae0e0ab0 Mon Sep 17 00:00:00 2001 From: Jack <1638169491@qq.com> Date: Wed, 10 Aug 2022 17:18:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B9=96=E9=87=8C=E5=A4=A7=E5=B1=8F(=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E8=AE=A1=E5=88=92)=EF=BC=9A=E6=8A=BD=E7=A6=BB?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=BF=9B=E5=BA=A6=E6=9D=A1=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jlw/planProgress/centerTop.vue | 64 ++++++++++--------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/src/views/projectAdmin/jlw/planProgress/centerTop.vue b/src/views/projectAdmin/jlw/planProgress/centerTop.vue index bc289a61..acdf0164 100644 --- a/src/views/projectAdmin/jlw/planProgress/centerTop.vue +++ b/src/views/projectAdmin/jlw/planProgress/centerTop.vue @@ -75,6 +75,7 @@ export default { pName: '地基与基础工程', startTime: '2020/04/06', endTime: '2020/05/09', + delay: 5, status: 0, gantts: [], // gantts: [{ left: '420px', width: '100px', status: '' }], @@ -91,45 +92,48 @@ export default { } }, methods: { + getGanttStyle(project) { + let { startTime, endTime, pName } = project + const startArr = startTime.split('/') + const endArr = endTime.split('/') + let startRef = null + let endRef = null + + if (!(startArr[2] % 2)) { + const day = startArr[2] - 1 + startArr[2] = day < 10 ? '0' + day : day + startTime = startArr.join('/') + console.log(startTime, 'xxx') + } + if (!(endArr[2] % 2)) { + const day = endArr[2] - 1 + endArr[2] = day < 10 ? '0' + day : day + endTime = endArr.join('/') + console.log(endTime, 'xxx') + } + + startRef = this.$refs[`${pName}-${startTime}`][0] + const startLeft = startRef.offsetLeft + + endRef = this.$refs[`${pName}-${endTime}`][0] + const endWidth = endRef.offsetWidth + const endLeft = endRef.offsetLeft + const ganttWidth = endLeft - startLeft + endWidth + + return { left: startLeft + 'px', width: ganttWidth + 'px' } + }, setGantts() { const configGantts = projects => { projects.map(project => { - let { startTime, endTime, pName, gantts } = project - const startArr = startTime.split('/') - const endArr = endTime.split('/') - let startRef = null - let endRef = null - - if (!(startArr[2] % 2)) { - const day = startArr[2] - 1 - startArr[2] = day < 10 ? '0' + day : day - startTime = startArr.join('/') - console.log(startTime, 'xxx') - } - if (!(endArr[2] % 2)) { - const day = endArr[2] - 1 - endArr[2] = day < 10 ? '0' + day : day - endTime = endArr.join('/') - console.log(endTime, 'xxx') - } - - startRef = this.$refs[`${pName}-${startTime}`][0] - const startLeft = startRef.offsetLeft - - endRef = this.$refs[`${pName}-${endTime}`][0] - const endWidth = endRef.offsetWidth - const endLeft = endRef.offsetLeft - const ganttWidth = endLeft - startLeft + endWidth - - const gantt = { left: startLeft + 'px', width: ganttWidth + 'px', background: this.colors[project.status] } + let { gantts } = project + const gantt = this.getGanttStyle(project) + gantt.background = this.colors[project.status] if (gantts) { gantts.push(gantt) } else { project.gantts = [gantt] } - console.log(startLeft, ganttWidth, '丢雷', `${pName}-${endTime}`) - // debugger project.children && configGantts(project.children) })