wlzboy
2025-12-24 b30c1ebb0e46e734e70f8731484764f449f48818
app/pages/task/index.vue
@@ -275,7 +275,7 @@
<script>
import uniDatetimePicker from "@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue";
import { listTask, changeTaskStatus } from "@/api/task";
import { listTask, changeTaskStatus, checkTaskConsentAttachment } from "@/api/task";
import { mapState } from "vuex";
import { formatDateTime } from "@/utils/common";
import { checkTaskCanDepart } from "@/utils/taskValidator";
@@ -825,12 +825,8 @@
        case "complete":
          // 已完成 -> 状态变为已完成
          this.$modal
            .confirm("确认任务已完成?")
            .then(() => {
              this.updateTaskStatus(task.taskId, "COMPLETED", "任务已完成");
            })
            .catch(() => {});
          // 需要检查是否上传了知情同意书
          this.checkConsentAttachmentAndThen(task.taskId, "COMPLETED", "任务已完成");
          break;
      }
    },
@@ -841,6 +837,45 @@
      this.getLocationAndUpdateStatus(taskId, status, remark);
    },
    // 检查知情同意书附件并更新状态
    async checkConsentAttachmentAndThen(taskId, status, remark) {
      try {
        uni.showLoading({
          title: '检查附件...'
        });
        const response = await checkTaskConsentAttachment(taskId);
        uni.hideLoading();
        if (response.code === 200) {
          // 已上传知情同意书,继续更新状态
          this.$modal
            .confirm("确认任务已完成?")
            .then(() => {
              this.updateTaskStatus(taskId, status, remark);
            })
            .catch(() => {});
        } else {
          // 未上传知情同意书,显示提示
          this.$modal.confirm('任务未上传知情同意书,无法完成任务。是否现在去上传?').then(() => {
            // 跳转到任务详情页上传附件
            uni.navigateTo({
              url: `/pagesTask/detail?id=${taskId}`
            });
          }).catch(() => {});
        }
      } catch (error) {
        uni.hideLoading();
        console.error('检查附件失败:', error);
        // 如果检查失败,询问用户是否继续
        this.$modal.confirm('检查附件状态失败,是否继续完成任务?').then(() => {
          this.updateTaskStatus(taskId, status, remark);
        }).catch(() => {});
      }
    },
    // 获取位置信息并更新状态
    getLocationAndUpdateStatus(taskId, status, remark) {
      const that = this;