Blame view

src/components/inspection/pointRoute.vue 2.82 KB
48ea9c43   wuxw   巡检开发完成
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
  <template>
    <div class="point-route-container">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-card class="route-list-card">
            <div class="route-list">
              <ul>
                <li v-for="(route, index) in pointRouteInfo.routes" :key="index" @click="_switchPointRoute(route)"
                  :class="{ 'active': route.inspectionRouteId === pointRouteInfo.inspectionRouteId }">
                  {{ route.routeName }}
                </li>
              </ul>
            </div>
          </el-card>
        </el-col>
        <el-col :span="18">
          <el-card>
            <inspection-route-map ref="inspectionRouteMap" />
          </el-card>
        </el-col>
      </el-row>
    </div>
  </template>
  
  <script>
  import { listInspectionRoutes } from '@/api/inspection/inspectionPointApi'
  import { getCommunityId } from '@/api/community/communityApi'
  import InspectionRouteMap from '@/components/inspection/inspectionRouteMap'
  
  export default {
    name: 'PointRoute',
    components: {
      InspectionRouteMap
    },
    data() {
      return {
        pointRouteInfo: {
          routes: [],
          inspectionRouteId: '',
          inspectionId: ''
        },
        communityId: ''
      }
    },
    created() {
      this.communityId = getCommunityId()
    },
    methods: {
      loadData(point) {
        if (!point) return
  
        this.pointRouteInfo.inspectionId = point.inspectionId
        this._loadPointRouteData()
      },
      async _loadPointRouteData() {
        try {
          const params = {
            communityId: this.communityId,
            inspectionId: this.pointRouteInfo.inspectionId,
            page: 1,
            row: 100
          }
  
          const response = await listInspectionRoutes(params)
          this.pointRouteInfo.routes = response.inspectionRoutes
  
          if (response.inspectionRoutes && response.inspectionRoutes.length > 0) {
            this._switchPointRoute(response.inspectionRoutes[0])
          }
        } catch (error) {
          console.error('获取巡检路线失败:', error)
          this.$message.error(this.$t('pointRoute.fetchError'))
        }
      },
      _switchPointRoute(route) {
        this.pointRouteInfo.inspectionRouteId = route.inspectionRouteId
  
        // 通知地图组件加载路线
        this.$nextTick(() => {
          if (this.$refs.inspectionRouteMap) {
            this.$refs.inspectionRouteMap.loadRoute(route)
          }
        })
      }
    }
  }
  </script>
  
  <style scoped>
  .point-route-container {
    padding: 20px;
  }
  
  .route-list-card {
    height: 600px;
    overflow: hidden;
  }
  
  .route-list {
    height: 550px;
    overflow-y: auto;
  }
  
  .route-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  
  .route-list li {
    padding: 12px 15px;
    border-bottom: 1px solid #ebeef5;
    cursor: pointer;
    transition: all 0.3s;
  }
  
  .route-list li:hover {
    background-color: #f5f7fa;
  }
  
  .route-list li.active {
    background-color: #ecf5ff;
    color: #409eff;
    font-weight: bold;
  }
  </style>