openatc-components 0.0.94 → 0.0.95

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.
Files changed (117) hide show
  1. package/package/kisscomps/components/Channelization/Channelization.vue +546 -0
  2. package/package/kisscomps/components/Channelization/index.js +2 -0
  3. package/package/kisscomps/components/ChannelizationWithInterface/ChannelizationWithInterface.vue +494 -0
  4. package/package/kisscomps/components/ChannelizationWithInterface/index.js +2 -0
  5. package/package/kisscomps/components/DrawChannelization/drawsvg/channelizationElements.vue +249 -0
  6. package/package/kisscomps/components/DrawChannelization/drawsvg/detectorAssociatedComponent.vue +152 -0
  7. package/package/kisscomps/components/DrawChannelization/drawsvg/drawElement/TextBox.vue +91 -0
  8. package/package/kisscomps/components/DrawChannelization/drawsvg/drawElement/crossMap.vue +176 -0
  9. package/package/kisscomps/components/DrawChannelization/drawsvg/drawElement/editText.vue +108 -0
  10. package/package/kisscomps/components/DrawChannelization/drawsvg/firstImportCrossmap.vue +48 -0
  11. package/package/kisscomps/components/DrawChannelization/drawsvg/iconSvg/countdownSvg.vue +182 -0
  12. package/package/kisscomps/components/DrawChannelization/drawsvg/iconSvg/detectorChart.vue +222 -0
  13. package/package/kisscomps/components/DrawChannelization/drawsvg/iconSvg/detectorIconSvg.vue +191 -0
  14. package/package/kisscomps/components/DrawChannelization/drawsvg/iconSvg/laneIcon.vue +78 -0
  15. package/package/kisscomps/components/DrawChannelization/drawsvg/iconSvg/motorwayIconSvg.vue +433 -0
  16. package/package/kisscomps/components/DrawChannelization/drawsvg/iconSvg/pedroadIconSvg.vue +195 -0
  17. package/package/kisscomps/components/DrawChannelization/drawsvg/importDialog.vue +71 -0
  18. package/package/kisscomps/components/DrawChannelization/drawsvg/index.draw.vue +940 -0
  19. package/package/kisscomps/components/DrawChannelization/drawsvg/index.vue +109 -0
  20. package/package/kisscomps/components/DrawChannelization/drawsvg/laneEditPanel.vue +563 -0
  21. package/package/kisscomps/components/DrawChannelization/drawsvg/overlapAssociatedComponent.vue +157 -0
  22. package/package/kisscomps/components/DrawChannelization/drawsvg/phaseAssociatedComponent.check.vue +191 -0
  23. package/package/kisscomps/components/DrawChannelization/drawsvg/phaseAssociatedComponent.syncOper.vue +331 -0
  24. package/package/kisscomps/components/DrawChannelization/drawsvg/phaseAssociatedComponent.vue +157 -0
  25. package/package/kisscomps/components/DrawChannelization/drawsvg/table.vue +99 -0
  26. package/package/kisscomps/components/DrawChannelization/drawsvg/utils/loadutils.js +43 -0
  27. package/package/kisscomps/components/DrawChannelization/drawsvg/utils/phaseDataModel.js +32 -0
  28. package/package/kisscomps/components/DrawChannelization/drawsvg/utils/phasePos.json +20 -0
  29. package/package/kisscomps/components/DrawChannelization/index.js +2 -0
  30. package/package/kisscomps/components/DrawChannelization/phaseDataMgr.js +278 -0
  31. package/package/kisscomps/components/KanBan/kanban.vue +1 -1
  32. package/package/kisscomps/components/MessageBox/index.vue +96 -0
  33. package/package/kisscomps/components/SchemeConfig/closePhaselControlModal/index.vue +2 -2
  34. package/package/kisscomps/index.js +11 -1
  35. package/package/kissui.min.js +1 -1
  36. package/package.json +4 -2
  37. package/src/api/cross.js +33 -0
  38. package/src/i18n/language/en.js +77 -2
  39. package/src/i18n/language/zh.js +77 -2
  40. package/src/icons/svg/custom-BRTlane.svg +40 -0
  41. package/src/icons/svg/custom-bicyclelane.svg +7 -0
  42. package/src/icons/svg/custom-buslane.svg +40 -0
  43. package/src/icons/svg/custom-detector.svg +12 -0
  44. package/src/icons/svg/custom-east-bottom.svg +32 -0
  45. package/src/icons/svg/custom-east-top.svg +32 -0
  46. package/src/icons/svg/custom-ewped.svg +35 -0
  47. package/src/icons/svg/custom-motorway.svg +7 -0
  48. package/src/icons/svg/custom-nonmotorizedlane.svg +40 -0
  49. package/src/icons/svg/custom-north-left.svg +32 -0
  50. package/src/icons/svg/custom-north-right.svg +32 -0
  51. package/src/icons/svg/custom-pedcrossing.svg +7 -0
  52. package/src/icons/svg/custom-peddetector.svg +17 -0
  53. package/src/icons/svg/custom-pedeastward.svg +9 -0
  54. package/src/icons/svg/custom-pedestrian.svg +7 -0
  55. package/src/icons/svg/custom-pednorthward.svg +9 -0
  56. package/src/icons/svg/custom-pedsouthward.svg +9 -0
  57. package/src/icons/svg/custom-pedwestward.svg +9 -0
  58. package/src/icons/svg/custom-secondcrossing.svg +7 -0
  59. package/src/icons/svg/custom-sectionpedestrian.svg +7 -0
  60. package/src/icons/svg/custom-snped.svg +35 -0
  61. package/src/icons/svg/custom-south-left.svg +32 -0
  62. package/src/icons/svg/custom-south-right.svg +32 -0
  63. package/src/icons/svg/custom-straightahead.svg +7 -0
  64. package/src/icons/svg/custom-tramlane.svg +40 -0
  65. package/src/icons/svg/custom-turnaround.svg +7 -0
  66. package/src/icons/svg/custom-turnleft.svg +7 -0
  67. package/src/icons/svg/custom-turnright.svg +7 -0
  68. package/src/icons/svg/custom-vehiclebranch.svg +40 -0
  69. package/src/icons/svg/custom-vehiclemainroad.svg +41 -0
  70. package/src/icons/svg/custom-west-bottom.svg +32 -0
  71. package/src/icons/svg/custom-west-top.svg +32 -0
  72. package/src/icons/svg/custom-xlped.svg +14 -0
  73. package/src/icons/svg/custom-xpedestrian.svg +7 -0
  74. package/src/icons/svg/custom-xrped.svg +14 -0
  75. package/src/kisscomps/components/Channelization/Channelization.vue +546 -0
  76. package/src/kisscomps/components/Channelization/index.js +2 -0
  77. package/src/kisscomps/components/ChannelizationWithInterface/ChannelizationWithInterface.vue +494 -0
  78. package/src/kisscomps/components/ChannelizationWithInterface/index.js +2 -0
  79. package/src/kisscomps/components/DrawChannelization/drawsvg/channelizationElements.vue +249 -0
  80. package/src/kisscomps/components/DrawChannelization/drawsvg/detectorAssociatedComponent.vue +152 -0
  81. package/src/kisscomps/components/DrawChannelization/drawsvg/drawElement/TextBox.vue +91 -0
  82. package/src/kisscomps/components/DrawChannelization/drawsvg/drawElement/crossMap.vue +176 -0
  83. package/src/kisscomps/components/DrawChannelization/drawsvg/drawElement/editText.vue +108 -0
  84. package/src/kisscomps/components/DrawChannelization/drawsvg/firstImportCrossmap.vue +48 -0
  85. package/src/kisscomps/components/DrawChannelization/drawsvg/iconSvg/countdownSvg.vue +182 -0
  86. package/src/kisscomps/components/DrawChannelization/drawsvg/iconSvg/detectorChart.vue +222 -0
  87. package/src/kisscomps/components/DrawChannelization/drawsvg/iconSvg/detectorIconSvg.vue +191 -0
  88. package/src/kisscomps/components/DrawChannelization/drawsvg/iconSvg/laneIcon.vue +78 -0
  89. package/src/kisscomps/components/DrawChannelization/drawsvg/iconSvg/motorwayIconSvg.vue +433 -0
  90. package/src/kisscomps/components/DrawChannelization/drawsvg/iconSvg/pedroadIconSvg.vue +195 -0
  91. package/src/kisscomps/components/DrawChannelization/drawsvg/importDialog.vue +71 -0
  92. package/src/kisscomps/components/DrawChannelization/drawsvg/index.draw.vue +940 -0
  93. package/src/kisscomps/components/DrawChannelization/drawsvg/index.vue +109 -0
  94. package/src/kisscomps/components/DrawChannelization/drawsvg/laneEditPanel.vue +563 -0
  95. package/src/kisscomps/components/DrawChannelization/drawsvg/overlapAssociatedComponent.vue +157 -0
  96. package/src/kisscomps/components/DrawChannelization/drawsvg/phaseAssociatedComponent.check.vue +191 -0
  97. package/src/kisscomps/components/DrawChannelization/drawsvg/phaseAssociatedComponent.syncOper.vue +331 -0
  98. package/src/kisscomps/components/DrawChannelization/drawsvg/phaseAssociatedComponent.vue +157 -0
  99. package/src/kisscomps/components/DrawChannelization/drawsvg/table.vue +99 -0
  100. package/src/kisscomps/components/DrawChannelization/drawsvg/utils/loadutils.js +43 -0
  101. package/src/kisscomps/components/DrawChannelization/drawsvg/utils/phaseDataModel.js +32 -0
  102. package/src/kisscomps/components/DrawChannelization/drawsvg/utils/phasePos.json +20 -0
  103. package/src/kisscomps/components/DrawChannelization/index.js +2 -0
  104. package/src/kisscomps/components/DrawChannelization/phaseDataMgr.js +278 -0
  105. package/src/kisscomps/components/KanBan/kanban.vue +1 -1
  106. package/src/kisscomps/components/MessageBox/index.vue +96 -0
  107. package/src/kisscomps/components/SchemeConfig/closePhaselControlModal/index.vue +2 -2
  108. package/src/kisscomps/index.js +11 -1
  109. package/src/main.js +3 -0
  110. package/src/router/index.js +7 -0
  111. package/src/store/index.js +2 -2
  112. package/src/store/modules/globalParam.js +56 -16
  113. package/src/views/customchannelization.vue +49 -0
  114. package/src/views/intersection.vue +17 -9
  115. package/static/apiconfig.json +15 -0
  116. package/static/styles/channelizatioon.scss +365 -0
  117. package/static/styles/common.scss +1 -0
