perf: 仪表盘完成任务

This commit is contained in:
kuaifan 2021-12-25 01:06:32 +08:00
parent e75408d20d
commit cf41e71494
3 changed files with 98 additions and 48 deletions

View File

@ -430,7 +430,7 @@ export default {
columnTopShow: {},
taskLoad: {},
completeJust: [],
completeTask: [],
sortField: 'end_at',
sortType: 'desc',
@ -534,13 +534,13 @@ export default {
},
myList() {
const {projectId, tasks, searchText, userId, completeJust, sortField, sortType} = this;
const {projectId, tasks, searchText, userId, completeTask, sortField, sortType} = this;
const array = tasks.filter((task) => {
if (task.project_id != projectId) {
return false;
}
if (!this.tablePanel('completedTask')) {
if (task.complete_at && !completeJust.find(id => id == task.id)) {
if (task.complete_at && !completeTask.find(id => id == task.id)) {
return false;
}
}
@ -567,13 +567,13 @@ export default {
},
helpList() {
const {projectId, tasks, searchText, userId, completeJust, sortField, sortType} = this;
const {projectId, tasks, searchText, userId, completeTask, sortField, sortType} = this;
const array = tasks.filter((task) => {
if (task.project_id != projectId) {
return false;
}
if (!this.tablePanel('completedTask')) {
if (task.complete_at && !completeJust.find(id => id == task.id)) {
if (task.complete_at && !completeTask.find(id => id == task.id)) {
return false;
}
}
@ -600,13 +600,13 @@ export default {
},
undoneList() {
const {projectId, tasks, searchText, completeJust, sortField, sortType} = this;
const {projectId, tasks, searchText, completeTask, sortField, sortType} = this;
const array = tasks.filter((task) => {
if (task.project_id != projectId) {
return false;
}
if (!this.tablePanel('completedTask')) {
if (task.complete_at && !completeJust.find(id => id == task.id)) {
if (task.complete_at && !completeTask.find(id => id == task.id)) {
return false;
}
}
@ -615,7 +615,7 @@ export default {
return false;
}
}
return !task.complete_at || completeJust.find(id => id == task.id);
return !task.complete_at || completeTask.find(id => id == task.id);
});
return array.sort((a, b) => {
if (sortType == 'asc') {
@ -681,7 +681,7 @@ export default {
this.sortData = this.getSort();
},
'$route'() {
this.completeJust = [];
this.completeTask = [];
}
},
@ -885,7 +885,7 @@ export default {
this.updateTask(task, {
complete_at: $A.formatDate("Y-m-d H:i:s")
})
this.completeJust.push(task.id)
this.completeTask.push(task.id)
break;
case 'uncomplete':
@ -893,6 +893,10 @@ export default {
this.updateTask(task, {
complete_at: false
})
let index = this.completeTask.findIndex(id => id == task.id)
if (index > -1) {
this.completeTask.splice(index, 1)
}
break;
case 'archived':
@ -903,7 +907,9 @@ export default {
},
updateTask(task, updata) {
return new Promise((resolve, reject) => {
if (this.taskLoad[task.id] === true) {
reject()
return;
}
this.$set(this.taskLoad, task.id, true);
@ -914,10 +920,13 @@ export default {
task_id: task.id,
})).then(() => {
this.$set(this.taskLoad, task.id, false);
resolve()
}).catch(({msg}) => {
$A.modalError(msg);
this.$set(this.taskLoad, task.id, false);
this.$store.dispatch("getTaskOne", task.id);
reject()
});
});
},
@ -1140,7 +1149,7 @@ export default {
toggleCompleted() {
this.$store.dispatch('toggleTablePanel', 'completedTask');
this.completeJust = [];
this.completeTask = [];
},
formatTime(date) {

View File

@ -33,16 +33,20 @@
<li
v-for="item in list"
:key="item.id"
:class="{complete: item.complete_at}"
:style="item.color ? {backgroundColor: item.color} : {}"
@click="$store.dispatch('openTask', item.id)">
<em v-if="item.p_name && item.parent_id === 0" class="priority-color" :style="{backgroundColor:item.p_color}"></em>
<em
v-if="item.p_name && item.parent_id === 0"
class="priority-color"
:style="{backgroundColor:item.p_color}"></em>
<EDropdown
trigger="click"
size="small"
placement="bottom"
@command="dropTask(item, $event)">
<div class="drop-icon" @click.stop="">
<i class="taskfont">&#xe625;</i>
<i class="taskfont" v-html="item.complete_at ? '&#xe627;' : '&#xe625;'"></i>
</div>
<EDropdownMenu slot="dropdown" class="project-list-more-dropdown-menu">
<EDropdownItem v-if="item.complete_at" command="uncomplete">
@ -111,7 +115,7 @@ export default {
taskLoad: {},
downList: []
completeTask: [],
}
},
@ -147,16 +151,23 @@ export default {
},
list() {
const {dashboard} = this;
const {dashboard, completeTask} = this;
let data = [];
switch (dashboard) {
case 'today':
data = this.dashboardData.today;
data = $A.cloneJSON(this.dashboardData.today);
break
case 'overdue':
data = this.dashboardData.overdue;
data = $A.cloneJSON(this.dashboardData.overdue);
break
}
if (completeTask.length > 0) {
completeTask.forEach(task => {
if (!data.find(({id}) => id == task.id)) {
data.push(task);
}
})
}
return data.sort((a, b) => {
return $A.Date(a.end_at) - $A.Date(b.end_at);
});
@ -176,6 +187,15 @@ export default {
},
},
watch: {
'$route'() {
this.completeTask = [];
},
dashboard() {
this.completeTask = [];
}
},
methods: {
dropTask(task, command) {
switch (command) {
@ -183,12 +203,19 @@ export default {
if (task.complete_at) return;
this.updateTask(task, {
complete_at: $A.formatDate("Y-m-d H:i:s")
}).then(() => {
this.completeTask.push(task)
})
break;
case 'uncomplete':
if (!task.complete_at) return;
this.updateTask(task, {
complete_at: false
}).then(() => {
let index = this.completeTask.findIndex(({id}) => id == task.id)
if (index > -1) {
this.completeTask.splice(index, 1)
}
})
break;
case 'archived':
@ -206,7 +233,9 @@ export default {
},
updateTask(task, updata) {
return new Promise((resolve, reject) => {
if (this.taskLoad[task.id] === true) {
reject()
return;
}
this.$set(this.taskLoad, task.id, true);
@ -217,11 +246,14 @@ export default {
task_id: task.id,
})).then(() => {
this.$set(this.taskLoad, task.id, false);
resolve()
}).catch(({msg}) => {
$A.modalError(msg);
this.$set(this.taskLoad, task.id, false);
this.$store.dispatch("getTaskOne", task.id);
reject();
});
})
},
archivedOrRemoveTask(task, type) {

View File

@ -102,6 +102,15 @@
&:last-child {
margin-bottom: 12px;
}
&.complete {
.item-title {
opacity: 0.5;
text-decoration: line-through;
}
.item-icon {
display: none;
}
}
.priority-color {
position: absolute;
top: 50%;