|
|
@ -38,7 +38,7 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
methods: { |
|
|
|
...mapMutations('home', ['setScrollTop', 'setShrink', 'setRoleId']), |
|
|
|
...mapMutations('home', ['setScrollTop', 'setShrink', 'setRoleId', 'setUpTasks', 'setDownTasks']), |
|
|
|
|
|
|
|
// 滚动 |
|
|
|
scroll(e) { |
|
|
@ -50,26 +50,79 @@ export default { |
|
|
|
// 滚动到顶部 |
|
|
|
async handleScrollTop() { |
|
|
|
if (this.topEnd) return; |
|
|
|
const startTime = this.tasks[0].planStart - 0; |
|
|
|
console.log('this.topEnd: ', this.topEnd); |
|
|
|
console.log('this.tasks: ', this.tasks); |
|
|
|
console.log('this.tasks[0].plugins: ', this.tasks[0].plugins); |
|
|
|
if (this.tasks[0].plugins && this.tasks[0].plugins.length === 0 && !this.topEnd) { |
|
|
|
// 没有数据时 自动加载数据 |
|
|
|
console.log('没有数据时: '); |
|
|
|
const addTasks = [ |
|
|
|
{ |
|
|
|
panel: {}, |
|
|
|
plugins: [], |
|
|
|
planStart: this.$t.time.add(startTime, -3, 'day').valueOf(), |
|
|
|
}, |
|
|
|
{ |
|
|
|
panel: {}, |
|
|
|
plugins: [], |
|
|
|
planStart: this.$t.time.add(startTime, -2, 'day').valueOf(), |
|
|
|
}, |
|
|
|
{ |
|
|
|
panel: {}, |
|
|
|
plugins: [], |
|
|
|
planStart: this.$t.time.add(startTime, -1, 'day').valueOf(), |
|
|
|
}, |
|
|
|
]; |
|
|
|
this.setUpTasks([...addTasks.concat(this.tasks)]); |
|
|
|
} else { |
|
|
|
// 有数据时 |
|
|
|
console.log('有数据时: '); |
|
|
|
const upQuery = { |
|
|
|
timeNode: +this.tasks[0].planStart, |
|
|
|
timeNode: startTime, |
|
|
|
queryType: 0, |
|
|
|
queryNum: 6, |
|
|
|
}; |
|
|
|
await this.$emit('getTasks', upQuery); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 滚动到底部 |
|
|
|
async handleScrollBottom() { |
|
|
|
if (this.bottomEnd) return; |
|
|
|
const startTime = this.tasks[this.tasks.length - 1].planStart - 0; |
|
|
|
if (this.tasks[0].plugins && this.tasks[0].plugins.length === 0 && !this.topEnd) { |
|
|
|
// 没有数据时 自动加载数据 |
|
|
|
console.log('没有数据时: '); |
|
|
|
const addTasks = [ |
|
|
|
{ |
|
|
|
panel: {}, |
|
|
|
plugins: [], |
|
|
|
planStart: this.$t.time.add(startTime, 1, 'day').valueOf(), |
|
|
|
}, |
|
|
|
{ |
|
|
|
panel: {}, |
|
|
|
plugins: [], |
|
|
|
planStart: this.$t.time.add(startTime, 2, 'day').valueOf(), |
|
|
|
}, |
|
|
|
{ |
|
|
|
panel: {}, |
|
|
|
plugins: [], |
|
|
|
planStart: this.$t.time.add(startTime, 3, 'day').valueOf(), |
|
|
|
}, |
|
|
|
]; |
|
|
|
this.setDownTasks([...this.tasks.concat(addTasks)]); |
|
|
|
} else { |
|
|
|
// 时间基准点=最后一个任务的开始时间+当前时间颗粒度 |
|
|
|
const cycle = this.$t.time.computeCycle('天'); |
|
|
|
const timeNode = this.$t.time.add(+this.tasks[this.tasks.length - 1].planStart, 1, cycle).valueOf(); |
|
|
|
const timeNode = this.$t.time.add(startTime, 1, cycle).valueOf(); |
|
|
|
const downQuery = { |
|
|
|
timeNode, |
|
|
|
queryType: 1, |
|
|
|
queryNum: 6, |
|
|
|
}; |
|
|
|
await this.$emit('getTasks', downQuery); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 设置基准点 |
|
|
@ -80,7 +133,6 @@ export default { |
|
|
|
const scrollHeight = document.getElementById('scroll').clientHeight; |
|
|
|
let width = document.documentElement.clientWidth; |
|
|
|
for (let i = 0; i < 3; i++) { |
|
|
|
// TODO: 高度不对 |
|
|
|
if (tasks[i].panel && tasks[i].panel.height) { |
|
|
|
// 如果后台返回了高度,就用返回得任务面板高度 + 固定边距42 |
|
|
|
tasksHeight += +tasks[i].panel.height + 42; |
|
|
|