湖里大屏(进度计划):抽离获取进度条参数代码
This commit is contained in:
parent
4dde2afbf0
commit
923aad5fef
@ -75,6 +75,7 @@ export default {
|
|||||||
pName: '地基与基础工程',
|
pName: '地基与基础工程',
|
||||||
startTime: '2020/04/06',
|
startTime: '2020/04/06',
|
||||||
endTime: '2020/05/09',
|
endTime: '2020/05/09',
|
||||||
|
delay: 5,
|
||||||
status: 0,
|
status: 0,
|
||||||
gantts: [],
|
gantts: [],
|
||||||
// gantts: [{ left: '420px', width: '100px', status: '' }],
|
// gantts: [{ left: '420px', width: '100px', status: '' }],
|
||||||
@ -91,45 +92,48 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
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() {
|
setGantts() {
|
||||||
const configGantts = projects => {
|
const configGantts = projects => {
|
||||||
projects.map(project => {
|
projects.map(project => {
|
||||||
let { startTime, endTime, pName, gantts } = project
|
let { gantts } = project
|
||||||
const startArr = startTime.split('/')
|
const gantt = this.getGanttStyle(project)
|
||||||
const endArr = endTime.split('/')
|
gantt.background = this.colors[project.status]
|
||||||
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] }
|
|
||||||
if (gantts) {
|
if (gantts) {
|
||||||
gantts.push(gantt)
|
gantts.push(gantt)
|
||||||
} else {
|
} else {
|
||||||
project.gantts = [gantt]
|
project.gantts = [gantt]
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(startLeft, ganttWidth, '丢雷', `${pName}-${endTime}`)
|
|
||||||
|
|
||||||
// debugger
|
// debugger
|
||||||
project.children && configGantts(project.children)
|
project.children && configGantts(project.children)
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user