openatc-components 0.1.139 → 0.1.142

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 (70) hide show
  1. package/package/kisscomps/components/CommonKanban/CommonKanban.vue +8 -4
  2. package/package/kisscomps/components/DrawChannelization/drawsvg/overlapAssociatedComponent.vue +1 -1
  3. package/package/kisscomps/components/DrawChannelization/drawsvg/phaseAssociatedComponent.vue +1 -1
  4. package/package/kisscomps/components/ExpendConfig/ExpendConfig.vue +1 -1
  5. package/package/kisscomps/components/KanBan/kanban.vue +1 -1
  6. package/package/kisscomps/components/OverLap/OverLap.vue +2 -2
  7. package/package/kisscomps/components/PatternOptimize/PatternOptimize.vue +1 -1
  8. package/package/kisscomps/components/PatternStatus/PatternStatus.vue +21 -20
  9. package/package/kisscomps/components/PhaseMarker/phasemarker.vue +1 -1
  10. package/package/kisscomps/components/SchemeConfig/SchemeConfig.vue +1 -1
  11. package/package/kisscomps/components/SchemeConfig/azimuthlocking/index.vue +54 -13
  12. package/package/kisscomps/components/SchemeConfig/azimuthlocking/utils.js +8 -8
  13. package/package/kisscomps/components/SchemeConfig/manualControlModal/index.vue +2 -0
  14. package/package/kisscomps/components/SchemeConfig/priorityControl/index.vue +1 -1
  15. package/package/kisscomps/components/SchemeConfig/tentativeplancontrolmodal/index.vue +1 -1
  16. package/package/kisscomps/components/Stages/index.vue +32 -2
  17. package/package/kisscomps/components/XRDDirSelector/XRDDirSelector.vue +458 -626
  18. package/package/kisscomps/components/XiaoKanban/DirSelector.vue +356 -0
  19. package/package/kisscomps/components/XiaoKanban/index.vue +102 -0
  20. package/package/kisscomps/components/patternConfig/index.js +2 -0
  21. package/package/kisscomps/components/patternConfig/index.vue +1010 -0
  22. package/package/kisscomps/components/patternConfig/pattern/patternTable.vue +349 -0
  23. package/package/kisscomps/components/patternConfig/pattern/planChart/model/coordinationModel.js +665 -0
  24. package/package/kisscomps/components/patternConfig/planContent.vue +572 -0
  25. package/package/kisscomps/components/patternConfig/planMenu.vue +329 -0
  26. package/package/kisscomps/components/patternConfig/utils.js +152 -0
  27. package/package/kisscomps/index.js +4 -0
  28. package/package/kissui.min.js +1 -1
  29. package/package.json +14 -13
  30. package/src/api/control.js +19 -0
  31. package/src/api/device.js +135 -0
  32. package/src/api/route.js +171 -0
  33. package/src/i18n/language/en.js +149 -0
  34. package/src/i18n/language/zh.js +133 -0
  35. package/src/kisscomps/components/CommonKanban/CommonKanban.vue +8 -4
  36. package/src/kisscomps/components/DrawChannelization/drawsvg/overlapAssociatedComponent.vue +1 -1
  37. package/src/kisscomps/components/DrawChannelization/drawsvg/phaseAssociatedComponent.vue +1 -1
  38. package/src/kisscomps/components/ExpendConfig/ExpendConfig.vue +1 -1
  39. package/src/kisscomps/components/KanBan/kanban.vue +1 -1
  40. package/src/kisscomps/components/OverLap/OverLap.vue +2 -2
  41. package/src/kisscomps/components/PatternOptimize/PatternOptimize.vue +1 -1
  42. package/src/kisscomps/components/PatternStatus/PatternStatus.vue +21 -20
  43. package/src/kisscomps/components/PhaseMarker/phasemarker.vue +1 -1
  44. package/src/kisscomps/components/SchemeConfig/SchemeConfig.vue +1 -1
  45. package/src/kisscomps/components/SchemeConfig/azimuthlocking/index.vue +54 -13
  46. package/src/kisscomps/components/SchemeConfig/azimuthlocking/utils.js +8 -8
  47. package/src/kisscomps/components/SchemeConfig/manualControlModal/index.vue +2 -0
  48. package/src/kisscomps/components/SchemeConfig/priorityControl/index.vue +1 -1
  49. package/src/kisscomps/components/SchemeConfig/tentativeplancontrolmodal/index.vue +1 -1
  50. package/src/kisscomps/components/Stages/index.vue +32 -2
  51. package/src/kisscomps/components/XRDDirSelector/XRDDirSelector.vue +458 -626
  52. package/src/kisscomps/components/XiaoKanban/DirSelector.vue +356 -0
  53. package/src/kisscomps/components/XiaoKanban/index.vue +102 -0
  54. package/src/kisscomps/components/patternConfig/index.js +2 -0
  55. package/src/kisscomps/components/patternConfig/index.vue +1010 -0
  56. package/src/kisscomps/components/patternConfig/pattern/patternTable.vue +349 -0
  57. package/src/kisscomps/components/patternConfig/pattern/planChart/model/coordinationModel.js +665 -0
  58. package/src/kisscomps/components/patternConfig/planContent.vue +572 -0
  59. package/src/kisscomps/components/patternConfig/planMenu.vue +329 -0
  60. package/src/kisscomps/components/patternConfig/utils.js +152 -0
  61. package/src/kisscomps/index.js +4 -0
  62. package/src/lib/publicjs/KissApi.js +2 -2
  63. package/src/router/index.js +7 -0
  64. package/src/utils/auth.js +24 -3
  65. package/src/views/intersection.vue +1 -1
  66. package/src/views/patternConfig.vue +1468 -0
  67. package/static/apiconfig.json +85 -0
  68. package/static/styles/common.scss +2 -0
  69. package/static/styles/patternConfig.scss +57 -0
  70. package/static/styles/xiaokanban.scss +51 -0
