diff --git a/CHANGELOG.md b/CHANGELOG.md
index e6a71a0..4f46e74 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -67,6 +67,7 @@
### 🚀 性能优化
范围|描述|commitId
--|--|--
+ - | 测试接口 | [215e074](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/215e074)
- | 角色栏文字颜色修改 | [215c6b3](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/215c6b3)
- | 解决警告 | [c932b09](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/c932b09)
- | 组件文件夹新建 | [22bfe7b](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/22bfe7b)
diff --git a/src/components/Globals/Globals.vue b/src/components/Globals/Globals.vue
index d8c338c..e33a2e1 100644
--- a/src/components/Globals/Globals.vue
+++ b/src/components/Globals/Globals.vue
@@ -39,7 +39,7 @@ export default {
},
mounted() {
- setTimeout(() => (this.loading = false), 5000);
+ setTimeout(() => (this.loading = false), 2000);
},
computed: mapState('home', ['isShrink']),
methods: {
diff --git a/src/components/Roles/Roles.vue b/src/components/Roles/Roles.vue
index 56f7575..e96017f 100644
--- a/src/components/Roles/Roles.vue
+++ b/src/components/Roles/Roles.vue
@@ -1,6 +1,6 @@
-
+
@@ -13,7 +13,12 @@ export default {
data() {
return {};
},
- methods: {},
+ methods: {
+ getTasks(query) {
+ console.log('query: ', query);
+ this.$emit('getTasks', query);
+ },
+ },
};
diff --git a/src/components/Roles/component/RoleList.vue b/src/components/Roles/component/RoleList.vue
index d4ad52f..1d2112b 100644
--- a/src/components/Roles/component/RoleList.vue
+++ b/src/components/Roles/component/RoleList.vue
@@ -39,32 +39,11 @@ export default {
pm: 0,
sequence: 2,
},
- {
- id: 3,
- name: '导师一',
- mine: 1,
- pm: 0,
- sequence: 3,
- },
- {
- id: 4,
- name: '导师二',
- mine: 1,
- pm: 0,
- sequence: 4,
- },
- {
- id: 5,
- name: '导师三',
- mine: 1,
- pm: 0,
- sequence: 5,
- },
],
};
},
- computed: { ...mapState('home', ['visibleRoles', 'roleId']) },
+ computed: { ...mapState('home', ['visibleRoles', 'roleId', 'tasks']) },
watch: {
visibleRoles(val) {
@@ -104,44 +83,44 @@ export default {
this.scrollLeft = left - screenWidth / 2;
},
- changeIndex(id, index) {
+ async changeIndex(id, index) {
this.setRoleId(id);
//改变index 即手动点击切换 我在此时将当前元素赋值给左边距 实现自动滚动
this.setCurrentRole(index);
// 根据时间基准点和角色查找定期任务
- this.getTasks();
- },
-
- /**
- * 根据时间基准点和角色查找定期任务
- * @param {string} roleId 角色id
- * @param {string} timeNode 时间基准点 默认当前
- * @param {string} timeUnit 时间颗粒度 默认天
- */
- async getTasks() {
- try {
- const { roleId, timeNode, timeUnit } = this;
- const params = {
- roleId,
- timeNode,
- timeUnit,
+ await this.$emit('getTasks', { queryType: 0 });
+ await this.$emit('getTasks', { queryType: 1 });
+ console.log('this.tasks && this.tasks.length: ', this.tasks && this.tasks.length);
+ if (this.tasks && this.tasks.length) {
+ debugger;
+ // 查上下的任务
+ const upQuery = {
+ timeNode: +this.tasks[0].planStart,
+ queryType: 0,
+ queryNum: 6,
+ };
+ console.log('upQuery: ', upQuery);
+ await this.$emit('getTasks', upQuery);
+ const downQuery = {
+ timeNode: +this.tasks[this.tasks.length - 1].planStart,
+ queryType: 0,
+ queryNum: 6,
};
- await this.handleRegularTask(params);
- } catch (error) {
- console.log('error: ', error);
+ console.log('downQuery: ', downQuery);
+ await this.$emit('getTasks', downQuery);
}
},
// 设置文字颜色
setColor(mine, id) {
const { roleId } = this;
- if (mine === 1 && roleId === id) {
+ if (mine === '1' && roleId === id) {
return 'default-tab-choice';
}
- if (mine === 1 && roleId !== id) {
+ if (mine === '1' && roleId !== id) {
return 'default-tab-item';
}
- if (mine === 0 && roleId === id) {
+ if (mine === '0' && roleId === id) {
return 'tab-choice';
}
},
diff --git a/src/components/TimeLine/TimeLine.vue b/src/components/TimeLine/TimeLine.vue
index f253bfb..94bc45f 100644
--- a/src/components/TimeLine/TimeLine.vue
+++ b/src/components/TimeLine/TimeLine.vue
@@ -36,19 +36,6 @@ export default {
computed: mapState('home', ['scrollTop', 'showTips', 'visibleRoles', 'tasks']),
- mounted() {
- // 设置默认基准点
- // let tasksHeight = 0;
- // const scrollHeight = document.getElementById('scroll').clientHeight;
- // if (this.visibleRoles && this.visibleRoles.length) {
- // for (let i = 0; i < 3; i++) {
- // tasksHeight += this.visibleRoles[i].panel.height - 0 + 42;
- // }
- // this.top = tasksHeight - scrollHeight / 2;
- // }
- // console.log('this.top: ', this.top);
- },
-
methods: {
...mapMutations('home', ['setScrollTop', 'setShrink', 'setRoleId']),
@@ -62,13 +49,13 @@ export default {
// 滚动到顶部
handleScrollTop() {
console.log('滚动到顶部');
- this.$emit('getTasks', 0);
+ this.$emit('getTasks', { queryType: 0 });
},
// 滚动到底部
handleScrollBottom() {
console.log('滚动到底部');
- this.$emit('getTasks', 0);
+ this.$emit('getTasks', { queryType: 1 });
},
// 设置基准点
@@ -78,7 +65,10 @@ export default {
let tasksHeight = 0;
const scrollHeight = document.getElementById('scroll').clientHeight;
for (let i = 0; i < 3; i++) {
- tasksHeight += +tasks[i].panel.height + 42;
+ // TODO: 高度不对
+ // if (tasks[i].panel && tasks[i].panel.height) {
+ // tasksHeight += +tasks[i].panel.height + 42;
+ // }
}
this.top = tasksHeight - scrollHeight / 2;
}
diff --git a/src/components/TimeLine/component/TimeBox.vue b/src/components/TimeLine/component/TimeBox.vue
index 2d9bb43..f303126 100644
--- a/src/components/TimeLine/component/TimeBox.vue
+++ b/src/components/TimeLine/component/TimeBox.vue
@@ -2,9 +2,10 @@
-
+
- 任务时间栏
+ {{ $u.timeFormat(+item.planStart, 'mm-dd hh:MM') }}
+
@@ -16,22 +17,11 @@
-
+
+
-
@@ -41,13 +31,6 @@
-
@@ -73,7 +56,18 @@ export default {
created() {},
- methods: { ...mapMutations('home', ['setTipsContent', 'setTipsContent']) },
+ methods: {
+ ...mapMutations('home', ['setTipsContent', 'setTipsContent']),
+
+ // 设置任务面板高度
+ setHeight(panel) {
+ if (panel && panel.height) {
+ return panel.height + 'px';
+ } else {
+ return 'auto';
+ }
+ },
+ },
};
diff --git a/src/pages/project/project.vue b/src/pages/project/project.vue
index 21ed757..5c2e4d5 100644
--- a/src/pages/project/project.vue
+++ b/src/pages/project/project.vue
@@ -2,7 +2,7 @@
-
+
@@ -18,7 +18,7 @@ export default {
computed: {
...mapState('user', ['user', 'token']),
- ...mapState('home', ['visibleRoles', 'roleId', 'timeNode', 'timeUnit']),
+ ...mapState('home', ['visibleRoles', 'roleId', 'timeNode', 'timeUnit', 'tasks']),
},
async onLoad(options) {
@@ -29,18 +29,26 @@ export default {
await this.getUserId(options.u);
}
const params = { projectId: options.p };
+ this.setProjectName(options.pname);
// 根据项目id获取项目信息
await this.getProjectById(params);
// 根据项目id获取角色列表
await this.getRoles(params);
this.setInitialRoleId(this.visibleRoles);
// 根据时间基准点和角色查找定期任务
- await this.getTasks(0);
- await this.getTasks(1);
+ await this.getTasks({ queryType: 0 });
+ await this.getTasks({ queryType: 1 });
// 根据角色查找永久的日常任务
await this.getPermanent();
// 根据时间和角色查找日常任务
await this.getGlobal();
+ // 查上下的定期任务
+ if (this.tasks && this.tasks.length) {
+ console.log('this.tasks[0].planStart: ', this.tasks[0].planStart);
+ await this.getTasks({ timeNode: +this.tasks[0].planStart, queryType: 0, queryNum: 6 });
+ console.log('this.tasks[this.tasks.length - 1].planStart: ', this.tasks[this.tasks.length - 1].planStart);
+ await this.getTasks({ timeNode: +this.tasks[this.tasks.length - 1].planStart, queryType: 1, queryNum: 6 });
+ }
},
mounted() {
@@ -56,6 +64,7 @@ export default {
'setUpTasks',
'setDownTasks',
'setDailyTasks',
+ 'setProjectName',
]),
...mapActions('user', ['getUserId']),
...mapActions('home', ['getProjectById', 'getRoles', 'handleRegularTask']),
@@ -81,18 +90,17 @@ export default {
* @param {string} queryNum 查找颗粒度数量 默认3个
* @param {string} queryType 0向上查找 1向下查找(默认) 下查包含自己,上查不包含
*/
- async getTasks(queryType) {
+ async getTasks(query) {
try {
const { roleId, timeNode, timeUnit } = this;
- const params = {
- roleId,
- timeNode,
- timeUnit,
- queryNum: 3,
- queryType,
- };
+ const params = { roleId };
+ params.timeNode = query.timeNode || timeNode;
+ params.timeUnit = query.timeUnit || timeUnit;
+ params.queryNum = query.queryNum || 3;
+ params.queryType = query.queryType;
+ console.log('params: ', params);
const res = await this.handleRegularTask(params);
- queryType === 0 ? this.setUpTasks(res) : this.setDownTasks(res);
+ query.queryType === 0 ? this.setUpTasks(res) : this.setDownTasks(res);
this.$refs.child.setDatumPoint();
} catch (error) {
console.log('error: ', error);
diff --git a/src/store/home/actions.js b/src/store/home/actions.js
index 2c0cdcd..b1471de 100644
--- a/src/store/home/actions.js
+++ b/src/store/home/actions.js
@@ -36,9 +36,9 @@ const actions = {
* @param {string} timeNode 时间基准点 默认当前
* @param {string} timeUnit 时间颗粒度 默认天
*/
+ // eslint-disable-next-line
async handleRegularTask({ commit }, param) {
try {
- console.log('commit: ', commit);
return await uni.$u.api.getRegularTask(param);
} catch (error) {
throw error || '获取定期任务失败';
diff --git a/src/store/home/getters.js b/src/store/home/getters.js
index 56c8c75..39b22a7 100644
--- a/src/store/home/getters.js
+++ b/src/store/home/getters.js
@@ -1,3 +1,11 @@
-const getters = {};
+const getters = {
+ /**
+ * 当前项目的id
+ * @param {object} project
+ */
+ projectId({ project }) {
+ return project.id;
+ },
+};
export default getters;
diff --git a/src/store/home/mutations.js b/src/store/home/mutations.js
index ada7ccd..e8a6f85 100644
--- a/src/store/home/mutations.js
+++ b/src/store/home/mutations.js
@@ -62,6 +62,15 @@ const mutations = {
state.project = { ...data };
},
+ /**
+ * 设置当前项目名称
+ * @param { object } state
+ * @param { string } data
+ */
+ setProjectName(state, data) {
+ state.project.name = data;
+ },
+
/**
* 设置不展示的角色信息
* @param {Object} state
diff --git a/src/store/user/getters.js b/src/store/user/getters.js
index 56c8c75..f7988ce 100644
--- a/src/store/user/getters.js
+++ b/src/store/user/getters.js
@@ -1,3 +1,14 @@
-const getters = {};
+const getters = {
+ // 获取用户的id
+ userId({ user }) {
+ try {
+ if (!user) return '';
+ return user.id;
+ } catch (error) {
+ console.warn("user's getters 获取userId失败", error);
+ return '';
+ }
+ },
+};
export default getters;