wlzboy
2025-12-24 b30c1ebb0e46e734e70f8731484764f449f48818
feat:已完成时,增加知情同意书的上传判断
7个文件已修改
188 ■■■■ 已修改文件
app/api/task.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/pages/index.vue 47 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/pages/task/index.vue 49 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/pagesTask/detail.vue 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskAttachmentSyncController.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/ITaskAttachmentSyncService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TaskAttachmentSyncServiceImpl.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/api/task.js
@@ -157,3 +157,11 @@
    method: 'post'
  })
}
// 检查任务是否上传了知情同意书
export function checkTaskConsentAttachment(taskId) {
  return request({
    url: '/task/attachment/sync/task/check/' + taskId,
    method: 'post'
  })
}
app/pages/index.vue
@@ -237,7 +237,7 @@
<script>
import { mapState } from "vuex";
import { getMyTasks, changeTaskStatus } from "@/api/task";
import { getMyTasks, changeTaskStatus, checkTaskConsentAttachment } from "@/api/task";
import { getUserProfile } from "@/api/system/user";
import { getUserBoundVehicle } from "@/api/vehicle";
import { getUnreadCount } from "@/api/message";
@@ -748,12 +748,8 @@
        case "complete":
          // 已完成 -> 状态变为已完成
          this.$modal
            .confirm("确认任务已完成?")
            .then(() => {
              this.updateTaskStatus(task.taskId, "COMPLETED", "任务已完成");
            })
            .catch(() => {});
          // 需要检查是否上传了知情同意书
          this.checkConsentAttachmentAndThen(task.taskId, "COMPLETED", "任务已完成");
          break;
      }
    },
@@ -763,6 +759,43 @@
      // 获取GPS位置信息
      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(() => {
            // 跳转到任务详情页上传附件
            this.$tab.navigateTo(`/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) {
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;
      }
    },
@@ -840,6 +836,45 @@
      // 获取GPS位置信息
      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) {
app/pagesTask/detail.vue
@@ -464,7 +464,7 @@
</template>
<script>
  import { getTask, changeTaskStatus, setAssigneeReady } from '@/api/task'
  import { getTask, changeTaskStatus, setAssigneeReady, checkTaskConsentAttachment } from '@/api/task'
  import { checkVehicleActiveTasks } from '@/api/task'
  import { getPaymentInfo } from '@/api/payment'
  import { formatDateTime } from '@/utils/common'
@@ -948,8 +948,50 @@
      
      // 更新任务状态
      updateTaskStatus(status, remark) {
        // 获取GPS位置信息
        this.getLocationAndUpdateStatus(status, remark)
        // 如果是完成状态,需要检查是否上传了知情同意书
        if (status === 'COMPLETED') {
          this.checkConsentAttachmentAndThen(status, remark);
        } else {
          // 获取GPS位置信息
          this.getLocationAndUpdateStatus(status, remark);
        }
      },
      // 检查知情同意书附件并更新状态
      async checkConsentAttachmentAndThen(status, remark) {
        try {
          uni.showLoading({
            title: '检查附件...'
          });
          const response = await checkTaskConsentAttachment(this.taskId);
          uni.hideLoading();
          if (response.code === 200) {
            // 已上传知情同意书,继续更新状态
            this.getLocationAndUpdateStatus(status, remark);
          } else {
            // 未上传知情同意书,显示提示
            this.$modal.confirm('任务未上传知情同意书,无法完成任务。是否现在去上传?').then(() => {
              // 滚动到附件上传区域
              this.$nextTick(() => {
                uni.pageScrollTo({
                  scrollTop: 9999, // 滚动到底部
                  duration: 300
                });
              });
            }).catch(() => {});
          }
        } catch (error) {
          uni.hideLoading();
          console.error('检查附件失败:', error);
          // 如果检查失败,询问用户是否继续
          this.$modal.confirm('检查附件状态失败,是否继续完成任务?').then(() => {
            this.getLocationAndUpdateStatus(status, remark);
          }).catch(() => {});
        }
      },
      
      // 获取位置信息并更新状态
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskAttachmentSyncController.java
@@ -87,6 +87,20 @@
        }
    }
    @PostMapping("/task/check/{taskId}")
    public AjaxResult checkTaskAttachment(@PathVariable("taskId") Long taskId) {
        try {
            Boolean ret=taskAttachmentSyncService.checkAttachment(taskId,"1");
            if(ret){
                return AjaxResult.success("已上传知情同意书");
            }else{
                return AjaxResult.error(-1,"未上传知情同意书");
            }
        }catch (Exception e){
            return AjaxResult.error("检查失败:" + e.getMessage());
        }
    }
    /**
     * 检查附件是否已同步
ruoyi-system/src/main/java/com/ruoyi/system/service/ITaskAttachmentSyncService.java
@@ -11,7 +11,9 @@
 * @author ruoyi
 */
public interface ITaskAttachmentSyncService {
    Boolean checkAttachment(Long taskId, String type);
    /**
     * 同步单个附件到ImageData
     * 
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TaskAttachmentSyncServiceImpl.java
@@ -1,9 +1,7 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.config.LegacySystemConfig;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.ImageData;
import com.ruoyi.system.domain.SysTaskAttachment;
import com.ruoyi.system.domain.SysTaskEmergency;
@@ -16,7 +14,6 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.io.File;
@@ -50,6 +47,21 @@
    private RuoYiConfig ruoYiConfig;
    /**
     *检查附件是否已经上传
     * @param taskId
     * @param type  1    知情同意书
     * 2    病人资料
     * 3    操作记录
     * 4    出车前
     * 5    出车后
     * 6    系安全带
     * @return Boolean
     */
    @Override
    public Boolean checkAttachment(Long taskId, String type){
        return taskAttachmentMapper.selectSysTaskAttachmentByTaskId(taskId).stream().anyMatch(attachment -> attachment.getAttachmentCategory().equals(type));
    }
    
    /**
     * 同步单个附件到ImageData