diff --git a/src/views/projectAdmin/jlw/planProgress/centerTop.vue b/src/views/projectAdmin/jlw/planProgress/centerTop.vue index b10a1b4c..972328d7 100644 --- a/src/views/projectAdmin/jlw/planProgress/centerTop.vue +++ b/src/views/projectAdmin/jlw/planProgress/centerTop.vue @@ -66,12 +66,11 @@ export default { console.log(this.getDays('2022/09'), '到') }, mounted() { - console.log(this.projects) - console.log(this.$refs, 'sdfsf') + this.getGantts() }, data() { return { - dates: ['2020/04', '2020/05', '2020/07', '2020/08'], + dates: ['2020/03', '2020/04', '2020/05', '2020/07', '2020/08'], projects: [ { pName: '地基与基础工程', @@ -90,6 +89,26 @@ export default { } }, methods: { + getGantts() { + this.projects.map(project => { + let { startTime, pName, gantts } = project + const dateArr = startTime.split('/') + let startRef = null + + if (!(dateArr[2] % 2)) { + const day = dateArr[2] - 1 + dateArr[2] = day < 10 ? '0' + day : day + startTime = dateArr.join('/') + console.log(startTime, 'xxx') + } + + startRef = this.$refs[`${pName}-${startTime}`][0] + const left = startRef.offsetLeft + gantts[0].left = left + 'px' + console.log(startRef.offsetLeft, '丢雷', startTime) + // 设置 left + }) + }, getDays(date) { const year = date.split('/')[0] const month = +date.split('/')[1] @@ -225,6 +244,7 @@ export default { height: 100%; display: flex; .grid { + position: relative; flex: 1; height: 100%; &:not(:last-child) {