From d643af2cfa47e8fbe6826378542fe1e95c449045 Mon Sep 17 00:00:00 2001 From: song Date: Tue, 17 Aug 2021 17:51:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.=E6=97=B6=E9=97=B4=E8=BD=B4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=B8=B2=E6=9F=93=202.=E6=97=B6=E9=97=B4=E5=9F=BA?= =?UTF-8?q?=E5=87=86=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 79 +--------- src/components/Roles/Roles.vue | 9 +- src/components/TimeLine/TimeLine.vue | 144 ++++------------- src/components/TimeLine/component/TimeBox.vue | 3 +- src/mixins/timeline.js | 44 ++++++ src/pages/project/project.vue | 144 ++++++++++++++--- src/store/task/actions.js | 16 +- src/store/task/mutations.js | 149 ++++-------------- src/store/task/state.js | 1 - src/utils/time.js | 12 ++ 10 files changed, 247 insertions(+), 354 deletions(-) create mode 100644 src/mixins/timeline.js diff --git a/CHANGELOG.md b/CHANGELOG.md index f4f1050..aa13ab5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# 0.1.0 (2021-08-13) +# 0.1.0 (2021-08-17) ### 🌟 新功能 范围|描述|commitId @@ -53,26 +53,6 @@ ### 🎨 代码样式 范围|描述|commitId --|--|-- - - | calendar注释 | a2ec112 - - | 代码审查 | d75134c - - | 代码格式细节调整 | cb2532b - - | 任务快捷方式图标增加 | 4aba872 - - | 修改角色样式 | 73e268e - - | 删除calendar中多余的console | e339eec - - | 删除console.log | 5064a38 - - | 删除index中没用的alert代码 | 9c9eec7 - - | 删除mock,console;upload添加loading | 99d42e2 - - | 删除多余字段 | 5ae3973 - - | 删除插件携带的多余文件 | 0f392bb - - | 删除没用代码 | 34b20e1 - - | 图标修改 | 54bca09 - - | 无基本变化 | 21ac4bb - - | 日常任务修改 | dfa7ee2 - - | 更新代码 | 8c27e68 - - | 更新代码 | 1f40a76 - - | 格式细节调整 | b907a03 - - | 添加插件数据 | 2f11b42 - - | 组件新建 | 89c0035 - | calendar注释 | [a2ec112](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/a2ec112) - | 代码审查 | [d75134c](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/d75134c) - | 代码格式细节调整 | [cb2532b](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/cb2532b) @@ -93,52 +73,12 @@ - | 格式细节调整 | [b907a03](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/b907a03) - | 添加插件数据 | [2f11b42](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/2f11b42) - | 组件新建 | [89c0035](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/89c0035) + - | 细节调整 | [2cfc09a](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/2cfc09a) ### 🐛 Bug 修复 范围|描述|commitId --|--|-- - ID1000343 | 解决向下预加载查询参数时间没+1颗粒度;以及滚动加载颗粒度写死的问题 | 940603a, closes #ID1000343 - plugin | 插件解析机制完善 | 0f5a27d - project title | 项目标题修改; 切换角色移除script | 5c20017 - roles | 修复默认显示不是我的角色的问题 | b69f94f - role | 切换角色的逻辑修正完善 | 4ae534f - task任务逻辑完善 | 减少初始global及regular的不必要请求 | bd4bd38 - - | title.vue根据页面栈显示返回按钮;标题文本超出显示... | 0cbacf4 - - | 上下滑动加载定期任务 | 4090d89 - - | 上下滚动时间轴 | d533a01 - - | 下拉加载定期任务传参,时间格式化修改 | 0b95a0e - - | 任务开始时间延迟插件 | 992a313 - - | 修改main | 749ae9a - - | 修改小红点传参 | 87b20fd - - | 修改报错 | 531c14d - - | 修改接口路径 | df6acf2 - - | 修改角色栏组件 | a54c601 - - | 切换到默认项目角色没有激活状态的bug | 438d448 - - | 切换日历时查询小红点 | 7091789 - - | 定期任务接口 | aa4981c - - | 定期任务插件 | 92b3254 - - | 定期任务未加载时,显示空的时间轴并能上下滑动 | ce38093 - - | 定期任务骨架屏修改 | 8ff72dd - - | 平车演示临时去掉项目快捷方式的toast提示 | e0b2c23 - - | 手动展开日常任务 | 0a4a622 - - | 提示信息显示bug及日常任务收缩问题 | f2f06c5 - - | 插件bug解决 | 41257eb - - | 收到消息修改任务状态 | c378063 - - | 日历无任务时添加小绿点,时间轴刻度无任务不显示时分 | 0f90868 - - | 日常任务html数据查验 | 880ce5c - - | 日常任务插件遍历时的key值修改 | cd26285 - - | 日常任务插件面板高度修改 | 249f9e4 - - | 时间轴上下滑动 | 4d0ae46 - - | 时间轴上下滚动数据加载bug修改 | e82ede4 - - | 时间轴插件 | 225d3cc - - | 时间轴无任务时时间刻度加载修改 | 4921672 - - | 时间轴骨架屏修改 | ca78d02 - - | 角色显示状态修改 | 7d3b906 - - | 角色栏修改 | 19228d6 - - | 解决时间轴报错 | da1eece - - | 跳转详情页返回路径修改 | c5e17c0 - - | 骨架屏替换 | e9fdd71 ID1000343 | 解决向下预加载查询参数时间没+1颗粒度;以及滚动加载颗粒度写死的问题 | [940603a](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/940603a), closes [#ID1000343](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/issues/ID1000343) plugin | 插件解析机制完善 | [0f5a27d](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/0f5a27d) project title | 项目标题修改; 切换角色移除script | [5c20017](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/5c20017) @@ -157,6 +97,7 @@ - | 修改角色栏组件 | [a54c601](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/a54c601) - | 切换到默认项目角色没有激活状态的bug | [438d448](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/438d448) - | 切换日历时查询小红点 | [7091789](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/7091789) + - | 定期任务key值修改 | [c6688db](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/c6688db) - | 定期任务接口 | [aa4981c](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/aa4981c) - | 定期任务插件 | [92b3254](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/92b3254) - | 定期任务未加载时,显示空的时间轴并能上下滑动 | [ce38093](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/ce38093) @@ -219,16 +160,6 @@ ### 🚀 性能优化 范围|描述|commitId --|--|-- - - | 修改定期任务骨架屏高度 | 909a734 - - | 插件查询及展示 | 4dba770 - - | 整理代码 | 7a55315 - - | 日历的更改 | 7353ac8 - - | 测试接口 | 215e074 - - | 组件文件夹新建 | 22bfe7b - - | 组件文件夹新建 | 17bb8c9 - - | 组件文件夹新建 | 1421504 - - | 角色栏文字颜色修改 | 215c6b3 - - | 解决警告 | c932b09 - | 修改定期任务骨架屏高度 | [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) @@ -260,9 +191,7 @@ 范围|描述|commitId --|--|-- - - | style:index | 978f272 - - | !2 基础模板v1.1.0 | f5e61dd - - | init | c0f1deb - | style:index | [978f272](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/978f272) - | !2 基础模板v1.1.0 | [f5e61dd](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/f5e61dd) - | init | [c0f1deb](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/c0f1deb) + diff --git a/src/components/Roles/Roles.vue b/src/components/Roles/Roles.vue index 1de30b1..524c0ef 100644 --- a/src/components/Roles/Roles.vue +++ b/src/components/Roles/Roles.vue @@ -58,7 +58,7 @@ export default { methods: { ...mapActions('task', ['handleRegularTask', 'getPermanent']), ...mapMutations('role', ['setRoleId']), - ...mapMutations('task', ['setPermanents', 'setDailyTasks', 'clearEndFlag', 'setTimeNode']), + ...mapMutations('task', ['setPermanents', 'setDailyTasks', 'clearEndFlag']), // 设置滚动位置 setCurrentRole(index) { @@ -92,13 +92,6 @@ export default { this.setRoleId(id); //改变index 即手动点击切换 我在此时将当前元素赋值给左边距 实现自动滚动 this.setCurrentRole(index); - // 清空日常任务的数据 - this.setPermanents([]); - this.setDailyTasks([]); - // 清空定期任务数据 - // 到顶的标志复位 - // 到底的标志复位 - 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 3b65aee..449b74e 100644 --- a/src/components/TimeLine/TimeLine.vue +++ b/src/components/TimeLine/TimeLine.vue @@ -4,9 +4,9 @@ - + {{ $moment(+task.planStart).format(startTimeFormat) }} {{ $moment(+task.planStart).format('D日') }} + diff --git a/src/mixins/timeline.js b/src/mixins/timeline.js new file mode 100644 index 0000000..b61c46a --- /dev/null +++ b/src/mixins/timeline.js @@ -0,0 +1,44 @@ +import { mapGetters } from 'vuex'; + +const mixin = { + computed: mapGetters('task', ['timeGranularity']), + + methods: { + /** + * 设置时间轴空数据 + * @param {*} startTime + * @param {*} show true 向上加载,false 向下加载 + */ + setTime(startTime, show) { + let { timeGranularity } = this; + let arr = []; + let str = {}; + if (show) { + for (let i = 10; i > 0; i--) { + str = { + id: this.$u.guid(20, false, 10), + panel: {}, + plugins: [], + process: 4, + planStart: this.$t.time.add(startTime, `-${i}` - 0, timeGranularity).valueOf(), + }; + arr.push(str); + } + } else { + for (let i = 0; i < 10; i++) { + str = { + id: this.$u.guid(20, false, 10), + panel: {}, + plugins: [], + process: 4, + planStart: this.$t.time.add(startTime, i + 1, timeGranularity).valueOf(), + }; + arr.push(str); + } + } + return arr; + }, + }, +}; + +export default mixin; diff --git a/src/pages/project/project.vue b/src/pages/project/project.vue index ad85156..b7b8416 100644 --- a/src/pages/project/project.vue +++ b/src/pages/project/project.vue @@ -18,8 +18,10 @@ diff --git a/src/store/task/actions.js b/src/store/task/actions.js index f48ced7..33e7da9 100644 --- a/src/store/task/actions.js +++ b/src/store/task/actions.js @@ -18,10 +18,10 @@ const actions = { * @param {*} commit * @param {object} param 请求参数 roleId, timeNode, timeUnit */ - async getGlobal({ commit }, param) { + async getGlobal(param) { try { - const data = await uni.$u.api.getGlobal(param); - commit('setDailyTasks', data); + await uni.$u.api.getGlobal(param); + // commit('setDailyTasks', data); } catch (error) { console.log('task actions getGlobal error: ', error); } @@ -33,16 +33,10 @@ const actions = { * @param {number} param.queryType 必填 0 -> 向上 1 -> 向下 */ // eslint-disable-next-line - async getRegulars({ commit, state }, param) { + async getRegulars(param) { try { - // 向上查 且 上边没数据了 不查 - // if (param.queryType === 0) return; - // 向下查 且 下边美术家了 不查 - // if (param.queryType === 1) return; const data = await uni.$u.api.getRegularTask(param); - // 0 -> 向上 1 -> 向下 - // data 有无的判断在mutations里 - param.queryType === 0 ? commit('setUpTasks', data) : commit('setDownTasks', data); + return data; } catch (error) { throw error || '获取定期任务失败'; } diff --git a/src/store/task/mutations.js b/src/store/task/mutations.js index 1994329..a0c51c4 100644 --- a/src/store/task/mutations.js +++ b/src/store/task/mutations.js @@ -52,7 +52,6 @@ const mutations = { */ setTimeNode(state, data) { state.timeNode = data; - console.log('state.timeNode : ', state.timeNode); }, /** @@ -70,65 +69,10 @@ const mutations = { * @param {Array} data 服务端返回的模板数组 */ setUpTasks(state, data) { - if (!data || !data.length) { - state.topEnd = true; - let sTime = ''; - if (!state.tasks || !state.tasks.length) { - sTime = +new Date().getTime(); - } else { - sTime = +state.tasks[0].planStart - 0; - } - const initData = [ - { - id: state.randomId, - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(sTime, -6, 'day').valueOf(), - }, - { - id: state.randomId, - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(sTime, -5, 'day').valueOf(), - }, - { - id: state.randomId, - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(sTime, -4, 'day').valueOf(), - }, - { - id: state.randomId, - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(sTime, -3, 'day').valueOf(), - }, - { - id: state.randomId, - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(sTime, -2, 'day').valueOf(), - }, - { - id: state.randomId, - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(sTime, -1, 'day').valueOf(), - }, - ]; - state.tasks = [...initData.concat(state.tasks)]; + if (!state.tasks.length) { + state.tasks = [...data]; } else { - if (!state.tasks && !state.tasks.length) { - state.tasks = [...data]; - } else { - state.tasks = [...data.concat(state.tasks)]; - } + state.tasks = [...data.concat(state.tasks)]; } }, @@ -138,65 +82,10 @@ const mutations = { * @param {Array} data 服务端返回的模板数组 */ setDownTasks(state, data) { - if (!data || !data.length) { - state.bottomEnd = true; - let sTime = ''; - if (!state.tasks || !state.tasks.length) { - sTime = +new Date().getTime(); - } else { - sTime = +state.tasks[state.tasks.length - 1].planStart - 0; - } - const initData = [ - { - id: state.randomId, - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(sTime, 1, 'day').valueOf(), - }, - { - id: state.randomId, - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(sTime, 2, 'day').valueOf(), - }, - { - id: state.randomId, - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(sTime, 3, 'day').valueOf(), - }, - { - id: state.randomId, - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(sTime, 4, 'day').valueOf(), - }, - { - id: state.randomId, - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(sTime, 5, 'day').valueOf(), - }, - { - id: state.randomId, - panel: {}, - plugins: [], - process: 4, - planStart: uni.$t.time.add(sTime, 6, 'day').valueOf(), - }, - ]; - state.tasks = [...state.tasks.concat(initData)]; + if (!state.tasks && !state.tasks.length) { + state.tasks = [...data]; } else { - if (!state.tasks && !state.tasks.length) { - state.tasks = [...data]; - } else { - state.tasks = [...state.tasks.concat(data)]; - } + state.tasks = [...state.tasks.concat(data)]; } }, @@ -218,13 +107,35 @@ const mutations = { state.permanents = tasks || []; }, - // 清空标志位 任务 如切换角色等使用 + /** + * 设置时间轴是否继续向上查任务 + * @param {Object} state + * @param {Boolean} show + */ + setTopEnd(state, show) { + state.topEnd = show; + }, + + /** + * 设置时间轴是否继续向下查任务 + * @param {Object} state + * @param {Boolean} show + */ + setBottomEnd(state, show) { + state.bottomEnd = show; + }, + + // 清空标志位 如切换角色等使用 clearEndFlag(state) { - state.tasks = []; state.topEnd = false; state.bottomEnd = false; }, + // 清空定期任务 + clearTasks(state) { + state.tasks = []; + }, + /** * 收到消息设置任务状态 * @param {Object} state diff --git a/src/store/task/state.js b/src/store/task/state.js index 7aca908..d453785 100644 --- a/src/store/task/state.js +++ b/src/store/task/state.js @@ -25,7 +25,6 @@ const state = { // 定期任务 tasks: [], showSkeleton: false, // 定期任务骨架屏 - randomId: Math.floor(Math.random() * 100000000000000000000), // 随机id }; export default state; diff --git a/src/utils/time.js b/src/utils/time.js index 4997acd..6f1fae2 100644 --- a/src/utils/time.js +++ b/src/utils/time.js @@ -100,6 +100,17 @@ const validateTimeIsToday = time => { return timeDate.getFullYear() === date.getFullYear() && timeDate.getMonth() === date.getMonth() && timeDate.getDate() === date.getDate(); }; +/** + * 检测两个日期是否相同 + * @param {number | date} time + * @param {number | date} value + * @param {string} cycle 传入 day 将会比较 day、 month和 year + */ +const isSame = (time, value, cycle) => { + const str = dayjs(time).isSame(value, cycle); + return str; +}; + /** * 格式化开始时间 * @param {Number} timestamp 时间戳 @@ -344,6 +355,7 @@ export default { convertTime, secondToMinute, setTimestampToStr, + isSame, formatBeginTime, formatDuration, formatDurationToObject,