perf: 仪表盘完成任务
This commit is contained in:
parent
e75408d20d
commit
cf41e71494
@ -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,7 +907,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
updateTask(task, updata) {
|
updateTask(task, updata) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
if (this.taskLoad[task.id] === true) {
|
if (this.taskLoad[task.id] === true) {
|
||||||
|
reject()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$set(this.taskLoad, task.id, true);
|
this.$set(this.taskLoad, task.id, true);
|
||||||
@ -914,10 +920,13 @@ export default {
|
|||||||
task_id: task.id,
|
task_id: task.id,
|
||||||
})).then(() => {
|
})).then(() => {
|
||||||
this.$set(this.taskLoad, task.id, false);
|
this.$set(this.taskLoad, task.id, false);
|
||||||
|
resolve()
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg);
|
$A.modalError(msg);
|
||||||
this.$set(this.taskLoad, task.id, false);
|
this.$set(this.taskLoad, task.id, false);
|
||||||
this.$store.dispatch("getTaskOne", task.id);
|
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) {
|
||||||
|
@ -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"></i>
|
<i class="taskfont" v-html="item.complete_at ? '' : ''"></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,7 +233,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
updateTask(task, updata) {
|
updateTask(task, updata) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
if (this.taskLoad[task.id] === true) {
|
if (this.taskLoad[task.id] === true) {
|
||||||
|
reject()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$set(this.taskLoad, task.id, true);
|
this.$set(this.taskLoad, task.id, true);
|
||||||
@ -217,11 +246,14 @@ export default {
|
|||||||
task_id: task.id,
|
task_id: task.id,
|
||||||
})).then(() => {
|
})).then(() => {
|
||||||
this.$set(this.taskLoad, task.id, false);
|
this.$set(this.taskLoad, task.id, false);
|
||||||
|
resolve()
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg);
|
$A.modalError(msg);
|
||||||
this.$set(this.taskLoad, task.id, false);
|
this.$set(this.taskLoad, task.id, false);
|
||||||
this.$store.dispatch("getTaskOne", task.id);
|
this.$store.dispatch("getTaskOne", task.id);
|
||||||
|
reject();
|
||||||
});
|
});
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
archivedOrRemoveTask(task, type) {
|
archivedOrRemoveTask(task, type) {
|
||||||
|
@ -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%;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user