diff --git a/app/Models/ProjectTask.php b/app/Models/ProjectTask.php index cc5ab4541..592e4d7f4 100644 --- a/app/Models/ProjectTask.php +++ b/app/Models/ProjectTask.php @@ -300,6 +300,7 @@ class ProjectTask extends AbstractModel 'project_tasks.*', 'project_task_users.owner' ]) + ->selectRaw("1 AS assist") ->join('project_task_users', 'project_tasks.id', '=', 'project_task_users.task_id') ->where('project_task_users.userid', $userid); if ($owner !== null) { diff --git a/resources/assets/js/pages/manage/dashboard.vue b/resources/assets/js/pages/manage/dashboard.vue index 9d39e37c1..9b93c61e2 100644 --- a/resources/assets/js/pages/manage/dashboard.vue +++ b/resources/assets/js/pages/manage/dashboard.vue @@ -118,12 +118,12 @@ export default { }, computed: { - ...mapState(['userInfo', 'loadDashboardTasks']), + ...mapState(['userInfo', 'cacheTasks', 'taskCompleteTemps', 'loadDashboardTasks']), ...mapGetters(['dashboardTask', 'transforTasks']), columns() { - let list = []; + const list = []; ['today', 'overdue', 'all'].some(type => { let data = this.transforTasks(this.dashboardTask[type]); list.push({ @@ -134,9 +134,37 @@ export default { }) }) }) + list.push({ + type: 'assist', + title: this.getTitle('assist'), + list: this.assistList.sort((a, b) => { + return $A.Date(a.end_at || "2099-12-31 23:59:59") - $A.Date(b.end_at || "2099-12-31 23:59:59"); + }) + }) return list; }, + assistList() { + const filterTask = (task, chackCompleted = true) => { + if (task.archived_at) { + return false; + } + if (task.complete_at && chackCompleted === true) { + return false; + } + return task.assist && !task.owner; + } + let array = this.cacheTasks.filter(task => filterTask(task)); + if (this.taskCompleteTemps.length > 0) { + let tmps = this.cacheTasks.filter(task => this.taskCompleteTemps.includes(task.id) && filterTask(task, false)); + if (tmps.length > 0) { + array = $A.cloneJSON(array) + array.push(...tmps); + } + } + return array + }, + total() { const {dashboardTask} = this; return dashboardTask.today_count + dashboardTask.overdue_count + dashboardTask.all_count; @@ -152,6 +180,8 @@ export default { return this.$L('超期任务'); case 'all': return this.$L('待完成任务'); + case 'assist': + return this.$L('协助的任务'); default: return ''; } diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index 62fea2dee..5ec9cd67b 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -1238,62 +1238,36 @@ export default { * @param timeout */ getTaskForDashboard({state, dispatch, getters}, timeout) { + window.__getTaskForDashboard && clearTimeout(window.__getTaskForDashboard) if (typeof timeout === "number") { - window.__getTaskForDashboard && clearTimeout(window.__getTaskForDashboard) if (timeout > -1) { - window.__getTaskForDashboard = setTimeout(() => { - dispatch("getTaskForDashboard", null) - }, timeout) + window.__getTaskForDashboard = setTimeout(_ => dispatch("getTaskForDashboard", null), timeout) } return; } + // if (state.loadDashboardTasks === true) { return; } state.loadDashboardTasks = true; // const time = $A.Time() - const {today, overdue,all} = getters.dashboardTask; + const {today, overdue, all} = getters.dashboardTask; const currentIds = today.map(({id}) => id) currentIds.push(...overdue.map(({id}) => id)) currentIds.push(...all.map(({id}) => id)) // - let loadIng = 3; - let call = () => { - if (loadIng <= 0) { - state.loadDashboardTasks = false; - // - const {today, overdue,all} = getters.dashboardTask; - const newIds = today.filter(task => task._time >= time).map(({id}) => id) - newIds.push(...overdue.filter(task => task._time >= time).map(({id}) => id)) - newIds.push(...all.filter(task => task._time >= time).map(({id}) => id)) - dispatch("forgetTask", currentIds.filter(v => newIds.indexOf(v) == -1)) - return; - } - loadIng--; - if (loadIng == 2) { - // 获取今日任务 - dispatch("getTasks", { - complete: "no", - time: [ - $A.formatDate("Y-m-d 00:00:00"), - $A.formatDate("Y-m-d 23:59:59") - ], - }).then(call).catch(call) - } else if (loadIng == 1) { - // 获取过期任务 - dispatch("getTasks", { - complete: "no", - time_before: $A.formatDate("Y-m-d H:i:s"), - }).then(call).catch(call) - } else if((loadIng == 0)) { - // 获取待处理任务 - dispatch("getTasks", { - complete: "no", - }).then(call).catch(call) - } - } - call(); + dispatch("getTasks", { + complete: "no", + }).finally(_ => { + state.loadDashboardTasks = false; + // + const {today, overdue, all} = getters.dashboardTask; + const newIds = today.filter(task => task._time >= time).map(({id}) => id) + newIds.push(...overdue.filter(task => task._time >= time).map(({id}) => id)) + newIds.push(...all.filter(task => task._time >= time).map(({id}) => id)) + dispatch("forgetTask", currentIds.filter(v => newIds.indexOf(v) == -1)) + }) }, /**