@@ -0,0 +1,940 @@
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="custom-cross" v-if="visible">
15
+ <ImportDialog ref="importDialog" @loadSvgString="loadSvgString"/>
16
+ <Messagebox :visible="canclesettingvisible" :text="$t('openatccomponents.channelizationmap.canclesetting')" @cancle="cancleSetting" @ok="completeSetting"/>
17
+ <div class="custom-main" ref="custommain">
18
+ <div class="custom-group drawPanelAnimation" ref="customGroup">
19
+ <!-- 绘制功能 -->
20
+ <div class="draw-function">
21
+ <div class="again-import">
22
+ <span class="import-label">{{$t('openatccomponents.channelizationmap.importcrosspicture')}}</span>
23
+ <el-button
24
+ class="again-import-btn"
25
+ type="primary"
26
+ :disabled="!isSeletable"
27
+ @click="clickOpen"
28
+ >{{$t('openatccomponents.channelizationmap.againimport')}}</el-button>
29
+ </div>
30
+
31
+ <div class="draw-to-sketchpad">
32
+ <div class="drawtip">{{$t('openatccomponents.channelizationmap.drawtips')}}</div>
33
+ <div class="draw-operation">
34
+ <!-- <el-button
35
+ type="primary"
36
+ :disabled="!isSeletable"
37
+ @click="addText"
38
+ >添加text</el-button>-->
39
+ <el-button
40
+ v-for="editbtn in editBtnGroup"
41
+ :key="editbtn.type"
42
+ class="edit-icon-btn"
43
+ @click="handleAddIcon(editbtn)"
44
+ >
45
+ <LaneIconSvg :laneicon="editbtn"/>
46
+ <div
47
+ class="btn-label"
48
+ :class="{'highlightColor': editbtn.active === true, 'defaultColor': editbtn.active === false}"
49
+ >{{editbtn.label}}</div>
50
+ </el-button>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ <!-- 画板区域 -->
55
+ <div class="sketchpad-area" id="sketchpadgroup" ref="sketchpadgroup">
56
+ <!-- <drr
57
+ id="sketchpadArea"
58
+ :resizable="false"
59
+ :x="allitem.x"
60
+ :y="allitem.y"
61
+ :w="allitem.w"
62
+ :h="allitem.h"
63
+ :angle="allitem.angle"
64
+ :selectable="false"
65
+ :aspectRatio="true"
66
+ > -->
67
+ <ChannelizationElements
68
+ id="channelizationElements"
69
+ :allitem="allitem"
70
+ :CrossMapVisible="CrossMapVisible"
71
+ :CrossMapData="CrossMapData"
72
+ :isSeletable="isSeletable"
73
+ :pointchange="pointchange"
74
+ @changeCrossMap="changeCrossMap"
75
+ :Motorways="Motorways"
76
+ :curChooseIconIndex="curChooseIconIndex"
77
+ @changeMotorwayItem="changeMotorwayItem"
78
+ @handleSelectIcon="handleSelectIcon"
79
+ :Countdown="Countdown"
80
+ :CountdownList="phaseCountdownMock"
81
+ @changeTimeItem="changeTimeItem"
82
+ :Pedwalk="Pedwalk"
83
+ @changePedItem="changePedItem"
84
+ :Detector="Detector"
85
+ @changeDetectorItem="changeDetectorItem"
86
+ :DetectorChart="DetectorChart"
87
+ :CurChooseIcon="curChooseIcon"
88
+ @changeDetectorChartItem="changeDetectorChartItem"
89
+ />
90
+ <!-- </drr> -->
91
+ </div>
92
+ <div class="draw-end-function">
93
+ <el-button type="primary" @click="handleReset()">{{$t('openatccomponents.button.reset')}}</el-button>
94
+ <!-- <el-button type="primary" @click="cancledraw()">{{$t('openatccomponents.button.Cancel')}}</el-button> -->
95
+ <el-button type="primary" @click="savedraw()">{{$t('openatccomponents.button.save')}}</el-button>
96
+ </div>
97
+ </div>
98
+ <div class="custom-edit" ref="customEdit">
99
+ <LaneEditPanel
100
+ :Data="curChooseIcon"
101
+ :choosedirections="curChooseIcon.direction"
102
+ :Motorways="Motorways"
103
+ @handleChooseDire="handleChooseDire"
104
+ @handleChoosePed="handleChoosePed"
105
+ @deleteItem="deleteItem"
106
+ @changeIconDataByType="changeIconDataByType"
107
+ @handleDisassociatePhase="handleDisassociatePhase"
108
+ />
109
+ </div>
110
+ </div>
111
+ <!-- <el-row>
112
+ <div class="phase-table">
113
+ <PhaseTable
114
+ :customlist="customlist"
115
+ @changeText="changeText"
116
+ @deleteItem="deleteItem"
117
+ @changeMotorwayItem="changeMotorwayItem"
118
+ @changeIconDataByType="changeIconDataByType"
119
+ />
120
+ </div>
121
+ </el-row> -->
122
+ </div>
123
+ </template>
124
+
125
+ <script>
126
+ import ChannelizationElements from './channelizationElements'
127
+
128
+ import LaneEditPanel from './laneEditPanel'
129
+
130
+ import PhaseTable from './table'
131
+ import PhaseDataModel from './utils/phaseDataModel.js'
132
+ import LaneIconSvg from './iconSvg/laneIcon'
133
+
134
+ import ImportDialog from './importDialog'
135
+ import Messagebox from '../../MessageBox/index'
136
+
137
+ import { mapState } from 'vuex'
138
+ import PhaseDataMgr from '../phaseDataMgr.js'
139
+
140
+ // import { getIframdevid } from '../../../../utils/auth.js'
141
+ import { saveChannelizatonChart } from '../../../../api/cross'
142
+ import { getMessageByCode } from '../../../../utils/responseMessage.js'
143
+
144
+ export default {
145
+ name: 'draw-channelization',
146
+ components: {
147
+ Messagebox,
148
+ ImportDialog,
149
+ ChannelizationElements,
150
+ PhaseTable,
151
+ LaneIconSvg,
152
+ LaneEditPanel
153
+ },
154
+ computed: {
155
+ ...mapState({
156
+ phaseList: state => state.globalParam.tscParam.phaseList,
157
+ PhaseDataMgr: state => state.globalParam.PhaseDataMgr
158
+ // ,curBodyWidth: state => state.globalParam.curBodyWidth
159
+ // ,curOpenatcAgentid: state => state.globalParam.curOpenatcAgentid
160
+ })
161
+ },
162
+ props: {
163
+ loadedChannelizatonData: {
164
+ type: Object
165
+ },
166
+ AgentId: {
167
+ type: String,
168
+ default: '0'
169
+ }
170
+ },
171
+ watch: {
172
+ // curBodyWidth: {
173
+ // handler: function (oldval, newval) {
174
+ // if (newval !== oldval) {
175
+ // this.resizePanelWidth(newval)
176
+ // }
177
+ // }
178
+ // },
179
+ // sidebar: {
180
+ // handler: function (oldval, newval) {
181
+ // setTimeout(() => {
182
+ // this.resizePanelWidth(this.curBodyWidth)
183
+ // }, 200)
184
+ // },
185
+ // deep: true
186
+ // },
187
+ AgentId: {
188
+ handler: function (val) {
189
+ // 平台设备切换时,清空上一个渠化配置
190
+ this.handleReset()
191
+ },
192
+ deep: true
193
+ },
194
+ loadedChannelizatonData: {
195
+ handler: function (val) {
196
+ // 平台设备切换时,重载当前路口保存的渠化配置
197
+ this.load('all')
198
+ },
199
+ deep: true
200
+ }
201
+ },
202
+ data () {
203
+ return {
204
+ visible: true,
205
+ canclesettingvisible: false,
206
+
207
+ isSeletable: true, // 元素是否可以编辑
208
+ index: 0,
209
+ motorid: 1, // 车道id
210
+ pedid: 1, // 人行道id
211
+ Motorways: [], // 管理所有自定义机动车图标数据
212
+ // Bicyclelanes: [], // 非机动车图标数据
213
+ customlist: [], // 所有自定义的图标列表
214
+ Texts: [], // 管理所有自定义文字数据
215
+ Pedwalk: [], // 管理所有人行横道
216
+ Detector: [], // 管理所有检测器
217
+ DetectorChart: [], // 管理所有检测器统计图
218
+ motorwayicon: '',
219
+ IconLengh: 45,
220
+ IconWdith: 100,
221
+ textareaW: 200,
222
+ textareaH: 100,
223
+ pedW: 206,
224
+ pedH: 22,
225
+ MapW: 800,
226
+ MapH: 200,
227
+ detectorW: 30,
228
+ detectorH: 30,
229
+ detectorchartW: 70,
230
+ detectorchartH: 100,
231
+ CrossMapData: {
232
+ svgstr: '',
233
+ imgfilesrc: ''
234
+ }, // 管理底图数据
235
+ allitem: {
236
+ x: 435,
237
+ y: 325,
238
+ w: 870,
239
+ h: 650,
240
+ angle: 0
241
+ },
242
+ countdownW: 140,
243
+ countdownH: 140,
244
+ Countdown: [], // 管理倒计时图标
245
+ phaseCountdownMock: [
246
+ {
247
+ id: 2,
248
+ phaseCountdown: 59,
249
+ phaseCountdownColor: '#fff'
250
+ },
251
+ {
252
+ id: 5,
253
+ phaseCountdown: 32,
254
+ phaseCountdownColor: '#fff'
255
+ }
256
+ ], // 倒计时动态数据模拟
257
+ svgvisible: false,
258
+ pointchange: false, // 控制选中时光标样式
259
+ CrossMapVisible: true, // 控制底图显示隐藏
260
+
261
+ curChooseIconIndex: -1,
262
+ curChooseIcon: {},
263
+ editBtnGroup: [
264
+ {
265
+ label: this.$t('openatccomponents.channelizationmap.motorway'),
266
+ type: 'motorway',
267
+ active: false,
268
+ width: '16px',
269
+ height: '16px'
270
+ },
271
+ // {
272
+ // label: this.$t('openatccomponents.channelizationmap.bicyclelane'),
273
+ // type: 'bicyclelane',
274
+ // active: false,
275
+ // width: '7px',
276
+ // height: '16px'
277
+ // },
278
+ {
279
+ label: this.$t('openatccomponents.channelizationmap.pedcrossing'),
280
+ type: 'pedcrossing',
281
+ active: false,
282
+ width: '16px',
283
+ height: '16px'
284
+ },
285
+ {
286
+ label: this.$t('openatccomponents.channelizationmap.countdown'),
287
+ type: 'countdown',
288
+ active: false,
289
+ width: '16px',
290
+ height: '16px'
291
+ },
292
+ {
293
+ label: this.$t('openatccomponents.channelizationmap.detector'),
294
+ type: 'detector',
295
+ active: false,
296
+ width: '16px',
297
+ height: '16px'
298
+ }
299
+ ],
300
+ AddType: '', // 正在添加的图标类型
301
+
302
+ dirNameMap: new Map([
303
+ [1, '直行'],
304
+ [2, '左转'],
305
+ [3, '右转'],
306
+ [4, '掉头']
307
+ ]),
308
+ phaseAssociatedMap: new Map() // 关联相位Map: key 是相位ID, value 是车道数据包含direction
309
+ }
310
+ },
311
+ methods: {
312
+ clickOpen () {
313
+ this.$refs.importDialog.clickOpen()
314
+ },
315
+
316
+ // 改变鼠标样式
317
+ changeMouse () {
318
+ if (!this.isSeletable) return
319
+ // document.getElementById('sketchpadArea').style.cursor = 'url(resource/pic/icons/magnifier3.cur) 12 12,crosshair'
320
+ document.getElementById('sketchpadArea').style.cursor =
321
+ 'url(resource/pic/icons/magnifier3.cur) 12 12,pointer'
322
+ this.pointchange = true
323
+ },
324
+
325
+ // 根据类型,表格编辑后,修改数据策略
326
+ changeIconDataByType (iconObj, changefield) {
327
+ this.curChooseIcon = JSON.parse(JSON.stringify(iconObj))
328
+ // 根据数据类型改变数据
329
+ switch (iconObj.icontype) {
330
+ case 'text':
331
+ this.changeText(iconObj, changefield)
332
+ break
333
+ case 'vehile':
334
+ this.changeMotorwayItem(iconObj, changefield)
335
+ if (changefield.indexOf('phaseid') !== -1) {
336
+ // 相位关联成功后,生成最新的相位关联map数据
337
+ this.PhaseDataMgr.updateLanePhaseAssociatedMap(this.Motorways)
338
+ }
339
+ break
340
+ case 'ped':
341
+ this.changePedItem(iconObj, changefield)
342
+ break
343
+ case 'countdown':
344
+ this.changeTimeItem(iconObj, changefield)
345
+ break
346
+ case 'detector':
347
+ this.changeDetectorItem(iconObj, changefield)
348
+ break
349
+ }
350
+ console.log('this.customlist', this.customlist)
351
+ },
352
+
353
+ // 被删除的相位所关联的车道,解除相位关联
354
+ handleDisassociatePhase (deletePhaseid) {
355
+ for (let i = 0; i < this.Motorways.length; i++) {
356
+ if (this.Motorways[i].phaseid === deletePhaseid) {
357
+ this.Motorways[i].phaseid = undefined
358
+ this.Motorways[i].phaselabel = ''
359
+ this.Motorways[i].phasetype = undefined
360
+ }
361
+ }
362
+ for (let i = 0; i < this.Pedwalk.length; i++) {
363
+ if (this.Pedwalk[i].phaseid === deletePhaseid) {
364
+ this.Pedwalk[i].phaseid = undefined
365
+ this.Pedwalk[i].phaselabel = ''
366
+ this.Pedwalk[i].phasetype = undefined
367
+ }
368
+ }
369
+ // 更新模型内初始相位列表数据
370
+ this.PhaseDataMgr.updateLanePhaseAssociatedMap(this.Motorways)
371
+ },
372
+
373
+ // 添加不同类型的车道图标
374
+ handleAddIcon (editbtn) {
375
+ // 按钮及图标高亮效果实现
376
+ this.editBtnGroup = this.editBtnGroup.map(btn => {
377
+ btn.active = false
378
+ return btn
379
+ })
380
+ for (let i = 0; i < this.editBtnGroup.length; i++) {
381
+ if (this.editBtnGroup[i].type === editbtn.type) {
382
+ this.editBtnGroup[i].active = true
383
+ }
384
+ }
385
+ this.changeMouse()
386
+ this.AddType = editbtn.type
387
+ },
388
+
389
+ addMotorwayIcon () {
390
+ this.PhaseDataModel = new PhaseDataModel()
391
+ let defaultMotorwayParam = {
392
+ x: this.setLeft,
393
+ y: this.setTop,
394
+ w: this.IconLengh,
395
+ h: this.IconWdith,
396
+ angle: 0
397
+ }
398
+ this.IconLengh = 45
399
+ this.IconWdith = 100
400
+ let Motorwaysitem = {
401
+ index: this.index,
402
+ id: this.motorid,
403
+ icontype: 'vehile',
404
+ icondireid: [1], // 前端区分箭头方向的标识
405
+ icondirename: [this.PhaseDataModel.getPhase(1).name],
406
+ lanePosition: 1,
407
+ controltype: 0,
408
+ phasetype: undefined,
409
+ phaseid: undefined,
410
+ phaselabel: '',
411
+ direction: [], // 值为1-16,对应16个方向
412
+ flip: false, // 车道类型是否翻转显示
413
+ ...defaultMotorwayParam
414
+ }
415
+ this.curChooseIconIndex = Motorwaysitem.index
416
+ this.curChooseIcon = JSON.parse(JSON.stringify(Motorwaysitem))
417
+ this.Motorways.push(Motorwaysitem)
418
+ this.customlist.push(Motorwaysitem)
419
+ this.index = this.increaseId(this.customlist, 'index')
420
+ this.motorid = this.increaseId(this.Motorways, 'id')
421
+ },
422
+ changeMotorwayItem (MotorwayItem, fields) {
423
+ this.changeItem(MotorwayItem, fields, this.Motorways)
424
+ this.changeCustomItem(MotorwayItem, fields)
425
+ },
426
+
427
+ // 选中图标
428
+ handleSelectIcon (iconobj) {
429
+ // console.log('选中的图标', iconobj)
430
+ this.curChooseIconIndex = iconobj.index
431
+ this.curChooseIcon = JSON.parse(JSON.stringify(iconobj))
432
+ },
433
+ // 根据多选的车道,修改车道图标
434
+ handleChooseDire (iconObj) {
435
+ this.curChooseIcon = JSON.parse(JSON.stringify(iconObj))
436
+ let editDirections = iconObj.icondireid
437
+ if (
438
+ this.curChooseIcon.icontype === 'vehile'
439
+ ) {
440
+ this.curChooseIcon.icondireid = editDirections
441
+ this.curChooseIcon.icondirename = editDirections.map(dir =>
442
+ this.dirNameMap.get(dir)
443
+ )
444
+ this.changeMotorwayItem(this.curChooseIcon, [
445
+ 'icondireid',
446
+ 'icondirename'
447
+ ])
448
+ }
449
+ console.log(this.curChooseIcon)
450
+ },
451
+
452
+ addPedwalkIcon () {
453
+ let defaulPedParam = {
454
+ x: this.setLeft,
455
+ y: this.setTop,
456
+ w: this.pedW,
457
+ h: this.pedH,
458
+ angle: 0,
459
+ viewbox: [0, 0, 206, 22]
460
+ }
461
+ this.pedW = 206
462
+ this.pedH = 22
463
+ let peditem = {
464
+ index: this.index,
465
+ id: this.pedid,
466
+ icontype: 'ped',
467
+ iconpedtypeid: 1,
468
+ iconpedposition: 1,
469
+ phasetype: undefined,
470
+ phaseid: undefined,
471
+ phaselabel: '',
472
+ ...defaulPedParam
473
+ }
474
+ this.curChooseIconIndex = peditem.index
475
+ this.curChooseIcon = JSON.parse(JSON.stringify(peditem))
476
+ this.Pedwalk.push(peditem)
477
+ this.customlist.push(peditem)
478
+ this.index = this.increaseId(this.customlist, 'index')
479
+ this.pedid = this.increaseId(this.Pedwalk, 'id')
480
+ },
481
+ changePedItem (PedItem, fields) {
482
+ this.changeItem(PedItem, fields, this.Pedwalk)
483
+ this.changeCustomItem(PedItem, fields)
484
+ },
485
+
486
+ handleChoosePed (pediconobj) {
487
+ this.curChooseIcon = JSON.parse(JSON.stringify(pediconobj))
488
+ if (this.curChooseIcon.icontype === 'ped') {
489
+ this.curChooseIcon.iconpedtypeid = pediconobj.iconpedtypeid
490
+ this.curChooseIcon.iconpedposition = pediconobj.iconpedposition
491
+ this.changePedItem(this.curChooseIcon, ['iconpedtypeid', 'iconpedposition'])
492
+ }
493
+ console.log(this.curChooseIcon)
494
+ },
495
+
496
+ addTimer () {
497
+ let defaultCountParam = {
498
+ x: this.setLeft,
499
+ y: this.setTop,
500
+ w: this.countdownW,
501
+ h: this.countdownH,
502
+ angle: 0
503
+ }
504
+ this.countdownW = 140
505
+ this.countdownH = 140
506
+ let countdownitem = {
507
+ index: this.index,
508
+ icontype: 'countdown',
509
+ ...defaultCountParam
510
+ }
511
+ this.curChooseIconIndex = countdownitem.index
512
+ this.curChooseIcon = JSON.parse(JSON.stringify(countdownitem))
513
+ this.Countdown.push(countdownitem)
514
+ this.customlist.push(countdownitem)
515
+ this.index = this.increaseId(this.customlist, 'index')
516
+ },
517
+ changeTimeItem (timeItem, fields) {
518
+ this.changeItem(timeItem, fields, this.Countdown)
519
+ this.changeCustomItem(timeItem, fields)
520
+ },
521
+
522
+ addAllDetector () {
523
+ // 统计图暂留
524
+ // this.addDetectorChart()
525
+ this.addDetector()
526
+ },
527
+ addDetector () {
528
+ let defaultDetectorParam = {
529
+ x: this.setLeft,
530
+ y: this.setTop,
531
+ w: this.detectorW,
532
+ h: this.detectorH,
533
+ angle: 0
534
+ }
535
+ this.detectorW = 30
536
+ this.detectorH = 30
537
+ let detectoritem = {
538
+ index: this.index,
539
+ icontype: 'detector',
540
+ detailtype: 'detector',
541
+ detectortype: 1, // 检测器类型: 1 车辆检测器 2 行人检测器
542
+ detectorid: undefined,
543
+ occupancythreshold: 80,
544
+ flowsaturationthreshold: 20,
545
+ ...defaultDetectorParam
546
+ }
547
+ this.curChooseIconIndex = detectoritem.index
548
+ this.curChooseIcon = JSON.parse(JSON.stringify(detectoritem))
549
+ this.Detector.push(detectoritem)
550
+ this.customlist.push(detectoritem)
551
+ this.index = this.increaseId(this.customlist, 'index')
552
+ },
553
+ changeDetectorItem (detectorItem, fields) {
554
+ this.changeItem(detectorItem, fields, this.Detector)
555
+ this.changeCustomItem(detectorItem, fields)
556
+ },
557
+ addDetectorChart () {
558
+ let defaultDetectorParam = {
559
+ x: this.setLeft,
560
+ y: this.setTop - 100, // 偏移到检测器正上方150
561
+ w: this.detectorchartW,
562
+ h: this.detectorchartH,
563
+ angle: 0
564
+ }
565
+ this.detectorchartW = 70
566
+ this.detectorchartH = 100
567
+ let detectoritem = {
568
+ index: this.index,
569
+ icontype: 'detector',
570
+ detailtype: 'detectorChart',
571
+ ...defaultDetectorParam
572
+ }
573
+ this.curChooseIconIndex = detectoritem.index
574
+ this.curChooseIcon = JSON.parse(JSON.stringify(detectoritem))
575
+ this.DetectorChart.push(detectoritem)
576
+ this.customlist.push(detectoritem)
577
+ this.index = this.increaseId(this.customlist, 'index')
578
+ },
579
+ changeDetectorChartItem (detectorItem, fields) {
580
+ this.changeItem(detectorItem, fields, this.DetectorChart)
581
+ this.changeCustomItem(detectorItem, fields)
582
+ },
583
+
584
+ // 添加文字
585
+ addText () {
586
+ let defaultTextParam = {
587
+ x: this.textareaW / 2,
588
+ y: this.textareaH / 2,
589
+ w: this.textareaW,
590
+ h: this.textareaH,
591
+ angle: 0
592
+ }
593
+ this.textareaW = 200
594
+ this.textareaH = 100
595
+ let textitem = {
596
+ index: this.index,
597
+ icontype: 'text',
598
+ text: '',
599
+ ...defaultTextParam
600
+ }
601
+ this.Texts.push(textitem)
602
+ this.customlist.push(textitem)
603
+ this.index = this.increaseId(this.customlist, 'index')
604
+ },
605
+ changeText (textobj, fields) {
606
+ this.changeItem(textobj, fields, this.Texts)
607
+ this.changeCustomItem(textobj, fields)
608
+ },
609
+
610
+ changeCustomItem (row, fields) {
611
+ this.changeItem(row, fields, this.customlist)
612
+ },
613
+ changeItem (row, fieldarr, data) {
614
+ for (let item of data) {
615
+ if (item.index === row.index) {
616
+ for (let field of fieldarr) {
617
+ item[field] = row[field]
618
+ }
619
+ }
620
+ }
621
+ },
622
+ deleteItem (row) {
623
+ let index = row.index
624
+ this.customlist = this.customlist.filter(ele => ele.index !== index)
625
+ switch (row.icontype) {
626
+ case 'text':
627
+ this.Texts = this.Texts.filter(ele => ele.index !== index)
628
+ break
629
+ case 'vehile':
630
+ this.Motorways = this.Motorways.filter(ele => ele.index !== index)
631
+ break
632
+ case 'ped':
633
+ this.Pedwalk = this.Pedwalk.filter(ele => ele.index !== index)
634
+ break
635
+ case 'countdown':
636
+ this.Countdown = this.Countdown.filter(ele => ele.index !== index)
637
+ break
638
+ case 'detector':
639
+ this.Detector = this.Detector.filter(ele => ele.index !== index)
640
+ this.DetectorChart = this.DetectorChart.filter(ele => ele.index !== index)
641
+ }
642
+ this.curChooseIconIndex = -1
643
+ this.curChooseIcon = {}
644
+ },
645
+
646
+ loadSvgString (type, imgstr) {
647
+ // 加载用户上传的底图svg字符串
648
+ if (type === 'vectorgraph') {
649
+ // 导入矢量图
650
+ this.getCrossMapViewbox(imgstr)
651
+ let defaultCrossMapParam = {
652
+ x: this.MapW / 2,
653
+ y: this.MapH / 2,
654
+ w: this.MapW,
655
+ h: this.MapH,
656
+ angle: 0
657
+ }
658
+ // (由于底图采用定位,导致脱离标准流,父元素高度塌陷,此处需要重新设置父元素高度,以防底图超出弹窗边界)
659
+ // this.$refs.crossmap.style.height = this.MapH
660
+ // this.$refs.crossmap.style.width = this.MapW
661
+ this.CrossMapData = {
662
+ type,
663
+ svgstr: imgstr,
664
+ ...defaultCrossMapParam
665
+ }
666
+ }
667
+ if (type === 'picture') {
668
+ // 导入图片
669
+ this.CrossMapData = {
670
+ type,
671
+ imgfilesrc: imgstr
672
+ }
673
+ }
674
+ },
675
+ getCrossMapViewbox (svgstr) {
676
+ // 获取户上传svg的viewBox属性的大小
677
+ let arr = svgstr.split('"')
678
+ let index, viewBox
679
+ for (let i = 0; i < arr.length - 1; i++) {
680
+ if (arr[i].indexOf('viewBox') !== -1) {
681
+ index = i
682
+ }
683
+ }
684
+ if (index) {
685
+ viewBox = arr[index + 1]
686
+ }
687
+ this.MapW = Number(viewBox.split(' ')[2])
688
+ this.MapH = Number(viewBox.split(' ')[3])
689
+ },
690
+ changeCrossMap (mapdata, fields) {
691
+ this.changeItem(mapdata, fields, [this.CrossMapData])
692
+ },
693
+
694
+ // 重置
695
+ handleReset () {
696
+ this.customlist = []
697
+ this.Texts = []
698
+ this.Motorways = []
699
+ this.Countdown = []
700
+ this.Pedwalk = []
701
+ this.Detector = []
702
+ this.DetectorChart = []
703
+ this.CrossMapData = {
704
+ svgstr: '',
705
+ imgfilesrc: ''
706
+ }
707
+ this.index = 0
708
+ this.curChooseIcon = {}
709
+ },
710
+ // 取消
711
+ cancledraw () {
712
+ this.canclesettingvisible = true
713
+ },
714
+ completeSetting () {
715
+ this.canclesettingvisible = false
716
+ this.$router.push('/overview/index')
717
+ },
718
+ cancleSetting () {
719
+ this.canclesettingvisible = false
720
+ },
721
+ // 保存
722
+ savedraw () {
723
+ let temp = {}
724
+ console.log(this.customlist)
725
+ for (const item of this.customlist) {
726
+ if (temp.hasOwnProperty(item.icontype)) {
727
+ temp[item.icontype].push(item)
728
+ } else {
729
+ temp[item.icontype] = [item]
730
+ }
731
+ }
732
+ if (this.CrossMapData.svgstr !== '') {
733
+ temp.crossMap = this.CrossMapData
734
+ }
735
+ this.saveChannelizatonChart(temp)
736
+ },
737
+ // 加载
738
+ load (type) {
739
+ this.curChooseIconIndex = -1
740
+ // this.getChannelizatonChart().then((channelizatondata) => {
741
+ // let savedTemp = JSON.parse(localStorage.getItem('savedTemp'))
742
+ let savedTemp = JSON.parse(JSON.stringify(this.loadedChannelizatonData))
743
+ let arr = []
744
+ for (const [key, value] of Object.entries(savedTemp)) {
745
+ if (key === 'vehile') {
746
+ this.Motorways = value
747
+ }
748
+ if (key === 'text') {
749
+ this.Texts = value
750
+ }
751
+ if (key === 'ped') {
752
+ this.Pedwalk = value
753
+ }
754
+ if (key === 'countdown') {
755
+ this.Countdown = value
756
+ }
757
+ if (key === 'detector') {
758
+ this.Detector = value.filter(ele => ele.detailtype === 'detector')
759
+ this.DetectorChart = value.filter(ele => ele.detailtype === 'detectorChart')
760
+ }
761
+ if (key === 'crossMap') {
762
+ this.CrossMapData = JSON.parse(JSON.stringify(value))
763
+ // if (value.type === 'vectorgraph') {
764
+ // // svg底图,只加载底图区域870*650范围内的元素
765
+ // let { svgstr, ...allitem } = value
766
+ // this.allitem = allitem
767
+ // }
768
+ } else {
769
+ if (value.length > 1) {
770
+ arr = [...arr, ...value]
771
+ } else {
772
+ arr.push(value[0])
773
+ }
774
+ }
775
+ }
776
+ this.customlist = JSON.parse(JSON.stringify(arr))
777
+ this.index = this.increaseId(this.customlist, 'index')
778
+ this.motorid = this.increaseId(this.Motorways, 'id')
779
+ this.pedid = this.increaseId(this.Pedwalk, 'id')
780
+ // if (type === 'all') {
781
+ // // 加载整体模版后,默认切换到元素不可编辑状态,但整体可编辑
782
+ // this.isSeletable = false
783
+ // } else {
784
+ // this.isSeletable = true
785
+ // }
786
+ // })
787
+ },
788
+ increaseId (arr, field) { // 实现field对应的index或者id, 在arr的基础上寻找最小的
789
+ let List = arr.map(ele => ele[field])
790
+ let i = List.length - 1
791
+ if (i >= 0) {
792
+ for (let j = 1; j <= 200; j++) {
793
+ if (!List.includes(j)) {
794
+ return j
795
+ }
796
+ }
797
+ }
798
+ },
799
+
800
+ exitEdit () {
801
+ this.isSeletable = !this.isSeletable
802
+ },
803
+
804
+ resetAddParams () {
805
+ this.AddType = ''
806
+ this.editBtnGroup = this.editBtnGroup.map(btn => {
807
+ btn.active = false
808
+ return btn
809
+ })
810
+ },
811
+ resizePanelWidth (bodywidth) {
812
+ // 根据1920适配,右侧过宽
813
+ // this.drawpartWidth = ((1089 / 1980) * bodywidth).toFixed(0)
814
+ // this.mainWidth = this.$refs.custommain.offsetWidth
815
+ // this.editpartWidth = Number(this.mainWidth) - Number(this.drawpartWidth) - 20
816
+ // this.$refs.customGroup.style.width = this.drawpartWidth + 'px'
817
+ // this.$refs.customEdit.style.width = this.editpartWidth + 'px'
818
+ // this.allitem.w = this.drawpartWidth
819
+ // this.allitem.x = this.drawpartWidth / 2
820
+ // 编辑面板固定宽度600,左侧适配
821
+ this.mainWidth = this.$refs.custommain.offsetWidth
822
+ this.drawpartWidth = this.mainWidth - 545
823
+ this.$refs.customGroup.style.width = this.drawpartWidth + 'px'
824
+ this.$refs.customGroup.style.transition = 'width 0.5s ease-in-out'
825
+ if (this.mainWidth && this.drawpartWidth) {
826
+ this.allitem.w = this.drawpartWidth
827
+ this.allitem.x = this.drawpartWidth / 2
828
+ }
829
+ },
830
+ saveChannelizatonChart (ChannelizatonData) {
831
+ // let agentid = getIframdevid()
832
+ let params = {
833
+ agentid: this.AgentId,
834
+ data: ChannelizatonData
835
+ }
836
+ saveChannelizatonChart(params).then(data => {
837
+ this.$emit('saveCallback', data)
838
+ if (!data.data.success) {
839
+ let parrenterror = getMessageByCode(data.data.code, this.$i18n.locale)
840
+ if (data.data.data) {
841
+ // 子类型错误
842
+ let childErrorCode = data.data.data.errorCode
843
+ if (childErrorCode) {
844
+ let childerror = getMessageByCode(data.data.data.errorCode, this.$i18n.locale)
845
+ this.$message.error(parrenterror + ',' + childerror)
846
+ }
847
+ } else {
848
+ this.$message.error(parrenterror)
849
+ }
850
+ return
851
+ }
852
+ let msg = this.$t('openatccomponents.common.savesucess')
853
+ this.$message({
854
+ message: msg,
855
+ type: 'success',
856
+ duration: 1 * 1000
857
+ })
858
+ })
859
+ },
860
+ // getChannelizatonChart () {
861
+ // let agentid = getIframdevid()
862
+ // return new Promise((resolve, reject) => {
863
+ // getChannelizatonChart(agentid).then(data => {
864
+ // if (!data.data.success) {
865
+ // let parrenterror = getMessageByCode(data.data.code, this.$i18n.locale)
866
+ // if (data.data.data) {
867
+ // // 子类型错误
868
+ // let childErrorCode = data.data.data.errorCode
869
+ // if (childErrorCode) {
870
+ // let childerror = getMessageByCode(data.data.data.errorCode, this.$i18n.locale)
871
+ // this.$message.error(parrenterror + ',' + childerror)
872
+ // }
873
+ // } else {
874
+ // this.$message.error(parrenterror)
875
+ // }
876
+ // this.handleReset()
877
+ // return
878
+ // }
879
+ // this.handleReset()
880
+ // let channelizatondata = data.data.data
881
+ // resolve(channelizatondata)
882
+ // })
883
+ // })
884
+ // },
885
+ handleClickSketchpad () {
886
+ // 监听画板区域点击事件,改变图标放置的位置
887
+ let sketchpadArea = document.getElementById('sketchpadArea')
888
+ let _this = this
889
+ sketchpadArea.addEventListener('click', function (e) {
890
+ if (_this.pointchange) {
891
+ document.getElementById('sketchpadArea').style.cursor =
892
+ 'url(resource/pic/icons/magnifier3.cur) 12 12,default'
893
+ _this.pointchange = false
894
+ _this.setLeft =
895
+ e.clientX -
896
+ document.getElementById('channelizationElements').getBoundingClientRect().left
897
+ _this.setTop =
898
+ e.clientY -
899
+ document.getElementById('channelizationElements').getBoundingClientRect().top
900
+ if (_this.AddType === '') return
901
+ switch (_this.AddType) {
902
+ case 'motorway':
903
+ _this.addMotorwayIcon()
904
+ break
905
+ case 'pedcrossing':
906
+ _this.addPedwalkIcon()
907
+ break
908
+ case 'countdown':
909
+ _this.addTimer()
910
+ break
911
+ case 'detector':
912
+ _this.addAllDetector()
913
+ }
914
+ _this.resetAddParams()
915
+ }
916
+ })
917
+ }
918
+ },
919
+ created () {},
920
+ mounted () {
921
+ // this.resizePanelWidth(this.curBodyWidth)
922
+ let PhaseData = new PhaseDataMgr(this.phaseList)
923
+ this.$store.dispatch('InitPhaseDataMgr', PhaseData)
924
+ this.handleClickSketchpad()
925
+ // 初始加载已保存的渠化图
926
+ // this.load('all')
927
+ }
928
+ // updated () {
929
+ // if (this.$refs.sketchpadgroup.offsetWidth) {
930
+ // this.allitem.w = this.$refs.sketchpadgroup.offsetWidth
931
+ // this.allitem.x = this.$refs.sketchpadgroup.offsetWidth / 2
932
+ // this.allitem.h = this.$refs.sketchpadgroup.offsetHeight
933
+ // this.allitem.y = this.$refs.sketchpadgroup.offsetHeight / 2
934
+ // }
935
+ // }
936
+ }
937
+ </script>
938
+
939
+ <style lang="css" rel="stylesheet/scss">
940
+ </style>