Browse Source

fix(role): 切换角色的逻辑修正完善

tall
wally 4 years ago
parent
commit
4ae534f2bc
  1. 1
      CHANGELOG.md
  2. 18
      src/components/Roles/Roles.vue
  3. 53
      src/pages/project/project.vue
  4. 6
      src/store/task/mutations.js

1
CHANGELOG.md

@ -87,6 +87,7 @@
--|--|-- --|--|--
- | project 代码健壮性完善 | a3202c5 - | project 代码健壮性完善 | a3202c5
store/home | 删除store/home | db8a3b4 store/home | 删除store/home | db8a3b4
task beginTime | 格式化任务开始时间 | fbc0301
template | eslint prettier sass uview tailwindcss | 9c966a1 template | eslint prettier sass uview tailwindcss | 9c966a1
- | 下滑时间轴添加备注 | 4fd20e3 - | 下滑时间轴添加备注 | 4fd20e3
- | 删除多余的技术验证界面 | 542ae5b - | 删除多余的技术验证界面 | 542ae5b

18
src/components/Roles/Roles.vue

@ -3,7 +3,7 @@
<view class="home-box u-skeleton"> <view class="home-box u-skeleton">
<scroll-view :enable-flex="true" :scroll-left="scrollLeft" :throttle="false" scroll-with-animation scroll-x> <scroll-view :enable-flex="true" :scroll-left="scrollLeft" :throttle="false" scroll-with-animation scroll-x>
<view class="tab-box"> <view class="tab-box">
<view :key="index" @click="changeIndex(item.id, index)" class="tab-item" v-for="(item, index) in roles"> <view :key="index" @click="changeRole(item.id, index)" class="tab-item" v-for="(item, index) in roles">
<view :class="setColor(item.mine, item.id)" class="tab-children u-skeleton-fillet u-font-14">{{ item.name }}</view> <view :class="setColor(item.mine, item.id)" class="tab-children u-skeleton-fillet u-font-14">{{ item.name }}</view>
</view> </view>
</view> </view>
@ -68,7 +68,7 @@ export default {
methods: { methods: {
...mapActions('task', ['handleRegularTask']), ...mapActions('task', ['handleRegularTask']),
...mapMutations('role', ['setRoleId']), ...mapMutations('role', ['setRoleId']),
...mapMutations('task', ['setTasks']), ...mapMutations('task', ['setTasks', 'setPermanents', 'setDailyTasks', 'clearEndFlag']),
// //
setCurrentRole(index) { setCurrentRole(index) {
@ -91,17 +91,23 @@ export default {
}, },
// //
async changeIndex(id, index) { // projectroleId
// projectroleId
changeRole(id, index) {
try { try {
this.setRoleId(id); this.setRoleId(id);
//index //index
this.setCurrentRole(index); this.setCurrentRole(index);
// //
this.setTasks(); this.setTasks();
// //
await this.$emit('getTasksByRole'); this.setPermanents([]);
this.setDailyTasks([]);
//
//
this.clearEndFlag();
} catch (error) { } catch (error) {
console.log('error: ', error); console.log('role.vue changeRole error: ', error);
} }
}, },

53
src/pages/project/project.vue

@ -38,9 +38,11 @@ export default {
* 永久日常任务不发生改变 * 永久日常任务不发生改变
*/ */
timeNode(val) { timeNode(val) {
console.log(val);
if (val && this.roleId) { if (val && this.roleId) {
// //
this.getGlobalData(); this.getGlobalData();
this.getInitTasks();
} }
}, },
@ -102,22 +104,25 @@ export default {
// id // id
await this.getRoles({ projectId: options.p }); await this.getRoles({ projectId: options.p });
this.setInitialRoleId(this.visibleRoles); 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) { } catch (error) {
console.error('project init function:', 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) { setInitialRoleId(visibleList) {
const index = visibleList.findIndex(item => item.mine); const index = visibleList.findIndex(item => item.mine);
@ -156,34 +161,6 @@ export default {
const param = { roleId, timeNode, timeUnit }; const param = { roleId, timeNode, timeUnit };
this.getGlobal(param); 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);
}
},
}, },
}; };
</script> </script>

6
src/store/task/mutations.js

@ -146,6 +146,12 @@ const mutations = {
setPermanents(state, tasks) { setPermanents(state, tasks) {
state.permanents = tasks || []; state.permanents = tasks || [];
}, },
// 清空标志位 如切换角色等使用
clearEndFlag(state) {
state.topEnd = false;
state.bottomEnd = false;
},
}; };
export default mutations; export default mutations;

Loading…
Cancel
Save