wlzboy
2025-11-27 668e570bd1db6bd00e4293b6977e6d3d051053ce
app/pages/task/detail.vue
@@ -189,8 +189,58 @@
          <view class="value">{{ taskDetail.emergencyInfo.transferDistance }}公里</view>
        </view>
        <view class="info-item" v-if="taskDetail.emergencyInfo.transferPrice">
          <view class="label">转运费用</view>
          <view class="label">基础费用</view>
          <view class="value">¥{{ taskDetail.emergencyInfo.transferPrice }}</view>
        </view>
        <view class="info-item" v-if="paymentInfo">
          <view class="label">附加费用</view>
          <view class="value">¥{{ paymentInfo.additionalAmount || 0 }}</view>
        </view>
        <view class="info-item" v-if="paymentInfo">
          <view class="label">总费用</view>
          <view class="value" style="color: #e54d42; font-weight: bold;">¥{{ paymentInfo.totalAmount || 0 }}</view>
        </view>
        <view class="info-item" v-if="paymentInfo && paymentInfo.paidAmount > 0">
          <view class="label">已支付</view>
          <view class="value" style="color: #34C759;">¥{{ paymentInfo.paidAmount }}</view>
        </view>
        <view class="info-item" v-if="paymentInfo && paymentInfo.paidAmount > 0">
          <view class="label">剩余未付</view>
          <view class="value" style="color: #ff9900; font-weight: bold;">¥{{ getRemainingAmount() }}</view>
        </view>
      </view>
      <!-- 支付记录明细 -->
      <view class="detail-section" v-if="paymentInfo && paymentInfo.paidPayments && paymentInfo.paidPayments.length > 0">
        <view class="section-title">支付记录</view>
        <view
          class="payment-record-item"
          v-for="payment in paymentInfo.paidPayments"
          :key="payment.id"
        >
          <view class="payment-header">
            <view
              class="payment-method-tag"
              :class="[
                payment.paymentMethod === '1' ? 'method-cash' : '',
                payment.paymentMethod === '2' ? 'method-bank' : '',
                payment.paymentMethod === '3' ? 'method-wechat' : '',
                payment.paymentMethod === '4' ? 'method-alipay' : '',
                payment.paymentMethod === '5' ? 'method-pos' : '',
                payment.paymentMethod === '6' ? 'method-account' : '',
                payment.paymentMethod === '7' ? 'method-yyt' : ''
              ]"
            >
              {{ getPaymentMethodLabel(payment.paymentMethod) }}
            </view>
            <view class="payment-amount">¥{{ payment.settlementAmount }}</view>
          </view>
          <view class="payment-time" v-if="payment.payTime">
            {{ formatPaymentTime(payment.payTime) }}
          </view>
          <view class="payment-remark" v-if="payment.remark">
            备注:{{ payment.remark }}
          </view>
        </view>
      </view>
      
@@ -345,7 +395,16 @@
        </button>
      </template>
      
      <!-- 已完成/已取消: 不显示按钮 -->
      <!-- 已完成/已取消: 不显示按钮,但如果是转运任务则显示结算按钮 -->
      <!-- 转运任务的结算按钮:仅完成/取消状态不显示 -->
      <button
        v-if="taskDetail.taskType === 'EMERGENCY_TRANSFER' && !isTaskFinished"
        class="action-btn settlement"
        @click="handleSettlement"
      >
        结算
      </button>
    </view>
  </view>
</template>
@@ -353,6 +412,7 @@
<script>
  import { getTask, changeTaskStatus } from '@/api/task'
  import { checkVehicleActiveTasks } from '@/api/task'
  import { getPaymentInfo } from '@/api/payment'
  import { formatDateTime } from '@/utils/common'
  import AttachmentUpload from '@/components/AttachmentUpload.vue'
  
