RouteTask.vue
3.25 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
<template>
<div class="route-task-container">
<el-row :gutter="20">
<el-col :span="6" class="task-list-col">
<el-card class="task-list-card">
<ul class="task-ul">
<li v-for="(task, index) in routeTaskInfo.tasks" :key="index"
:class="{ 'active-task': task.taskId == routeTaskInfo.taskId }" @click="_switchRouteTask(task)">
<div class="task-user">{{ task.planUserName }}({{ task.inspectionPlanName }})</div>
<div class="task-time">{{ task.planInsTime }}</div>
</li>
</ul>
</el-card>
</el-col>
<el-col :span="18" class="task-map-col">
<inspection-task-map ref="inspectionTaskMap"/>
</el-col>
</el-row>
</div>
</template>
<script>
import { getCommunityId } from '@/api/community/communityApi'
import { queryRouteInspectionTask } from '@/api/inspection/inspectionRouteApi'
import InspectionTaskMap from './inspectionTaskMap'
export default {
name: 'RouteTask',
components: {
InspectionTaskMap
},
data() {
return {
routeTaskInfo: {
tasks: [],
taskId: '',
inspectionRouteId: ''
},
communityId: ''
}
},
created() {
this.communityId = getCommunityId()
},
beforeDestroy() {
},
methods: {
open(params) {
this.routeTaskInfo.inspectionRouteId = params.inspectionRouteId
this._loadRouteTaskData()
},
loadData(params) {
this.routeTaskInfo.inspectionRouteId = params.inspectionRouteId
this._loadRouteTaskData()
},
handleSwitch(params) {
this.routeTaskInfo.inspectionRouteId = params.inspectionRouteId
this._loadRouteTaskData()
},
async _loadRouteTaskData() {
try {
const params = {
communityId: this.communityId,
inspectionRouteId: this.routeTaskInfo.inspectionRouteId,
page: 1,
row: 100
}
const { data } = await queryRouteInspectionTask(params)
this.routeTaskInfo.tasks = data
if (data && data.length > 0) {
this._switchRouteTask(data[0])
}
} catch (error) {
console.error('获取巡检任务失败:', error)
}
},
_switchRouteTask(task) {
this.routeTaskInfo.taskId = task.taskId
this.routeTaskInfo.inspectionRouteId = task.inspectionRouteId
// 通知地图组件加载任务
setTimeout(() => {
if (this.$refs.inspectionTaskMap) {
this.$refs.inspectionTaskMap.loadData(task)
}
}, 500)
}
}
}
</script>
<style lang="scss" scoped>
.route-task-container {
padding: 20px;
height: 100%;
.task-list-col {
height: 100%;
.task-list-card {
height: 100%;
overflow-y: auto;
.task-ul {
list-style: none;
padding: 0;
margin: 0;
li {
padding: 10px;
cursor: pointer;
transition: all 0.3s;
&:hover {
background-color: #f5f5f5;
}
&.active-task {
background-color: #409eff;
color: white;
}
.task-user {
}
.task-time {
font-size: 12px;
color: inherit;
}
}
}
}
}
.task-map-col {
height: 100%;
}
}
</style>