openatc-components 0.0.103 → 0.0.106

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 (52) hide show
  1. package/package/kisscomps/components/Channelization/Channelization.vue +11 -14
  2. package/package/kisscomps/components/ChannelizationFlowStatistic/ChannelizationFlowStatistic.vue +348 -0
  3. package/package/kisscomps/components/ChannelizationFlowStatistic/index.js +2 -0
  4. package/package/kisscomps/components/DrawChannelization/drawsvg/basicCoordInfo.vue +113 -0
  5. package/package/kisscomps/components/DrawChannelization/drawsvg/channelizationElements.vue +24 -18
  6. package/package/kisscomps/components/DrawChannelization/drawsvg/drawElement/crossMap.vue +72 -54
  7. package/package/kisscomps/components/DrawChannelization/drawsvg/firstImportCrossmap.vue +4 -1
  8. package/package/kisscomps/components/DrawChannelization/drawsvg/iconSvg/countdownSvg.vue +56 -14
  9. package/package/kisscomps/components/DrawChannelization/drawsvg/iconSvg/detectorChart.vue +26 -1
  10. package/package/kisscomps/components/DrawChannelization/drawsvg/iconSvg/detectorIconSvg.vue +37 -18
  11. package/package/kisscomps/components/DrawChannelization/drawsvg/iconSvg/laneIcon.vue +0 -6
  12. package/package/kisscomps/components/DrawChannelization/drawsvg/iconSvg/motorwayIconSvg.vue +50 -28
  13. package/package/kisscomps/components/DrawChannelization/drawsvg/iconSvg/pedroadIconSvg.vue +53 -29
  14. package/package/kisscomps/components/DrawChannelization/drawsvg/importDialog.vue +4 -1
  15. package/package/kisscomps/components/DrawChannelization/drawsvg/index.draw.vue +213 -164
  16. package/package/kisscomps/components/DrawChannelization/drawsvg/index.vue +6 -5
  17. package/package/kisscomps/components/DrawChannelization/drawsvg/laneEditPanel.vue +144 -43
  18. package/package/kisscomps/components/DrawChannelization/drawsvg/utils/loadutils.js +52 -8
  19. package/package/kisscomps/index.js +2 -0
  20. package/package/kissui.min.js +1 -1
  21. package/package.json +1 -1
  22. package/src/i18n/language/en.js +7 -3
  23. package/src/i18n/language/zh.js +6 -2
  24. package/src/kisscomps/components/Channelization/Channelization.vue +11 -14
  25. package/src/kisscomps/components/ChannelizationFlowStatistic/ChannelizationFlowStatistic.vue +348 -0
  26. package/src/kisscomps/components/ChannelizationFlowStatistic/index.js +2 -0
  27. package/src/kisscomps/components/DrawChannelization/drawsvg/basicCoordInfo.vue +113 -0
  28. package/src/kisscomps/components/DrawChannelization/drawsvg/channelizationElements.vue +24 -18
  29. package/src/kisscomps/components/DrawChannelization/drawsvg/drawElement/crossMap.vue +72 -54
  30. package/src/kisscomps/components/DrawChannelization/drawsvg/firstImportCrossmap.vue +4 -1
  31. package/src/kisscomps/components/DrawChannelization/drawsvg/iconSvg/countdownSvg.vue +56 -14
  32. package/src/kisscomps/components/DrawChannelization/drawsvg/iconSvg/detectorChart.vue +26 -1
  33. package/src/kisscomps/components/DrawChannelization/drawsvg/iconSvg/detectorIconSvg.vue +37 -18
  34. package/src/kisscomps/components/DrawChannelization/drawsvg/iconSvg/laneIcon.vue +0 -6
  35. package/src/kisscomps/components/DrawChannelization/drawsvg/iconSvg/motorwayIconSvg.vue +50 -28
  36. package/src/kisscomps/components/DrawChannelization/drawsvg/iconSvg/pedroadIconSvg.vue +53 -29
  37. package/src/kisscomps/components/DrawChannelization/drawsvg/importDialog.vue +4 -1
  38. package/src/kisscomps/components/DrawChannelization/drawsvg/index.draw.vue +213 -164
  39. package/src/kisscomps/components/DrawChannelization/drawsvg/index.vue +6 -5
  40. package/src/kisscomps/components/DrawChannelization/drawsvg/laneEditPanel.vue +144 -43
  41. package/src/kisscomps/components/DrawChannelization/drawsvg/utils/loadutils.js +52 -8
  42. package/src/kisscomps/index.js +2 -0
  43. package/src/router/index.js +9 -10
  44. package/src/views/customchannelization.vue +1 -1
  45. package/src/views/intersection.vue +67 -45
  46. package/src/views/schemeconfig.vue +2 -2
  47. package/static/styles/channelizatioon.scss +49 -2
  48. package/static/styles/commonkanban.scss +27 -27
  49. package/package/kisscomps/components/DrawChannelization/drawsvg/phaseAssociatedComponent.check.vue +0 -191
  50. package/package/kisscomps/components/DrawChannelization/drawsvg/phaseAssociatedComponent.syncOper.vue +0 -331
  51. package/src/kisscomps/components/DrawChannelization/drawsvg/phaseAssociatedComponent.check.vue +0 -191
  52. package/src/kisscomps/components/DrawChannelization/drawsvg/phaseAssociatedComponent.syncOper.vue +0 -331
