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

View File

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

View File

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