openatc-components 0.2.6 → 0.2.8

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.
@@ -47,7 +47,8 @@ export default {
47
47
  },
48
48
  data () {
49
49
  return {
50
- overlapDatas: []
50
+ overlapDatas: [],
51
+ max: ''
51
52
  }
52
53
  },
53
54
  props: {
@@ -67,6 +68,10 @@ export default {
67
68
  type: Boolean,
68
69
  default: false
69
70
  },
71
+ cycleChange: {
72
+ type: Boolean,
73
+ default: true
74
+ },
70
75
  cycle: {
71
76
  type: Number
72
77
  },
@@ -82,6 +87,13 @@ export default {
82
87
  // 深度观察监听
83
88
  deep: true
84
89
  },
90
+ cycleChange: {
91
+ handler: function (val, oldVal) {
92
+ this.doAdd(this.stageList, this.overlap)
93
+ },
94
+ // 深度观察监听
95
+ deep: true
96
+ },
85
97
  stageList: {
86
98
  handler: function (val, oldVal) {
87
99
  this.doAdd(this.stageList, this.overlap)
@@ -140,6 +152,15 @@ export default {
140
152
  if (findItems.length) findIndexs.push(...findItems.map(m => m.key))
141
153
  })
142
154
  findIndexs = Array.from(new Set(findIndexs))
155
+ if (this.cycleChange) {
156
+ const globalParamModel = this.$store.getters.globalParamModel
157
+ let pattern = globalParamModel.getParamsByType('patternList')
158
+ const allCycle = pattern.map(item => item.cycle)
159
+ let cycle = Math.max(...allCycle)
160
+ this.max = cycle
161
+ } else {
162
+ this.max = ''
163
+ }
143
164
  return {
144
165
  ...item,
145
166
  peddirection: this.getPedPhasePos(item.peddirection),
@@ -150,8 +171,8 @@ export default {
150
171
  ...sta,
151
172
  direction: this.getRoad(item),
152
173
  // peddirection: this.getPedPhasePos(item.peddirection),
153
- greenWidth: find ? (sta.split / this.cycle * 100).toFixed(3) + '%' : '0%',
154
- redWidth: !find ? (sta.split / this.cycle * 100).toFixed(3) + '%' : '0%'
174
+ greenWidth: find ? (sta.split / (this.max ? this.max : this.cycle) * 100).toFixed(3) + '%' : '0%',
175
+ redWidth: !find ? (sta.split / (this.max ? this.max : this.cycle) * 100).toFixed(3) + '%' : '0%'
155
176
  }
156
177
  })
157
178
  }
