|
|
@ -79,6 +79,7 @@ export default { |
|
|
|
* 永久日常任务不发生改变 |
|
|
|
*/ |
|
|
|
timeNode(val) { |
|
|
|
console.log('timeNode: ', val); |
|
|
|
if (val && this.roleId) { |
|
|
|
this.clearTasksData(); |
|
|
|
this.getGlobalData(); // 查可变日常任务 |
|
|
@ -159,8 +160,8 @@ export default { |
|
|
|
|
|
|
|
// 初始化 定期任务 |
|
|
|
async initPlanTasks() { |
|
|
|
this.setPrevPlaceholderTasks(); // 向上加载空数据 |
|
|
|
this.setNextPlaceholderTasks(); // 向下加载空数据 |
|
|
|
// this.setPrevPlaceholderTasks(); // 向上加载空数据 |
|
|
|
// this.setNextPlaceholderTasks(); // 向下加载空数据 |
|
|
|
await this.getInitTasks(); // 获取初始数据 |
|
|
|
// 滚动到对应位置 |
|
|
|
let timer = null; |
|
|
@ -169,7 +170,7 @@ export default { |
|
|
|
clearInterval(timer); |
|
|
|
this.$nextTick(() => this.$refs.timeLine.setScrollPosition()); |
|
|
|
} |
|
|
|
}, 500); |
|
|
|
}, 2000); |
|
|
|
}, |
|
|
|
|
|
|
|
// 切换了 颗粒度 || 角色时候 获取初始定期任务 |
|
|
@ -202,11 +203,13 @@ export default { |
|
|
|
// 有数据用数据替换刻度 |
|
|
|
// 没有数据 继续加载刻度 |
|
|
|
if (data && data.length) { |
|
|
|
this.replacePrevData(data, params.queryType); |
|
|
|
// this.replacePrevData(data, params.queryType); |
|
|
|
this.setData(data, params.queryType); |
|
|
|
params.queryType === 0 ? this.setTopEnd(false) : this.setBottomEnd(false); |
|
|
|
} else { |
|
|
|
// TODO: 0 -> 向上 1 -> 向下 |
|
|
|
params.queryType === 0 ? this.setPrevPlaceholderTasks() : this.setNextPlaceholderTasks(); |
|
|
|
// params.queryType === 0 ? this.setPrevPlaceholderTasks() : this.setNextPlaceholderTasks(); |
|
|
|
params.queryType === 0 ? this.setTopEnd(true) : this.setBottomEnd(true); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
@ -233,28 +236,28 @@ export default { |
|
|
|
// 设置时间轴向上的空数据 |
|
|
|
setPrevPlaceholderTasks() { |
|
|
|
this.setTopEnd(true); |
|
|
|
let startTime = ''; |
|
|
|
const { tasks } = this; |
|
|
|
if (!tasks || !tasks.length) { |
|
|
|
startTime = Date.now(); // 没有任务就应该是时间基准点 |
|
|
|
} else { |
|
|
|
startTime = tasks[0].planStart - 0; // 有任务就是第一个任务的计划开始时间 |
|
|
|
} |
|
|
|
const placeholderTasks = setPlaceholderTasks(startTime, true, this.timeGranularity, 3); |
|
|
|
this.setUpTasks(placeholderTasks); |
|
|
|
// let startTime = ''; |
|
|
|
// const { tasks } = this; |
|
|
|
// if (!tasks || !tasks.length) { |
|
|
|
// startTime = Date.now(); // 没有任务就应该是时间基准点 |
|
|
|
// } else { |
|
|
|
// startTime = tasks[0].planStart - 0; // 有任务就是第一个任务的计划开始时间 |
|
|
|
// } |
|
|
|
// const placeholderTasks = setPlaceholderTasks(startTime, true, this.timeGranularity, 3); |
|
|
|
// this.setUpTasks(placeholderTasks); |
|
|
|
}, |
|
|
|
|
|
|
|
// 设置时间轴向下的空数据 |
|
|
|
setNextPlaceholderTasks() { |
|
|
|
this.setBottomEnd(true); |
|
|
|
let startTime = ''; |
|
|
|
if (!this.tasks || !this.tasks.length) { |
|
|
|
startTime = Date.now(); |
|
|
|
} else { |
|
|
|
startTime = +this.tasks[this.tasks.length - 1].planStart; |
|
|
|
} |
|
|
|
const initData = setPlaceholderTasks(startTime, false, this.timeGranularity); |
|
|
|
this.setDownTasks(initData); |
|
|
|
// let startTime = ''; |
|
|
|
// if (!this.tasks || !this.tasks.length) { |
|
|
|
// startTime = Date.now(); |
|
|
|
// } else { |
|
|
|
// startTime = +this.tasks[this.tasks.length - 1].planStart; |
|
|
|
// } |
|
|
|
// const initData = setPlaceholderTasks(startTime, false, this.timeGranularity); |
|
|
|
// this.setDownTasks(initData); |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
@ -283,6 +286,31 @@ export default { |
|
|
|
type === 0 ? this.setUpTasks(oldTasks) : this.setDownTasks(oldTasks); |
|
|
|
}, |
|
|
|
|
|
|
|
// 设置数据 |
|
|
|
setData(data, type) { |
|
|
|
let tasks = []; |
|
|
|
for (let index = 0; index < data.length; index++) { |
|
|
|
let taskItem = { id: '', array: [] }; |
|
|
|
const item = data[index]; |
|
|
|
if (index === 0) { |
|
|
|
taskItem.id = item.id; |
|
|
|
taskItem.array.push(item); |
|
|
|
tasks.push(taskItem); |
|
|
|
} |
|
|
|
if (index > 0) { |
|
|
|
if (item.planStart === data[index - 1].planStart) { |
|
|
|
tasks[tasks.length - 1].array.push({ ...item }); |
|
|
|
} else { |
|
|
|
taskItem.id = item.id; |
|
|
|
taskItem.array.push({ ...item }); |
|
|
|
tasks.push(taskItem); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.clearTasks(); // setUpTasks setUpTasks 的限制 需要清空 |
|
|
|
type === 0 ? this.setUpTasks(tasks) : this.setDownTasks(tasks); |
|
|
|
}, |
|
|
|
|
|
|
|
// 生成指定位数随机数 |
|
|
|
randomNum(n) { |
|
|
|
var t = ''; |
|
|
|