From 4ae534f2bc3846415e8d754d31d5d33aedaf67c2 Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Thu, 29 Jul 2021 16:55:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(role):=20=E5=88=87=E6=8D=A2=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E7=9A=84=E9=80=BB=E8=BE=91=E4=BF=AE=E6=AD=A3=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + src/components/Roles/Roles.vue | 18 ++++++++---- src/pages/project/project.vue | 53 ++++++++++------------------------ src/store/task/mutations.js | 6 ++++ 4 files changed, 34 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4cd75b..25b0d1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -87,6 +87,7 @@ --|--|-- - | project 代码健壮性完善 | a3202c5 store/home | 删除store/home | db8a3b4 + task beginTime | 格式化任务开始时间 | fbc0301 template | eslint prettier sass uview tailwindcss | 9c966a1 - | 下滑时间轴添加备注 | 4fd20e3 - | 删除多余的技术验证界面 | 542ae5b diff --git a/src/components/Roles/Roles.vue b/src/components/Roles/Roles.vue index d503c22..b7827d8 100644 --- a/src/components/Roles/Roles.vue +++ b/src/components/Roles/Roles.vue @@ -3,7 +3,7 @@ - + {{ item.name }} @@ -68,7 +68,7 @@ export default { methods: { ...mapActions('task', ['handleRegularTask']), ...mapMutations('role', ['setRoleId']), - ...mapMutations('task', ['setTasks']), + ...mapMutations('task', ['setTasks', 'setPermanents', 'setDailyTasks', 'clearEndFlag']), // 设置滚动位置 setCurrentRole(index) { @@ -91,17 +91,23 @@ export default { }, // 切换角色 - async changeIndex(id, index) { + // 查任务这里不用管 project监听了roleId的变化 + // 时间基准点不用管 project监听了roleId 里处理了 + changeRole(id, index) { try { this.setRoleId(id); //改变index 即手动点击切换 我在此时将当前元素赋值给左边距 实现自动滚动 this.setCurrentRole(index); // 清空定期任务数据 this.setTasks(); - // 根据时间基准点和角色查找定期任务 - await this.$emit('getTasksByRole'); + // 清空日常任务的数据 + this.setPermanents([]); + this.setDailyTasks([]); + // 到顶的标志复位 + // 到底的标志复位 + this.clearEndFlag(); } catch (error) { - console.log('error: ', error); + console.log('role.vue changeRole error: ', error); } }, diff --git a/src/pages/project/project.vue b/src/pages/project/project.vue index 05e7212..73dad51 100644 --- a/src/pages/project/project.vue +++ b/src/pages/project/project.vue @@ -38,9 +38,11 @@ export default { * 永久日常任务不发生改变 */ timeNode(val) { + console.log(val); if (val && this.roleId) { // 根据时间和角色查找日常任务 this.getGlobalData(); + this.getInitTasks(); } }, @@ -102,22 +104,25 @@ export default { // 根据项目id获取角色列表 await this.getRoles({ projectId: options.p }); this.setInitialRoleId(this.visibleRoles); - - // 根据时间基准点和角色查找定期任务 - await this.getTasks({ queryType: 0 }); - await this.getTasks({ queryType: 1 }); - - // 预加载 上下的定期任务 - if (this.tasks && this.tasks.length) { - await this.getTasks({ timeNode: +this.tasks[0].planStart, queryType: 0, queryNum: 6 }); - await this.getTasks({ timeNode: +this.tasks[this.tasks.length - 1].planStart, queryType: 1, queryNum: 6 }); - } } } catch (error) { console.error('project init function:', error); } }, + // 切换了 颗粒度 || 角色时候 获取初始定期任务 + async getInitTasks() { + // 根据时间基准点和角色查找定期任务 + await this.getTasks({ queryType: 0 }); + await this.getTasks({ queryType: 1 }); + + // 预加载 上下的定期任务 + if (this.tasks && this.tasks.length) { + this.getTasks({ timeNode: +this.tasks[0].planStart, queryType: 0, queryNum: 6 }); + this.getTasks({ timeNode: +this.tasks[this.tasks.length - 1].planStart, queryType: 1, queryNum: 6 }); + } + }, + // 设置 初始显示角色信息 setInitialRoleId(visibleList) { const index = visibleList.findIndex(item => item.mine); @@ -156,34 +161,6 @@ export default { const param = { roleId, timeNode, timeUnit }; this.getGlobal(param); }, - - // 切换角色获取任务 - async getTasksByRole() { - try { - await this.getTasks({ queryType: 0 }); - await this.getTasks({ queryType: 1 }); - // 查上页的任务 - const upQuery = { - timeNode: +this.tasks[0].planStart, - queryType: 0, - queryNum: 6, - }; - await this.getTasks(upQuery); - - // 查下页的任务 - // 时间基准点=最后一个任务的开始时间+当前时间颗粒度 - const cycle = this.$t.time.computeCycle('天'); - const timeNode = this.$t.time.add(+this.tasks[this.tasks.length - 1].planStart, 1, cycle).valueOf(); - const downQuery = { - timeNode, - queryType: 1, - queryNum: 6, - }; - await this.getTasks(downQuery); - } catch (error) { - console.log('error: ', error); - } - }, }, }; diff --git a/src/store/task/mutations.js b/src/store/task/mutations.js index 593942d..ef4e5c9 100644 --- a/src/store/task/mutations.js +++ b/src/store/task/mutations.js @@ -146,6 +146,12 @@ const mutations = { setPermanents(state, tasks) { state.permanents = tasks || []; }, + + // 清空标志位 如切换角色等使用 + clearEndFlag(state) { + state.topEnd = false; + state.bottomEnd = false; + }, }; export default mutations;