wlzboy
3 天以前 8cb5d3440208a3be3e772e65f1bd0ec63031ba62
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<template>
  <div class="app-container">
    <el-page-header @back="goBack" content="任务详情">
    </el-page-header>
 
    <el-card class="box-card" style="margin-top: 20px;" shadow="hover">
      <div slot="header" class="clearfix">
        <span><i class="el-icon-document"></i> 任务基本信息</span>
      </div>
      
      <el-descriptions :column="2" border>
        <el-descriptions-item label="任务编号">{{ taskInfo.taskCode }}</el-descriptions-item>
        <el-descriptions-item label="任务状态">
          <el-tag :type="getStatusType(taskInfo.taskStatus)">
            {{ getStatusText(taskInfo.taskStatus) }}
          </el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="车牌号">{{ taskInfo.vehicleNo }}</el-descriptions-item>
        <el-descriptions-item label="执行人">{{ taskInfo.assigneeName }}</el-descriptions-item>
        <el-descriptions-item label="计划开始时间">{{ taskInfo.plannedStartTime }}</el-descriptions-item>
        <el-descriptions-item label="计划结束时间">{{ taskInfo.plannedEndTime }}</el-descriptions-item>
        <el-descriptions-item label="实际开始时间">{{ taskInfo.actualStartTime || '-' }}</el-descriptions-item>
        <el-descriptions-item label="实际结束时间">{{ taskInfo.actualEndTime || '-' }}</el-descriptions-item>
        <el-descriptions-item label="出发地址" :span="2">{{ taskInfo.departureAddress }}</el-descriptions-item>
        <el-descriptions-item label="目的地址" :span="2">{{ taskInfo.destinationAddress }}</el-descriptions-item>
      </el-descriptions>
    </el-card>
 
    <!-- GPS里程统计组件 -->
    <task-mileage-detail v-if="taskInfo.taskId" :task-id="taskInfo.taskId" />
    
    <!-- 支付信息卡片 -->
    <el-card v-if="showPaymentInfo && paymentInfo" class="box-card" style="margin-top: 20px;" shadow="hover">
      <div slot="header" class="clearfix">
        <span><i class="el-icon-wallet"></i> 支付信息</span>
      </div>
      
      <el-descriptions :column="2" border>
        <el-descriptions-item label="成交价">¥{{ paymentInfo.transferPrice || 0 }}</el-descriptions-item>
        <el-descriptions-item label="附加费用">¥{{ paymentInfo.additionalAmount || 0 }}</el-descriptions-item>
        <el-descriptions-item label="总金额">
          <span style="color: #e54d42; font-weight: bold; font-size: 16px;">¥{{ paymentInfo.totalAmount || 0 }}</span>
        </el-descriptions-item>
        <el-descriptions-item label="支付状态" v-if="paymentInfo.latestPayment">
          <el-tag :type="getPaymentStatusType(paymentInfo.latestPayment.payStatus)">
            {{ getPaymentStatusText(paymentInfo.latestPayment.payStatus) }}
          </el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="支付状态" v-else>
          <el-tag type="info">未支付</el-tag>
        </el-descriptions-item>
        <template v-if="paymentInfo.latestPayment">
          <el-descriptions-item label="支付方式">{{ getPaymentMethodText(paymentInfo.latestPayment.paymentMethod) }}</el-descriptions-item>
          <el-descriptions-item label="结算金额">¥{{ paymentInfo.latestPayment.settlementAmount }}</el-descriptions-item>
          <el-descriptions-item label="交易号" v-if="paymentInfo.latestPayment.tradeNo">{{ paymentInfo.latestPayment.tradeNo }}</el-descriptions-item>
          <el-descriptions-item label="支付时间" v-if="paymentInfo.latestPayment.payTime">{{ paymentInfo.latestPayment.payTime }}</el-descriptions-item>
        </template>
      </el-descriptions>
      
      <!-- 附加费用明细 -->
      <div v-if="paymentInfo.additionalFees && paymentInfo.additionalFees.length > 0" style="margin-top: 20px;">
        <el-divider content-position="left">附加费用明细</el-divider>
        <el-table :data="paymentInfo.additionalFees" border style="width: 100%">
          <el-table-column prop="feeName" label="费用名称" width="150" />
          <el-table-column prop="unitAmount" label="单价" width="100">
            <template slot-scope="scope">
              ¥{{ scope.row.unitAmount }}
            </template>
          </el-table-column>
          <el-table-column prop="quantity" label="数量" width="80" />
          <el-table-column prop="totalAmount" label="小计" width="100">
            <template slot-scope="scope">
              ¥{{ scope.row.totalAmount }}
            </template>
          </el-table-column>
          <el-table-column prop="remark" label="备注" show-overflow-tooltip />
        </el-table>
      </div>
    </el-card>
  </div>