@@ -363,7 +423,8 @@
    data() {
      return {
        taskDetail: null,
        taskId: null
        taskId: null,
        paymentInfo: null // 支付信息
      }
    },
    computed: {
@@ -456,10 +517,67 @@
          console.log('出发地址:', this.taskDetail.departureAddress)
          console.log('目的地址:', this.taskDetail.destinationAddress)
          console.log('转运任务信息 (emergencyInfo):', this.taskDetail.emergencyInfo)
          // 如果是转运任务,加载支付信息
          if (this.taskDetail.taskType === 'EMERGENCY_TRANSFER') {
            this.loadPaymentInfo()
          }
        }).catch(error => {
          console.error('加载任务详情失败:', error)
          this.$modal.showToast('加载任务详情失败')
        })
      },
      // 加载支付信息
      loadPaymentInfo() {
        getPaymentInfo(this.taskId).then(res => {
          this.paymentInfo = res.data
          console.log('支付信息:', this.paymentInfo)
        }).catch(err => {
          console.error('加载支付信息失败', err)
        })
      },
      // 根据支付方式字典值获取显示标签
      getPaymentMethodLabel(dictValue) {
        const methodMap = {
          '1': '现金',
          '2': '银行转账',
          '3': '微信支付',
          '4': '支付宝',
          '5': 'POS收款',
          '6': '挂账',
          '7': '易医通挂账',
          '8': '退款',
          '9': '积分'
        }
        return methodMap[dictValue] || dictValue
      },
      // 格式化支付时间
      formatPaymentTime(time) {
        if (!time) return '未知'
        const date = new Date(time)
        const year = date.getFullYear()
        const month = String(date.getMonth() + 1).padStart(2, '0')
        const day = String(date.getDate()).padStart(2, '0')
        const hour = String(date.getHours()).padStart(2, '0')
        const minute = String(date.getMinutes()).padStart(2, '0')
        return `${year}-${month}-${day} ${hour}:${minute}`
      },
      // 计算剩余未付金额
      getRemainingAmount() {
        if (!this.paymentInfo) {
          return '0.00'
        }
        const total = parseFloat(this.paymentInfo.totalAmount || 0)
        const paid = parseFloat(this.paymentInfo.paidAmount || 0)
        const remaining = total - paid
        console.log('总金额:', total.toFixed(2))
        console.log('已付金额:', paid.toFixed(2))
        console.log('剩余未付金额:', remaining.toFixed(2))
        return remaining > 0 ? remaining.toFixed(2) : '0.00'
      },
      
      // 获取车辆信息
@@ -565,6 +683,13 @@
          'WELFARE': '福祉车'
        }
        return typeMap[type] || '未知类型'
      },
      // 处理结算
      handleSettlement() {
        uni.navigateTo({
          url: '/pages/task/settlement?taskId=' + this.taskId
        })
      },
      
      // 处理任务操作
@@ -674,10 +799,10 @@
        if (!this.taskDetail) {
          return null;
        }
        // 从车辆列表中获取第一个车辆的ID
        if (this.taskDetail.vehicleList && this.taskDetail.vehicleList.length > 0) {
          return this.taskDetail.vehicleList[0].vehicleId;
        console.log("taskDetail assignedVehicles",this.taskDetail.assignedVehicles);
        // 从车辆列表中获取第一个车辆的ID(后端返回的字段名是assignedVehicles)
        if (this.taskDetail.assignedVehicles && this.taskDetail.assignedVehicles.length > 0) {
          return this.taskDetail.assignedVehicles[0].vehicleId;
        }
        
        // 或者从单个车辆对象获取
@@ -1128,6 +1253,80 @@
      }
    }
    
    // 支付记录样式
    .payment-record-item {
      background-color: #f9f9f9;
      border-radius: 10rpx;
      padding: 20rpx;
      margin-bottom: 20rpx;
      &:last-child {
        margin-bottom: 0;
      }
      .payment-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 15rpx;
        .payment-method-tag {
          display: inline-block;
          padding: 6rpx 16rpx;
          border-radius: 6rpx;
          font-size: 24rpx;
          color: white;
          font-weight: 500;
          &.method-cash {
            background-color: #34C759;
          }
          &.method-bank {
            background-color: #5AC8FA;
          }
          &.method-wechat {
            background-color: #09BB07;
          }
          &.method-alipay {
            background-color: #1677FF;
          }
          &.method-pos {
            background-color: #FF9500;
          }
          &.method-account {
            background-color: #FF9500;
          }
          &.method-yyt {
            background-color: #AF52DE;
          }
        }
        .payment-amount {
          font-size: 32rpx;
          font-weight: bold;
          color: #34C759;
        }
      }
      .payment-time {
        font-size: 24rpx;
        color: #999;
        margin-bottom: 10rpx;
      }
      .payment-remark {
        font-size: 24rpx;
        color: #666;
        line-height: 1.5;
      }
    }
    .loading {
      display: flex;
      flex-direction: column;
@@ -1176,6 +1375,11 @@
          color: white;
        }
        
        &.settlement {
          background-color: #34C759;
          color: white;
        }
        &:first-child {
          margin-left: 0;
        }