@@ -0,0 +1,1010 @@
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
+ <template>
13
+ <div class="patternConfig">
14
+ <el-container>
15
+ <!-- <el-aside width="180px">
16
+ <PlanMenu :planData="planData"
17
+ :zIndexObj="zIndexObj"
18
+ :loading="loading"
19
+ @maskChange="maskChange"
20
+ @chooseRoute="chooseRoute"
21
+ @resetContentComponent="resetContentComponent"
22
+ @editStart="editStart"
23
+ @refresh="refresh"/>
24
+ </el-aside> -->
25
+ <!-- <el-main> -->
26
+ <div class="main-container" style="height: 100%;width: 100%;">
27
+ <el-tabs v-model="editableTabsValue" type="card" @edit="handleTabsEdit" :before-leave="beforeLeave" style="height: 100%;">
28
+ <el-tab-pane
29
+ :closable="true"
30
+ :key="item.tabName"
31
+ v-for="(item) in editableTabs"
32
+ :label="$t('openatccomponents.greenwaveoptimize.scene') + ' ' + item.tabName"
33
+ :name="item.tabName"
34
+ >
35
+ <div class="panel-content" style="height: 100%;">
36
+ <!-- <div style="height: 12%;">
37
+ <div class="route-filter-container" style="display:flex;">
38
+ <div class="filter">
39
+ <span class="header-span">{{$t('openatccomponents.greenwaveoptimize.patternName')}}:</span>
40
+ <el-input
41
+ clearable
42
+ size="small"
43
+ v-model="item.name"
44
+ style="width:70%;"
45
+ @change="onConditionChange"
46
+ />
47
+ </div>
48
+ <div class="filter">
49
+ <span class="header-span">{{$t('edge.date.month')}}:</span>
50
+ <el-select multiple
51
+ v-model="item.month"
52
+ style="width:70%;"
53
+ :placeholder="$t('edge.common.select')"
54
+ size="small"
55
+ :collapse-tags="true"
56
+ @change="handleMonth(item.month, index)"
57
+ @visible-change="initOldOptions(item.month, $event)">
58
+ <el-option
59
+ v-for="item in months"
60
+ :key="item.label"
61
+ :label="item.label"
62
+ :value="item.value">
63
+ </el-option>
64
+ </el-select>
65
+ </div>
66
+ <div class="filter">
67
+ <span class="header-span">{{$t('edge.date.day') }}:</span>
68
+ <el-select multiple
69
+ style="width:70%;"
70
+ v-model="item.day"
71
+ :placeholder="$t('edge.common.select')"
72
+ size="small"
73
+ :collapse-tags="true"
74
+ @change="handleDay(item.day, index)"
75
+ @visible-change="initOldOptions(item.day, $event)">
76
+ <el-option
77
+ v-for="item in days"
78
+ :key="item.label"
79
+ :label="item.label"
80
+ :value="item.value">
81
+ </el-option>
82
+ </el-select>
83
+ </div>
84
+ <div class="filter">
85
+ <span class="header-span">{{$t('edge.date.date') }}:</span>
86
+ <el-select multiple
87
+ style="width:70%;"
88
+ :collapse-tags="true"
89
+ v-model="item.date"
90
+ :placeholder="$t('edge.common.select')"
91
+ size="small"
92
+ @change="handleDate(item.date, index)"
93
+ @visible-change="initOldOptions(item.date, $event)">
94
+ <el-option
95
+ v-for="item in dates"
96
+ :key="item"
97
+ :label="item"
98
+ :value="item">
99
+ </el-option>
100
+ </el-select>
101
+ </div>
102
+ <div class="filter">
103
+ <span class="header-span">{{$t('openatccomponents.greenwaveoptimize.period')}}:</span>
104
+ <template>
105
+ <el-time-select
106
+ style="width:35%;"
107
+ size="small"
108
+ v-model="item.plan.start"
109
+ :picker-options="{
110
+ start: '00:00',
111
+ step: '00:05',
112
+ end: '23:59'
113
+ }">
114
+ </el-time-select>
115
+ <el-time-select
116
+ style="width:35%;"
117
+ size="small"
118
+ v-model="item.plan.end"
119
+ :picker-options="{
120
+ start: '00:00',
121
+ step: '00:05',
122
+ end: '23:59',
123
+ minTime: item.plan.start
124
+ }">
125
+ </el-time-select>
126
+ </template>
127
+ </div>
128
+ <div class="filter">
129
+ <span class="header-span">{{$t('openatccomponents.greenwaveoptimize.coordinationstrategy')}}:</span>
130
+ <el-select v-model="item.optstrategy"
131
+ style="width:70%;"
132
+ @change="onOptstrategyChange"
133
+ :placeholder="$t('openatccomponents.common.placeholder')"
134
+ size="small">
135
+ <el-option
136
+ v-for="item in optstrategyOptions"
137
+ :key="item.value"
138
+ :label="$t('openatccomponents.greenwaveoptimize.optstrategyoption' + item.id)"
139
+ :value="item.value">
140
+ </el-option>
141
+ </el-select>
142
+ </div>
143
+ <div class="filter">
144
+ <span class="header-span">{{$t('openatccomponents.greenwaveoptimize.coordinationdirection')}}:</span>
145
+ <el-select v-model="item.direction"
146
+ :placeholder="$t('openatccomponents.common.placeholder')"
147
+ size="small"
148
+ style="width:70%;"
149
+ @change="onDirectionChange">
150
+ <el-option
151
+ v-for="dir in directionOptions"
152
+ :key="dir.value"
153
+ :label="$t('openatccomponents.greenwaveoptimize.directionOption' + dir.id)"
154
+ :disabled="item.optstrategy != 'green' && dir.value === 'all'"
155
+ :value="dir.value">
156
+ </el-option>
157
+ </el-select>
158
+ </div>
159
+ <div class="filter">
160
+ <span class="header-span">{{$t('openatccomponents.greenwaveoptimize.keyintersection')}}:</span>
161
+ <el-select v-model="item.keyintsid"
162
+ :placeholder="$t('openatccomponents.common.placeholder')"
163
+ style="width:70%;"
164
+ size="small">
165
+ <el-option
166
+ v-for="item in keyintsidOptions"
167
+ :key="item.value"
168
+ :label="item.label"
169
+ :value="item.value">
170
+ </el-option>
171
+ </el-select>
172
+ </div>
173
+ <div class="filter">
174
+ <span class="header-span">{{$t('openatccomponents.greenwaveoptimize.upspeed')}}:</span>
175
+ <el-input-number :controls="false"
176
+ style="width:70%;"
177
+ :min="0"
178
+ size="small"
179
+ @change="onUpspeedChange"
180
+ v-model="item.upspeed"
181
+ ></el-input-number>
182
+ </div>
183
+ <div class="filter">
184
+ <span class="header-span">{{$t('openatccomponents.greenwaveoptimize.downspeed')}}:</span>
185
+ <el-input-number :controls="false"
186
+ style="width:70%;"
187
+ :min="0"
188
+ size="small"
189
+ @change="onDownspeedChange"
190
+ v-model="item.downspeed"
191
+ ></el-input-number>
192
+ </div>
193
+ </div>
194
+ </div> -->
195
+ <div style="height: 100%;" class="table-container">
196
+ <PatternTable ref="patterntable"
197
+ :opt="item.devs"
198
+ :isAllowedExpand="isAllowedExpand"
199
+ @onNewPatternListChange="onNewPatternListChange"/>
200
+ </div>
201
+ </div>
202
+ </el-tab-pane>
203
+ <el-tab-pane key="add" name="add" :closable="false">
204
+ <span slot="label" style="padding: 8px;font-size:20px;font-weight:bold;">
205
+ +
206
+ </span>
207
+ </el-tab-pane>
208
+ </el-tabs>
209
+ </div>
210
+ <!-- <div style="display:flex;justify-content:center;">
211
+ <el-button type="primary" @click="onChartClick" plain>{{$t('openatccomponents.greenwaveoptimize.spaceGraph')}}</el-button>
212
+ <el-button type="primary" @click="onGenerateClick" plain>{{$t('openatccomponents.greenwaveoptimize.generate')}}</el-button>
213
+ <el-button type="primary" @click="onSaveClick" plain>{{$t('openatccomponents.common.save')}}</el-button>
214
+ <el-button type="primary" @click="onExecuteClick" plain>{{$t('openatc.dutyroute.executen')}}</el-button>
215
+ <el-button type="primary" @click="onDownloadClick" plain>{{$t('openatc.button.download')}}</el-button>
216
+ </div> -->
217
+ <!-- </el-main> -->
218
+ </el-container>
219
+ <PlanContent v-show="false"
220
+ :schemeData="schemeData"
221
+ :step="step"
222
+ :zIndexObj="zIndexObj"
223
+ ref="planContent"
224
+ @handlePlanChart="handlePlanChart"
225
+ @handlePatternTable="handlePatternTable"
226
+ @ErrorOcurrred='onErrorOcurrred'
227
+ @resetContentComponent="resetContentComponent"/>
228
+ <!-- <chartDialog ref="chartDialog" ></chartDialog> -->
229
+ <!-- <PlanExecute ref="planExecute" ></PlanExecute> -->
230
+ </div>
231
+ </template>
232
+
233
+ <script>
234
+ // import PlanMenu from './planMenu'
235
+ import PlanContent from './planContent'
236
+ // import { GetAllRoute } from '../../../api/route'
237
+ // import chartDialog from './pattern/planChart/chartDialog'
238
+ import { getMessageByCode } from '../../../utils/responseMessage'
239
+ import PatternTable from './pattern/patternTable'
240
+ import dateObj from './utils.js'
241
+ // import routeChart from './pattern/planChart/index'
242
+ // import PlanExecute from './components/planExecute'
243
+ import { GetDeviceByIds } from '../../../api/device.js'
244
+ const { monthsModel, daysModelCh, daysModelEn, datesModel, monthsModelEn, datesModelEn } = dateObj
245
+ export default {
246
+ name: 'PatternConfig',
247
+ components: {
248
+ // routeChart,
249
+ PatternTable,
250
+ // PlanMenu,
251
+ PlanContent
252
+ // chartDialog,
253
+ // PlanExecute
254
+ },
255
+ props: {
256
+ agentids: {
257
+ type: Array,
258
+ default: () => []
259
+ },
260
+ opt: {
261
+ type: Object,
262
+ default: () => null
263
+ },
264
+ isOnlyOneTab: {
265
+ type: Boolean,
266
+ default: true
267
+ },
268
+ isAllowedExpand: {
269
+ type: Boolean,
270
+ default: true
271
+ }
272
+ },
273
+ watch: {
274
+ agentids: {
275
+ handler (val, old) {
276
+ if (old && val.join('') === old.join('')) {
277
+ return false
278
+ }
279
+ this.handeAgentidsChange()
280
+ },
281
+ immediate: true
282
+ }
283
+ },
284
+ data () {
285
+ return {
286
+ chartData: {},
287
+ months: monthsModel,
288
+ days: [],
289
+ dates: datesModel,
290
+ planData: [],
291
+ schemeData: [],
292
+ step: false, // 控制第二个蒙层是否可以显示
293
+ zIndexObj: {
294
+ // 由于“新增”“编辑”均有蒙层,因此需动态改变可点击按钮层级
295
+ addZIndex: 98,
296
+ editZIndex: 98
297
+ },
298
+ reset: false,
299
+ activeName: 'first',
300
+ chooseId: 0, // 选中的计划id
301
+ // agentids: [],
302
+ // isOnlyOneTab: true,
303
+ loading: false,
304
+ keyintsidOptions: [],
305
+ directionOptions: [{
306
+ value: 'up',
307
+ label: this.$t('openatccomponents.greenwaveoptimize.directionOption1'),
308
+ id: '1'
309
+ }, {
310
+ value: 'down',
311
+ label: this.$t('openatccomponents.greenwaveoptimize.directionOption2'),
312
+ id: '2'
313
+ }, {
314
+ value: 'all',
315
+ label: this.$t('openatccomponents.greenwaveoptimize.directionOption3'),
316
+ id: '3'
317
+ }],
318
+ optstrategyOptions: [{
319
+ value: 'green',
320
+ label: this.$t('openatccomponents.greenwaveoptimize.optstrategyoption1'),
321
+ id: '1'
322
+ }, {
323
+ value: 'red',
324
+ label: this.$t('openatccomponents.greenwaveoptimize.optstrategyoption2'),
325
+ id: '2'
326
+ }, {
327
+ value: 'motorcade-end',
328
+ label: this.$t('openatccomponents.greenwaveoptimize.optstrategyoption3'),
329
+ id: '3'
330
+ }, {
331
+ value: 'dynamicGreen',
332
+ label: this.$t('openatccomponents.greenwaveoptimize.optstrategyoption4'),
333
+ id: '4'
334
+ }],
335
+ editableTabsValue: '1',
336
+ routePattern: {
337
+ 'id': 1,
338
+ 'optPatternList': []
339
+ },
340
+ defaultOptPattern: {
341
+ 'tabName': '1',
342
+ 'month': [],
343
+ patternid: 1,
344
+ 'day': [],
345
+ 'date': [],
346
+ 'plan': {
347
+ 'start': '11:00',
348
+ 'end': '13:00'
349
+ },
350
+ 'optstrategy': 'green',
351
+ 'direction': 'up',
352
+ 'keyintsid': '',
353
+ 'upspeed': 0,
354
+ 'downspeed': 0,
355
+ 'devs': []
356
+ },
357
+ currentIndex: 0,
358
+ editableTabs: [{
359
+ title: '方案 1',
360
+ tabName: '1',
361
+ content: 'Tab 1 content',
362
+ patternid: 1,
363
+ 'month': [],
364
+ 'day': [],
365
+ 'date': [],
366
+ 'plan': {
367
+ 'start': '11:00',
368
+ 'end': '13:00'
369
+ },
370
+ 'optstrategy': 'green',
371
+ 'direction': 'up',
372
+ 'keyintsid': '',
373
+ 'upspeed': 0,
374
+ 'downspeed': 0,
375
+ 'devs': []
376
+ }],
377
+ tabIndex: 1
378
+ }
379
+ },
380
+ created () {
381
+ this.resetTab()
382
+ let lan = this.$i18n.locale
383
+ if (lan === 'en') {
384
+ this.days = daysModelEn
385
+ this.dates = datesModelEn
386
+ this.months = monthsModelEn
387
+ }
388
+ if (lan === 'zh') {
389
+ this.days = daysModelCh
390
+ this.dates = datesModel
391
+ this.months = monthsModel
392
+ }
393
+ },
394
+ mounted () {
395
+ // this.getAllPlan()
396
+ },
397
+ methods: {
398
+ handeAgentidsChange () {
399
+ let devs = []
400
+ for (let agentid of this.agentids) {
401
+ let item = {
402
+ agentid: agentid,
403
+ patternid: 1,
404
+ isused: true
405
+ }
406
+ devs.push(item)
407
+ }
408
+ let _this = this
409
+ this.$nextTick(() => {
410
+ let route = {
411
+ devs: devs
412
+ }
413
+ let optPatternList
414
+ if (_this.opt && _this.opt.optPatternList && _this.opt.optPatternList.length > 0) {
415
+ route = _this.opt.optPatternList[0]
416
+ let arr = []
417
+ for (let dev of route.devs) {
418
+ arr.push(dev.agentid)
419
+ }
420
+ if (arr.length === this.agentids.length && arr.join('') !== this.agentids.join('')) {
421
+ optPatternList = _this.opt.optPatternList
422
+ }
423
+ }
424
+ this.route = route
425
+ _this.onAgentidsChange('', optPatternList, _this.agentids)
426
+ })
427
+ },
428
+ handlePlanChart (routeData, patternList, greenwave, allPatternList) {
429
+ let chartData = {
430
+ routeData,
431
+ patternList,
432
+ greenwave,
433
+ allPatternList
434
+ }
435
+ this.chartData = chartData
436
+ },
437
+ handlePatternTable (routeData, patternList, phaseList) {
438
+ let index = this.currentIndex
439
+ let patterntable = this.$refs.patterntable[index]
440
+ patterntable.onPatternTable(routeData, patternList, phaseList)
441
+ },
442
+ onNewPatternListChange (newPatternList) {
443
+ let list = JSON.parse(JSON.stringify(newPatternList))
444
+ let editableTab = this.editableTabs[this.currentIndex]
445
+ let devs = editableTab.devs
446
+ let devList = []
447
+ for (let dev of devs) {
448
+ for (let pattern of list) {
449
+ if (dev.agentid === pattern.agentid) {
450
+ dev = {...dev, ...pattern}
451
+ dev.isused = pattern.isused
452
+ let allPatterns = pattern.allPatterns
453
+ for (let p of allPatterns) {
454
+ if (p.id === dev.patternid) {
455
+ p.cycle = dev.cycle
456
+ p.offset = dev.offset
457
+ p.rings = dev.rings
458
+ }
459
+ }
460
+ dev.patternList = JSON.parse(JSON.stringify(allPatterns))
461
+ if (dev.feature && dev.feature.patternList) {
462
+ dev.feature.patternList = JSON.parse(JSON.stringify(allPatterns))
463
+ } else {
464
+ let feature = {
465
+ patternList: JSON.parse(JSON.stringify(allPatterns))
466
+ }
467
+ dev.feature = feature
468
+ }
469
+ devList.push(dev)
470
+ }
471
+ }
472
+ }
473
+ editableTab.devs = devList
474
+ // this.refreshChart()
475
+ },
476
+ afterEnter () {
477
+ if (this.chooseId === 0) {
478
+ return false
479
+ }
480
+ // let {routeData, patternList, greenwave, allPatternList} = {...this.chartData}
481
+ // this.$refs.routeChart.onPlanChart(routeData, patternList, greenwave, allPatternList)
482
+ },
483
+ onChartClick () {
484
+ let routeData = this.editableTabs[this.currentIndex]
485
+ let check = this.checkData([routeData], false)
486
+ if (!check) {
487
+ return false
488
+ }
489
+ this.getDeviceByIds(routeData)
490
+ },
491
+ onGenerateClick () {
492
+ let routeData = this.editableTabs[this.currentIndex]
493
+ // check
494
+ let check = this.checkData([routeData], false)
495
+ if (!check) {
496
+ return false
497
+ }
498
+ let planContent = this.$refs.planContent
499
+ planContent.handleCreate(routeData)
500
+ },
501
+ checkData (tabs, isCheckName = true) {
502
+ let res = true
503
+ // if (this.chooseId === 0) {
504
+ if (this.agentids.length === 0) {
505
+ this.$message.warning(this.$t('openatccomponents.greenwaveoptimize.chooseRoute'))
506
+ return false
507
+ }
508
+ for (let tab of tabs) {
509
+ // if (!tab.optstrategy) {
510
+ // this.$message.warning(this.$t('openatccomponents.greenwaveoptimize.pleaseChoseOptstrategy'))
511
+ // return false
512
+ // }
513
+ // if (isCheckName && !tab.name) {
514
+ // this.$message.warning(this.$t('openatccomponents.greenwaveoptimize.pleaseInputPatternName'))
515
+ // return false
516
+ // }
517
+ // let filterList = tabs.filter(item => item.name === tab.name)
518
+ // if (filterList.length > 1) {
519
+ // this.$message.warning(this.$t('openatccomponents.greenwaveoptimize.repeatPatternName'))
520
+ // return false
521
+ // }
522
+ // if (!tab.keyintsid) {
523
+ // this.$message.warning(this.$t('openatccomponents.greenwaveoptimize.pleaseChoseKeyintersection'))
524
+ // return false
525
+ // }
526
+ // if (!tab.upspeed) {
527
+ // this.$message.warning(this.$t('openatccomponents.greenwaveoptimize.pleaseInputUpspeed'))
528
+ // return false
529
+ // }
530
+ // if (!tab.downspeed) {
531
+ // this.$message.warning(this.$t('openatccomponents.greenwaveoptimize.pleaseInputDownspeed'))
532
+ // return false
533
+ // }
534
+ if (!tab.devs || tab.devs.length === 0) {
535
+ this.$message.warning(this.$t('openatccomponents.greenwaveoptimize.abnormalIntersections'))
536
+ return false
537
+ }
538
+ // reset date
539
+ this.resetDate(tab)
540
+ }
541
+ return res
542
+ },
543
+ getPatternConfig () {
544
+ let res = this.getSaveParam(true)
545
+ return res
546
+ },
547
+ getSaveParam (filter) {
548
+ // check
549
+ let check = this.checkData(this.editableTabs)
550
+ if (!check) {
551
+ return false
552
+ }
553
+ let routeData = this.editableTabs
554
+ let planContent = this.$refs.planContent
555
+ let params = planContent.getSaveParam(this.route.id, routeData, filter)
556
+ return params
557
+ },
558
+ onSaveClick () {
559
+ // check
560
+ let check = this.checkData(this.editableTabs)
561
+ if (!check) {
562
+ return false
563
+ }
564
+ let routeData = this.editableTabs
565
+ let planContent = this.$refs.planContent
566
+ planContent.handleSave(this.route.id, routeData)
567
+ },
568
+ onDownSendClick () {
569
+ let routeData = this.editableTabs[this.currentIndex]
570
+ let check = this.checkData([routeData])
571
+ if (!check) {
572
+ return false
573
+ }
574
+ this.resetDate(routeData)
575
+ let planContent = this.$refs.planContent
576
+ planContent.handleDownload(this.route.id, routeData)
577
+ },
578
+ async onDeleteClick (targetName) {
579
+ let routeData = this.editableTabs[this.currentIndex]
580
+ // check
581
+ let id = routeData.id
582
+ if (targetName !== routeData.tabName) {
583
+ this.$message.warning(this.$t('openatccomponents.greenwaveoptimize.choosePattern'))
584
+ return false
585
+ }
586
+ if (this.editableTabs.length === 1) {
587
+ this.$message.warning(this.$t('openatccomponents.greenwaveoptimize.atleastOnePattern'))
588
+ return false
589
+ }
590
+ let optPatternList = this.route.optPatternList
591
+ if (!optPatternList) {
592
+ return true
593
+ }
594
+ let list = optPatternList.filter(item => item.id === id)
595
+ if (list.length === 0) {
596
+ return true
597
+ } else {
598
+ let planContent = this.$refs.planContent
599
+ let param = {
600
+ routeid: this.route.id,
601
+ optpatternid: id
602
+ }
603
+ let flag = await planContent.handleDelete(param)
604
+ return flag
605
+ }
606
+ },
607
+ resetDate (tab) {
608
+ let date = tab.date
609
+ let day = tab.day
610
+ let month = tab.month
611
+ if (date && date.includes('全选')) {
612
+ let index = date.indexOf('全选')
613
+ date.splice(index, 1) // 排除全选选项
614
+ } else if (date && date.includes('All')) {
615
+ let index = date.indexOf('All')
616
+ date.splice(index, 1) // 排除全选选项
617
+ }
618
+ if (day && day.includes(8)) {
619
+ let index = day.indexOf(8)
620
+ day.splice(index, 1) // 排除全选选项
621
+ }
622
+ if (month && month.includes(0)) {
623
+ let index = month.indexOf(0)
624
+ month.splice(index, 1) // 排除全选选项
625
+ }
626
+ },
627
+ onConditionChange () {},
628
+ onOptstrategyChange (val) {
629
+ if (this.chartData.patternList) {
630
+ this.chartData.routeData.optstrategy = val
631
+ }
632
+ },
633
+ onDirectionChange (val) {
634
+ if (this.chartData.patternList) {
635
+ this.chartData.routeData.direction = val
636
+ }
637
+ },
638
+ onUpspeedChange (val) {
639
+ if (this.chartData.patternList) {
640
+ this.chartData.routeData.upspeed = val
641
+ }
642
+ },
643
+ onDownspeedChange (val) {
644
+ if (this.chartData.patternList) {
645
+ this.chartData.routeData.downspeed = val
646
+ }
647
+ },
648
+ handleMonth (val, index) {
649
+ let allValues = []
650
+ // 保留所有值
651
+ for (let item of this.months) {
652
+ allValues.push(item.value)
653
+ }
654
+ // 若是全部选择
655
+ if (val.includes(0)) this.editableTabs[index].month = allValues
656
+ // 取消全部选中,上次有,当前没有,表示取消全选
657
+ if (this.oldOptions.includes(0) && !val.includes(0)) this.editableTabs[index].month = []
658
+ // 点击非全部选中,需要排除全部选中,以及,当前点击的选项
659
+ // 新老数据都有全部选中
660
+ if (this.oldOptions.includes(0) && val.includes(0)) {
661
+ let tempIndex = val.indexOf(0)
662
+ val.splice(tempIndex, 1) // 排除全选选项
663
+ this.editableTabs[index].month = val
664
+ }
665
+ // 全选未选,但是其他选项全部选上,则全选选上,上次和当前,都没有全选
666
+ if (!this.oldOptions.includes(0) && !val.includes(0)) {
667
+ if (val.length === allValues.length - 1) this.editableTabs[index].month = [0].concat(val)
668
+ }
669
+ this.oldOptions = this.editableTabs[index].month
670
+ },
671
+ handleDate (val, index) {
672
+ let allValues = []
673
+ // 保留所有值
674
+ for (let item of this.dates) {
675
+ allValues.push(item)
676
+ }
677
+ // 判断中英文
678
+ if (this.$i18n.locale === 'en') {
679
+ // 若是全部选择
680
+ if (val.includes('All')) this.editableTabs[index].date = allValues
681
+ // 取消全部选中,上次有,当前没有,表示取消全选
682
+ if (this.oldOptions.includes('All') && !val.includes('All')) this.editableTabs[index].date = []
683
+ // 点击非全部选中,需要排除全部选中,以及,当前点击的选项
684
+ // 新老数据都有全部选中
685
+ if (this.oldOptions.includes('All') && val.includes('All')) {
686
+ let tempIndex = val.indexOf('All')
687
+ val.splice(tempIndex, 1) // 排除全选选项
688
+ this.editableTabs[index].date = val
689
+ }
690
+ // 全选未选,但是其他选项全部选上,则全选选上,上次和当前,都没有全选
691
+ if (!this.oldOptions.includes('All') && !val.includes('All')) {
692
+ if (val.length === allValues.length - 1) this.editableTabs[index].date = ['All'].concat(val)
693
+ }
694
+ } else if (this.$i18n.locale === 'zh') {
695
+ // 若是全部选择
696
+ if (val.includes('全选')) this.editableTabs[index].date = allValues
697
+ // 取消全部选中,上次有,当前没有,表示取消全选
698
+ if (this.oldOptions.includes('全选') && !val.includes('全选')) this.editableTabs[index].date = []
699
+ // 点击非全部选中,需要排除全部选中,以及,当前点击的选项
700
+ // 新老数据都有全部选中
701
+ if (this.oldOptions.includes('全选') && val.includes('全选')) {
702
+ let tempIndex = val.indexOf('全选')
703
+ val.splice(tempIndex, 1) // 排除全选选项
704
+ this.editableTabs[index].date = val
705
+ }
706
+ // 全选未选,但是其他选项全部选上,则全选选上,上次和当前,都没有全选
707
+ if (!this.oldOptions.includes('全选') && !val.includes('全选')) {
708
+ if (val.length === allValues.length - 1) this.editableTabs[index].date = ['全选'].concat(val)
709
+ }
710
+ }
711
+ this.oldOptions = this.editableTabs[index].date
712
+ },
713
+ handleDateInit (val, status) {
714
+ if (status) {
715
+ this.oldOptions = val
716
+ } else {
717
+ this.oldOptions = []
718
+ }
719
+ },
720
+ handleDay (val, index) {
721
+ let allValues = []
722
+ // 保留所有值
723
+ for (let item of this.days) {
724
+ allValues.push(item.value)
725
+ }
726
+ // 若是全部选择
727
+ if (val.includes(8)) this.editableTabs[index].day = allValues
728
+ // 取消全部选中,上次有,当前没有,表示取消全选
729
+ if (this.oldOptions.includes(8) && !val.includes(8)) this.editableTabs[index].day = []
730
+ // 点击非全部选中,需要排除全部选中,以及,当前点击的选项
731
+ // 新老数据都有全部选中
732
+ if (this.oldOptions.includes(8) && val.includes(8)) {
733
+ let tempIndex = val.indexOf(8)
734
+ val.splice(tempIndex, 1) // 排除全选选项
735
+ this.editableTabs[index].day = val
736
+ }
737
+ // 全选未选,但是其他选项全部选上,则全选选上,上次和当前,都没有全选
738
+ if (!this.oldOptions.includes(8) && !val.includes(8)) {
739
+ if (val.length === allValues.length - 1) this.editableTabs[index].day = [8].concat(val)
740
+ }
741
+ this.oldOptions = this.editableTabs[index].day
742
+ },
743
+ initOldOptions (val, status) {
744
+ if (status) {
745
+ this.oldOptions = val
746
+ } else {
747
+ this.oldOptions = []
748
+ }
749
+ },
750
+ beforeLeave (currentName, oldName) {
751
+ // var self = this // 重点,如果name是add,则什么都不触发
752
+ if (currentName === 'add') {
753
+ if (this.agentids.length === 0) {
754
+ this.$message.warning(this.$t('openatccomponents.greenwaveoptimize.chooseCros'))
755
+ return false
756
+ }
757
+ if (this.isOnlyOneTab) {
758
+ this.$message.warning(this.$t('openatccomponents.greenwaveoptimize.onlyOneTab'))
759
+ return false
760
+ }
761
+ // if (!this.route || !this.route.id) {
762
+ // this.$message.warning(this.$t('openatccomponents.greenwaveoptimize.routeDeviceNotOnline'))
763
+ // return false
764
+ // }
765
+ this.addTab()
766
+ return false
767
+ }
768
+ for (let i = 0; i < this.editableTabs.length; i++) {
769
+ let tab = this.editableTabs[i]
770
+ if (tab.tabName === currentName) {
771
+ this.currentIndex = i
772
+ break
773
+ }
774
+ }
775
+ this.initPatternList(this.chooseId, this.agentids)
776
+ },
777
+ addTab () {
778
+ this.handleTabsEdit('', 'add')
779
+ },
780
+ async handleTabsEdit (targetName, action) {
781
+ if (action === 'add') {
782
+ let newTabName = ++this.tabIndex + ''
783
+ let tabObj = {
784
+ id: this.currentIndex + 1,
785
+ name: '',
786
+ title: this.$t('openatccomponents.greenwaveoptimize.pattern') + ' ' + newTabName,
787
+ tabName: newTabName,
788
+ content: 'New Tab content',
789
+ patternid: 1,
790
+ 'month': [],
791
+ 'day': [],
792
+ 'date': [],
793
+ 'plan': {
794
+ 'start': '08:00',
795
+ 'end': '09:30'
796
+ },
797
+ 'optstrategy': 'green',
798
+ 'direction': 'up',
799
+ 'keyintsid': '',
800
+ 'upspeed': 0,
801
+ 'downspeed': 0,
802
+ 'devs': []
803
+ }
804
+ this.editableTabs.push(tabObj)
805
+ }
806
+ if (action === 'remove') {
807
+ let flag = await this.onDeleteClick(targetName)
808
+ if (!flag) {
809
+ return false
810
+ }
811
+ let tabs = this.editableTabs
812
+ let activeName = this.editableTabsValue
813
+ if (activeName === targetName) {
814
+ tabs.forEach((tab, index) => {
815
+ if (tab.tabName === targetName) {
816
+ let nextTab = tabs[index + 1] || tabs[index - 1]
817
+ if (nextTab) {
818
+ activeName = nextTab.tabName
819
+ }
820
+ }
821
+ })
822
+ }
823
+ this.editableTabsValue = activeName
824
+ this.editableTabs = tabs.filter(tab => tab.tabName !== targetName)
825
+ }
826
+ },
827
+ refresh () {
828
+ // this.getAllPlan()
829
+ let planContent = this.$refs.planContent
830
+ if (planContent) {
831
+ planContent.closeInterval()
832
+ planContent.startInterval()
833
+ }
834
+ },
835
+ editStart () {
836
+ let planContent = this.$refs.planContent
837
+ if (planContent && planContent.timer > 0) {
838
+ planContent.closeInterval()
839
+ }
840
+ },
841
+ maskChange (val) {
842
+ // 控制两个蒙层下按钮的层级关系,并判断第二个蒙层显示的时机
843
+ if (val) {
844
+ this.step = false
845
+ this.zIndexObj = {
846
+ addZIndex: 99,
847
+ editZIndex: 96
848
+ }
849
+ } else {
850
+ this.step = true
851
+ this.zIndexObj = {
852
+ addZIndex: 96,
853
+ editZIndex: 99
854
+ }
855
+ }
856
+ },
857
+ resetContentComponent () {
858
+ // 每次切换侧边栏方案时,重置销毁planContent组件
859
+ this.reset = false
860
+ this.$nextTick(() => {
861
+ this.reset = true
862
+ })
863
+ },
864
+ // getAllPlan () {
865
+ // this.loading = true
866
+ // GetAllRoute().then(res => {
867
+ // this.loading = false
868
+ // if (!res.data.success) {
869
+ // this.$message.error(getMessageByCode(res.data.code, this.$i18n.locale))
870
+ // return
871
+ // }
872
+ // this.planData = res.data.data
873
+ // })
874
+ // },
875
+ resetTab () {
876
+ this.editableTabs = [
877
+ {
878
+ title: this.$t('openatccomponents.greenwaveoptimize.pattern') + ' 1',
879
+ id: 1,
880
+ name: '',
881
+ tabName: '1',
882
+ content: 'Tab 1 content',
883
+ patternid: 1,
884
+ 'month': [],
885
+ 'day': [],
886
+ 'date': [],
887
+ 'plan': {
888
+ 'start': '08:00',
889
+ 'end': '09:30'
890
+ },
891
+ 'optstrategy': 'green',
892
+ 'direction': 'up',
893
+ 'keyintsid': '',
894
+ 'upspeed': 0,
895
+ 'downspeed': 0,
896
+ 'devs': []
897
+ }
898
+ ]
899
+ this.tabIndex = 1
900
+ this.currentIndex = 0
901
+ this.editableTabsValue = '1'
902
+ this.keyintsidOptions = []
903
+ this.chartData = {}
904
+ // this.route = {}
905
+ // this.agentids = []
906
+ },
907
+ onAgentidsChange (id, optPatternList, agentids) {
908
+ // reset data
909
+ if (agentids.length === 0) {
910
+ return false
911
+ }
912
+ this.resetTab()
913
+ this.chooseId = id
914
+ // this.agentids = agentids
915
+ if (optPatternList && optPatternList.length > 0) {
916
+ this.editableTabs = JSON.parse(JSON.stringify(optPatternList))
917
+ } else {
918
+ this.editableTabs[0].devs = this.route.devs
919
+ }
920
+ this.tabIndex = this.editableTabs.length
921
+ // this.keyintsidOptions = route.devs.map(item => {
922
+ // return {
923
+ // label: item.name,
924
+ // value: item.agentid
925
+ // }
926
+ // })
927
+ this.initPatternList(id, agentids)
928
+ },
929
+ chooseRoute (id, route, agentids) {
930
+ this.agentids = agentids
931
+ },
932
+ initPatternList (id, agentids) {
933
+ let index = this.currentIndex
934
+ let editableTab = this.editableTabs[index]
935
+ let planContent = this.$refs.planContent
936
+ if (planContent) {
937
+ if (editableTab.devs && editableTab.devs.length === 0) {
938
+ let devs = []
939
+ for (let agentid of agentids) {
940
+ let item = {
941
+ agentid: agentid,
942
+ isused: true,
943
+ patternid: 1
944
+ }
945
+ devs.push(item)
946
+ }
947
+ let route = {
948
+ devs: devs
949
+ }
950
+ editableTab = {...editableTab, ...route}
951
+ editableTab.id = this.currentIndex + 1
952
+ }
953
+ if (this.editableTabs[index].devs.length === 0) {
954
+ this.editableTabs[index] = editableTab
955
+ }
956
+ planContent.init(this.chooseId, editableTab, agentids)
957
+ }
958
+ },
959
+ onErrorOcurrred () {
960
+ this.resetTab()
961
+ let patterntable = this.$refs.patterntable
962
+ if (patterntable instanceof Array) {
963
+ patterntable = patterntable[0]
964
+ }
965
+ patterntable.newPatternList = []
966
+ },
967
+ getDeviceByIds (routeData) {
968
+ // 获取设备表格信息
969
+ let realtimeRouteData = JSON.parse(JSON.stringify(routeData))
970
+ this.deviceIds = realtimeRouteData.devs.map(ele => ele.agentid)
971
+ GetDeviceByIds(this.deviceIds).then(res => {
972
+ if (!res.data.success) {
973
+ this.$message.error(getMessageByCode(res.data.code, this.$i18n.locale))
974
+ return
975
+ }
976
+ this.devicesData = res.data.data
977
+ // 取路口对应的实际方案id
978
+ let devs = realtimeRouteData.devs
979
+ for (let inter of devs) {
980
+ inter.patternid = this.getActurlPatternid(inter.agentid)
981
+ }
982
+ this.chartData.realPatternRouteData = realtimeRouteData
983
+ // this.$refs.chartDialog.show(true, this.chartData, this.route.name, this.devicesData)
984
+ })
985
+ },
986
+ getActurlPatternid (agentid) {
987
+ let devinfo = this.devicesData.filter(dev => dev.agentid === agentid)[0]
988
+ if (devinfo.patternid !== undefined) {
989
+ return devinfo.patternid
990
+ } else {
991
+ return 1
992
+ }
993
+ }
994
+ }
995
+ }
996
+ </script>
997
+
998
+ <style lang="scss" scoped>
999
+ .el-button--primary.is-plain:active{
1000
+ color: #fff;
1001
+ }
1002
+ .el-button--primary.is-plain:hover, .el-button--primary.is-plain:focus{
1003
+ color: #fff;
1004
+ }
1005
+ >>> .el-tabs__header {
1006
+ padding: 0;
1007
+ position: relative;
1008
+ margin: 0 0 0px;
1009
+ }
1010
+ </style>