</template>
 
<script>
import TaskMileageDetail from '@/components/TaskMileageDetail'
import { getTask } from '@/api/task'
import { getPaymentInfo } from '@/api/task'
 
export default {
  name: 'TaskDetail',
  components: {
    TaskMileageDetail
  },
  data() {
    return {
      taskInfo: {
        taskId: null,
        taskCode: '',
        taskStatus: '',
        taskType: '',
        vehicleNo: '',
        assigneeName: '',
        plannedStartTime: '',
        plannedEndTime: '',
        actualStartTime: '',
        actualEndTime: '',
        departureAddress: '',
        destinationAddress: ''
      },
      paymentInfo: null,
      showPaymentInfo: false
    }
  },
  created() {
    const taskId = this.$route.params && this.$route.params.taskId
    if (taskId) {
      this.loadTaskInfo(taskId)
      this.loadPaymentInfo(taskId)
    }
  },
  methods: {
    /** 加载任务信息 */
    loadTaskInfo(taskId) {
      getTask(taskId).then(response => {
        this.taskInfo = response.data
        // 只有转运任务才显示支付信息
        this.showPaymentInfo = this.taskInfo.taskType === 'EMERGENCY_TRANSFER'
      })
    },
    
    /** 加载支付信息 */
    loadPaymentInfo(taskId) {
      getPaymentInfo(taskId).then(response => {
        if (response.code === 200) {
          this.paymentInfo = response.data
        }
      }).catch(error => {
        console.error('加载支付信息失败:', error)
      })
    },
    
    /** 返回 */
    goBack() {
      this.$router.go(-1)
    },
    
    /** 获取状态类型 */
    getStatusType(status) {
      const statusMap = {
        'PENDING': 'info',
        'DEPARTING': 'warning',
        'ARRIVED': 'primary',
        'RETURNING': 'warning',
        'COMPLETED': 'success',
        'CANCELLED': 'danger'
      }
      return statusMap[status] || 'info'
    },
    
    /** 获取状态文本 */
    getStatusText(status) {
      const statusMap = {
        'PENDING': '待出发',
        'DEPARTING': '出发中',
        'ARRIVED': '已到达',
        'RETURNING': '返程中',
        'COMPLETED': '已完成',
        'CANCELLED': '已取消'
      }
      return statusMap[status] || status
    },
    
    /** 获取支付状态类型 */
    getPaymentStatusType(status) {
      const typeMap = {
        'UNPAID': 'info',
        'PENDING': 'warning',
        'PAID': 'success',
        'FAILED': 'danger',
        'REFUNDED': 'info'
      }
      return typeMap[status] || 'info'
    },
    
    /** 获取支付状态文本 */
    getPaymentStatusText(status) {
      const textMap = {
        'UNPAID': '未支付',
        'PENDING': '支付中',
        'PAID': '已支付',
        'FAILED': '支付失败',
        'REFUNDED': '已退款'
      }
      return textMap[status] || status
    },
    
    /** 获取支付方式文本 */
    getPaymentMethodText(method) {
      const methodMap = {
        'CASH': '现金支付',
        'ON_ACCOUNT': '挂账支付',
        'WECHAT': '微信支付',
        'ALIPAY': '支付宝支付'
      }
      return methodMap[method] || method
    }
  }
}
</script>
 
<style scoped>
.app-container {
  padding: 20px;
}
</style>