From 49216721765e8bfafc26d51287bc26ce9687da2d Mon Sep 17 00:00:00 2001 From: song Date: Thu, 12 Aug 2021 19:36:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=B6=E9=97=B4=E8=BD=B4=E6=97=A0?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=97=B6=E6=97=B6=E9=97=B4=E5=88=BB=E5=BA=A6?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + src/components/Roles/Roles.vue | 7 +- src/components/TimeLine/TimeLine.vue | 19 ++--- .../TimeLine/component/TimeStatus.vue | 1 - src/components/Upload/Upload.vue | 1 - src/pages/project/project.vue | 13 +++- src/store/task/mutations.js | 71 +++++++------------ src/store/task/state.js | 36 +++++----- 8 files changed, 64 insertions(+), 85 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bfa5f4..f988898 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,6 +101,7 @@ - | 手动展开日常任务 | [0a4a622](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/0a4a622) - | 提示信息显示bug及日常任务收缩问题 | [f2f06c5](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/f2f06c5) - | 插件bug解决 | [41257eb](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/41257eb) + - | 收到消息修改任务状态 | [c378063](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/c378063) - | 日常任务html数据查验 | [880ce5c](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/880ce5c) - | 日常任务插件遍历时的key值修改 | [cd26285](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/cd26285) - | 日常任务插件面板高度修改 | [249f9e4](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/249f9e4) diff --git a/src/components/Roles/Roles.vue b/src/components/Roles/Roles.vue index f70bf68..ab6eaa5 100644 --- a/src/components/Roles/Roles.vue +++ b/src/components/Roles/Roles.vue @@ -58,7 +58,7 @@ export default { methods: { ...mapActions('task', ['handleRegularTask']), ...mapMutations('role', ['setRoleId']), - ...mapMutations('task', ['setTasks', 'setPermanents', 'setDailyTasks', 'clearEndFlag']), + ...mapMutations('task', ['setPermanents', 'setDailyTasks', 'clearEndFlag']), // 设置滚动位置 setCurrentRole(index) { @@ -91,14 +91,13 @@ export default { this.setRoleId(id); //改变index 即手动点击切换 我在此时将当前元素赋值给左边距 实现自动滚动 this.setCurrentRole(index); - // 清空定期任务数据 - this.setTasks(); // 清空日常任务的数据 this.setPermanents([]); this.setDailyTasks([]); + // 清空定期任务数据 // 到顶的标志复位 // 到底的标志复位 - // this.clearEndFlag(); + this.clearEndFlag(); }); } catch (error) { console.error('role.vue changeRole error: ', error); diff --git a/src/components/TimeLine/TimeLine.vue b/src/components/TimeLine/TimeLine.vue index d754930..5f582a2 100644 --- a/src/components/TimeLine/TimeLine.vue +++ b/src/components/TimeLine/TimeLine.vue @@ -54,13 +54,11 @@ export default { // 滚动到顶部 async handleScrollTop() { + if (!this.tasks || !this.tasks.length) return; const startTime = this.tasks[0].planStart - 0; if ((this.tasks[0].plugins && this.tasks[0].plugins.length === 0) || this.topEnd) { // 没有数据时 自动加载数据 - console.warn( - '滚动到顶部没有数据时: ', - this.$moment(+this.$t.time.add(startTime, -1, 'day').valueOf()).format('YYYY-MM-DD HH:mm:ss'), - ); + console.warn('滚动到顶部没有数据时: '); const addTasks = [ { panel: {}, @@ -82,7 +80,7 @@ export default { }, ]; - this.setUpTasks([...addTasks.concat(this.tasks)]); + this.setUpTasks(addTasks); } else { // 有数据时 console.warn('滚动到顶部有数据时: '); @@ -97,17 +95,12 @@ export default { // 滚动到底部 async handleScrollBottom() { + if (!this.tasks || !this.tasks.length) return; const { tasks, timeGranularity } = this; - console.log('timeGranularity: ', timeGranularity); const startTime = tasks[tasks.length - 1].planStart - 0; - console.log('startTime: ', startTime); if ((tasks[0].plugins && tasks[0].plugins.length === 0) || this.bottomEnd) { // 没有数据时 自动加载数据 - console.warn( - '滚动到底部没有数据时: ', - this.$moment(+startTime).format('YYYY-MM-DD HH:mm:ss'), - this.$moment(+this.$t.time.add(startTime, 1, timeGranularity).valueOf()).format('YYYY-MM-DD HH:mm:ss'), - ); + console.warn('滚动到底部没有数据时: '); const addTasks = [ { panel: {}, @@ -128,7 +121,7 @@ export default { planStart: this.$t.time.add(startTime, 3, timeGranularity).valueOf(), }, ]; - this.setDownTasks([...tasks.concat(addTasks)]); + this.setDownTasks(addTasks); } else { // 时间基准点=最后一个任务的开始时间+当前时间颗粒度 const timeNode = this.$t.time.add(startTime, 1, timeGranularity).valueOf(); diff --git a/src/components/TimeLine/component/TimeStatus.vue b/src/components/TimeLine/component/TimeStatus.vue index 7708d45..1fefc6a 100644 --- a/src/components/TimeLine/component/TimeStatus.vue +++ b/src/components/TimeLine/component/TimeStatus.vue @@ -189,7 +189,6 @@ export default { } else { time = null; } - console.log('time', time); // DEBUG: this.$nextTick(() => { if (!time) return; this.timer = setTimeout(() => { diff --git a/src/components/Upload/Upload.vue b/src/components/Upload/Upload.vue index 240985d..cf3e802 100644 --- a/src/components/Upload/Upload.vue +++ b/src/components/Upload/Upload.vue @@ -14,7 +14,6 @@ export default { async handleUpload() { try { const data = await this.$u.api.import(); - console.log('data: ', data); // 导入WBS成功后 // 直接打开导入的项目 this.$emit('success'); diff --git a/src/pages/project/project.vue b/src/pages/project/project.vue index 9e1a8ed..f3526a3 100644 --- a/src/pages/project/project.vue +++ b/src/pages/project/project.vue @@ -68,6 +68,10 @@ export default { this.height = window.screen.height + 'px'; }, + onUnload() { + this.clearEndFlag(); + }, + methods: { ...mapActions('user', ['getToken']), ...mapActions('project', ['getProjectById']), @@ -76,7 +80,7 @@ export default { ...mapMutations('user', ['setToken']), ...mapMutations('project', ['setProject', 'setProjectName']), ...mapMutations('role', ['setInvisibleRoles', 'setVisibleRoles', 'setRoleId']), - ...mapMutations('task', ['setUpTasks', 'setDownTasks', 'setDailyTasks', 'setTimeNode']), + ...mapMutations('task', ['setUpTasks', 'setDownTasks', 'setDailyTasks', 'setTimeNode', 'clearEndFlag']), /** * 初始化 @@ -117,14 +121,12 @@ export default { // 切换了 颗粒度 || 角色时候 获取初始定期任务 async getInitTasks() { - console.log('获取初始定期任务: '); // 根据时间基准点和角色查找定期任务 await this.getTasks({ queryType: 0 }); await this.getTasks({ queryType: 1 }); // 预加载 上下的定期任务 if (this.tasks && this.tasks.length && this.tasks.plugins && this.tasks.plugins.length) { - console.log('预加载: '); this.$nextTick(() => { const { tasks, timeGranularity } = this; this.getTasks({ timeNode: +tasks[0].planStart, queryType: 0, queryNum: 6 }); @@ -132,6 +134,11 @@ export default { const nextQueryTime = +this.$t.time.add(+tasks[tasks.length - 1].planStart, 1, timeGranularity); this.getTasks({ timeNode: nextQueryTime, queryType: 1, queryNum: 6 }); }); + } else { + // 向上加载 + this.setUpTasks(); + // 向下加载 + this.setDownTasks(); } }, diff --git a/src/store/task/mutations.js b/src/store/task/mutations.js index dbf2973..cda9e99 100644 --- a/src/store/task/mutations.js +++ b/src/store/task/mutations.js @@ -71,30 +71,35 @@ const mutations = { setUpTasks(state, data) { if (!data || !data.length) { state.topEnd = true; - const time = +state.tasks[0].planStart - 0; + let sTime = ''; + if (!state.tasks || !state.tasks.length) { + sTime = +new Date().getTime(); + } else { + sTime = +state.tasks[0].planStart - 0; + } const initData = [ { panel: {}, plugins: [], process: 4, - planStart: uni.$t.time.add(time, -3, 'day').valueOf(), + planStart: uni.$t.time.add(sTime, -3, 'day').valueOf(), }, { panel: {}, plugins: [], process: 4, - planStart: uni.$t.time.add(time, -2, 'day').valueOf(), + planStart: uni.$t.time.add(sTime, -2, 'day').valueOf(), }, { panel: {}, plugins: [], process: 4, - planStart: uni.$t.time.add(time, -1, 'day').valueOf(), + planStart: uni.$t.time.add(sTime, -1, 'day').valueOf(), }, ]; state.tasks = [...initData.concat(state.tasks)]; } else { - if (!state.tasks[0].name) { + if (!state.tasks && !state.tasks.length) { state.tasks = [...data]; } else { state.tasks = [...data.concat(state.tasks)]; @@ -110,30 +115,35 @@ const mutations = { setDownTasks(state, data) { if (!data || !data.length) { state.bottomEnd = true; - const time = +state.tasks[state.tasks.length - 1].planStart - 0; + let sTime = ''; + if (!state.tasks || !state.tasks.length) { + sTime = +new Date().getTime(); + } else { + sTime = +state.tasks[state.tasks.length - 1].planStart - 0; + } const initData = [ { panel: {}, plugins: [], process: 4, - planStart: uni.$t.time.add(time, 1, 'day').valueOf(), + planStart: uni.$t.time.add(sTime, 1, 'day').valueOf(), }, { panel: {}, plugins: [], process: 4, - planStart: uni.$t.time.add(time, 2, 'day').valueOf(), + planStart: uni.$t.time.add(sTime, 2, 'day').valueOf(), }, { panel: {}, plugins: [], process: 4, - planStart: uni.$t.time.add(time, 3, 'day').valueOf(), + planStart: uni.$t.time.add(sTime, 3, 'day').valueOf(), }, ]; state.tasks = [...state.tasks.concat(initData)]; } else { - if (!state.tasks[0] || !state.tasks[0].name) { + if (!state.tasks && !state.tasks.length) { state.tasks = [...data]; } else { state.tasks = [...state.tasks.concat(data)]; @@ -141,36 +151,6 @@ const mutations = { } }, - /** - * 清空定期任务数据 - * @param {Object} state - * @param {Array} data 服务端返回的模板数组 - */ - setTasks(state) { - const time = +new Date().getTime(); - const initData = [ - { - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(time, -1, 'day').valueOf(), - }, - { - panel: {}, - plugins: [], - process: 4, - planStart: time, - }, - { - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(time, 1, 'day').valueOf(), - }, - ]; - state.tasks = initData; - }, - /** * 设置日常任务数据 * @param {Object} state @@ -189,11 +169,12 @@ const mutations = { state.permanents = tasks || []; }, - // 清空标志位 如切换角色等使用 - // clearEndFlag(state) { - // state.topEnd = false; - // state.bottomEnd = false; - // }, + // 清空标志位 任务 如切换角色等使用 + clearEndFlag(state) { + state.tasks = []; + state.topEnd = false; + state.bottomEnd = false; + }, /** * 收到消息设置任务状态 diff --git a/src/store/task/state.js b/src/store/task/state.js index ff213ed..75d0f09 100644 --- a/src/store/task/state.js +++ b/src/store/task/state.js @@ -24,24 +24,24 @@ const state = { dailyTasks: [], // 日常任务 // 定期任务 tasks: [ - { - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(+new Date().getTime(), -1, 'day').valueOf(), - }, - { - panel: {}, - plugins: [], - process: 4, - planStart: new Date().getTime(), - }, - { - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(+new Date().getTime(), 1, 'day').valueOf(), - }, + // { + // panel: {}, + // plugins: [], + // process: 4, + // planStart: uni.$t.time.add(+new Date().getTime(), -1, 'day').valueOf(), + // }, + // { + // panel: {}, + // plugins: [], + // process: 4, + // planStart: new Date().getTime(), + // }, + // { + // panel: {}, + // plugins: [], + // process: 4, + // planStart: uni.$t.time.add(+new Date().getTime(), 1, 'day').valueOf(), + // }, ], };