@@ -12,7 +12,7 @@
12
12
  <!--渠化绘制功能-->
13
13
  <template>
14
14
  <div class="custom-cross" v-if="visible">
15
- <ImportDialog ref="importDialog" @loadSvgString="loadSvgString"/>
15
+ <ImportDialog ref="importDialog" @loadSvgString="loadSvgString" @loadMapSize="loadMapSize" />
16
16
  <Messagebox :visible="canclesettingvisible" :text="$t('openatccomponents.channelizationmap.canclesetting')" @cancle="cancleSetting" @ok="completeSetting"/>
17
17
  <div class="custom-main" ref="custommain">
18
18
  <div class="custom-group drawPanelAnimation" ref="customGroup">
@@ -26,6 +26,8 @@
26
26
  :disabled="!isSeletable"
27
27
  @click="clickOpen"
28
28
  >{{$t('openatccomponents.channelizationmap.againimport')}}</el-button>
29
+ <i class="lock-map el-icon-unlock" v-if="isLockedCrossMap" @click="handleLockCrossMap()"></i>
30
+ <i class="lock-map el-icon-lock" v-if="!isLockedCrossMap" @click="handleLockCrossMap()"></i>
29
31
  </div>
30
32
 
31
33
  <div class="draw-to-sketchpad">
@@ -53,17 +55,6 @@
53
55
  </div>
54
56
  <!-- 画板区域 -->
55
57
  <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
58
  <ChannelizationElements
68
59
  id="channelizationElements"
69
60
  :allitem="allitem"
@@ -86,13 +77,15 @@
86
77
  :DetectorChart="DetectorChart"
87
78
  :CurChooseIcon="curChooseIcon"
88
79
  @changeDetectorChartItem="changeDetectorChartItem"
80
+ :isLockedCrossMap="isLockedCrossMap"
89
81
  />
90
- <!-- </drr> -->
91
82
  </div>
92
83
  <div class="draw-end-function">
93
84
  <el-button type="primary" @click="handleReset()">{{$t('openatccomponents.button.reset')}}</el-button>
94
85
  <!-- <el-button type="primary" @click="cancledraw()">{{$t('openatccomponents.button.Cancel')}}</el-button> -->
95
86
  <el-button type="primary" @click="savedraw()">{{$t('openatccomponents.button.save')}}</el-button>
87
+ <el-button type="primary" @click="importFromFile()">{{$t('openatccomponents.main.import')}}</el-button>
88
+ <el-button type="primary" @click="exportToFile()">{{$t('openatccomponents.main.export')}}</el-button>
96
89
  </div>
97
90
  </div>
98
91
  <div class="custom-edit" ref="customEdit">
@@ -103,6 +96,7 @@
103
96
  @handleChooseDire="handleChooseDire"
104
97
  @handleChoosePed="handleChoosePed"
105
98
  @deleteItem="deleteItem"
99
+ @cloneItem="cloneItem"
106
100
  @changeIconDataByType="changeIconDataByType"
107
101
  @handleDisassociatePhase="handleDisassociatePhase"
108
102
  />
@@ -119,7 +113,28 @@
119
113
  />
120
114
  </div>
121
115
  </el-row> -->
