openatc-components 0.5.81 → 0.5.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/_diff_a.txt ADDED
@@ -0,0 +1,360 @@
1
+ /**
2
+ * Copyright (c) 2020 kedacom
3
+ * OpenATC is licensed under Mulan PSL v2.
4
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
5
+ * You may obtain a copy of Mulan PSL v2 at:
6
+ * http://license.coscl.org.cn/MulanPSL2
7
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
8
+ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
9
+ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
10
+ * See the Mulan PSL v2 for more details.
11
+ **/
12
+ <!--流量统计渠化路口图-->
13
+ <template>
14
+ <div class="show-channelization channelization-base-map" :class="{
15
+ 'widescreenCrossImg': bodyDomWidth > 1680,
16
+ 'superlargeCrossImg': bodyDomWidth <= 1680 && bodyDomWidth > 1440,
17
+ 'largeCrossImg': bodyDomWidth <= 1440 && bodyDomWidth > 1280,
18
+ 'middleCrossImg2': bodyDomWidth <= 1280 && bodyDomWidth > 960,
19
+ 'smallCrossImg': bodyDomWidth <= 960 && bodyDomWidth > 890,
20
+ 'smallCrossImg2': bodyDomWidth <= 890 && bodyDomWidth > 720,
21
+ 'miniCrossImg': bodyDomWidth <= 720 && bodyDomWidth > 650,
22
+ 'superminiCrossImg': bodyDomWidth <= 650 && bodyDomWidth > 450,
23
+ 'transMiddleCrossImg': bodyDomWidth <= 450 && bodyDomWidth > 350,
24
+ 'transMiddleCrossImg2': bodyDomWidth <= 350 && bodyDomWidth > 300,
25
+ 'transMiddleCrossImg3': bodyDomWidth <= 300 && bodyDomWidth > 260,
26
+ 'transMiniCrossImg': bodyDomWidth <= 260,
27
+ 'changePaddingBottom': true }">
28
+ <ChannelizationElements
29
+ ref="channelizationElements"
30
+ UsageMode="show"
31
+ :allitem="allitem"
32
+ :CrossMapVisible="CrossMapVisible"
33
+ :CrossMapData="CrossMapData"
34
+ :isSeletable="isSeletable"
35
+ :Motorways="LanePhaseStatisticsData"
36
+ :Pedwalk="sidewalkPhaseData"
37
+ :Countdown="Countdown"
38
+ :customText="customText"
39
+ :textFontSize="textFontSize"
40
+ :Detector="DetectorData"
41
+ :bcgColor="bcgColor"
42
+ />
43
+ </div>
44
+ </template>
45
+
46
+ <script>
47
+ import ChannelizationElements from '../DrawChannelization/drawsvg/channelizationElements'
48
+ import { getChannelizatonChart } from '../../../api/cross'
49
+
50
+ export default {
51
+ name: 'channelization-flow-statistic',
52
+ components: {
53
+ ChannelizationElements
54
+ },
55
+ computed: {
56
+ },
57
+ props: {
58
+ phasesStatisticsList: {
59
+ type: Array,
60
+ default: () => []
61
+ },
62
+ AgentId: {
63
+ type: String,
64
+ default: '0'
65
+ },
66
+ resizeMap: { // 重新获取容器大小,调整底图大小
67
+ type: Boolean,
68
+ default: false
69
+ },
70
+ customText: {
71
+ type: String
72
+ },
73
+ bcgColor: {
74
+ type: String
75
+ },
76
+ textFontSize: {
77
+ type: String
78
+ }
79
+ },
80
+ watch: {
81
+ phasesStatisticsList: {
82
+ handler: function (val) {
83
+ // 相位统计数据数据
84
+ this.phasesStatisticsData = JSON.parse(JSON.stringify(val))
85
+ this.createPhaseStatisticsMap()
86
+ this.getLanePhaseStatusData()
87
+ },
88
+ // 深度观察监听
89
+ deep: true
90
+ },
91
+ AgentId: {
92
+ handler: function (val) {
93
+ // 平台设备切换时,重载当前路口保存的渠化配置
94
+ this.load('all')
95
+ },
96
+ deep: true
97
+ },
98
+ resizeMap: {
99
+ handler: function (newval, oldval) {
100
+ if (newval === true && oldval === false) {
101
+ this.getParentSize()
102
+ }
103
+ }
104
+ }
105
+ },
106
+ data () {
107
+ return {
108
+ isSeletable: false,
109
+ bodyDomWidth: 352,
110
+ bodyDomSize: {
111
+ width: 1920,
112
+ height: 1080
113
+ },
114
+ CrossMapVisible: true, // 控制底图显示隐藏
115
+ CrossMapData: {
116
+ x: 400,
117
+ y: 100,
118
+ w: 800,
119
+ h: 200,
120
+ angle: 0,
121
+ svgstr: '',
122
+ imgfilesrc: ''
123
+ }, // 管理底图数据
124
+ Motorways: [],
125
+ Texts: [],
126
+ Pedwalk: [],
127
+ Countdown: [],
128
+ Detector: [],
129
+ allitem: {
130
+ x: 435,
131
+ y: 325,
132
+ w: 870,
133
+ h: 650,
134
+ angle: 0
135
+ },
136
+ LanePhaseStatisticsData: [], // 车道相位数据
137
+ phasesStatisticsMap: new Map(), // 相位统计数据映射
138
+ colorMap: new Map([['A', '#009900'], ['B', '#00FF00'], ['C', '#FFFF00'], ['D', '#FF9900'], ['E', '#FF0000'], ['F', '#990000']]),
139
+ sidewalkPhaseData: [], // 行人相位
140
+ DetectorData: [] // 检测器数据(包括车辆和行人)
141
+ }
142
+ },
143
+ methods: {
144
+ createPhaseStatisticsMap () {
145
+ // 生成相位id和相位状态对应数据结构
146
+ this.phasesStatisticsData.map(phase => {
147
+ let phaseId = phase.phaseno
148
+ let phaseInfo = {
149
+ time: phase.time,
150
+ ...phase.phasestatistics
151
+ }
152
+ this.phasesStatisticsMap.set(phaseId, phaseInfo)
153
+ })
154
+ },
155
+ getLanePhaseStatusData () {
156
+ let curLanePhaseData = []
157
+ for (let i = 0; i < this.LanePhaseStatisticsData.length; i++) {
158
+ let curPhaseStatus
159
+ if (this.LanePhaseStatisticsData[i].phasetype === 'phase') {
160
+ console.log(this.phasesStatisticsMap)
161
+ curPhaseStatus = this.phasesStatisticsMap.get(this.LanePhaseStatisticsData[i].phaseid)
162
+ }
163
+ // if (!curPhaseStatus) continue // 没有关联相位的车道不显示
164
+ let data
165
+ if (curPhaseStatus) {
166
+ data = {
167
+ ...this.LanePhaseStatisticsData[i],
168
+ congestionindex: curPhaseStatus.congestionindex,
169
+ color: this.colorMap.get(curPhaseStatus.congestionindex)
170
+ }
171
+ } else {
172
+ // 没有关联的,或者没有对应状态的,车道显示默认白色
173
+ data = {
174
+ ...this.LanePhaseStatisticsData[i],
175
+ congestionindex: undefined,
176
+ color: '#fff'
177
+ }
178
+ }
179
+ curLanePhaseData.push(data)
180
+ }
181
+ this.LanePhaseStatisticsData = JSON.parse(JSON.stringify(curLanePhaseData))
182
+ },
183
+ // 加载
184
+ load (type) {
185
+ this.getChannelizatonChart().then((channelizatondata) => {
186
+ console.log(channelizatondata)
187
+ let savedTemp = JSON.parse(JSON.stringify(channelizatondata))
188
+ for (const [key, value] of Object.entries(savedTemp)) {
189
+ if (key === 'vehile') {
190
+ this.Motorways = value
191
+ }
192
+ if (key === 'text') {
193
+ this.Texts = value
194
+ }
195
+ if (key === 'ped') {
196
+ this.Pedwalk = value
197
+ }
198
+ if (key === 'countdown') {
199
+ this.Countdown = value
200
+ }
201
+ if (key === 'detector') {
202
+ this.Detector = value.filter(ele => ele.detailtype === 'detector')
203
+ }
204
+ if (key === 'crossMap') {
205
+ this.CrossMapData = JSON.parse(JSON.stringify(value))
206
+ }
207
+ }
208
+ this.isSeletable = false
209
+ // 从接口得到所有渠化车道和人行道数据
210
+ this.LanePhaseStatisticsData = JSON.parse(JSON.stringify(this.Motorways))
211
+ this.sidewalkPhaseData = JSON.parse(JSON.stringify(this.Pedwalk))
212
+ this.DetectorData = JSON.parse(JSON.stringify(this.Detector))
213
+ this.getLanePhaseStatusData()
214
+ })
215
+ },
216
+ // 重置
217
+ handleReset () {
218
+ this.Texts = []
219
+ this.Motorways = []
220
+ this.Countdown = []
221
+ this.phaseCountdownList = []
222
+ this.Pedwalk = []
223
+ this.Detector = []
224
+ this.CrossMapData = {
225
+ x: 400,
226
+ y: 100,
227
+ w: 800,
228
+ h: 200,
229
+ angle: 0,
230
+ svgstr: '',
231
+ imgfilesrc: ''
232
+ }
233
+ this.LanePhaseStatisticsData = []
234
+ this.sidewalkPhaseData = []
235
+ this.DetectorData = []
236
+ },
237
+ getChannelizatonChart () {
238
+ // let agentid = getIframdevid()
239
+ // 路口已设置渠化,则总览默认显示渠化路口,未设置显示模版路口
240
+ // if (this.isfromatc === true) {
241
+ // this.$store.dispatch('SetShowHomePage', 'Graphical')
242
+ // }
243
+ this.handleReset()
244
+ return new Promise((resolve, reject) => {
245
+ getChannelizatonChart(this.AgentId).then(data => {
246
+ if (!data.data.success) {
247
+ // let parrenterror = getMessageByCode(data.data.code, this.$i18n.locale)
248
+ // if (data.data.data) {
249
+ // // 子类型错误
250
+ // let childErrorCode = data.data.data.errorCode
251
+ // if (childErrorCode) {
252
+ // let childerror = getMessageByCode(data.data.data.errorCode, this.$i18n.locale)
253
+ // this.$message.error(parrenterror + ',' + childerror)
254
+ // }
255
+ // } else {
256
+ // this.$message.error(parrenterror)
257
+ // }
258
+ return
259
+ }
260
+ if (data.data.data === undefined || JSON.stringify(data.data.data) === '{}') return
261
+ // if (this.isfromatc === true) {
262
+ // this.$store.dispatch('SetShowHomePage', 'Channelization')
263
+ // }
264
+ this.handleReset()
265
+ let channelizatondata = data.data.data
266
+ resolve(channelizatondata)
267
+ })
268
+ })
269
+ },
270
+ getParentSize () {
271
+ // 获取最外层dom尺寸,适配准备
272
+ var _this = this
273
+ this.$nextTick(function () {
274
+ if (this.$el.parentElement === null || this.$el.parentElement === undefined) return
275
+ this.bodyDomSize.width = this.$el.parentElement.clientWidth
276
+ this.bodyDomWidth = this.bodyDomSize.width
277
+ window.addEventListener('resize', () => {
278
+ // 定义窗口大小变更通知事件
279
+ if (_this.$el.parentElement === null || _this.$el.parentElement === undefined) return
280
+ _this.bodyDomSize.width = _this.$el.parentElement.clientWidth
281
+ this.bodyDomWidth = this.bodyDomSize.width
282
+ console.log('resize this.bodyDomSize.width', _this.bodyDomSize.width)
283
+ }, false)
284
+ })
285
+ }
286
+ },
287
+ created () {
288
+ this.load()
289
+ },
290
+ mounted () {
291
+ this.getParentSize()
292
+ this.phasesStatisticsData = JSON.parse(JSON.stringify(this.phasesStatisticsList))
293
+ this.createPhaseStatisticsMap()
294
+ },
295
+ destroyed () {
296
+ this.handleReset()
297
+ }
298
+ }
299
+ </script>
300
+
301
+ <style lang="css" rel="stylesheet/scss">
302
+ .show-channelization {
303
+ position: relative;
304
+ overflow: hidden;
305
+ }
306
+ .widescreenCrossImg {
307
+ zoom: 1.3;
308
+ }
309
+ .superlargeCrossImg {
310
+ zoom: 1.1;
311
+ }
312
+ .largeCrossImg {
313
+ zoom: 1.1;
314
+ }
315
+ .middleCrossImg {
316
+ zoom: 1;
317
+ }
318
+ .middleCrossImg2 {
319
+ zoom: 0.8;
320
+ }
321
+ .smallCrossImg {
322
+ zoom: 0.8;
323
+ }
324
+ .smallCrossImg2 {
325
+ zoom: 0.8;
326
+ }
327
+ .miniCrossImg {
328
+ zoom: 0.7;
329
+ }
330
+ .superminiCrossImg {
331
+ zoom: 0.6;
332
+ }
333
+ .minimumCrossImg {
334
+ zoom: 0.35;
335
+ }
336
+ .transMiddleCrossImg {
337
+ -webkit-transform-origin-y: 0;
338
+ transform: scale(0.55);
339
+ margin-top: 3%;
340
+ padding: 0PX;
341
+ }
342
+ .transMiddleCrossImg2 {
343
+ -webkit-transform-origin-y: 0;
344
+ transform: scale(0.27);
345
+ margin-top: -1.5%;
346
+ padding: 0PX;
347
+ }
348
+ .transMiddleCrossImg3 {
349
+ -webkit-transform-origin-y: 0;
350
+ transform: scale(0.22);
351
+ margin-top: -1%;
352
+ padding: 0PX;
353
+ }
354
+ .transMiniCrossImg {
355
+ -webkit-transform-origin-y: 0;
356
+ transform: scale(0.18);
357
+ margin-top: -1.6%;
358
+ padding: 0PX;
359
+ }
360
+ </style>