湖里大屏(进度计划):完成甘特图进度条宽度设置

This commit is contained in:
Jack 2022-08-10 10:09:38 +08:00
parent 08ef44cf8b
commit 005b0cb0e6

View File

@ -70,7 +70,7 @@ export default {
}, },
data() { data() {
return { return {
dates: ['2020/03', '2020/04', '2020/05', '2020/07', '2020/08'], dates: ['2020/03', '2020/04', '2020/05', '2020/06', '2020/07', '2020/08'],
projects: [ projects: [
{ {
pName: '地基与基础工程', pName: '地基与基础工程',
@ -91,21 +91,38 @@ export default {
methods: { methods: {
getGantts() { getGantts() {
this.projects.map(project => { this.projects.map(project => {
let { startTime, pName, gantts } = project let { startTime, endTime, pName, gantts } = project
const dateArr = startTime.split('/') const startArr = startTime.split('/')
const endArr = endTime.split('/')
let startRef = null let startRef = null
let endRef = null
if (!(dateArr[2] % 2)) { if (!(startArr[2] % 2)) {
const day = dateArr[2] - 1 const day = startArr[2] - 1
dateArr[2] = day < 10 ? '0' + day : day startArr[2] = day < 10 ? '0' + day : day
startTime = dateArr.join('/') startTime = startArr.join('/')
console.log(startTime, 'xxx') 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] startRef = this.$refs[`${pName}-${startTime}`][0]
const left = startRef.offsetLeft const startLeft = startRef.offsetLeft
gantts[0].left = left + 'px'
console.log(startRef.offsetLeft, '丢雷', startTime) endRef = this.$refs[`${pName}-${endTime}`][0]
const endWidth = endRef.offsetWidth
const endLeft = endRef.offsetLeft
const ganttWidth = endLeft - startLeft + endWidth
if (gantts) {
gantts[0].left = startLeft + 'px'
gantts[0].width = ganttWidth + 'px'
}
console.log(startLeft, ganttWidth, '丢雷', `${pName}-${endTime}`)
// left // left
}) })
}, },