wlzboy
2025-12-24 b30c1ebb0e46e734e70f8731484764f449f48818
app/pagesTask/detail.vue
@@ -12,7 +12,11 @@
        <view class="section-title">基本信息</view>
        <view class="info-item">
          <view class="label">任务编号</view>
          <view class="value">{{ taskDetail.showTaskCode }}</view>
          <view class="value">
            {{ taskDetail.showTaskCode }}
            <text v-if="taskDetail.emergencyInfo && taskDetail.emergencyInfo.serviceOrdVip === '1'" class="vip-tag">VIP</text>
            <text v-if="taskDetail.emergencyInfo && taskDetail.emergencyInfo.fromHq2Is === '1'" class="hq-tag">广总</text>
          </view>
        </view>
        <view class="info-item">
          <view class="label">任务类型</view>
@@ -51,21 +55,12 @@
              <view class="assignee-role">
                <view 
                  class="role-tag"
                  :class="{
                    'role-driver': assignee.userType === 'driver',
                    'role-doctor': assignee.userType === 'doctor',
                    'role-nurse': assignee.userType === 'nurse'
                  }"
                >
                  :class="{'role-driver': assignee.userType === 'driver','role-doctor': assignee.userType === 'doctor','role-nurse': assignee.userType === 'nurse'}">
                  {{ getUserTypeLabel(assignee.userType) }}
                </view>
                <view 
                  class="ready-badge"
                  :class="{
                    'ready': isAssigneeReady(assignee),
                    'unready': !isAssigneeReady(assignee)
                  }"
                >
                  :class="{'ready': isAssigneeReady(assignee),'unready': !isAssigneeReady(assignee)}">
                  {{ isAssigneeReady(assignee) ? '已就绪' : '未就绪' }}
                </view>
              </view>
@@ -102,13 +97,13 @@
        <view class="section-title">位置信息</view>
        <!-- 转运任务:显示转出/转入医院地址 -->
        <template v-if="taskDetail.taskType === 'EMERGENCY_TRANSFER' && taskDetail.emergencyInfo">
          <view class="info-item" v-if="taskDetail.emergencyInfo.hospitalOutAddress">
          <view class="info-item" v-if="taskDetail.emergencyInfo.hospitalOutName">
            <view class="label">转出医院</view>
            <view class="value">{{ taskDetail.emergencyInfo.hospitalOutAddress }}</view>
            <view class="value">{{ taskDetail.emergencyInfo.hospitalOutName }}</view>
          </view>
          <view class="info-item" v-if="taskDetail.emergencyInfo.hospitalInAddress">
          <view class="info-item" v-if="taskDetail.emergencyInfo.hospitalInName">
            <view class="label">转入医院</view>
            <view class="value">{{ taskDetail.emergencyInfo.hospitalInAddress }}</view>
            <view class="value">{{ taskDetail.emergencyInfo.hospitalInName }}</view>
          </view>
        </template>
        <!-- 福祉车任务:显示接送/目的地址 -->
@@ -469,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'
@@ -496,7 +491,19 @@
        }
        return ['COMPLETED', 'CANCELLED'].includes(this.taskDetail.taskStatus)
      },
      // 显示任务类型
      // 生成执行人员角色标签的类名
      getRoleTagClass() {
        return (userType) => {
          const baseClass = 'role-tag'
          const roleClasses = {
            'driver': 'role-driver',
            'doctor': 'role-doctor',
            'nurse': 'role-nurse'
          }
          return [baseClass, roleClasses[userType] || '']
        }
      },      // 显示任务类型
      displayTaskType() {
        if (!this.taskDetail || !this.taskDetail.taskType) {
          return '未设置'
@@ -528,9 +535,9 @@
          return '未设置'
        }
        const formatted = formatDateTime(this.taskDetail.plannedStartTime, 'YYYY-MM-DD HH:mm')
        // 如果年份是1900,表示无效日期,显示为未设置
        if (formatted && formatted.startsWith('1900')) {
          return '未设置'
        // 如果年份是1900或1970,表示无效日期,显示为未分配时间
        if (formatted && (formatted.startsWith('1900') || formatted.startsWith('1970'))) {
          return '未分配时间'
        }
        return formatted
      },
@@ -540,9 +547,9 @@
          return '未设置'
        }
        const formatted = formatDateTime(this.taskDetail.plannedEndTime, 'YYYY-MM-DD HH:mm')
        // 如果年份是1900,表示无效日期,显示为未设置
        if (formatted && formatted.startsWith('1900')) {
          return '未设置'
        // 如果年份是1900或1970,表示无效日期,显示为未分配时间
        if (formatted && (formatted.startsWith('1900') || formatted.startsWith('1970'))) {
          return '未分配时间'
        }
        return formatted
      },
@@ -552,9 +559,9 @@
          return '未设置'
        }
        const formatted = formatDateTime(this.taskDetail.actualStartTime, 'YYYY-MM-DD HH:mm')
        // 如果年份是1900,表示无效日期,显示为未设置
        if (formatted && formatted.startsWith('1900')) {
          return '未设置'
        // 如果年份是1900或1970,表示无效日期,显示为未分配时间
        if (formatted && (formatted.startsWith('1900') || formatted.startsWith('1970'))) {
          return '未分配时间'
        }
        return formatted
      },
@@ -564,9 +571,9 @@
          return '未设置'
        }
        const formatted = formatDateTime(this.taskDetail.actualEndTime, 'YYYY-MM-DD HH:mm')
        // 如果年份是1900,表示无效日期,显示为未设置
        if (formatted && formatted.startsWith('1900')) {
          return '未设置'
        // 如果年份是1900或1970,表示无效日期,显示为未分配时间
        if (formatted && (formatted.startsWith('1900') || formatted.startsWith('1970'))) {
          return '未分配时间'
        }
        return formatted
      }
@@ -591,13 +598,7 @@
        
        getTask(this.taskId).then(response => {
          this.taskDetail = response.data || response
          // 调试:打印返回的数据
          // console.log('任务详情完整数据:', JSON.stringify(this.taskDetail, null, 2))
          // console.log('任务类型字段值:', this.taskDetail.taskType)
          // console.log('任务状态字段值:', this.taskDetail.taskStatus)
          // console.log('出发地址:', this.taskDetail.departureAddress)
          // console.log('目的地址:', this.taskDetail.destinationAddress)
          // console.log('转运任务信息 (emergencyInfo):', this.taskDetail.emergencyInfo)
          
          // 如果是转运任务,加载支付信息
          if (this.taskDetail.taskType === 'EMERGENCY_TRANSFER') {
@@ -947,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(() => {});
        }
      },
      
      // 获取位置信息并更新状态
@@ -1802,5 +1845,27 @@
        }
      }
    }
    .vip-tag {
      display: inline-block;
      padding: 2rpx 8rpx;
      font-size: 20rpx;
      color: #fff;
      background-color: #ff0000;
      border-radius: 4rpx;
      margin-left: 10rpx;
      vertical-align: middle;
    }
    .hq-tag {
      display: inline-block;
      padding: 2rpx 8rpx;
      font-size: 20rpx;
      color: #fff;
      background-color: #5856d6;
      border-radius: 4rpx;
      margin-left: 10rpx;
      vertical-align: middle;
    }
  }
</style>