wlzboy
2025-12-26 c10b1e130ccbc94e6481a43e8e2d35cfc8fcf83b
app/pages/task/index.vue
@@ -188,7 +188,7 @@
                <view class="info-row">
                  <view class="info-item">
                    <view class="label">执行人员:</view>
                    <view class="value">{{ task.assignee }}</view>
                    <view class="value">{{ getAssigneesDisplay(task) }}</view>
                  </view>
                </view>
              </view>
@@ -663,13 +663,36 @@
        // 优先显示转入医院名称
        if (task.emergencyInfo.hospitalInName) {
          if(task.emergencyInfo.hospitalInName.includes("家中")){
            return task.emergencyInfo.destinationAddress;
            return task.emergencyInfo.hospitalInAddress;
          }
          return task.emergencyInfo.hospitalInName;
        }
        }
        // 如果没有转入医院名称,但有转入医院地址,则显示地址
        if (task.emergencyInfo.hospitalInAddress) {
          return task.emergencyInfo.hospitalInAddress;
        }
      }
      // 其他情况使用原来的endLocation
      return this.formatAddress(task.endLocation || "未设置");
    },
    // 获取执行人员显示(从 assignees 数组中提取 userName)
    getAssigneesDisplay(task) {
      // 如果有 assignees 数组且不为空
      if (task.assignees && task.assignees.length > 0) {
        // 提取所有 userName,过滤掉空值
        const userNames = task.assignees
          .map(assignee => assignee.userName)
          .filter(name => name); // 过滤掉 null/undefined/空字符串
        // 如果有有效的用户名,用逗号连接
        if (userNames.length > 0) {
          return userNames.join('、');
        }
      }
      // 如果没有 assignees 数组,使用旧的 assigneeName 或 assignee 字段
      return task.assigneeName || task.assignee || '未分配';
    },
    // 切换查询界面显示/隐藏
@@ -940,12 +963,19 @@
          title: '检查附件...'
        });
        
        const response = await checkTaskConsentAttachment(taskId);
        // 注意:这里会被请求拦截器处理,code !== 200 时会 reject
        const response = await checkTaskConsentAttachment(taskId).catch(err => {
          // 拦截器 reject 的情况,返回一个默认对象
          console.log('请求被拦截器 reject,err:', err);
          return { code: -1, msg: '未上传知情同意书' };
        });
        
        uni.hideLoading();
        console.log('检查附件结果:', response);
        
        if (response.code === 200) {
        if (response && response.code === 200) {
          // 已上传知情同意书,继续更新状态
          console.log('已上传知情同意书,继续完成任务');
          this.$modal
            .confirm("确认任务已完成?")
            .then(() => {
@@ -953,8 +983,11 @@
            })
            .catch(() => {});
        } else {
          // 未上传知情同意书,显示提示
          this.$modal.confirm('任务未上传知情同意书,无法完成任务。是否现在去上传?').then(() => {
          // 未上传知情同意书或其他错误,阻止完成
          const message = (response && response.msg) || '任务未上传知情同意书,无法完成任务';
          console.log('未上传知情同意书,阻止完成');
          this.$modal.confirm(message + '。是否现在去上传?').then(() => {
            // 跳转到任务详情页上传附件
            uni.navigateTo({
              url: `/pagesTask/detail?id=${taskId}`
@@ -963,12 +996,10 @@
        }
      } catch (error) {
        uni.hideLoading();
        console.error('检查附件失败:', error);
        console.error('检查附件异常:', error);
        
        // 如果检查失败,询问用户是否继续
        this.$modal.confirm('检查附件状态失败,是否继续完成任务?').then(() => {
          this.updateTaskStatus(taskId, status, remark);
        }).catch(() => {});
        // 如果检查失败(网络异常等),不允许完成任务
        this.$modal.showToast('检查附件状态失败,无法完成任务');
      }
    },
@@ -1426,6 +1457,10 @@
              font-size: 26rpx;
              flex: 1;
              word-break: break-all;
              overflow-wrap: break-word;
              line-height: 1.5;
              max-height: none;
              overflow: visible;
            }
          }
        }