From e082ccb76ffd713bf5ab49ba4991514e80d12aef Mon Sep 17 00:00:00 2001 From: song Date: Wed, 18 Aug 2021 11:37:51 +0800 Subject: [PATCH] =?UTF-8?q?perf:=201.=E6=97=B6=E9=97=B4=E8=BD=B4=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E7=9B=B8=E5=90=8C=E7=9A=84=E6=97=B6=E9=97=B4=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E6=95=B0=E6=8D=AE=202.=E6=95=B4=E7=90=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + src/components/Roles/Roles.vue | 1 - src/components/TimeLine/TimeLine.vue | 21 ++++++++++--------- src/components/TimeLine/component/TimeBox.vue | 7 ++++--- src/pages/project/project.vue | 14 ++++++------- src/plugins/p-wbs-import/p-wbs-import.vue | 3 +-- src/store/task/mutations.js | 9 ++++++++ src/store/task/state.js | 1 + 8 files changed, 34 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca779c3..9636235 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -161,6 +161,7 @@ ### 🚀 性能优化 范围|描述|commitId --|--|-- + - | 修改代码格式 | [14123d7](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/14123d7) - | 修改定期任务骨架屏高度 | [909a734](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/909a734) - | 插件查询及展示 | [4dba770](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/4dba770) - | 整理代码 | [7a55315](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/7a55315) diff --git a/src/components/Roles/Roles.vue b/src/components/Roles/Roles.vue index 2a087f9..798ef98 100644 --- a/src/components/Roles/Roles.vue +++ b/src/components/Roles/Roles.vue @@ -85,7 +85,6 @@ export default { // 时间基准点不用管 project监听了roleId 里处理了 changeRole(id, index) { try { - console.log('切换角色'); // 清除多余的script this.clearPluginScript(); this.$nextTick(() => { diff --git a/src/components/TimeLine/TimeLine.vue b/src/components/TimeLine/TimeLine.vue index 449b74e..efcc1ff 100644 --- a/src/components/TimeLine/TimeLine.vue +++ b/src/components/TimeLine/TimeLine.vue @@ -31,20 +31,17 @@ export default { mixins: [mixin], data() { - return { - top: 0, - viewId: '', // 距离顶部的距离 - }; + return { top: 0 }; }, computed: { ...mapState('role', ['visibleRoles']), - ...mapState('task', ['scrollTop', 'showTips', 'tasks', 'topEnd', 'bottomEnd', 'showSkeleton', 'timeNode']), + ...mapState('task', ['scrollTop', 'showTips', 'tasks', 'topEnd', 'bottomEnd', 'showSkeleton', 'timeNode', 'viewId']), ...mapGetters('task', ['timeGranularity']), }, methods: { - ...mapMutations('task', ['setScrollTop', 'setShrink', 'setUpTasks', 'setDownTasks']), + ...mapMutations('task', ['setScrollTop', 'setShrink', 'setUpTasks', 'setDownTasks', 'setViewId']), // 滚动 scroll(e) { @@ -98,17 +95,21 @@ export default { }, // 设置自动滚动位置 - setViewId() { + setScrollPosition() { const { tasks, timeNode } = this; for (let i = 0; i < tasks.length; i++) { const item = tasks[i]; const show = this.$t.time.isSame(+item.planStart, +timeNode, this.timeGranularity); - if (item.detailId) { - this.viewId = `a${item.id}`; + // 如果storage里有timeNode,修改store里的timeNode + const taskId = this.$t.storage.getStorageSync('taskId'); + // 清空storage + if (taskId) { + this.setViewId(`a${taskId}`); + this.$t.storage.setStorageSync('taskId', ''); return; } if (show) { - this.viewId = `a${item.id}`; + this.setViewId(`a${item.id}`); return; } } diff --git a/src/components/TimeLine/component/TimeBox.vue b/src/components/TimeLine/component/TimeBox.vue index a35c0e6..b8e10c3 100644 --- a/src/components/TimeLine/component/TimeBox.vue +++ b/src/components/TimeLine/component/TimeBox.vue @@ -38,7 +38,7 @@ class="h-16" margin="0" v-if="tasks && tasks.length && task.process !== 4 && !showSkeleton" - @click="onClickTask(+task.planStart)" + @click="onClickTask(+task.planStart, task.id)" > @@ -105,11 +105,12 @@ export default { /** * 点击了定期任务的面板 更新可变的日常任务 * @param {number} planStart 任务计划开始时间 + * @param {string} taskId 任务id */ - onClickTask(planStart) { + onClickTask(planStart, taskId) { const param = { roleId: this.roleId, timeNode: planStart, timeUnit: this.timeUnit }; this.getGlobal(param); - this.$t.storage.setStorageSync('timeNode', planStart); + this.$t.storage.setStorageSync('taskId', taskId); this.$t.storage.setStorageSync('roleId', this.roleId); }, diff --git a/src/pages/project/project.vue b/src/pages/project/project.vue index b7b8416..9086a26 100644 --- a/src/pages/project/project.vue +++ b/src/pages/project/project.vue @@ -44,6 +44,7 @@ export default { * 永久日常任务不发生改变 */ async timeNode(val) { + console.log('时间基准点发生变化: ', val); if (val && this.roleId) { // 根据时间和角色查找日常任务 await this.initTasks(); @@ -59,10 +60,7 @@ export default { roleId(val) { if (val) { console.log('角色发生变化: ', val); - // 如果storage里有timeNode,修改store里的timeNode - this.setTimeNode(+this.$t.storage.getStorageSync('timeNode') !== 0 ? +this.$t.storage.getStorageSync('timeNode') : Date.now()); - // 清空storage - this.$t.storage.setStorageSync('timeNode', ''); + this.setTimeNode(Date.now()); // 根据角色查找永久的日常任务 this.getPermanent(val); } @@ -152,7 +150,7 @@ export default { this.setNextTasks(); await this.getInitTasks(); setTimeout(() => { - this.$refs.child.setViewId(); + this.$refs.child.setScrollPosition(); }, 2000); }, @@ -268,17 +266,19 @@ export default { for (let j = 0; j < data.length; j++) { const item = data[j]; // 查找有没有超出时间刻度的时间 - if (+data[0].planStart < +newTasks[0].planStart) { + if (+newTasks[0].planStart > +data[0].planStart) { this.setPrevTasks(); newTasks = [...this.tasks]; + i--; break; } else if (+data[data.length - 1].planStart > +newTasks[newTasks.length - 1].planStart) { this.setNextTasks(); newTasks = [...this.tasks]; + i--; break; } else { // 筛选相同的时间替换数据 - const taskItem = this.$t.time.isSame(+item.planStart, +task.planStart, this.timeGranularity); + const taskItem = this.$t.time.isSame(+task.planStart, +item.planStart, this.timeGranularity); if (taskItem) { arr.push(item); if (task.detailId) { diff --git a/src/plugins/p-wbs-import/p-wbs-import.vue b/src/plugins/p-wbs-import/p-wbs-import.vue index 0e37dd2..00b9b1b 100644 --- a/src/plugins/p-wbs-import/p-wbs-import.vue +++ b/src/plugins/p-wbs-import/p-wbs-import.vue @@ -54,8 +54,7 @@ export default { // TODO: 更新接口没写完 async handleUpdate() { try { - const data = await this.$u.api.import({ projectId: this.projectId }); - console.log('data: ', data); + await this.$u.api.import({ projectId: this.projectId }); // 导入WBS成功后 // 直接打开导入的项目 this.onUploadSuccess(); diff --git a/src/store/task/mutations.js b/src/store/task/mutations.js index a0c51c4..e644faa 100644 --- a/src/store/task/mutations.js +++ b/src/store/task/mutations.js @@ -8,6 +8,15 @@ const mutations = { state.scrollTop = num; }, + /** + * 记录时间轴向上滚动的距离 + * @param { object } state + * @param { string } data + */ + setViewId(state, data) { + state.viewId = data; + }, + /** * 设置日常任务当前是否应该处于收缩状态 * @param { object } state diff --git a/src/store/task/state.js b/src/store/task/state.js index d453785..e8397e0 100644 --- a/src/store/task/state.js +++ b/src/store/task/state.js @@ -1,5 +1,6 @@ const state = { scrollTop: 0, + viewId: '', // 时间轴自动滚动的位置 isShrink: false, // true: 收起, false:展开 tip: { taskId: '', // 当前正在修改状态的任务的id