collision.vue
18.3 KB
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
<template>
<GLDialog mode="big" bigTitle="碰撞位置" :before-close="closeDialogFn" @onCancel="closeDialogFn" :visible.sync="showFuncIntro" :hasFooter="false">
<div class="head-tip" v-if="detailDataObj.collisionTimeOutFlag">
<img class="tip-img" src="@/images/tip.png" alt="" />
<span>车辆碰撞后,停留时间超过3分钟,建议去电回访。</span>
<span class="follow-up" @click="openRecordDialog">立即跟进</span>
</div>
<div class="accident-wrap">
<div class="accident-item">
<span class="title">事故情况</span>
<div class="media-box">
<template v-if="detailDataObj.mediaDetailList && detailDataObj.mediaDetailList.length">
<div class="media-item" v-for="(item, index) in detailDataObj.mediaDetailList" :key="index">
<img class="img" v-if="item.mediaType == 'IMAGE'" :src="item.fileUrl" alt="" />
<video v-if="item.mediaType == 'VIDEO'" class="video" preload loop muted>
<source :src="item.fileUrl" type="video/mp4" />
</video>
<div class="mask">
<img class="preview" src="@/images/eyes.png" alt="" @click="previewFile(item)" />
</div>
</div>
</template>
<div class="empty-wrap" v-else>
<img class="empty-img" src="@/images/empty-file.png" alt="" />
<p>暂无碰撞视频、暂无碰撞图片</p>
</div>
</div>
</div>
<div class="accident-item">
<span class="title">行车速度趋势(Km/h)</span>
<div v-if="showMap" class="eChart-box" id="echarts"></div>
<div class="empty-wrap" v-else>
<img class="empty-img" style="height: 70px; width: 176px" src="@/images/empty-speed.png" alt="" />
<p>未获取到行车速度趋势</p>
</div>
</div>
</div>
<div v-for="(item, index) in infoData" :key="index">
<span class="title">{{ item.title }}</span>
<div>
<div v-for="(ele, idx) in item.objList" :key="idx" class="obj-item">
<label class="label" for="">{{ ele.name }}:</label>
<span class="value">{{ detailDataObj[ele.key] || '--' }}</span>
</div>
</div>
</div>
<div>
<span class="title">事故地点</span>
<div v-if="showMap" id="mapContainer"></div>
<div class="empty-wrap" v-else>
<img class="empty-img" style="height: 120px; width: 100px" src="@/images/empty-addr.png" alt="" />
<p>未获取到设备定位</p>
</div>
</div>
<GLDialog mode="mid" title="新增跟进记录" :modal-append-to-body="true" :append-to-body="true" :visible.sync="recordVisible" :hasFooter="true" :before-close="handleCancel" @onOk="handleOk" @onCancel="handleCancel">
<glsx-combi-form class="record-form" ref="recordRef" :formRules="recordRule" labelWidth="154px" defaultWidth="432px" :formObj="recordForm" :formData="recordFormData"></glsx-combi-form>
</GLDialog>
<el-dialog class="image-dialog" :modal-append-to-body="true" :append-to-body="true" :visible.sync="previewFileVisible" width="30%">
<big-View ref="viewForm" v-if="previewFileVisible" :dialogSrc="previewObj.previewFileUrl" :dialogType="previewObj.dialogType"></big-View>
</el-dialog>
</GLDialog>
</template>
<script>
import * as echarts from 'echarts'
import * as dayjs from 'dayjs'
import startUrl from '@/images/icon_start.png'
import endUrl from '@/images/endPoint.png'
import accidUrl from '@/images/accidPoint.png'
// import AMapLoader from '@amap/amap-jsapi-loader';
import glsxCombiForm from '@/components/glsx-combi-form'
import bigView from '@/components/big-view'
import { PHONE_MAX_NUM, FOLLOW_STATUS, FOLLOW_RESULT, SN_TYPE } from './constant'
import GLMapSdk from '@/utils/glsk-map-sdk'
const infoData = [
{
title: '客户信息',
objList: [
{
name: '联系人',
key: 'customerName'
},
{
name: '手机号码',
key: 'customerPhone'
}
]
},
{
title: '基本信息',
objList: [
{
name: '车架',
key: 'standNo'
},
{
name: '子品牌',
key: 'vehicleSubBrandName'
},
{
name: '车系',
key: 'vehicleSeriesName'
},
{
name: '车牌',
key: 'licensePlate'
}
]
},
{
title: '碰撞信息',
objList: [
{
name: '碰撞时间',
key: 'acciTime'
},
{
name: '碰撞点',
key: 'address'
}
]
},
{
title: '跟进信息',
objList: [
{
name: '回访状态',
key: 'followUpStatus'
},
{
name: '回访时间',
key: 'followUpTime'
},
{
name: '回访结果',
key: 'followUpResult'
}
]
}
]
export default {
name: 'leadManage',
components: {
glsxCombiForm,
bigView
},
props: {
curCollId: String
},
data() {
return {
BMap: null,
showMap: true,
previewFileVisible: false,
previewObj: {
previewFileUrl: '',
dialogType: 'video'
},
showFuncIntro: true,
recordVisible: false,
infoData,
detailDataObj: {},
recordRule: {
followResult: [{ required: true, message: '请选择跟进结果', trigger: 'change' }]
},
recordForm: {
followResult: '',
followRemark: ''
},
recordFormData: [
{
label: '跟进结果',
name: 'followResult',
type: 'select',
optionLabel: 'label',
optionId: 'value',
optionList: [
{
label: '真实事故',
value: 0
},
{
label: '非真实事故',
value: 1
},
{
label: '无法处理',
value: 2
}
]
},
{
label: '备注',
name: 'followRemark',
type: 'input',
maxlength: 50,
showLimit: true,
inputType: 'textarea'
}
]
}
},
created() {},
mounted() {
this.getDetail()
},
methods: {
previewFile(item) {
console.log(item)
this.previewFileVisible = true
this.previewObj = {
previewFileUrl: item.fileUrl,
dialogType: item.mediaType == 'VIDEO' ? 'video' : 'img'
}
},
handleOk() {
this.$refs.recordRef.$refs.formRef.validate(valid => {
if (valid) {
const params = {
id: this.curCollId,
...this.recordForm
}
this.$apis.sendRepair.setFollowInfoApi(params).then(res => {
if (res) {
this.$message({
type: 'success',
message: '操作成功',
customClass: 'customMessageClass'
})
// const { followResult, followRemark} = this.recordForm
// this.detailDataObj.followResult = followResult
// this.detailDataObj.followRemark = followRemark
this.getDetail()
this.resetRecordData()
}
})
}
})
},
handleCancel() {
this.resetRecordData()
},
closeDialogFn() {
this.$emit('closeDialogFn')
},
resetRecordData() {
this.recordVisible = false
this.recordForm = {
followResult: '',
followRemark: ''
}
},
getDetail() {
this.$apis.sendRepair.getCollisionDetailApi({ id: this.curCollId }).then(res => {
if (res) {
console.log(res)
const result = FOLLOW_RESULT.find(item => item.value == res.followResult)
const status = FOLLOW_STATUS.find(item => item.value == res.followStatus)
res.followUpResult = result ? result.label : ''
res.followUpStatus = status ? status.label : ''
res.followUpTime = res.followTime ? dayjs(res.followTime).format('YYYY-MM-DD HH:mm:ss') : ''
res.acciTime = res.collisionTime ? dayjs(res.collisionTime).format('YYYY-MM-DD HH:mm:ss') : ''
this.detailDataObj = res
if (!res.carAddressList?.length) return (this.showMap = false)
const addr = [res.longitude ? +res.longitude : 0, res.latitude ? +res.latitude : 0]
this.handleData(res.carAddressList, res.collisionTime, addr)
}
})
},
openRecordDialog() {
this.recordForm = {
followResult: this.detailDataObj.followResult,
followRemark: this.detailDataObj.followRemark
}
this.recordVisible = true
},
handleData(list, collTime, addr) {
let xList = [],
yList = [],
lineList = [],
mapLnglatList = []
let startAddr = [],
pointAddr = [],
endAddr = []
const time = dayjs(collTime).format('HH:mm:ss')
list.forEach((ele, index) => {
// console.log(ele)
mapLnglatList.push(ele.lnglat)
if (index == 0 || index == list.length - 1) {
if (index == 0) startAddr = ele.lnglat
if (index != 0) endAddr = ele.lnglat
xList.push(`${ele.time}${index == 0 ? '起点' : '终点'}`)
} else {
if (ele.time == time) pointAddr = ele.lnglat
xList.push(ele.time == time ? ele.time + '碰撞点' : '')
}
yList.push(ele.sp)
})
const maxByList = Math.max.apply(null, yList)
const yMax = maxByList + (10 - (maxByList % 10 != 0 ? maxByList % 10 : 10))
xList.forEach(item => {
if (item) {
const itemlist = [
{
lineStyle: {
type: 'solid',
color: '#e0e6f1'
},
coord: [item, 0]
},
{
coord: [item, yMax]
}
]
lineList.push(itemlist)
}
})
this.drawLine(xList, yList, lineList)
// this.initMap(mapLnglatList, startAddr, addr, endAddr)
this.initBMap(mapLnglatList, startAddr, addr, endAddr)
},
drawLine(xList, yList, lineList) {
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('echarts'))
// 绘制图表
myChart.setOption({
tooltip: {
trigger: 'axis',
formatter: function (params) {
return (params[0]?.value || 0) + '(Km/h)'
}
},
grid: {
top: '3%',
left: '3%',
right: '8%',
bottom: '1%',
containLabel: true
},
xAxis: {
axisTick: {
show: false
}, // 隐藏 y 轴刻度线
type: 'category',
boundaryGap: false,
data: xList,
axisLine: {
lineStyle: {
color: '#e0e6f1' // 设置 x 轴的颜色为红色
}
},
axisLabel: {
interval: 0,
color: '#333333' // 让刻度标签的颜色自动适应主题
}
},
yAxis: {
type: 'value'
},
series: [
{
type: 'line',
smooth: true,
symbol: 'circle', // 将圆点改为点
stack: 'Total',
itemStyle: {
color: '#5850FF'
},
lineStyle: {
color: '#5850FF', // 设置线条颜色
width: 1
},
areaStyle: {
// 使用 areaStyle 来设置渐变背景
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(88, 80, 255, 0.5)'
}, // 渐变起始颜色
{
offset: 1,
color: 'rgba(145, 136, 255, 0)'
} // 渐变结束颜色
])
},
markLine: {
name: 'cc',
symbol: 'none',
data: lineList
},
data: yList
}
]
})
},
initMap(mapLnglatList, startAddr, pointAddr, endAddr) {
AMapLoader.load({
key: '44cc16e43ad7ed3358df507bd0618181', //此处填入我们注册账号后获取的Key
version: '2.0', //指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: ['AMap.Scale'] //需要使用的的插件列表,如比例尺'AMap.Scale'等
})
.then(AMap => {
var map = new AMap.Map('mapContainer', {
zoom: 12, // 初始缩放级别
center: startAddr // 初始地图中心点坐标
})
// 添加缩放控件
map.plugin(['AMap.ToolBar'], function () {
var toolbar = new AMap.ToolBar({
position: 'RT'
})
map.addControl(toolbar)
})
// 自定义起点图标
var startPointIcon = new AMap.Icon({
image: startUrl, // 替换成你的起点图标路径
size: new AMap.Size(36, 36)
})
// 自定义终点图标
var endPointIcon = new AMap.Icon({
image: endUrl, // 替换成你的终点图标路径
size: new AMap.Size(36, 36)
})
// 自定义碰撞位置图标
var collisionPointIcon = new AMap.Icon({
image: accidUrl, // 替换成你的碰撞位置图标路径
size: new AMap.Size(36, 36)
})
// 创建起点标记
var startPoint = new AMap.Marker({
position: startAddr,
icon: startPointIcon,
offset: new AMap.Pixel(-20, -35),
map: map
})
// 创建终点标记
var endPoint = new AMap.Marker({
position: endAddr,
icon: endPointIcon,
offset: new AMap.Pixel(-20, -35),
map: map
})
// 创建碰撞位置标记
var collisionPoint = new AMap.Marker({
position: pointAddr,
icon: collisionPointIcon,
offset: new AMap.Pixel(-20, -35),
map: map
})
// 创建轨迹线
var polyline = new AMap.Polyline({
path: mapLnglatList,
strokeColor: '#3366FF',
strokeOpacity: 1.0,
strokeWeight: 5
})
polyline.setMap(map)
})
.catch(e => {
console.log(e)
})
},
initBMap(mapLnglatList, startAddr, pointAddr, endAddr) {
console.log(mapLnglatList, startAddr, pointAddr, endAddr)
new GLMapSdk(
{
env: 3,
version: 1
},
async mapapi => {
this.BMap = mapapi
let map = await mapapi.invoke('Map', 'mapContainer')
map.enableScrollWheelZoom() //启用滚轮放大缩小
map.enableAutoResize() //启用自动适应容器尺寸变化
mapapi.invoke('OverviewMapControl')
mapapi.invoke('centerAndZoom', mapapi.invoke('Point', 116.404, 39.915), 13)
// mapapi.invoke('LocalCity', res => {
// mapapi.invoke('panTo', res.center)
// })
// 添加比例尺
mapapi.invoke('ScaleControl')
// 距离测量
mapapi.invoke('DistanceTool', map)
// 创建起点标记
var startPoint = this.createMarker(startUrl, startAddr)
// 创建终点标记
var endPoint = this.createMarker(endUrl, endAddr)
// 创建碰撞位置标记
var collisionPoint = this.createMarker(accidUrl, pointAddr)
let lnglatXY = mapLnglatList.map(item => {
return this.BMap.invoke('Point', item[0], item[1])
})
// 创建轨迹线
let polyline = this.BMap.invoke('Polyline', lnglatXY, { strokeColor: '#3366FF', strokeWeight: 5, strokeOpacity: 1.0 })
this.BMap.invoke('addOverlay', polyline)
this.BMap.invoke('addOverlay', startPoint)
this.BMap.invoke('addOverlay', endPoint)
this.BMap.invoke('addOverlay', collisionPoint)
}
)
},
createMarker(url, lnglat) {
console.log(url, lnglat)
let self = this
let lnglatXY = this.BMap.invoke('Point', lnglat[0], lnglat[1])
let marker = self.BMap.invoke('Marker', lnglatXY, {
icon: self.BMap.invoke('Icon', url, self.BMap.invoke('Size', 24, 34))
})
console.log(marker)
self.BMap.invoke('panTo', lnglatXY)
return marker
}
}
}
</script>
<style lang="scss" scoped>
.empty-wrap {
width: 100%;
height: 100%;
text-align: center;
.empty-img {
width: 64px;
height: 40px;
margin-bottom: 10px;
}
}
.head-tip {
height: 40px;
line-height: 40px;
background: #e4e3ff;
border-radius: 4px;
width: 100%;
font-size: 14px;
box-sizing: border-box;
margin-bottom: 16px;
padding: 0 16px;
.tip-img {
height: 14px;
width: 14px;
vertical-align: middle;
margin-right: 8px;
}
.follow-up {
cursor: pointer;
color: #5850ff;
}
}
.title {
display: inline-block;
height: 24px;
line-height: 24px;
font-family: PingFangSC-Medium;
font-weight: 600;
font-size: 16px;
color: #000000d9;
margin-bottom: 10px;
}
.accident-wrap {
display: flex;
margin-bottom: 20px;
.accident-item {
flex: 1;
.media-box {
display: flex;
.media-item {
display: inline-block;
position: relative;
margin-right: 10px;
.img,
.video {
display: inline-block;
width: 104px;
height: 104px;
border-radius: 4px;
}
.mask {
display: none;
}
}
.media-item:hover {
.mask {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.3);
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
.preview {
height: 20px;
width: 20px;
cursor: pointer;
}
}
}
}
}
}
.record-form {
/deep/ .el-textarea__inner {
height: 75px;
}
}
.obj-item {
display: inline-block;
margin-bottom: 20px;
.label {
display: inline-block;
text-align: right;
width: 154px;
line-height: 20px;
color: #666666;
}
.value {
display: inline-block;
min-width: 230px;
color: #333;
}
}
.eChart-box {
width: 100%;
height: 187px;
}
#mapContainer {
width: 100%;
height: 275px;
}
</style>