Blame view

src/components/inspection/pointRoute.vue 3.17 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
57c370b2   wuxw   v1.9 优化巡检地图展示问题
2
3
    <div class="point-route-container" >
      <el-row :gutter="20" v-if="pointRouteInfo.routes && pointRouteInfo.routes.length>0">
48ea9c43   wuxw   巡检开发完成
4
5
6
7
8
        <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)"
57c370b2   wuxw   v1.9 优化巡检地图展示问题
9
                  :class="{ 'active': route.inspectionRouteId == pointRouteInfo.inspectionRouteId }">
48ea9c43   wuxw   巡检开发完成
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
                  {{ 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: {
56c7fec9   wuxw   巡检功能测试完成
49
50
      open(params) {
        this.pointRouteInfo.inspectionId = params.inspectionId
77f5558e   wuxw   v1.9 巡检计划中 修改巡检路线...
51
        this.pointRouteInfo.inspectionRouteId = params.inspectionRouteId
56c7fec9   wuxw   巡检功能测试完成
52
53
        this._loadPointRouteData()
      },
48ea9c43   wuxw   巡检开发完成
54
55
56
57
      loadData(point) {
        if (!point) return
  
        this.pointRouteInfo.inspectionId = point.inspectionId
77f5558e   wuxw   v1.9 巡检计划中 修改巡检路线...
58
        this.pointRouteInfo.inspectionRouteId = point.inspectionRouteId
48ea9c43   wuxw   巡检开发完成
59
60
61
62
63
64
65
        this._loadPointRouteData()
      },
      async _loadPointRouteData() {
        try {
          const params = {
            communityId: this.communityId,
            inspectionId: this.pointRouteInfo.inspectionId,
77f5558e   wuxw   v1.9 巡检计划中 修改巡检路线...
66
            inspectionRouteId: this.pointRouteInfo.inspectionRouteId,
48ea9c43   wuxw   巡检开发完成
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
            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) {
d367e130   wuxw   巡检功能测试
88
            this.$refs.inspectionRouteMap.loadData(route)
48ea9c43   wuxw   巡检开发完成
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
          }
        })
      }
    }
  }
  </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;
48ea9c43   wuxw   巡检开发完成
119
120
121
122
123
124
125
126
127
128
129
130
131
132
    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>