122
- </div>
116
+ <!-- 从文件导入弹窗 -->
117
+ <el-dialog
118
+ :title="$t('openatccomponents.main.tip')"
119
+ :visible.sync="dialogVisible"
120
+ width="30%"
121
+ >
122
+ <input
123
+ type="file"
124
+ id="file"
125
+ />
126
+ <span
127
+ slot="footer"
128
+ class="dialog-footer"
129
+ >
130
+ <el-button @click="dialogVisible = false">{{$t('openatccomponents.common.cancel')}}</el-button>
131
+ <el-button
132
+ type="primary"
133
+ @click="readAsText"
134
+ >{{$t('openatccomponents.common.confirm')}}</el-button>
135
+ </span>
136
+ </el-dialog>
137
+ </div>
123
138
  </template>
124
139
 
125
140
  <script>
@@ -135,9 +150,7 @@ import ImportDialog from './importDialog'
135
150
  import Messagebox from '../../MessageBox/index'
136
151
 
137
152
  import { mapState } from 'vuex'
138
- import PhaseDataMgr from '../phaseDataMgr.js'
139
153
 
140
- // import { getIframdevid } from '../../../../utils/auth.js'
141
154
  import { saveChannelizatonChart } from '../../../../api/cross'
142
155
  import { getMessageByCode } from '../../../../utils/responseMessage.js'
143
156
 
@@ -153,10 +166,7 @@ export default {
153
166
  },
154
167
  computed: {
155
168
  ...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
169
+ phaseList: state => state.globalParam.tscParam.phaseList
160
170
  })
161
171
  },
162
172
  props: {
@@ -169,21 +179,6 @@ export default {
169
179
  }
170
180
  },
171
181
  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
