|
|
@ -5,7 +5,9 @@ |
|
|
|
<view class="container flex flex-col flex-1 overflow-hidden bg-gray-100" style="margin: auto"> |
|
|
|
<!-- 角色栏 --> |
|
|
|
<Roles @getTasksByRole="getTasksByRole" /> |
|
|
|
<Globals :tasks="allPlugins.concat(timePlugins)" /> |
|
|
|
<!-- 日常任务面板 --> |
|
|
|
<Globals /> |
|
|
|
<!-- 定期任务面板 --> |
|
|
|
<TimeLine @getTasks="getTasks" class="flex-1 overflow-hidden" ref="child" /> |
|
|
|
</view> |
|
|
|
</view> |
|
|
@ -16,7 +18,7 @@ import { mapState, mapMutations, mapActions } from 'vuex'; |
|
|
|
|
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { height: '', plugins: [], allPlugins: [], timePlugins: [] }; |
|
|
|
return { height: '' }; |
|
|
|
}, |
|
|
|
|
|
|
|
computed: { |
|
|
@ -35,24 +37,24 @@ export default { |
|
|
|
* 重新根据时间和角色查询普通日常任务 |
|
|
|
* 永久日常任务不发生改变 |
|
|
|
*/ |
|
|
|
async timeNode(val) { |
|
|
|
if (val) { |
|
|
|
timeNode(val) { |
|
|
|
if (val && this.roleId) { |
|
|
|
// 根据时间和角色查找日常任务 |
|
|
|
await this.getGlobal(); |
|
|
|
this.getGlobalData(); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 当角色发生变化时 |
|
|
|
* 重新查询永久日常任务和普通日常任务 |
|
|
|
* 注意: 切换角色后 重新设置了时间基准点 时间基准点一定会变 |
|
|
|
* 所以监听时间基准点获取 可变日常任务即可 这里不用获取 避免重复获取 |
|
|
|
*/ |
|
|
|
async roleId(val) { |
|
|
|
roleId(val) { |
|
|
|
if (val) { |
|
|
|
this.setTimeNode(new Date().getTime()); |
|
|
|
this.setTimeNode(Date.now()); |
|
|
|
// 根据角色查找永久的日常任务 |
|
|
|
await this.getPermanent(); |
|
|
|
// 根据时间和角色查找日常任务 |
|
|
|
await this.getGlobal(); |
|
|
|
this.getPermanent(val); |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
@ -65,7 +67,7 @@ export default { |
|
|
|
...mapActions('user', ['getUserId']), |
|
|
|
...mapActions('project', ['getProjectById']), |
|
|
|
...mapActions('role', ['getRoles']), |
|
|
|
...mapActions('task', ['handleRegularTask']), |
|
|
|
...mapActions('task', ['getRegulars', 'getPermanent', 'getGlobal']), |
|
|
|
...mapMutations('user', ['setToken']), |
|
|
|
...mapMutations('project', ['setProject', 'setProjectName']), |
|
|
|
...mapMutations('role', ['setInvisibleRoles', 'setVisibleRoles', 'setRoleId']), |
|
|
@ -105,10 +107,6 @@ export default { |
|
|
|
await this.getTasks({ queryType: 0 }); |
|
|
|
await this.getTasks({ queryType: 1 }); |
|
|
|
|
|
|
|
// 根据角色查找 永久的日常任务 |
|
|
|
await this.getPermanent(); |
|
|
|
// 根据时间和角色查找 可变的日常任务 |
|
|
|
await this.getGlobal(); |
|
|
|
// 预加载 上下的定期任务 |
|
|
|
if (this.tasks && this.tasks.length) { |
|
|
|
await this.getTasks({ timeNode: +this.tasks[0].planStart, queryType: 0, queryNum: 6 }); |
|
|
@ -130,68 +128,33 @@ export default { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据时间基准点和角色查找定期任务 |
|
|
|
* @param {string} roleId 角色id |
|
|
|
* @param {string} timeNode 时间基准点 默认当前 |
|
|
|
* @param {string} timeUnit 时间颗粒度 默认天 |
|
|
|
* @param {string} queryNum 查找颗粒度数量 默认3个 |
|
|
|
* @param {string} queryType 0向上查找 1向下查找(默认) 下查包含自己,上查不包含 |
|
|
|
* @param {object} query |
|
|
|
* @param {string} query.roleId 角色id |
|
|
|
* @param {string} query.timeNode 时间基准点 默认当前 |
|
|
|
* @param {string} query.timeUnit 时间颗粒度 默认天 |
|
|
|
* @param {string} query.queryNum 查找颗粒度数量 默认3个 |
|
|
|
* @param {string} query.queryType 0向上查找 1向下查找(默认) 下查包含自己,上查不包含 |
|
|
|
*/ |
|
|
|
async getTasks(query) { |
|
|
|
try { |
|
|
|
const { roleId, timeNode, timeUnit } = this; |
|
|
|
const params = { roleId }; |
|
|
|
params.timeNode = query.timeNode || timeNode; |
|
|
|
params.timeUnit = query.timeUnit || timeUnit; |
|
|
|
params.queryNum = query.queryNum || 3; |
|
|
|
params.queryType = query.queryType; |
|
|
|
const res = await this.handleRegularTask(params); |
|
|
|
query.queryType === 0 ? this.setUpTasks(res) : this.setDownTasks(res); |
|
|
|
} catch (error) { |
|
|
|
console.log('error: ', error); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据角色查找永久的日常任务 |
|
|
|
* @param {string} roleId 角色id |
|
|
|
*/ |
|
|
|
async getPermanent() { |
|
|
|
try { |
|
|
|
this.allPlugins = []; |
|
|
|
const res = await this.$u.api.getPermanent({ roleId: this.roleId }); |
|
|
|
// for (let item of res) { |
|
|
|
// if (item.plugins) { |
|
|
|
// this.allPlugins = this.allPlugins.concat(item.plugins); |
|
|
|
// } |
|
|
|
// } |
|
|
|
this.allPlugins = res; |
|
|
|
const params = { |
|
|
|
roleId, |
|
|
|
timeNode: query.timeNode || timeNode, |
|
|
|
timeUnit: query.timeUnit || timeUnit, |
|
|
|
queryNum: query.queryNum || 3, |
|
|
|
queryType: query.queryType, |
|
|
|
}; |
|
|
|
await this.getRegulars(params); |
|
|
|
} catch (error) { |
|
|
|
console.log('error: ', error); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据时间和角色查找日常任务 |
|
|
|
* @param {string} roleId 角色id |
|
|
|
* @param {string} timeNode 时间基准点 默认当前 |
|
|
|
* @param {string} timeUnit 时间颗粒度 默认天 |
|
|
|
*/ |
|
|
|
async getGlobal() { |
|
|
|
try { |
|
|
|
this.timePlugins = []; |
|
|
|
getGlobalData() { |
|
|
|
const { roleId, timeNode, timeUnit } = this; |
|
|
|
const params = { roleId, timeNode, timeUnit }; |
|
|
|
const res = await this.$u.api.getGlobal(params); |
|
|
|
// for (let task of res) { |
|
|
|
// for (let item of task.plugins) { |
|
|
|
// this.timePlugins.push(...item); |
|
|
|
// } |
|
|
|
// } |
|
|
|
this.timePlugins = res; |
|
|
|
this.setDailyTasks(res); |
|
|
|
} catch (error) { |
|
|
|
console.log('error: ', error); |
|
|
|
} |
|
|
|
const param = { roleId, timeNode, timeUnit }; |
|
|
|
this.getGlobal(param); |
|
|
|
}, |
|
|
|
|
|
|
|
// 切换角色获取任务 |
|
|
|