|
|
@@ -439,6 +439,74 @@ export default {
|
|
|
if (!dateStr) return ''
|
|
|
const date = new Date(dateStr)
|
|
|
return `${date.getHours()}:${String(date.getMinutes()).padStart(2, '0')}`
|
|
|
+ },
|
|
|
+ enterBatchMode() {
|
|
|
+ this.batchMode = true
|
|
|
+ this.selectedTasks = []
|
|
|
+ },
|
|
|
+ exitBatchMode() {
|
|
|
+ this.batchMode = false
|
|
|
+ this.selectedTasks = []
|
|
|
+ },
|
|
|
+ toggleTaskSelect(taskId) {
|
|
|
+ const index = this.selectedTasks.indexOf(taskId)
|
|
|
+ if (index > -1) {
|
|
|
+ this.selectedTasks.splice(index, 1)
|
|
|
+ } else {
|
|
|
+ this.selectedTasks.push(taskId)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ toggleSelectAll() {
|
|
|
+ if (this.isAllSelected) {
|
|
|
+ this.selectedTasks = []
|
|
|
+ } else {
|
|
|
+ this.selectedTasks = this.tasks.filter(t => t.status === 'pending').map(t => t.id)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async batchComplete() {
|
|
|
+ if (this.selectedTasks.length === 0) {
|
|
|
+ uni.showToast({ title: '请选择任务', icon: 'none' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ await batchCompleteTasks(this.selectedTasks)
|
|
|
+ uni.showToast({ title: '批量完成成功', icon: 'success' })
|
|
|
+ this.exitBatchMode()
|
|
|
+ this.loadParentTasks()
|
|
|
+ } catch (e) {
|
|
|
+ console.error('批量完成失败', e)
|
|
|
+ uni.showToast({ title: '批量完成失败', icon: 'none' })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async batchDelete() {
|
|
|
+ if (this.selectedTasks.length === 0) {
|
|
|
+ uni.showToast({ title: '请选择任务', icon: 'none' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uni.showModal({
|
|
|
+ title: '确认删除',
|
|
|
+ content: `确定要删除选中的 ${this.selectedTasks.length} 个任务吗?`,
|
|
|
+ success: async (res) => {
|
|
|
+ if (res.confirm) {
|
|
|
+ try {
|
|
|
+ await batchDeleteTasks(this.selectedTasks)
|
|
|
+ uni.showToast({ title: '批量删除成功', icon: 'success' })
|
|
|
+ this.exitBatchMode()
|
|
|
+ this.loadParentTasks()
|
|
|
+ } catch (e) {
|
|
|
+ console.error('批量删除失败', e)
|
|
|
+ uni.showToast({ title: '批量删除失败', icon: 'none' })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ isAllSelected() {
|
|
|
+ if (this.selectedTasks.length === 0) return false
|
|
|
+ const pendingTasks = this.tasks.filter(t => t.status === 'pending')
|
|
|
+ return pendingTasks.length > 0 && pendingTasks.every(t => this.selectedTasks.includes(t.id))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -450,6 +518,74 @@ export default {
|
|
|
padding-bottom: 120rpx;
|
|
|
}
|
|
|
|
|
|
+.header-bar {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ margin-bottom: 30rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.header-title {
|
|
|
+ font-size: 32rpx;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #333;
|
|
|
+}
|
|
|
+
|
|
|
+.btn-batch {
|
|
|
+ background: #FF6B6B;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 24rpx;
|
|
|
+ padding: 10rpx 30rpx;
|
|
|
+ border-radius: 30rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.batch-bar {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ background: #f5f5f5;
|
|
|
+ padding: 20rpx 30rpx;
|
|
|
+ border-radius: 16rpx;
|
|
|
+ margin-bottom: 30rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.batch-label {
|
|
|
+ font-size: 28rpx;
|
|
|
+ color: #333;
|
|
|
+ margin-left: 10rpx;
|
|
|
+ margin-right: auto;
|
|
|
+}
|
|
|
+
|
|
|
+.batch-actions {
|
|
|
+ display: flex;
|
|
|
+ gap: 20rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.batch-btn {
|
|
|
+ font-size: 24rpx;
|
|
|
+ padding: 10rpx 30rpx;
|
|
|
+ border-radius: 30rpx;
|
|
|
+ background: #FF6B6B;
|
|
|
+ color: #fff;
|
|
|
+}
|
|
|
+
|
|
|
+.batch-btn.complete {
|
|
|
+ background: #52C41A;
|
|
|
+}
|
|
|
+
|
|
|
+.batch-btn.delete {
|
|
|
+ background: #FF4D4F;
|
|
|
+}
|
|
|
+
|
|
|
+.batch-btn[disabled] {
|
|
|
+ background: #ccc;
|
|
|
+}
|
|
|
+
|
|
|
+.batch-exit {
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: #999;
|
|
|
+ margin-left: 20rpx;
|
|
|
+}
|
|
|
+
|
|
|
.task-item {
|
|
|
background: #fff;
|
|
|
border-radius: 16rpx;
|
|
|
@@ -460,6 +596,25 @@ export default {
|
|
|
align-items: center;
|
|
|
}
|
|
|
|
|
|
+.task-item.selected {
|
|
|
+ background: #FFF1F0;
|
|
|
+ border: 2rpx solid #FF6B6B;
|
|
|
+}
|
|
|
+
|
|
|
+.task-checkbox {
|
|
|
+ margin-right: 20rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.task-title {
|
|
|
+ background: #fff;
|
|
|
+ border-radius: 16rpx;
|
|
|
+ padding: 30rpx;
|
|
|
+ margin-bottom: 20rpx;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+
|
|
|
.task-item.completed {
|
|
|
opacity: 0.6;
|
|
|
}
|