wujianwei
2026-01-08 850e19bd9655071cd801d74c240b70c61167b4cd
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<template>
  <view class="container">
    <!-- 标题栏 -->
    <Nav :title="formData.name" :customBack="formData.router" customType="navigateBack"></Nav>
 
    <!-- 行程历史列表-可下拉滚动 -->
    <scroll-view class="history-scroll" scroll-y="true" style="height: calc(100vh - 80rpx);">
      <view class="timeline-item" v-for="(item, index) in historyList" :key="index">
        <!-- 左侧时间轴 -->
        <view class="timeline-left">
          <view class="timeline-dot"></view>
          <view class="timeline-line" :class="{ last: index === historyList.length - 1 }"></view>
          <view class="timeline-distance">{{ item.odometer }}km</view>
        </view>
 
        <!-- 右侧行程内容 -->
        <view class="timeline-right">
          <view class="item-header">
            <view class="driver-action">{{ item.driverName }} {{ item.statusStr }}</view>
            <view class="vehicle-info">{{ item.vehicleNumber }}</view>
            <view class="location">{{ item.address }}</view>
            <view class="time">{{ item.tripTime }}</view>
          </view>
 
          <!-- 图片区域 -->
          <view class="image-grid">
            <view class="image-item" v-for="(img, imgIndex) in item.voucherUrl" :key="imgIndex">
              <image class="img" :src="img" mode="aspectFill"></image>
            </view>
          </view>
        </view>
      </view>
    </scroll-view>
  </view>
</template>
 
<script>
import { tmsTripList, getcarType } from "@/common/examine";
 
export default {
  data() {
    return {
      formData: {},
      historyList: [
     
      ]
    };
  },
  onLoad(options) {
    this.formData = options;
    console.log(options)
     this.formData.router = options.router;
    // 获取 URL 参数
    if (options.id) {
      this.getList();
    }
  },
  methods: {
    getList() {
      getcarType('trip_type').then((res) => {
        this.actionButtonRows = res
        if (res.length > 0) {
          tmsTripList(this.formData.id).then((res1) => {
            this.historyList = res1;
            this.historyList.forEach(item => {
              // 查找匹配的dictLabel
              const matchedDict = this.actionButtonRows.find(dictItem => dictItem.dictValue == item.tripType);
              item.statusStr = matchedDict ? matchedDict.dictLabel : '';
 
              // 转换voucherUrl为数组
              if (item.voucherUrl) {
                item.voucherUrl = item.voucherUrl.split(',').filter(url => url.trim() !== '');
              } else {
                item.voucherUrl = [];
              }
            });
 
            // 再处理odometer计算
            for (let i = 0; i < this.historyList.length; i++) {
              if (i === 0) {
                this.historyList[i].odometer = this.historyList[i].odometer;
              } else {
                let diff = this.historyList[i - 1].odometer - this.historyList[i].odometer;
                // 负数处理为0,保留最多2位小数
                this.historyList[i].odometer = diff < 0 ? 0 :
                  (Number.isInteger(diff) ? diff : parseFloat(diff.toFixed(2)));
              }
            }
 
          }).catch(err => {
            console.error('获取调度信息失败:', err);
          });
        }
 
 
      }).catch(err => {
      });
 
 
    },
  }
};
</script>
 
<style scoped>
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #f7f7f7;
}
 
/* 标题栏 */
.title-bar {
  height: 80rpx;
  line-height: 80rpx;
  text-align: center;
  font-size: 32rpx;
  font-weight: 500;
  background-color: #fff;
  border-bottom: 1rpx solid #ccc;
}
 
/* 行程滚动区域 */
.history-scroll {
  flex: 1;
  padding: 20rpx;
  box-sizing: border-box;
}
 
/* 单个行程项 */
.timeline-item {
  display: flex;
  margin-bottom: 30rpx;
}
 
/* 左侧时间轴 */
.timeline-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 60rpx;
  /* 固定宽度确保对齐 */
  margin-right: 20rpx;
}
 
/* 时间轴圆点 */
.timeline-dot {
  width: 20rpx;
  height: 20rpx;
  border-radius: 50%;
  background-color: #4285f4;
  border: 4rpx solid #fff;
  box-shadow: 0 0 0 6rpx rgba(66, 133, 244, 0.1);
  flex-shrink: 0;
  /* 防止压缩 */
  margin-top: 10rpx;
  /* 上边距 */
}
 
/* 时间轴连接线 */
.timeline-line {
  width: 8rpx;
  flex: 1;
  background-color: #eee;
  margin: 4rpx 0;
  /* 上下留出间距 */
}
 
/* 最后一个节点无连接线 */
.timeline-line.last {
  display: none;
}
 
/* 里程数 */
.timeline-distance {
  font-size: 24rpx;
  color: #666;
  white-space: nowrap;
  margin-bottom: 10rpx;
  /* 下边距 */
  flex-shrink: 0;
  /* 防止压缩 */
  height: 30rpx;
  /* 固定高度 */
  display: flex;
  align-items: center;
  justify-content: center;
}
 
/* 右侧行程内容 */
.timeline-right {
  flex: 1;
  background-color: #fff;
  border-radius: 12rpx;
  padding: 24rpx;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
 
/* 行程头部信息 */
.item-header {
  margin-bottom: 16rpx;
}
 
.driver-action {
  font-size: 28rpx;
  font-weight: 500;
  color: #333;
  margin-bottom: 8rpx;
}
 
.vehicle-info,
.location,
.time {
  font-size: 26rpx;
  color: #666;
  margin-bottom: 6rpx;
}
 
/* 图片网格 */
.image-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10rpx;
}
 
/* 图片项 */
.image-item {
  width: 23%;
  padding-bottom: 23%;
  /* 正方形比例 */
  position: relative;
}
 
/* 图片占位 */
.img {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  border: 1rpx solid #eee;
  border-radius: 4rpx;
}
</style>