Blame view

src/components/inspection/pointTask.vue 2.87 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
48ea9c43   wuxw   巡检开发完成
2
    <div class="point-task-container">
57c370b2   wuxw   v1.9 优化巡检地图展示问题
3
      <el-row :gutter="20" v-if="pointTaskInfo.tasks && pointTaskInfo.tasks.length>0">
48ea9c43   wuxw   巡检开发完成
4
5
6
7
8
        <el-col :span="6">
          <el-card class="task-list-card">
            <div class="task-list">
              <ul>
                <li v-for="(task, index) in pointTaskInfo.tasks" :key="index" @click="_switchPointTask(task)"
57c370b2   wuxw   v1.9 优化巡检地图展示问题
9
                  :class="{ 'active': task.inspectionRouteId == pointTaskInfo.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
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
                  {{ task.planUserName }}({{ task.inspectionPlanName }})
                </li>
              </ul>
            </div>
          </el-card>
        </el-col>
        <el-col :span="18">
          <el-card>
            <inspection-task-map ref="inspectionTaskMap" />
          </el-card>
        </el-col>
      </el-row>
    </div>
  </template>
  
  <script>
  import { queryPointInspectionTask } from '@/api/inspection/inspectionPointApi'
  import { getCommunityId } from '@/api/community/communityApi'
  import InspectionTaskMap from '@/components/inspection/inspectionTaskMap'
  
  export default {
    name: 'PointTask',
    components: {
      InspectionTaskMap
    },
    data() {
      return {
        pointTaskInfo: {
          tasks: [],
          inspectionId: '',
          taskId: '',
          inspectionRouteId: ''
        },
        communityId: ''
      }
    },
    created() {
      this.communityId = getCommunityId()
    },
    methods: {
      loadData(point) {
        if (!point) return
  
        this.pointTaskInfo.inspectionId = point.inspectionId
        this._loadPointTaskData()
      },
  
      async _loadPointTaskData() {
        try {
          const params = {
            communityId: this.communityId,
            inspectionId: this.pointTaskInfo.inspectionId,
            page: 1,
            row: 100
          }
  
          const {data} = await queryPointInspectionTask(params)
          this.pointTaskInfo.tasks = data
  
          if (data && data.length > 0) {
            this._switchPointTask(data[0])
          }
        } catch (error) {
          console.error('获取巡检任务失败:', error)
          this.$message.error(this.$t('pointTask.fetchError'))
        }
      },
  
      _switchPointTask(task) {
        this.pointTaskInfo.taskId = task.taskId
        this.pointTaskInfo.inspectionRouteId = task.inspectionRouteId
  
        // 通知地图组件加载任务
        this.$nextTick(() => {
          if (this.$refs.inspectionTaskMap) {
57c370b2   wuxw   v1.9 优化巡检地图展示问题
85
            this.$refs.inspectionTaskMap.loadData(task)
48ea9c43   wuxw   巡检开发完成
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
          }
        })
      }
    }
  }
  </script>
  
  <style scoped>
  .point-task-container {
    padding: 20px;
  }
  
  .task-list-card {
    height: 600px;
    overflow: hidden;
  }
  
  .task-list {
    height: 550px;
    overflow-y: auto;
  }
  
  .task-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  
  .task-list li {
    padding: 12px 15px;
    border-bottom: 1px solid #ebeef5;
    cursor: pointer;
    transition: all 0.3s;
  }
  
  .task-list li:hover {
    background-color: #f5f7fa;
  }
  
  .task-list li.active {
    background-color: #ecf5ff;
    color: #409eff;
    font-weight: bold;
  }
  </style>