AdminPointRoute.vue
2.17 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
<template>
<div class="route-container">
<el-row :gutter="20">
<el-col :span="6">
<el-card class="route-list">
<el-scrollbar>
<ul class="route-ul">
<li v-for="(route, index) in routes" :key="index"
:class="{ 'active': route.inspectionRouteId === currentRouteId }" @click="switchRoute(route)">
{{ route.routeName }}
</li>
</ul>
</el-scrollbar>
</el-card>
</el-col>
<el-col :span="18">
<a-inspection-route-map ref="routeMap" />
</el-col>
</el-row>
</div>
</template>
<script>
import { listAdminInspectionRoutes } from '@/api/inspection/aInspectionPlanDetailApi'
import AInspectionRouteMap from './AInspectionRouteMap'
export default {
name: 'AdminPointRoute',
components: {
AInspectionRouteMap
},
data() {
return {
loading: false,
routes: [],
currentRouteId: '',
inspectionId: ''
}
},
methods: {
async loadData(params) {
this.inspectionId = params.inspectionPlanId
await this.getRouteList()
},
async getRouteList() {
try {
this.loading = true
const params = {
inspectionId: this.inspectionId,
page: 1,
row: 100
}
const { inspectionRoutes } = await listAdminInspectionRoutes(params)
this.routes = inspectionRoutes
if (this.routes.length > 0) {
this.switchRoute(this.routes[0])
}
} catch (error) {
this.$message.error(this.$t('common.fetchError'))
} finally {
this.loading = false
}
},
switchRoute(route) {
this.currentRouteId = route.inspectionRouteId
this.$refs.routeMap.initMap({
inspectionRouteId: route.inspectionRouteId
})
}
}
}
</script>
<style scoped>
.route-container {
padding: 20px;
}
.route-list {
height: 600px;
}
.route-ul {
list-style: none;
padding: 0;
margin: 0;
}
.route-ul li {
padding: 10px;
cursor: pointer;
border-bottom: 1px solid #eee;
}
.route-ul li:hover {
background-color: #f5f5f5;
}
.route-ul li.active {
background-color: #409EFF;
color: white;
}
</style>