|
@ -33,55 +33,25 @@ import dayjs from 'dayjs'; |
|
|
const initHook = useInit(); |
|
|
const initHook = useInit(); |
|
|
const getTasksHook = useGetTasks(); |
|
|
const getTasksHook = useGetTasks(); |
|
|
const store = useStore(); |
|
|
const store = useStore(); |
|
|
const roleId = computed(() => store.state.role.roleId); |
|
|
|
|
|
const timeNode = computed(() => store.state.task.timeNode); |
|
|
|
|
|
const timeUnit = computed(() => store.state.task.timeUnit); |
|
|
|
|
|
const projectId = computed(() => store.getters['project/projectId']); |
|
|
const projectId = computed(() => store.getters['project/projectId']); |
|
|
const userId = computed(() => store.getters['user/userId']); |
|
|
const userId = computed(() => store.getters['user/userId']); |
|
|
|
|
|
const roleId = computed(() => store.state.role.roleId); // 当前展示查看的角色id |
|
|
|
|
|
const roleIndex = computed(() => store.state.role.roleIndex); // 时间轴角色索引 |
|
|
|
|
|
const visibleRoles = computed(() => store.state.role.visibleRoles); // 展示的角色信息 |
|
|
|
|
|
const timeNode = computed(() => store.state.task.timeNode); // 时间基准点 |
|
|
|
|
|
const timeUnit = computed(() => store.state.task.timeUnit); // 时间颗粒度 |
|
|
const newProjectInfo = computed(() => store.state.task.newProjectInfo); |
|
|
const newProjectInfo = computed(() => store.state.task.newProjectInfo); |
|
|
const showScrollTo = computed(() => store.state.task.showScrollTo); |
|
|
const showScrollTo = computed(() => store.state.task.showScrollTo); // 是否可以设置时间轴自动滚动的位置 |
|
|
const visibleRoles = computed(() => store.state.role.visibleRoles); |
|
|
const allTasks = computed(() => store.state.task.allTasks); // 所有任务 |
|
|
const allTasks = computed(() => store.state.task.allTasks); |
|
|
const globals = computed(() => store.getters['task/globals']); // 所有的日常任务 永久 + 可变 日常任务 |
|
|
const roleIndex = computed(() => store.state.role.roleIndex); |
|
|
const timeGranularity = computed(() => store.getters['task/timeGranularity']); // 计算颗粒度 对应的 dayjs add 的单位 |
|
|
const globals = computed(() => store.getters['task/globals']); |
|
|
const height = ref(null); // 页面高度 |
|
|
const timeGranularity = computed(() => store.getters['task/timeGranularity']); |
|
|
|
|
|
const height = ref(null); |
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
onMounted(() => { |
|
|
const system = uni.getSystemInfoSync(); |
|
|
const system = uni.getSystemInfoSync(); |
|
|
height.value = `${system.windowHeight}px`; |
|
|
height.value = `${system.windowHeight}px`; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 获取可变全局任务 |
|
|
|
|
|
function getGlobalData() { |
|
|
|
|
|
if(!allTasks.value[roleIndex]) { |
|
|
|
|
|
const param = { |
|
|
|
|
|
roleId: roleId.value, |
|
|
|
|
|
timeNode: timeNode.value, |
|
|
|
|
|
timeUnit: timeUnit.value, |
|
|
|
|
|
projectId: projectId.value, |
|
|
|
|
|
}; |
|
|
|
|
|
store.dispatch('task/getGlobal', param); |
|
|
|
|
|
} |
|
|
|
|
|
// 添加到allTasks里 |
|
|
|
|
|
const index = visibleRoles.value.findIndex(role => role.id === roleId.value); |
|
|
|
|
|
const arr = [...allTasks.value]; |
|
|
|
|
|
arr[index].global = [...globals.value]; |
|
|
|
|
|
store.commit('task/setAllTasks', arr); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 清除已有的任务数据 |
|
|
|
|
|
function clearTasksData() { |
|
|
|
|
|
// 清空日常任务的数据 |
|
|
|
|
|
store.commit('task/setPermanents', []); |
|
|
|
|
|
store.commit('task/setDailyTasks', []); |
|
|
|
|
|
// 清空定期任务数据 |
|
|
|
|
|
store.commit('task/clearTasks'); |
|
|
|
|
|
// 到顶的标志复位 |
|
|
|
|
|
// 到底的标志复位 |
|
|
|
|
|
store.commit('task/clearEndFlag'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 当角色发生变化时 |
|
|
* 当角色发生变化时 |
|
|
* 重新查询永久日常任务和普通日常任务 |
|
|
* 重新查询永久日常任务和普通日常任务 |
|
@ -91,7 +61,8 @@ function clearTasksData() { |
|
|
watch(roleId, newValue => { |
|
|
watch(roleId, newValue => { |
|
|
if (newValue) { |
|
|
if (newValue) { |
|
|
// 判断如果allTasks里有就不用加了 |
|
|
// 判断如果allTasks里有就不用加了 |
|
|
if (allTasks.value.length && allTasks.value[roleIndex.value].global && allTasks.value[roleIndex.value].task) return; |
|
|
if (allTasks.value.length && allTasks.value[roleIndex.value].global && allTasks.value[roleIndex.value].task) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
console.log('当角色发生变化时', newValue); |
|
|
console.log('当角色发生变化时', newValue); |
|
|
store.commit('task/setTimeNode', Date.now()); |
|
|
store.commit('task/setTimeNode', Date.now()); |
|
@ -149,13 +120,47 @@ watch(newProjectInfo, newValue => { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 获取可变全局任务 |
|
|
|
|
|
function getGlobalData() { |
|
|
|
|
|
if (!allTasks.value[roleIndex]) { |
|
|
|
|
|
const param = { |
|
|
|
|
|
roleId: roleId.value, |
|
|
|
|
|
timeNode: timeNode.value, |
|
|
|
|
|
timeUnit: timeUnit.value, |
|
|
|
|
|
projectId: projectId.value, |
|
|
|
|
|
}; |
|
|
|
|
|
store.dispatch('task/getGlobal', param); |
|
|
|
|
|
} |
|
|
|
|
|
// 添加到allTasks里 |
|
|
|
|
|
const index = visibleRoles.value.findIndex(role => role.id === roleId.value); |
|
|
|
|
|
const arr = [...allTasks.value]; |
|
|
|
|
|
arr[index].global = [...globals.value]; |
|
|
|
|
|
store.commit('task/setAllTasks', arr); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 清除已有的任务数据 |
|
|
|
|
|
function clearTasksData() { |
|
|
|
|
|
// 清空日常任务的数据 |
|
|
|
|
|
store.commit('task/setPermanents', []); |
|
|
|
|
|
store.commit('task/setDailyTasks', []); |
|
|
|
|
|
// 清空定期任务数据 |
|
|
|
|
|
store.commit('task/clearTasks'); |
|
|
|
|
|
// 到顶的标志复位 |
|
|
|
|
|
// 到底的标志复位 |
|
|
|
|
|
store.commit('task/clearEndFlag'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getTasks(params) { |
|
|
function getTasks(params) { |
|
|
getTasksHook.initPlanTasks(params); // 处理定期任务 |
|
|
getTasksHook.initPlanTasks(params); // 处理定期任务 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// tabs通知swiper切换 |
|
|
// tabs通知swiper切换 |
|
|
function tabsChange(e) { |
|
|
function tabsChange(e) { |
|
|
const { id } = visibleRoles.value[e.detail.current]; |
|
|
const { |
|
|
|
|
|
id |
|
|
|
|
|
} = visibleRoles.value[e.detail.current]; |
|
|
store.commit('role/setRoleIndex', e.detail.current); |
|
|
store.commit('role/setRoleIndex', e.detail.current); |
|
|
store.commit('role/setRoleId', id); |
|
|
store.commit('role/setRoleId', id); |
|
|
|
|
|
|
|
@ -175,7 +180,8 @@ function setScrollPosition() { |
|
|
} else { |
|
|
} else { |
|
|
// 没有本地记录的taskId |
|
|
// 没有本地记录的taskId |
|
|
// 找到当前时间基准线的任务id 记录 并滚动到当前时间基准线 |
|
|
// 找到当前时间基准线的任务id 记录 并滚动到当前时间基准线 |
|
|
const task = allTasks.value[roleIndex.value].task.find(item => dayjs(+item.planStart).isSame(timeNode.value, timeGranularity.value)); |
|
|
const task = allTasks.value[roleIndex.value].task.find(item => dayjs(+item.planStart).isSame(timeNode.value, |
|
|
|
|
|
timeGranularity.value)); |
|
|
task && store.commit('task/setScrollToTaskId', `a${task.id}`); // 有这个task 就记录他的id |
|
|
task && store.commit('task/setScrollToTaskId', `a${task.id}`); // 有这个task 就记录他的id |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|