riku
2025-07-18 306ef09707d6bcf9ffa67de55f86ab6f4362deee
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<template>
  <CardDialog
    v-model="dialogVisible"
    title="走航智能分析"
    draggable
    :modal="false"
    width="400px"
  >
    <template #default>
      <!-- <template v-if="latestResult">
        <el-row>
          <el-text size="small">{{ latestResult._timestr }}</el-text>
        </el-row>
        <el-space>
          <el-icon color="#F56C6C" :size="40"><WarnTriangleFilled /></el-icon>
          <el-text>
            {{ latestResult.advice }}
          </el-text>
        </el-space>
        <el-row justify="end">
          <el-link type="primary" :underline="true" @click="showPolyline">
            {{ lineShow ? '收起路线' : '定位路线' }}
          </el-link>
          <el-text size="small">
            推荐路线总长{{ latestResult.direction.distance }}米
          </el-text>
        </el-row>
      </template> -->
      <el-button icon="Plus" @click="addAdvice"></el-button>
      <el-button icon="Minus" @click="removeAdvice"></el-button>
      <el-scrollbar height="200">
        <TransitionGroup name="list">
          <div v-for="(item, index) in analysisResultList" :key="index">
            <template v-if="index == 0">
              <el-row justify="space-between">
                <el-text size="small">{{ item._timestr }}</el-text>
                <el-tag type="danger" effect="dark">最新线索</el-tag>
              </el-row>
              <el-space>
                <el-icon color="#F56C6C" :size="40"
                  ><WarnTriangleFilled
                /></el-icon>
                <el-text>
                  {{ item.advice }}
                </el-text>
              </el-space>
              <el-row justify="space-between">
                <el-link type="primary" :underline="true" @click="showPolyline">
                  {{ lineShow ? '收起路线' : '定位路线' }}
                </el-link>
                <el-text size="small">
                  推荐路线总长{{ item.direction.distance }}米
                </el-text>
              </el-row>
              <el-divider>历史线索</el-divider>
            </template>
            <template v-else>
              <el-row>
                <el-text size="small">{{ item._timestr }}</el-text>
              </el-row>
              <el-space>
                <!-- <el-icon color="#F56C6C" :size="40"><WarnTriangleFilled /></el-icon> -->
                <el-text>
                  {{ item.advice }}
                </el-text>
              </el-space>
              <!-- <el-row justify="space-between">
              <el-link type="primary" :underline="true" @click="showPolyline">
                {{ lineShow ? '收起路线' : '定位路线' }}
              </el-link>
              <el-text size="small">
                推荐路线总长{{ item.direction.distance }}米
              </el-text>
            </el-row> -->
              <el-divider></el-divider>
            </template>
          </div>
        </TransitionGroup>
      </el-scrollbar>
    </template>
    <template #footer> </template>
  </CardDialog>
</template>
 
<script setup>
import moment from 'moment';
import { ref, onMounted, onUnmounted, reactive } from 'vue';
import websocket from '@/api/websocket';
import websocketMsgParser from '@/views/sourcetrace/websocketMsgParser.js';
import mapLine from '@/utils/map/line';
import mapUtil from '@/utils/map/util';
 
const dialogVisible = ref(false);
const lineShow = ref(true);
const latestResult = ref();
let latestPolyline = undefined;
const analysisResultList = reactive([]);
const polylineList = [];
 
onMounted(() => {
  websocket.registerReceiveEvent(dealMsg);
});
onUnmounted(() => {
  websocket.removeReceiveEvent(dealMsg);
  showPolyline(false);
});
 
function dealMsg(data) {
  const { type, content } = websocketMsgParser.parseMsg(data);
  // 污染分析结果 AnalysisResult
  if (type == '2') {
    const obj = JSON.parse(content);
    console.log('污染分析结果: ', obj);
    obj._timestr = timeFormatter(obj.time);
    analysisResultList.unshift(obj);
    latestResult.value = obj;
 
    // obj.sortedSceneList;
    // obj.time;
    // obj.advice;
    // obj.direction;
 
    const polyline = mapLine.drawDirection(
      obj.direction.paths.map((v) => [v.first, v.second])
    );
    polylineList.unshift(polyline);
    if (latestPolyline) {
      mapUtil.removeViews(latestPolyline);
    }
    latestPolyline = polyline;
    dialogVisible.value = true;
  }
}
 
function showPolyline(show) {
  if (typeof show === 'boolean') {
    lineShow.value = show;
  } else {
    lineShow.value = !lineShow.value;
  }
  if (lineShow.value) {
    mapUtil.addViews(latestPolyline);
  } else {
    mapUtil.removeViews(latestPolyline);
  }
}
 
function timeFormatter(time) {
  return moment(time).format('YYYY-MM-DD HH:mm:ss');
}
 
function addAdvice() {
  analysisResultList.unshift(analysisResultList[0]);
}
 
function removeAdvice() {
  analysisResultList.splice(0, 1);
}
</script>
<style scoped>
:deep(.el-text) {
  --el-text-color: white;
}
 
:deep(.el-link) {
  --el-link-text-color: #23dad1;
  /* color: #ffd82a; */
}
</style>
<!-- <style>
.list-move, /* 对移动中的元素应用的过渡 */
.list-enter-active,
.list-leave-active {
  transition: all 0.5s ease;
}
 
.list-enter-from,
.list-leave-to {
  opacity: 0;
  transform: translateX(-30px);
}
 
/* 确保将离开的元素从布局流中删除
  以便能够正确地计算移动的动画。 */
.list-leave-active {
  position: absolute;
}
</style> -->