openatc-components 0.5.70 → 0.5.72

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.
@@ -1,210 +1,247 @@
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 v-if="reset" class="detector-icon">
14
- <drr
15
- :style="{'z-index': chooseIndex === DetectorData.index ? 9 : 0}"
16
- :x="item.x"
17
- :y="item.y"
18
- :w="item.w"
19
- :h="item.h"
20
- :selected="chooseIndex === DetectorData.index"
21
- :selectable="isSeletable"
22
- :angle="item.angle"
23
- :aspectRatio="true"
24
- @select="handleSelectIcon(item)"
25
- @dragstop="boxDragStop(item, ...arguments)"
26
- @resize="boxResize(...arguments)"
27
- @resizestop="boxResizeStop(item, ...arguments)"
28
- @rotatestop="boxRotateStop(item, ...arguments)"
29
- >
30
- <div v-if="UsageMode === 'draw'">
31
- <div v-if="chooseIndex !== DetectorData.index" class="centerText defaultBg" :style="{'width': item.w + 'px', 'height': item.h + 'px'}">
32
- <div class="detectorIcon"
33
- :style="{'width': item.w + 'px', 'fontSize': Fontsize + 'px', 'lineHeight': item.h - 4 + 'px'}"
34
- :class="{'defaultVehicleBorder': DetectorData.detectortype === 1,
35
- 'defaultPedBorder': DetectorData.detectortype === 2 }">{{DetectorData.detectorid}}</div>
36
- </div>
37
- <div v-if="chooseIndex === DetectorData.index" class="centerText highlightBg" :style="{'width': item.w + 'px', 'height': item.h + 'px'}">
38
- <div class="detectorIcon"
39
- :style="{'width': item.w + 'px', 'fontSize': Fontsize + 'px', 'lineHeight': item.h - 4 + 'px'}"
40
- :class="{'defaultVehicleBorder': CurChooseIcon.detectortype == 1,
41
- 'defaultPedBorder': CurChooseIcon.detectortype == 2 }">{{CurChooseIcon.detectorid}}</div>
42
- </div>
43
- </div>
44
-
45
- <div v-if="UsageMode === 'show'" class="centerText" :style="{'width': item.w + 'px', 'height': item.h + 'px'}">
46
- <div class="detectorIcon"
47
- :style="{'width': item.w + 'px', 'fontSize': Fontsize + 'px','lineHeight': item.h - 4 + 'px', 'background': DetectorData.fillcolor}"
48
- :class="{'defaultVehicleBorder': DetectorData.detectortype == 1,
49
- 'defaultPedBorder': DetectorData.detectortype == 2 }"
50
- >{{DetectorData.detectorid}}</div>
51
- </div>
52
- </drr>
53
- </div>
54
- </template>
55
- <script>
56
- export default {
57
- name: 'countdownsvg',
58
- data () {
59
- return {
60
- defaultColor: 'DeepSkyBlue', // 默认状态颜色
61
- item: {},
62
- reset: true,
63
- Fontsize: 16 // 默认字号
64
- }
65
- },
66
- watch: {
67
- // item: {
68
- // handler: function (newval, oldval) {
69
- // if ((JSON.stringify(oldval) !== '{}')) {
70
- // // 更改原数据的位置大小数据
71
- // let data = {
72
- // ...this.DetectorData,
73
- // ...newval
74
- // }
75
- // let fields = Object.keys(newval)
76
- // this.$emit('changeDetectorItem', data, fields)
77
- // }
78
- // }
79
- // }
80
- DetectorData: {
81
- handler: function (val) {
82
- if (this.UsageMode === 'draw') {
83
- this.item.x = val.x
84
- this.item.y = val.y
85
- this.item.angle = val.angle
86
- }
87
- },
88
- deep: true
89
- }
90
-
91
- // CurChooseIcon: {
92
- // handler: function (data) {
93
- // debugger
94
- // },
95
- // deep: true
96
- // }
97
- },
98
- props: {
99
- DetectorData: {
100
- type: Object
101
- },
102
- isSeletable: {
103
- type: Boolean
104
- },
105
- chooseIndex: {
106
- type: Number
107
- },
108
- UsageMode: { // 当前图标模式: 绘制draw 展示show
109
- type: String,
110
- default: 'draw'
111
- },
112
- CurChooseIcon: {
113
- type: Object
114
- }
115
- },
116
- methods: {
117
- boxDragStop (origin, final) {
118
- this.item = JSON.parse(JSON.stringify(final))
119
- this.$emit('handleSelectIcon', this.DetectorData)
120
- this.handleChangeData()
121
- },
122
- boxResize (final) {
123
- // this.resetSvg()
124
- this.item = JSON.parse(JSON.stringify(final))
125
- this.handleChangeData()
126
- },
127
- boxResizeStop (origin, final) {
128
- // this.resetSvg()
129
- // this.item = JSON.parse(JSON.stringify(final))
130
- },
131
- boxRotateStop (origin, final) {
132
- this.item = JSON.parse(JSON.stringify(final))
133
- // 第四象限的角度是负值(开源组件接口返回),转化为正值便于理解
134
- if (this.item.angle < 0) {
135
- this.item.angle = this.item.angle + 360
136
- }
137
- this.handleChangeData()
138
- },
139
- resetSvg () {
140
- this.reset = false
141
- this.$nextTick(() => {
142
- this.reset = true
143
- })
144
- },
145
- handleSelectIcon (iconparams) {
146
- this.$emit('handleSelectIcon', this.DetectorData)
147
- },
148
- culculateFontsize () {
149
- // 根据倒计时图标大小,动态计算内部文字大小
150
- this.Fontsize = Math.floor(this.DetectorData.w / 140 * 20)
151
- },
152
- handleChangeData () {
153
- let data = {
154
- ...this.DetectorData,
155
- ...this.item
156
- }
157
- let fields = Object.keys(this.item)
158
- this.$emit('changeDetectorItem', data, fields)
159
- this.handleSelectIcon()
160
- }
161
- },
162
- created () {
163
- this.item = {
164
- x: this.DetectorData.x,
165
- y: this.DetectorData.y,
166
- w: this.DetectorData.w,
167
- h: this.DetectorData.h,
168
- angle: this.DetectorData.angle
169
- }
170
- }
171
- }
172
- </script>
173
- <style scoped>
174
- .centerText {
175
- position: absolute;
176
- left: 50%;
177
- top: 50%;
178
- transform: translateX(-50%) translateY(-50%);
179
- z-index: 9;
180
- display: flex;
181
- align-items: center;
182
- }
183
- .detectorIcon {
184
- font-family: SourceHanSansCN-Regular;
185
- font-weight: normal;
186
- font-stretch: normal;
187
- letter-spacing: 0px;
188
- color: #fff;
189
- margin: 0 auto;
190
- text-align: center;
191
- height: 100%;
192
- }
193
- .defaultBg {
194
- background-color: transparent;
195
- }
196
- .highlightBg {
197
- background-color: #299BCC;
198
- }
199
- .defaultVehicleBorder {
200
- border: 2px solid #00FF00;
201
- }
202
- .defaultPedBorder {
203
- border: 2px solid #0080FF;
204
- }
205
- .centerText .text {
206
- display: inline-block;
207
- color: #299BCC;
208
- margin-top: 20px;
209
- }
210
- </style>
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 v-if="reset" class="detector-icon">
14
+ <drr
15
+ :style="{'z-index': chooseIndex === DetectorData.index ? 9 : 0}"
16
+ :x="item.x"
17
+ :y="item.y"
18
+ :w="item.w"
19
+ :h="item.h"
20
+ :selected="chooseIndex === DetectorData.index"
21
+ :selectable="isSeletable"
22
+ :angle="item.angle"
23
+ :aspectRatio="true"
24
+ @select="handleSelectIcon(item)"
25
+ @dragstop="boxDragStop(item, ...arguments)"
26
+ @resize="boxResize(...arguments)"
27
+ @resizestop="boxResizeStop(item, ...arguments)"
28
+ @rotatestop="boxRotateStop(item, ...arguments)"
29
+ >
30
+ <div v-if="UsageMode === 'draw'">
31
+ <div v-if="chooseIndex !== DetectorData.index" class="centerText defaultBg" :style="{'width': item.w + 'px', 'height': item.h + 'px'}">
32
+ <div class="detectorIcon"
33
+ :style="{'width': item.w + 'px', 'fontSize': Fontsize + 'px', 'lineHeight': item.h - 4 + 'px'}"
34
+ :class="{'defaultVehicleBorder': DetectorData.detectortype === 1,
35
+ 'defaultPedBorder': DetectorData.detectortype === 2 }">{{DetectorData.detectorid}}</div>
36
+ </div>
37
+ <div v-if="chooseIndex === DetectorData.index" class="centerText highlightBg" :style="{'width': item.w + 'px', 'height': item.h + 'px'}">
38
+ <div class="detectorIcon"
39
+ :style="{'width': item.w + 'px', 'fontSize': Fontsize + 'px', 'lineHeight': item.h - 4 + 'px'}"
40
+ :class="{'defaultVehicleBorder': CurChooseIcon.detectortype == 1,
41
+ 'defaultPedBorder': CurChooseIcon.detectortype == 2 }">{{CurChooseIcon.detectorid}}</div>
42
+ </div>
43
+ </div>
44
+
45
+ <div v-if="UsageMode === 'show'" class="detector-container">
46
+ <div class="detector-content">
47
+ <div class="centerText" :style="{'width': item.w + 'px', 'height': item.h + 'px'}">
48
+ <div class="detectorIcon"
49
+ :style="{'width': item.w + 'px', 'fontSize': Fontsize + 'px','lineHeight': item.h - 4 + 'px', 'background': DetectorData.fillcolor}"
50
+ :class="{'defaultVehicleBorder': DetectorData.detectortype == 1,
51
+ 'defaultPedBorder': DetectorData.detectortype == 2 }"
52
+ >{{DetectorData.detectorid}}</div>
53
+ </div>
54
+
55
+ <!-- 排队长度显示在检测器右侧 -->
56
+ <div v-if="DetectorData.queue !== undefined"
57
+ class="queue-display">
58
+ {{DetectorData.queue}}
59
+ </div>
60
+ </div>
61
+ </div>
62
+ </drr>
63
+ </div>
64
+ </template>
65
+ <script>
66
+ export default {
67
+ name: 'countdownsvg',
68
+ data () {
69
+ return {
70
+ defaultColor: 'DeepSkyBlue', // 默认状态颜色
71
+ item: {},
72
+ reset: true,
73
+ Fontsize: 16 // 默认字号
74
+ }
75
+ },
76
+ watch: {
77
+ // item: {
78
+ // handler: function (newval, oldval) {
79
+ // if ((JSON.stringify(oldval) !== '{}')) {
80
+ // // 更改原数据的位置大小数据
81
+ // let data = {
82
+ // ...this.DetectorData,
83
+ // ...newval
84
+ // }
85
+ // let fields = Object.keys(newval)
86
+ // this.$emit('changeDetectorItem', data, fields)
87
+ // }
88
+ // }
89
+ // }
90
+ DetectorData: {
91
+ handler: function (val) {
92
+ if (this.UsageMode === 'draw') {
93
+ this.item.x = val.x
94
+ this.item.y = val.y
95
+ this.item.angle = val.angle
96
+ }
97
+ },
98
+ deep: true
99
+ }
100
+
101
+ // CurChooseIcon: {
102
+ // handler: function (data) {
103
+ // debugger
104
+ // },
105
+ // deep: true
106
+ // }
107
+ },
108
+ props: {
109
+ DetectorData: {
110
+ type: Object
111
+ },
112
+ isSeletable: {
113
+ type: Boolean
114
+ },
115
+ chooseIndex: {
116
+ type: Number
117
+ },
118
+ UsageMode: { // 当前图标模式: 绘制draw 展示show
119
+ type: String,
120
+ default: 'draw'
121
+ },
122
+ CurChooseIcon: {
123
+ type: Object
124
+ }
125
+ },
126
+ methods: {
127
+ boxDragStop (origin, final) {
128
+ this.item = JSON.parse(JSON.stringify(final))
129
+ this.$emit('handleSelectIcon', this.DetectorData)
130
+ this.handleChangeData()
131
+ },
132
+ boxResize (final) {
133
+ // this.resetSvg()
134
+ this.item = JSON.parse(JSON.stringify(final))
135
+ this.handleChangeData()
136
+ },
137
+ boxResizeStop (origin, final) {
138
+ // this.resetSvg()
139
+ // this.item = JSON.parse(JSON.stringify(final))
140
+ },
141
+ boxRotateStop (origin, final) {
142
+ this.item = JSON.parse(JSON.stringify(final))
143
+ // 第四象限的角度是负值(开源组件接口返回),转化为正值便于理解
144
+ if (this.item.angle < 0) {
145
+ this.item.angle = this.item.angle + 360
146
+ }
147
+ this.handleChangeData()
148
+ },
149
+ resetSvg () {
150
+ this.reset = false
151
+ this.$nextTick(() => {
152
+ this.reset = true
153
+ })
154
+ },
155
+ handleSelectIcon (iconparams) {
156
+ this.$emit('handleSelectIcon', this.DetectorData)
157
+ },
158
+ culculateFontsize () {
159
+ // 根据倒计时图标大小,动态计算内部文字大小
160
+ this.Fontsize = Math.floor(this.DetectorData.w / 140 * 20)
161
+ },
162
+ handleChangeData () {
163
+ let data = {
164
+ ...this.DetectorData,
165
+ ...this.item
166
+ }
167
+ let fields = Object.keys(this.item)
168
+ this.$emit('changeDetectorItem', data, fields)
169
+ this.handleSelectIcon()
170
+ }
171
+ },
172
+ created () {
173
+ this.item = {
174
+ x: this.DetectorData.x,
175
+ y: this.DetectorData.y,
176
+ w: this.DetectorData.w,
177
+ h: this.DetectorData.h,
178
+ angle: this.DetectorData.angle
179
+ }
180
+ }
181
+ }
182
+ </script>
183
+ <style scoped>
184
+ .detector-container {
185
+ position: relative;
186
+ width: 100%;
187
+ height: 100%;
188
+ }
189
+
190
+ .detector-content {
191
+ display: flex;
192
+ align-items: center;
193
+ width: 100%;
194
+ height: 100%;
195
+ }
196
+
197
+ .centerText {
198
+ position: relative;
199
+ z-index: 9;
200
+ display: flex;
201
+ align-items: center;
202
+ flex-shrink: 0; /* 防止检测器被压缩 */
203
+ width: auto; /* 不占用额外空间 */
204
+ }
205
+ .detectorIcon {
206
+ font-family: SourceHanSansCN-Regular;
207
+ font-weight: normal;
208
+ font-stretch: normal;
209
+ letter-spacing: 0px;
210
+ color: #fff;
211
+ margin: 0 auto;
212
+ text-align: center;
213
+ height: 100%;
214
+ display: flex;
215
+ align-items: center;
216
+ justify-content: center;
217
+ }
218
+ .defaultBg {
219
+ background-color: transparent;
220
+ }
221
+ .highlightBg {
222
+ background-color: #299BCC;
223
+ }
224
+ .defaultVehicleBorder {
225
+ border: 2px solid #00FF00;
226
+ }
227
+ .defaultPedBorder {
228
+ border: 2px solid #0080FF;
229
+ }
230
+ .centerText .text {
231
+ display: inline-block;
232
+ color: #299BCC;
233
+ margin-top: 20px;
234
+ }
235
+ .queue-display {
236
+ display: flex;
237
+ align-items: center;
238
+ justify-content: center;
239
+ color: #00FF00;
240
+ font-size: 14px;
241
+ font-weight: bold;
242
+ white-space: nowrap;
243
+ margin-left: 4px; /* 增加间距 */
244
+ min-width: 20px; /* 确保数字有足够的显示空间 */
245
+ text-align: center;
246
+ }
247
+ </style>