@@ -0,0 +1,417 @@
1
+ <template>
2
+ <div>
3
+ <el-select
4
+ v-model="valuess"
5
+ :multiple="multiple"
6
+ :disabled="disabled"
7
+ @visible-change="visibleChange($event)"
8
+ :clearable="clearable"
9
+ :filterable="filterable"
10
+ :placeholder="$t('openatccomponents.common.select')"
11
+ @change="onChange"
12
+ @focus="onFocus"
13
+ >
14
+ <el-option
15
+ id="aaa"
16
+ v-for="(item, index) in Options"
17
+ :key="index"
18
+ :label="getLable(item.label)"
19
+ :value="item.value"
20
+ >
21
+ <div class="single-model" @click="selectStages(item.value)">
22
+ <xdrdirselector
23
+ Width="60px"
24
+ Height="60px"
25
+ :showlist="item.item"
26
+ ></xdrdirselector>
27
+ <span
28
+ style="
29
+ float: right;
30
+ margin-left: 10px;
31
+ color: #8492a6;
32
+ font-size: 13px;
33
+ "
34
+ >{{ item.label }}</span
35
+ >
36
+ </div>
37
+ </el-option>
38
+ </el-select>
39
+ <span v-if="pattern">{{ getIncludedPhasesDesc(valuess) }}</span>
40
+ <!-- <span id="xrd"></span> -->
41
+ <!-- <xdrdirselector :Data="Data" :Datas="Datas" Width="60px" Height="60px" :showlist="dirArr"></xdrdirselector> -->
42
+ </div>
43
+ </template>
44
+ <script>
45
+ import { getTscControl } from '../../../api/control'
46
+ import { getPhaseDesc } from '../../../utils/phasedesc.js'
47
+ // import { uploadSingleTscParam } from '../../api/param'
48
+ import { getMessageByCode } from '../../../utils/responseMessage'
49
+ import xdrdirselector from '../XRDDirSelector/XRDDirSelector.vue'
50
+ import PhaseDataModel from '../IntersectionMap/crossDirection/utils'
51
+ // import CrossDiagramMgr from '@/EdgeMgr/controller/crossDiagramMgr'
52
+ // import { getDirName } from './utils.js'
53
+ import { getTheme } from '../../../utils/auth'
54
+ export default {
55
+ name: 'SelectCrossPhase',
56
+ components: {
57
+ xdrdirselector
58
+ },
59
+ props: {
60
+ multiple: {
61
+ type: Boolean,
62
+ default: false
63
+ },
64
+ pattern: {
65
+ type: Boolean,
66
+ default: false
67
+ },
68
+ filterable: {
69
+ type: Boolean,
70
+ default: false
71
+ },
72
+ disabled: {
73
+ type: Boolean,
74
+ default: false
75
+ },
76
+ row: {
77
+ type: Object
78
+ },
79
+ valueModel: {
80
+ type: Array
81
+ },
82
+ type: {
83
+ type: String || Array
84
+ },
85
+ phaseOption: {
86
+ type: Array,
87
+ default: () => []
88
+ },
89
+ // placeholder: {
90
+ // type: String,
91
+ // default: ''
92
+ // },
93
+ bizType: {
94
+ type: String,
95
+ default: ''
96
+ },
97
+ agentid: {
98
+ type: String,
99
+ default: '10501'
100
+ },
101
+ clearable: {
102
+ type: Boolean,
103
+ default: false
104
+ }
105
+ },
106
+ data () {
107
+ return {
108
+ list: [],
109
+ valuess: [],
110
+ Data: {
111
+ left: '60px',
112
+ top: '10px'
113
+ },
114
+ Datas: {
115
+ left: '60px',
116
+ top: '10px'
117
+ },
118
+ Options: [],
119
+ phaseList: [],
120
+ dirArr: [],
121
+ sidewalkPhaseData: []
122
+ }
123
+ },
124
+ watch: {
125
+ phaseOption: {
126
+ handler (val) {
127
+ this.phaseOption = val
128
+ this.getPhase()
129
+ this.showxdr(this.valuess)
130
+ },
131
+ deep: true
132
+ },
133
+ agentid (val) {
134
+ // this.value = ''
135
+ this.Options = []
136
+ // this.onLoad()
137
+ }
138
+ },
139
+ created () {
140
+ this.PhaseDataModel = new PhaseDataModel()
141
+ this.onLoad()
142
+ },
143
+ methods: {
144
+ getLable (str) {
145
+ const match = str.match(/\d+/)
146
+ if (match) {
147
+ return this.getPhaseDescs(Number(match[0]))
148
+ }
149
+ },
150
+ // getXrd (data) {
151
+ // let Profile = Vue.extend({
152
+ // // template: 'xdrdirselector',
153
+ // components: {
154
+ // xdrdirselector
155
+ // },
156
+ // render (h) {
157
+ // return h('xdrdirselector', {
158
+ // props: {
159
+ // Width: '60px',
160
+ // Height: '60px',
161
+ // showlist: data,
162
+ // Data: {
163
+ // left: '60px',
164
+ // top: '10px'
165
+ // },
166
+ // Datas: {
167
+ // left: '60px',
168
+ // top: '10px'
169
+ // }
170
+ // }
171
+ // })
172
+ // }
173
+ // })
174
+ // let profile = new Profile()
175
+ // profile.$mount('#xrd')
176
+ // },
177
+ getPhaseDescs (id) {
178
+ let phasedesc = this.phaseOption.filter((item) => {
179
+ return item.id === id
180
+ })[0].direction
181
+ if (phasedesc.length === 0) return id
182
+ let description = getPhaseDesc(phasedesc, this.$i18n.locale)
183
+ return id + '-' + description
184
+ },
185
+ showxdr (data) {
186
+ let color = getTheme() === 'light' ? '#1E1E1E' : '#F1F3F4'
187
+ this.dirArr = []
188
+ this.phaseOption.filter((item) => {
189
+ if (item.id === data) {
190
+ if (item.direction.length === 0) {
191
+ let recd = {
192
+ id: 0,
193
+ peddirection: this.getPed(item.peddirection),
194
+ color: color
195
+ }
196
+ this.dirArr.push(recd)
197
+ } else {
198
+ for (let rec of item.direction) {
199
+ let recd = {
200
+ id: rec,
201
+ peddirection: this.getPed(item.peddirection),
202
+ color: color
203
+ }
204
+ this.dirArr.push(recd)
205
+ }
206
+ }
207
+ }
208
+ })
209
+ },
210
+ onFocus () {
211
+ if (!this.Options || this.Options.length === 0) {
212
+ this.onLoad()
213
+ }
214
+ },
215
+ onLoad () {
216
+ this.getPhase()
217
+ // this.initData()
218
+ },
219
+ setOption (list) {
220
+ if (this.row.callphase) {
221
+ this.valuess = this.row.callphase
222
+ this.showxdr(this.valuess)
223
+ }
224
+ if (this.row.phases) {
225
+ this.valuess = this.row.phases
226
+ }
227
+ if (this.row.linkphase) {
228
+ this.valuess = this.row.linkphase
229
+ this.showxdr(this.valuess)
230
+ }
231
+ if (this.row.includedphases) {
232
+ this.valuess = this.row.includedphases
233
+ }
234
+ if (this.row.data && this.row.data.phase) {
235
+ this.valuess = this.row.data.phase
236
+ this.showxdr(this.valuess)
237
+ }
238
+ let color = getTheme() === 'light' ? '#1E1E1E' : '#F1F3F4'
239
+ this.Options = list.map((item, index) => {
240
+ let dirArr = []
241
+ if (item.direction.length === 0) {
242
+ let recd = {
243
+ id: 0,
244
+ peddirection: this.getPed(item.peddirection),
245
+ color: color
246
+ }
247
+ dirArr.push(recd)
248
+ } else {
249
+ for (let rec of item.direction) {
250
+ let recd = {
251
+ id: rec,
252
+ peddirection: this.getPed(item.peddirection),
253
+ color: color
254
+ }
255
+ dirArr.push(recd)
256
+ }
257
+ }
258
+ let name = ''
259
+ name = this.$t('openatccomponents.pattern.phase') + item.id
260
+ // name = this.getPhaseDescs(item.id)
261
+ return {
262
+ label: name,
263
+ item: dirArr,
264
+ value: item.id
265
+ }
266
+ })
267
+ },
268
+ visibleChange (status) {
269
+ if (!status) {
270
+ this.showxdr(this.valuess)
271
+ }
272
+ },
273
+ onChange (value) {
274
+ if (this.type === 'callphase') {
275
+ this.row.callphase = this.valuess
276
+ } else if (this.type === 'linkphase') {
277
+ this.row.linkphase = this.valuess
278
+ } else if (this.type === 'phase') {
279
+ this.row.data.phase = this.valuess
280
+ } else if (this.multiple && this.type === 'phases') {
281
+ this.row.phases = this.valuess
282
+ } else if (this.multiple && this.type === 'includedphases') {
283
+ this.row.includedphases = this.valuess
284
+ }
285
+ let option = this.Options.filter(item => item.value === value)[0]
286
+ this.$emit('onChange', value, option, this.agentid, this.bizType)
287
+ },
288
+ selectStages (value) {
289
+ this.$emit('selectStages', value)
290
+ },
291
+ getPhase () {
292
+ this.getPedPhasePos(this.phaseOption)
293
+ this.setOption(this.phaseOption)
294
+ },
295
+ initData () {
296
+ let agentId = this.agentid
297
+ getTscControl(agentId).then((data) => {
298
+ if (!data.data.success) {
299
+ if (data.data.code === '4003') {
300
+ this.devStatus = 2
301
+ this.$message.error(this.$t('openatccomponents.errorTip.devicenotonline'))
302
+ return
303
+ }
304
+ this.$message.error(getMessageByCode(data.data.code, this.$i18n.locale))
305
+ return
306
+ }
307
+ let TscData = JSON.parse(JSON.stringify(data.data.data.data))
308
+ this.handleStageData(TscData) // 处理阶段(驻留)stage数据
309
+ }).catch(error => {
310
+ this.$message.error(error)
311
+ console.log(error)
312
+ })
313
+ },
314
+ getPed (data) {
315
+ let ped = []
316
+ let peddirections = []
317
+ let color = getTheme() === 'light' ? '#1E1E1E' : '#F1F3F4'
318
+ for (let walk of this.sidewalkPhaseData) {
319
+ for (let ped of data) {
320
+ let objs = {}
321
+ objs.name = walk.name
322
+ objs.id = walk.id
323
+ objs.color = color
324
+ if (ped === walk.id) {
325
+ peddirections.push(objs)
326
+ peddirections = Array.from(new Set(peddirections))
327
+ }
328
+ }
329
+ }
330
+ ped.push(...peddirections)
331
+ return ped
332
+ },
333
+ getPedPhasePos (phaseList) {
334
+ // 行人相位信息
335
+ this.sidewalkPhaseData = []
336
+ phaseList.forEach((ele, i) => {
337
+ if (ele.peddirection) {
338
+ ele.peddirection.forEach((dir, index) => {
339
+ // 行人相位
340
+ if (this.PhaseDataModel.getSidePos(dir)) {
341
+ this.sidewalkPhaseData.push({
342
+ // key: this.CrossDiagramMgr.getUniqueKey('pedphase'),
343
+ phaseid: ele.id, // 相位id,用于对应相位状态
344
+ id: dir,
345
+ name: this.PhaseDataModel.getSidePos(dir).name
346
+ })
347
+ }
348
+ })
349
+ }
350
+ })
351
+ return this.sidewalkPhaseData
352
+ },
353
+ handleStageData (data) {
354
+ this.stagesList = []
355
+ let stages = data.stages
356
+ for (let stage of stages) {
357
+ let tempList = []
358
+ let directionList = []
359
+ for (let stg of stage) {
360
+ let currPhase = this.phaseList.filter((item) => {
361
+ return item.id === stg
362
+ })[0]
363
+ if (currPhase !== undefined) {
364
+ directionList = [...currPhase.direction, ...directionList]
365
+ }
366
+ // directionList = [...currPhase.direction, ...directionList]
367
+ }
368
+ directionList = [...new Set(directionList)]
369
+ tempList = directionList.map(dir => ({
370
+ id: dir,
371
+ color: '#606266'
372
+ }))
373
+ this.stagesList.push(tempList)
374
+ }
375
+ this.list = this.stagesList
376
+ // this.setOption()
377
+ },
378
+ // init (val) {
379
+ // let target = val
380
+ // if (this.multiple) {
381
+ // target = [val]
382
+ // }
383
+ // this.value = target
384
+ // },
385
+ getNameById (id) {
386
+ let res = ''
387
+ for (const item of this.Options) {
388
+ if (id === item.agentid) {
389
+ res = item.name
390
+ break
391
+ }
392
+ }
393
+ return res
394
+ },
395
+ getIncludedPhasesDesc (ids) {
396
+ let str = ''
397
+ for (let id of ids) {
398
+ str = str + this.getPhaseDescs(id) + ' '
399
+ }
400
+ return str
401
+ }
402
+ }
403
+ }
404
+ </script>
405
+ <style lang="scss">
406
+
407
+ .el-select-dropdown__wrap {
408
+ max-height: 500px !important;
409
+ }
410
+
411
+ #aaa{
412
+ // :deep(.el-select-dropdown__item){
413
+ margin: 10px 0 !important;
414
+ // }
415
+ }
416
+
417
+ </style>
@@ -0,0 +1,142 @@
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
+ // import Edgebase from '@openatc/edgebase-front'
13
+ let images = [{
14
+ id: 1,
15
+ // name: 'East-Straight',
16
+ name: 'edge.phase.es',
17
+ // img: require('./images/East-Straight.svg'),
18
+ class: 'iconfont icon-icon-test2'
19
+ },
20
+ {
21
+ id: 2,
22
+ // name: 'East-Left',
23
+ name: 'edge.phase.el',
24
+ // img: require('./images/East-Left.svg'),
25
+ class: 'iconfont icon-icon-test4'
26
+ },
27
+ {
28
+ id: 3,
29
+ // name: 'East-Right',
30
+ name: 'edge.phase.er',
31
+ // img: require('./images/East-Right.svg'),
32
+ class: 'iconfont icon-icon-test3'
33
+ },
34
+ {
35
+ id: 4,
36
+ // name: 'East-Back',
37
+ name: 'edge.phase.eb',
38
+ // img: require('./images/East-Back.svg'),
39
+ class: 'iconfont icon-icon-test6'
40
+ },
41
+ {
42
+ id: 5,
43
+ // name: 'West-Straight',
44
+ name: 'edge.phase.ws',
45
+ // img: require('./images/West-Straight.svg'),
46
+ class: 'iconfont icon-icon-test5'
47
+ },
48
+ {
49
+ id: 6,
50
+ // name: 'West-Left',
51
+ name: 'edge.phase.wl',
52
+ // img: require('./images/West-Left.svg'),
53
+ class: 'iconfont icon-icon-test7'
54
+ },
55
+ {
56
+ id: 7,
57
+ // name: 'West-Right',
58
+ name: 'edge.phase.wr',
59
+ // img: require('./images/West-Right.svg'),
60
+ class: 'iconfont icon-icon-test9'
61
+ },
62
+ {
63
+ id: 8,
64
+ // name: 'West-Back',
65
+ name: 'edge.phase.wb',
66
+ // img: require('./images/West-Back.svg'),
67
+ class: 'iconfont icon-icon-test8'
68
+ },
69
+ {
70
+ id: 9,
71
+ // name: 'North-Straight',
72
+ name: 'edge.phase.ns',
73
+ // img: require('./images/North-Straight.svg'),
74
+ class: 'iconfont icon-icon-test10'
75
+ },
76
+ {
77
+ id: 10,
78
+ // name: 'North-Left',
79
+ name: 'edge.phase.nl',
80
+ // img: require('./images/North-Left.svg'),
81
+ class: 'iconfont icon-icon-test12'
82
+ },
83
+ {
84
+ id: 11,
85
+ // name: 'North-Right',
86
+ name: 'edge.phase.nr',
87
+ // img: require('./images/North-Right.svg'),
88
+ class: 'iconfont icon-icon-test13'
89
+ },
90
+ {
91
+ id: 12,
92
+ // name: 'North-Back',
93
+ name: 'edge.phase.nb',
94
+ // img: require('./images/North-Back.svg'),
95
+ class: 'iconfont icon-icon-test11'
96
+ },
97
+ {
98
+ id: 13,
99
+ // name: 'South-Straight',
100
+ name: 'edge.phase.ss',
101
+ // img: require('./images/South-Straight.svg'),
102
+ class: 'iconfont icon-icon-test15'
103
+ },
104
+ {
105
+ id: 14,
106
+ // name: 'South-Left',
107
+ name: 'edge.phase.sl',
108
+ // img: require('./images/South-Left.svg'),
109
+ class: 'iconfont icon-icon-test14'
110
+ },
111
+ {
112
+ id: 15,
113
+ // name: 'South-Right',
114
+ name: 'edge.phase.sr',
115
+ // img: require('./images/South-Right.svg'),
116
+ class: 'iconfont icon-icon-test'
117
+ },
118
+ {
119
+ id: 16,
120
+ // name: 'South-Back',
121
+ name: 'edge.phase.sb',
122
+ // img: require('./images/South-Back.svg'),
123
+ class: 'iconfont icon-icon-test1'
124
+ }]
125
+
126
+ const getDirName = (arr) => {
127
+ let res = ''
128
+ let nameArr = []
129
+ for (let item of arr) {
130
+ let id = item.id
131
+ for (let img of images) {
132
+ if (id === img.id) {
133
+ let name = img.name
134
+ nameArr.push(name)
135
+ }
136
+ }
137
+ }
138
+ res = nameArr
139
+ return res
140
+ }
141
+
142
+ export {getDirName}