182
  AgentId: {
188
183
  handler: function (val) {
189
184
  // 平台设备切换时,清空上一个渠化配置
@@ -194,6 +189,7 @@ export default {
194
189
  loadedChannelizatonData: {
195
190
  handler: function (val) {
196
191
  // 平台设备切换时,重载当前路口保存的渠化配置
192
+ this.LoadedChannelizatonData = JSON.parse(JSON.stringify(val))
197
193
  this.load('all')
198
194
  },
199
195
  deep: true
@@ -208,8 +204,8 @@ export default {
208
204
  index: 0,
209
205
  motorid: 1, // 车道id
210
206
  pedid: 1, // 人行道id
207
+ detectorcoilid: 1, // 检测器线圈id(非关联检测器id)
211
208
  Motorways: [], // 管理所有自定义机动车图标数据
212
- // Bicyclelanes: [], // 非机动车图标数据
213
209
  customlist: [], // 所有自定义的图标列表
214
210
  Texts: [], // 管理所有自定义文字数据
215
211
  Pedwalk: [], // 管理所有人行横道
@@ -224,11 +220,19 @@ export default {
224
220
  pedH: 22,
225
221
  MapW: 800,
226
222
  MapH: 200,
227
- detectorW: 30,
228
- detectorH: 30,
223
+ detectorW: 20,
224
+ detectorH: 20,
229
225
  detectorchartW: 70,
230
226
  detectorchartH: 100,
227
+ isLockedCrossMap: true, // 底图是否是锁定状态
231
228
  CrossMapData: {
229
+ index: -2,
230
+ icontype: 'crossmap',
231
+ x: 400,
232
+ y: 100,
233
+ w: 800,
234
+ h: 200,
235
+ angle: 0,
232
236
  svgstr: '',
233
237
  imgfilesrc: ''
234
238
  }, // 管理底图数据
@@ -258,7 +262,7 @@ export default {
258
262
  pointchange: false, // 控制选中时光标样式
259
263
  CrossMapVisible: true, // 控制底图显示隐藏
260
264
 
261
- curChooseIconIndex: -1,
265
+ curChooseIconIndex: -1, // 底图暂用-2代替,别的图标与递增的index相关
262
266
  curChooseIcon: {},
263
267
  editBtnGroup: [
264
268
  {
@@ -268,13 +272,6 @@ export default {
268
272
  width: '16px',
269
273
  height: '16px'
270
274
  },
271
- // {
272
- // label: this.$t('openatccomponents.channelizationmap.bicyclelane'),
273
- // type: 'bicyclelane',
274
- // active: false,
275
- // width: '7px',
276
- // height: '16px'
277
- // },
278
275
  {
279
276
  label: this.$t('openatccomponents.channelizationmap.pedcrossing'),
280
277
  type: 'pedcrossing',
@@ -305,7 +302,9 @@ export default {
305
302
  [3, '右转'],
306
303
  [4, '掉头']
307
304
  ]),
308
- phaseAssociatedMap: new Map() // 关联相位Map: key 是相位ID, value 是车道数据包含direction
305
+ phaseAssociatedMap: new Map(), // 关联相位Map: key 是相位ID, value 是车道数据包含direction
306
+ dialogVisible: false,
307
+ LoadedChannelizatonData: {} // 从接口获取到的渠化参数,用于作为加载数据,从文件导入可修改
309
308
  }
310
309
  },
311
310
  methods: {
@@ -316,7 +315,6 @@ export default {
316
315
  // 改变鼠标样式
317
316
  changeMouse () {
318
317
  if (!this.isSeletable) return
319
- // document.getElementById('sketchpadArea').style.cursor = 'url(resource/pic/icons/magnifier3.cur) 12 12,crosshair'
320
318
  document.getElementById('sketchpadArea').style.cursor =
321
319
  'url(resource/pic/icons/magnifier3.cur) 12 12,pointer'
322
320
  this.pointchange = true
@@ -332,10 +330,6 @@ export default {
332
330
  break
333
331
  case 'vehile':
334
332
  this.changeMotorwayItem(iconObj, changefield)
335
- if (changefield.indexOf('phaseid') !== -1) {
336
- // 相位关联成功后,生成最新的相位关联map数据
337
- this.PhaseDataMgr.updateLanePhaseAssociatedMap(this.Motorways)
338
- }
339
333
  break
340
334
  case 'ped':
341
335
  this.changePedItem(iconObj, changefield)
@@ -346,6 +340,8 @@ export default {
346
340
  case 'detector':
347
341
  this.changeDetectorItem(iconObj, changefield)
348
342
  break
343
+ case 'crossmap':
344
+ this.changeCrossMap(iconObj, changefield)
349
345
  }
350
346
  console.log('this.customlist', this.customlist)
351
347
  },
@@ -366,8 +362,6 @@ export default {
366
362
  this.Pedwalk[i].phasetype = undefined
367
363
  }
368
364
  }
369
- // 更新模型内初始相位列表数据
370
- this.PhaseDataMgr.updateLanePhaseAssociatedMap(this.Motorways)
371
365
  },
372
366
 
373
367
  // 添加不同类型的车道图标
@@ -425,9 +419,13 @@ export default {
425
419
  },
426
420
 
427
421
  // 选中图标
428
- handleSelectIcon (iconobj) {
422
+ handleSelectIcon (iconobj, isCrossMap) {
429
423
  // console.log('选中的图标', iconobj)
430
- this.curChooseIconIndex = iconobj.index
424
+ if (isCrossMap === 'crossmap') {
425
+ this.curChooseIconIndex = -2
426
+ } else {
427
+ this.curChooseIconIndex = iconobj.index
428
+ }
431
429
  this.curChooseIcon = JSON.parse(JSON.stringify(iconobj))
432
430
  },
433
431
  // 根据多选的车道,修改车道图标
@@ -446,7 +444,6 @@ export default {
446
444
  'icondirename'
447
445
  ])
448
446
  }
449
- console.log(this.curChooseIcon)
450
447
  },
451
448
 
452
449
  addPedwalkIcon () {
@@ -521,8 +518,9 @@ export default {
521
518
 
522
519
  addAllDetector () {
523
520
  // 统计图暂留
524
- // this.addDetectorChart()
525
521
  this.addDetector()
522
+ // this.addDetectorChart()
523
+ this.detectorcoilid = this.increaseId(this.Detector, 'id')
526
524
  },
527
525
  addDetector () {
528
526
  let defaultDetectorParam = {
@@ -532,16 +530,18 @@ export default {
532
530
  h: this.detectorH,
533
531
  angle: 0
534
532
  }
535
- this.detectorW = 30
536
- this.detectorH = 30
533
+ this.detectorW = 20
534
+ this.detectorH = 20
537
535
  let detectoritem = {
538
536
  index: this.index,
537
+ id: this.detectorcoilid,
539
538
  icontype: 'detector',
540
539
  detailtype: 'detector',
541
540
  detectortype: 1, // 检测器类型: 1 车辆检测器 2 行人检测器
542
541
  detectorid: undefined,
543
542
  occupancythreshold: 80,
544
- flowsaturationthreshold: 20,
543
+ minflowsaturationthreshold: 30,
544
+ maxflowsaturationthreshold: 70,
545
545
  ...defaultDetectorParam
546
546
  }
547
547
  this.curChooseIconIndex = detectoritem.index
@@ -566,6 +566,7 @@ export default {
566
566
  this.detectorchartH = 100
567
567
  let detectoritem = {
568
568
  index: this.index,
569
+ id: this.detectorcoilid,
569
570
  icontype: 'detector',
570
571
  detailtype: 'detectorChart',
571
572
  ...defaultDetectorParam
@@ -621,57 +622,109 @@ export default {
621
622
  },
622
623
  deleteItem (row) {
623
624
  let index = row.index
625
+ // let id = row.id
624
626
  this.customlist = this.customlist.filter(ele => ele.index !== index)
625
627
  switch (row.icontype) {
626
- case 'text':
627
- this.Texts = this.Texts.filter(ele => ele.index !== index)
628
- break
628
+ // case 'text':
629
+ // this.Texts = this.Texts.filter(ele => ele.index !== index)
630
+ // break
629
631
  case 'vehile':
630
632
  this.Motorways = this.Motorways.filter(ele => ele.index !== index)
633
+ this.motorid = this.increaseId(this.Motorways, 'id')
631
634
  break
632
635
  case 'ped':
633
636
  this.Pedwalk = this.Pedwalk.filter(ele => ele.index !== index)
637
+ this.pedid = this.increaseId(this.Pedwalk, 'id')
634
638
  break
635
639
  case 'countdown':
636
640
  this.Countdown = this.Countdown.filter(ele => ele.index !== index)
637
641
  break
638
642
  case 'detector':
639
643
  this.Detector = this.Detector.filter(ele => ele.index !== index)
640
- this.DetectorChart = this.DetectorChart.filter(ele => ele.index !== index)
644
+ // this.DetectorChart = this.DetectorChart.filter(ele => ele.id !== id)
645
+ this.detectorcoilid = this.increaseId(this.Detector, 'id')
641
646
  }
642
647
  this.curChooseIconIndex = -1
643
648
  this.curChooseIcon = {}
644
649
  },
650
+ cloneItem (row) {
651
+ // 克隆元素
652
+ let cloneObj = {
653
+ ...row,
654
+ index: this.index,
655
+ x: 435,
656
+ y: 325
657
+ }
658
+ switch (row.icontype) {
659
+ case 'vehile':
660
+ cloneObj.id = this.motorid
661
+ this.Motorways.push(cloneObj)
662
+ this.motorid = this.increaseId(this.Motorways, 'id')
663
+ this.customlist.push(cloneObj)
664
+ break
665
+ case 'ped':
666
+ cloneObj.id = this.pedid
667
+ this.Pedwalk.push(cloneObj)
668
+ this.pedid = this.increaseId(this.Pedwalk, 'id')
669
+ this.customlist.push(cloneObj)
670
+ break
671
+ // case 'countdown':
672
+ // this.Countdown.push(cloneObj)
673
+ // this.customlist.push(cloneObj)
674
+ // break
675
+ case 'detector':
676
+ cloneObj.id = this.detectorcoilid
677
+ this.Detector.push(cloneObj)
678
+ this.customlist.push(cloneObj)
679
+ // 同时克隆统计图
680
+ // this.index = this.increaseId(this.customlist, 'index')
681
+ // let curchartobj = JSON.parse(JSON.stringify(this.DetectorChart)).filter(ele => ele.id === row.id)[0]
682
+ // curchartobj.index = this.index
683
+ // curchartobj.id = this.detectorcoilid
684
+ // curchartobj.x = 435
685
+ // curchartobj.y = 325 - 100
686
+ // this.DetectorChart.push(curchartobj)
687
+ // this.customlist.push(curchartobj)
688
+ this.detectorcoilid = this.increaseId(this.Detector, 'id')
689
+ }
690
+ this.curChooseIconIndex = this.index
691
+ this.curChooseIcon = JSON.parse(JSON.stringify(cloneObj))
692
+ this.index = this.increaseId(this.customlist, 'index')
693
+ },
645
694
 
646
695
  loadSvgString (type, imgstr) {
647
696
  // 加载用户上传的底图svg字符串
648
697
  if (type === 'vectorgraph') {
649
698
  // 导入矢量图
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
699
+ // this.getCrossMapViewbox(imgstr)
661
700
  this.CrossMapData = {
701
+ ...this.CrossMapData,
662
702
  type,
663
- svgstr: imgstr,
664
- ...defaultCrossMapParam
703
+ svgstr: imgstr
665
704
  }
666
705
  }
667
706
  if (type === 'picture') {
668
707
  // 导入图片
669
708
  this.CrossMapData = {
709
+ ...this.CrossMapData,
670
710
  type,
671
711
  imgfilesrc: imgstr
672
712
  }
673
713
  }
674
714
  },
715
+ loadMapSize (type, mapsize) {
716
+ this.CrossMapData = {
717
+ ...this.CrossMapData,
718
+ angle: 0,
719
+ x: Math.round(mapsize.width / 2),
720
+ y: Math.round(mapsize.height / 2),
721
+ w: Math.round(mapsize.width),
722
+ h: Math.round(mapsize.height)
723
+ }
724
+ this.MapW = mapsize.width
725
+ this.MapH = mapsize.height
726
+ },
727
+
675
728
  getCrossMapViewbox (svgstr) {
676
729
  // 获取户上传svg的viewBox属性的大小
677
730
  let arr = svgstr.split('"')
@@ -701,6 +754,13 @@ export default {
701
754
  this.Detector = []
702
755
  this.DetectorChart = []
703
756
  this.CrossMapData = {
757
+ index: -2, // 暂定为-2,用于复用图标判断逻辑
758
+ icontype: 'crossmap',
759
+ x: this.MapW / 2,
760
+ y: this.MapH / 2,
761
+ w: this.MapW,
762
+ h: this.MapH,
763
+ angle: 0,
704
764
  svgstr: '',
705
765
  imgfilesrc: ''
706
766
  }
@@ -718,8 +778,7 @@ export default {
718
778
  cancleSetting () {
719
779
  this.canclesettingvisible = false
720
780
  },
721
- // 保存
722
- savedraw () {
781
+ handleSaveParams () {
723
782
  let temp = {}
724
783
  console.log(this.customlist)
725
784
  for (const item of this.customlist) {
@@ -729,17 +788,21 @@ export default {
729
788
  temp[item.icontype] = [item]
730
789
  }
731
790
  }
732
- if (this.CrossMapData.svgstr !== '') {
791
+ if (this.CrossMapData.svgstr !== '' || this.CrossMapData.imgfilesrc !== '') {
733
792
  temp.crossMap = this.CrossMapData
734
793
  }
794
+ return temp
795
+ },
796
+ // 保存
797
+ savedraw () {
798
+ let temp = {}
799
+ temp = this.handleSaveParams()
735
800
  this.saveChannelizatonChart(temp)
736
801
  },
737
802
  // 加载
738
803
  load (type) {
739
804
  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))
805
+ let savedTemp = JSON.parse(JSON.stringify(this.LoadedChannelizatonData))
743
806
  let arr = []
744
807
  for (const [key, value] of Object.entries(savedTemp)) {
745
808
  if (key === 'vehile') {
@@ -756,15 +819,13 @@ export default {
756
819
  }
757
820
  if (key === 'detector') {
758
821
  this.Detector = value.filter(ele => ele.detailtype === 'detector')
759
- this.DetectorChart = value.filter(ele => ele.detailtype === 'detectorChart')
822
+ // this.DetectorChart = value.filter(ele => ele.detailtype === 'detectorChart')
760
823
  }
761
824
  if (key === 'crossMap') {
762
825
  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
- // }
826
+ if (value.icontype === undefined) {
827
+ this.CrossMapData.icontype = 'crossmap'
828
+ }
768
829
  } else {
769
830
  if (value.length > 1) {
770
831
  arr = [...arr, ...value]
@@ -774,16 +835,18 @@ export default {
774
835
  }
775
836
  }
776
837
  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
- // })
838
+ if (this.customlist.length > 0) {
839
+ this.index = this.increaseId(this.customlist, 'index')
840
+ }
841
+ if (this.Motorways.length > 0) {
842
+ this.motorid = this.increaseId(this.Motorways, 'id')
843
+ }
844
+ if (this.Pedwalk.length > 0) {
845
+ this.pedid = this.increaseId(this.Pedwalk, 'id')
846
+ }
847
+ if (this.Detector.length > 0) {
848
+ this.detectorcoilid = this.increaseId(this.Detector, 'id')
849
+ }
787
850
  },
788
851
  increaseId (arr, field) { // 实现field对应的index或者id, 在arr的基础上寻找最小的
789
852
  let List = arr.map(ele => ele[field])
@@ -808,31 +871,18 @@ export default {
808
871
  return btn
809
872
  })
810
873
  },
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
874
  saveChannelizatonChart (ChannelizatonData) {
831
875
  // let agentid = getIframdevid()
832
876
  let params = {
833
877
  agentid: this.AgentId,
834
878
  data: ChannelizatonData
835
879
  }
880
+ if (ChannelizatonData.crossMap.type === 'vectorgraph') {
881
+ ChannelizatonData.crossMap.imgfilesrc = ''
882
+ }
883
+ if (ChannelizatonData.crossMap.type === 'picture') {
884
+ ChannelizatonData.crossMap.svgstr = ''
885
+ }
836
886
  saveChannelizatonChart(params).then(data => {
837
887
  this.$emit('saveCallback', data)
838
888
  if (!data.data.success) {
@@ -857,31 +907,6 @@ export default {
857
907
  })
858
908
  })
859
909
  },
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
910
  handleClickSketchpad () {
886
911
  // 监听画板区域点击事件,改变图标放置的位置
887
912
  let sketchpadArea = document.getElementById('sketchpadArea')
@@ -891,12 +916,10 @@ export default {
891
916
  document.getElementById('sketchpadArea').style.cursor =
892
917
  'url(resource/pic/icons/magnifier3.cur) 12 12,default'
893
918
  _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
919
+ let boundingClientLeft = document.getElementById('channelizationElements').getBoundingClientRect().left
920
+ let boundingClientTop = document.getElementById('channelizationElements').getBoundingClientRect().top
921
+ _this.setLeft = Math.round(e.clientX - boundingClientLeft) // 四舍五入
922
+ _this.setTop = Math.round(e.clientY - boundingClientTop)
900
923
  if (_this.AddType === '') return
901
924
  switch (_this.AddType) {
902
925
  case 'motorway':
@@ -914,25 +937,51 @@ export default {
914
937
  _this.resetAddParams()
915
938
  }
916
939
  })
940
+ },
941
+ handleLockCrossMap () {
942
+ this.isLockedCrossMap = !this.isLockedCrossMap
943
+ },
944
+ importFromFile () {
945
+ this.dialogVisible = true
946
+ },
947
+ readAsText () {
948
+ let _this = this
949
+ var file = document.getElementById('file').files[0]
950
+ var reader = new FileReader()
951
+ reader.async = true
952
+ // 将文件以文本形式读入页面
953
+ reader.readAsText(file)
954
+ reader.onload = function (f) {
955
+ setTimeout(() => {
956
+ _this.LoadedChannelizatonData = {}
957
+ _this.handleReset()
958
+ _this.dialogVisible = false
959
+ _this.LoadedChannelizatonData = JSON.parse(this.result)
960
+ _this.load()
961
+ _this.$alert(_this.$t('openatccomponents.channelizationmap.importfilesuccess'), { type: 'success' })
962
+ }, 50)
963
+ }
964
+ },
965
+ async exportToFile () {
966
+ let tscParam = this.handleSaveParams()
967
+ let content = new Blob([JSON.stringify(tscParam)])
968
+ // 生成url对象
969
+ let urlObject = window.URL || window.webkitURL || window
970
+ let url = urlObject.createObjectURL(content)
971
+ // 生成<a></a>DOM元素
972
+ let el = document.createElement('a')
973
+ // 链接赋值
974
+ el.href = url
975
+ el.download = 'ChanelizationParam.json'
976
+ // 必须点击否则不会下载
977
+ el.click()
978
+ // 移除链接释放资源
979
+ urlObject.revokeObjectURL(url)
917
980
  }
918
981
  },
919
- created () {},
920
982
  mounted () {
921
- // this.resizePanelWidth(this.curBodyWidth)
922
- let PhaseData = new PhaseDataMgr(this.phaseList)
923
- this.$store.dispatch('InitPhaseDataMgr', PhaseData)
924
983
  this.handleClickSketchpad()
925
- // 初始加载已保存的渠化图
926
- // this.load('all')
927
984
  }
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
985
  }
937
986
  </script>
938
987