mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-10 18:02:55 +00:00
feat: 添加一键归档列表中已完成任务
This commit is contained in:
parent
dd2cd1df9a
commit
e6ad1218bc
@ -130,6 +130,7 @@
|
|||||||
<EDropdown
|
<EDropdown
|
||||||
v-else
|
v-else
|
||||||
trigger="click"
|
trigger="click"
|
||||||
|
size="medium"
|
||||||
@command="dropColumn(column, $event)">
|
@command="dropColumn(column, $event)">
|
||||||
<Icon type="ios-more" />
|
<Icon type="ios-more" />
|
||||||
<EDropdownMenu slot="dropdown" class="project-panel-more-dropdown-menu">
|
<EDropdownMenu slot="dropdown" class="project-panel-more-dropdown-menu">
|
||||||
@ -140,6 +141,11 @@
|
|||||||
<Icon type="md-create" />{{$L('修改')}}
|
<Icon type="md-create" />{{$L('修改')}}
|
||||||
</div>
|
</div>
|
||||||
</EDropdownItem>
|
</EDropdownItem>
|
||||||
|
<EDropdownItem command="archive_completed">
|
||||||
|
<div class="item">
|
||||||
|
<Icon type="ios-filing" />{{$L('归档')}}
|
||||||
|
</div>
|
||||||
|
</EDropdownItem>
|
||||||
<EDropdownItem command="remove">
|
<EDropdownItem command="remove">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<Icon type="md-trash" />{{$L('删除')}}
|
<Icon type="md-trash" />{{$L('删除')}}
|
||||||
@ -1249,6 +1255,9 @@ export default {
|
|||||||
if (command === 'title') {
|
if (command === 'title') {
|
||||||
this.titleColumn(column);
|
this.titleColumn(column);
|
||||||
}
|
}
|
||||||
|
else if (command === 'archive_completed') {
|
||||||
|
this.archiveColumnCompletedTasks(column);
|
||||||
|
}
|
||||||
else if (command === 'remove') {
|
else if (command === 'remove') {
|
||||||
this.removeColumn(column);
|
this.removeColumn(column);
|
||||||
}
|
}
|
||||||
@ -1304,6 +1313,51 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
archiveColumnCompletedTasks(column) {
|
||||||
|
const tasks = this.getColumnCompletedTasks(column);
|
||||||
|
if (tasks.length === 0) {
|
||||||
|
$A.messageWarning('当前列表没有可归档的已完成任务');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$A.modalConfirm({
|
||||||
|
title: '归档已完成任务',
|
||||||
|
content: `你确定将列表【${column.name}】中所有已完成的任务归档吗?`,
|
||||||
|
loading: true,
|
||||||
|
onOk: () => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.batchArchiveTasks(tasks).then(() => {
|
||||||
|
$A.messageSuccess('已归档列表中所有已完成任务');
|
||||||
|
resolve();
|
||||||
|
}).catch(({msg}) => {
|
||||||
|
$A.modalError(msg || '归档失败,请稍后再试');
|
||||||
|
reject();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
getColumnCompletedTasks(column) {
|
||||||
|
if (!column || !Array.isArray(column.tasks)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return column.tasks.filter(task => task && task.complete_at && !task.archived_at);
|
||||||
|
},
|
||||||
|
|
||||||
|
batchArchiveTasks(tasks) {
|
||||||
|
const archive = (index = 0) => {
|
||||||
|
if (index >= tasks.length) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
const task = tasks[index];
|
||||||
|
return this.$store.dispatch("archivedTask", {task_id: task.id}).then(() => {
|
||||||
|
this.$store.dispatch("saveTaskBrowse", task.id);
|
||||||
|
return archive(index + 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return archive();
|
||||||
|
},
|
||||||
|
|
||||||
removeColumn(column) {
|
removeColumn(column) {
|
||||||
$A.modalConfirm({
|
$A.modalConfirm({
|
||||||
title: '删除列表',
|
title: '删除列表',
|
||||||
|
|||||||
@ -966,6 +966,9 @@
|
|||||||
max-height: calc(100vh - 250px);
|
max-height: calc(100vh - 250px);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
display: none
|
||||||
|
}
|
||||||
.item {
|
.item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user