vue-wiring-diagram 1.1.24 → 1.1.26
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.
- package/README.md +93 -93
- package/dist/style.css +1 -1
- package/dist/vue-wiring-diagram.es.js +4501 -4488
- package/dist/vue-wiring-diagram.umd.js +35 -35
- package/package.json +1 -1
- package/packages/components/Shortcuts.vue +31 -31
- package/packages/components/baseShape.js +62 -62
- package/packages/components/common.js +105 -105
- package/packages/components/edge-control/arrow-line.vue +292 -292
- package/packages/components/edge-control/condition.vue +110 -110
- package/packages/components/edge-control/default-line.vue +156 -156
- package/packages/components/edge-control/index.vue +94 -94
- package/packages/components/edge-control/pipe-line.vue +354 -354
- package/packages/components/editor/index.vue +590 -590
- package/packages/components/enums.js +80 -80
- package/packages/components/graph-control/index.vue +121 -121
- package/packages/components/image-control/group-form.vue +114 -114
- package/packages/components/image-control/image-condition.vue +117 -117
- package/packages/components/image-control/image-form.vue +184 -184
- package/packages/components/image-control/image-management.vue +213 -213
- package/packages/components/image-control/index.vue +290 -290
- package/packages/components/portsOptions.js +21 -21
- package/packages/components/preview/index.vue +399 -399
- package/packages/components/settings.js +262 -262
- package/packages/components/text-control/index.vue +472 -457
- package/packages/components/tools.js +256 -256
- package/packages/http.js +104 -104
- package/packages/index.js +43 -43
- package/packages/styles/animation.scss +27 -27
- package/packages/styles/dialog.scss +4 -4
- package/packages/styles/editor.scss +165 -165
- package/packages/styles/elPath.scss +257 -257
|
@@ -1,457 +1,472 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Author: HuaYJ
|
|
3
|
-
* @Date: 2024/10/22 15:03
|
|
4
|
-
*/
|
|
5
|
-
<template>
|
|
6
|
-
<div class="control">
|
|
7
|
-
<el-collapse v-model="activeName" accordion>
|
|
8
|
-
<el-collapse-item title="文本内容" name="0" v-if="payload.data.type === 'text'">
|
|
9
|
-
<el-input ref="inputRef" type="textarea" v-model="text" @input="changeContent" @blur="leaveInput"
|
|
10
|
-
:rows="10"></el-input>
|
|
11
|
-
<el-alert type="info" title="提示"
|
|
12
|
-
description="请先选择设备,再选择字段,最后点击确定按钮,即可绑定设备数据。绑定完成后会由 $<> 进行包裹!"
|
|
13
|
-
style="margin-top: 20px;"></el-alert>
|
|
14
|
-
<el-select v-model="deviceCode" placeholder="请选择设备" @change="checkDevice" filterable clearable
|
|
15
|
-
style="margin-top: 20px">
|
|
16
|
-
<el-option v-for="item in deviceList" :key="item.deviceCode" :label="item.deviceName"
|
|
17
|
-
:value="item.deviceCode"/>
|
|
18
|
-
</el-select>
|
|
19
|
-
<el-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<el-table-column
|
|
23
|
-
<el-table-column prop="
|
|
24
|
-
<el-table-column prop="
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
<el-button type="primary" @click="
|
|
127
|
-
<el-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
</
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
import {
|
|
163
|
-
import {
|
|
164
|
-
import {
|
|
165
|
-
import {
|
|
166
|
-
import {
|
|
167
|
-
import {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
//
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @Author: HuaYJ
|
|
3
|
+
* @Date: 2024/10/22 15:03
|
|
4
|
+
*/
|
|
5
|
+
<template>
|
|
6
|
+
<div class="control">
|
|
7
|
+
<el-collapse v-model="activeName" accordion>
|
|
8
|
+
<el-collapse-item title="文本内容" name="0" v-if="payload.data.type === 'text'">
|
|
9
|
+
<el-input ref="inputRef" type="textarea" v-model="text" @input="changeContent" @blur="leaveInput"
|
|
10
|
+
:rows="10"></el-input>
|
|
11
|
+
<el-alert type="info" title="提示"
|
|
12
|
+
description="请先选择设备,再选择字段,最后点击确定按钮,即可绑定设备数据。绑定完成后会由 $<> 进行包裹!"
|
|
13
|
+
style="margin-top: 20px;"></el-alert>
|
|
14
|
+
<el-select v-model="deviceCode" placeholder="请选择设备" @change="checkDevice" filterable clearable
|
|
15
|
+
style="margin-top: 20px">
|
|
16
|
+
<el-option v-for="item in deviceList" :key="item.deviceCode" :label="item.deviceName"
|
|
17
|
+
:value="item.deviceCode"/>
|
|
18
|
+
</el-select>
|
|
19
|
+
<el-input v-model="deviceName" placeholder="请输入设备名称" clearable style="margin-top: 5px"/>
|
|
20
|
+
<el-table :data="filterFieldList" border style="margin-top: 20px;" size="small" height="500"
|
|
21
|
+
@row-click="checkField">
|
|
22
|
+
<el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
|
|
23
|
+
<el-table-column prop="name" label="字段名称" show-overflow-tooltip></el-table-column>
|
|
24
|
+
<el-table-column prop="dataField" label="字段编码" show-overflow-tooltip></el-table-column>
|
|
25
|
+
<el-table-column prop="unit" label="单位" width="50"></el-table-column>
|
|
26
|
+
</el-table>
|
|
27
|
+
</el-collapse-item>
|
|
28
|
+
<el-collapse-item title="图形设置" name="1">
|
|
29
|
+
<div class="row-column">
|
|
30
|
+
<el-row :gutter="20">
|
|
31
|
+
<el-col :span="12">
|
|
32
|
+
<div class="row-label">背景颜色</div>
|
|
33
|
+
</el-col>
|
|
34
|
+
<el-col :span="12">
|
|
35
|
+
<el-color-picker v-model="background" :show-alpha="true" size="small" @change="changeText"/>
|
|
36
|
+
</el-col>
|
|
37
|
+
</el-row>
|
|
38
|
+
<el-row :gutter="20">
|
|
39
|
+
<el-col :span="12">
|
|
40
|
+
<div class="row-label">边框颜色</div>
|
|
41
|
+
</el-col>
|
|
42
|
+
<el-col :span="12">
|
|
43
|
+
<el-color-picker v-model="stroke" :show-alpha="true" size="small" @change="changeText"/>
|
|
44
|
+
</el-col>
|
|
45
|
+
</el-row>
|
|
46
|
+
<el-row :gutter="20">
|
|
47
|
+
<el-col :span="12">
|
|
48
|
+
<div class="row-label">边框宽度</div>
|
|
49
|
+
</el-col>
|
|
50
|
+
<el-col :span="12">
|
|
51
|
+
<el-input-number v-model="strokeWidth" size="small" controls-position="right"
|
|
52
|
+
@change="changeText" :min="0" :max="10" :step="1"/>
|
|
53
|
+
</el-col>
|
|
54
|
+
</el-row>
|
|
55
|
+
<el-row :gutter="20">
|
|
56
|
+
<el-col :span="12">
|
|
57
|
+
<div class="row-label">背景圆角rx</div>
|
|
58
|
+
</el-col>
|
|
59
|
+
<el-col :span="12">
|
|
60
|
+
<el-input-number v-model="rx" size="small" controls-position="right" @change="changeText"
|
|
61
|
+
:min="0" :max="50" :step="1"/>
|
|
62
|
+
</el-col>
|
|
63
|
+
</el-row>
|
|
64
|
+
<el-row :gutter="20">
|
|
65
|
+
<el-col :span="12">
|
|
66
|
+
<div class="row-label">背景圆角ry</div>
|
|
67
|
+
</el-col>
|
|
68
|
+
<el-col :span="12">
|
|
69
|
+
<el-input-number v-model="ry" size="small" controls-position="right" @change="changeText"
|
|
70
|
+
:min="0" :max="50" :step="1"/>
|
|
71
|
+
</el-col>
|
|
72
|
+
</el-row>
|
|
73
|
+
</div>
|
|
74
|
+
</el-collapse-item>
|
|
75
|
+
<el-collapse-item title="文字设置" name="2" v-if="payload.data.type === 'text'">
|
|
76
|
+
<div class="row-column">
|
|
77
|
+
<el-row :gutter="20">
|
|
78
|
+
<el-col :span="12">
|
|
79
|
+
<div class="row-label">字体颜色</div>
|
|
80
|
+
</el-col>
|
|
81
|
+
<el-col :span="12">
|
|
82
|
+
<el-color-picker v-model="color" :show-alpha="true" size="small" @change="changeText"/>
|
|
83
|
+
</el-col>
|
|
84
|
+
</el-row>
|
|
85
|
+
<el-row :gutter="20">
|
|
86
|
+
<el-col :span="12">
|
|
87
|
+
<div class="row-label">字体大小</div>
|
|
88
|
+
</el-col>
|
|
89
|
+
<el-col :span="12">
|
|
90
|
+
<el-input-number v-model="size" size="small" controls-position="right" @change="changeText"
|
|
91
|
+
:min="12" :max="48" :step="2"/>
|
|
92
|
+
</el-col>
|
|
93
|
+
</el-row>
|
|
94
|
+
<el-row :gutter="20">
|
|
95
|
+
<el-col :span="12">
|
|
96
|
+
<div class="row-label">对齐方式</div>
|
|
97
|
+
</el-col>
|
|
98
|
+
<el-col :span="12">
|
|
99
|
+
<el-select v-model="textAnchor" size="small" @change="changeText">
|
|
100
|
+
<el-option v-for="item in ['start', 'middle', 'end']" :key="item" :label="item"
|
|
101
|
+
:value="item"/>
|
|
102
|
+
</el-select>
|
|
103
|
+
</el-col>
|
|
104
|
+
</el-row>
|
|
105
|
+
<el-row :gutter="20">
|
|
106
|
+
<el-col :span="12">
|
|
107
|
+
<div class="row-label">x轴偏移</div>
|
|
108
|
+
</el-col>
|
|
109
|
+
<el-col :span="12">
|
|
110
|
+
<el-input-number v-model="x" size="small" controls-position="right" @change="changeText"
|
|
111
|
+
:min="0" :max="100" :step="1"/>
|
|
112
|
+
</el-col>
|
|
113
|
+
</el-row>
|
|
114
|
+
<el-row :gutter="20">
|
|
115
|
+
<el-col :span="12">
|
|
116
|
+
<div class="row-label">y轴偏移</div>
|
|
117
|
+
</el-col>
|
|
118
|
+
<el-col :span="12">
|
|
119
|
+
<el-input-number v-model="y" size="small" controls-position="right" @change="changeText"
|
|
120
|
+
:min="0" :max="100" :step="1"/>
|
|
121
|
+
</el-col>
|
|
122
|
+
</el-row>
|
|
123
|
+
</div>
|
|
124
|
+
</el-collapse-item>
|
|
125
|
+
<el-collapse-item title="连接桩设置" name="3">
|
|
126
|
+
<el-button type="primary" @click="addPorts" size="small">添加连接桩</el-button>
|
|
127
|
+
<el-button type="primary" @click="showPort" size="small">显示连接桩</el-button>
|
|
128
|
+
<el-table :data="ports" border size="small" style="margin-top: 10px;">
|
|
129
|
+
<el-table-column label="ID" width="50" align="center">
|
|
130
|
+
<template v-slot="{row}">
|
|
131
|
+
{{ row.attrs.text.text }}
|
|
132
|
+
</template>
|
|
133
|
+
</el-table-column>
|
|
134
|
+
<el-table-column label="x" width="100" align="center">
|
|
135
|
+
<template v-slot="{row}">
|
|
136
|
+
<el-slider v-model="row.args.x" :min="0" :max="100" :step="1"
|
|
137
|
+
@input="(e) => changePorts(row.id, 'x', e)"/>
|
|
138
|
+
</template>
|
|
139
|
+
</el-table-column>
|
|
140
|
+
<el-table-column label="y" width="100" align="center">
|
|
141
|
+
<template v-slot="{row}">
|
|
142
|
+
<el-slider v-model="row.args.y" :min="0" :max="100" :step="1"
|
|
143
|
+
@input="(e) => changePorts(row.id, 'y', e)"/>
|
|
144
|
+
</template>
|
|
145
|
+
</el-table-column>
|
|
146
|
+
<el-table-column label="操作" align="center">
|
|
147
|
+
<template v-slot="{row}">
|
|
148
|
+
<el-button type="danger" size="small" @click="deletePort(row.id)">
|
|
149
|
+
<el-icon>
|
|
150
|
+
<delete-filled/>
|
|
151
|
+
</el-icon>
|
|
152
|
+
</el-button>
|
|
153
|
+
</template>
|
|
154
|
+
</el-table-column>
|
|
155
|
+
</el-table>
|
|
156
|
+
</el-collapse-item>
|
|
157
|
+
</el-collapse>
|
|
158
|
+
</div>
|
|
159
|
+
</template>
|
|
160
|
+
|
|
161
|
+
<script setup>
|
|
162
|
+
import {nextTick, onMounted, reactive, ref, watch,} from "vue";
|
|
163
|
+
import {DeleteFilled} from '@element-plus/icons-vue'
|
|
164
|
+
import {getFieldList, showPorts} from "../common.js";
|
|
165
|
+
import {ElMessageBox} from "element-plus";
|
|
166
|
+
import {portOption} from "../settings.js";
|
|
167
|
+
import {defaultMatch, defaultText} from "packages/components/tools.js";
|
|
168
|
+
import {getDeviceList} from "/packages/components/common.js";
|
|
169
|
+
|
|
170
|
+
defineOptions({
|
|
171
|
+
name: 'text-control'
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
const props = defineProps({
|
|
175
|
+
payload: Object,
|
|
176
|
+
itemId: {
|
|
177
|
+
type: String,
|
|
178
|
+
default: ''
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
const activeName = ref(props.payload.attrs.label?.textAnchor ? '0' : '1') // 激活的折叠面板
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
const deviceList = ref([]) // 设备列表
|
|
186
|
+
const fieldList = ref([])
|
|
187
|
+
const filterFieldList = ref([])
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* 获取设备列表
|
|
191
|
+
*/
|
|
192
|
+
const getDevices = async () => {
|
|
193
|
+
deviceList.value = await getDeviceList(props.itemId)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const deviceCode = ref() // 设备编码
|
|
197
|
+
const deviceName = ref() // 设备名称
|
|
198
|
+
|
|
199
|
+
watch(
|
|
200
|
+
() => deviceName.value,
|
|
201
|
+
(v) => {
|
|
202
|
+
if (v) {
|
|
203
|
+
filterFieldList.value = fieldList.value.filter(item => item.name.includes(v))
|
|
204
|
+
} else {
|
|
205
|
+
filterFieldList.value = fieldList.value
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
let currentDevice = reactive({}) // 当前设备信息
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* 监听设备编码变化
|
|
214
|
+
*/
|
|
215
|
+
const checkDevice = () => {
|
|
216
|
+
currentDevice = deviceList.value.find(item => item.deviceCode === deviceCode.value)
|
|
217
|
+
if (currentDevice) {
|
|
218
|
+
getFields()
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 获取字段列表
|
|
224
|
+
*/
|
|
225
|
+
const getFields = async () => {
|
|
226
|
+
filterFieldList.value = fieldList.value = await getFieldList(currentDevice.deviceCode)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
const replace = (str) => {
|
|
231
|
+
return str.replace(defaultMatch, defaultText)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* 监听字段变化
|
|
236
|
+
* @param row
|
|
237
|
+
*/
|
|
238
|
+
const checkField = (row) => {
|
|
239
|
+
ElMessageBox.confirm(`是否确定要添加${currentDevice.deviceName}-${row.name}?\n 添加后为:--${row.unit ?? ''}`, '提示', {
|
|
240
|
+
confirmButtonText: '确定',
|
|
241
|
+
cancelButtonText: '取消',
|
|
242
|
+
type: 'warning'
|
|
243
|
+
}).then(() => {
|
|
244
|
+
const unit = row.unit ?? ''
|
|
245
|
+
const content = props.payload.data.content
|
|
246
|
+
console.log(cursorPosition.value)
|
|
247
|
+
if (cursorPosition.value) {
|
|
248
|
+
// 在记录的光标位置后面添加字段
|
|
249
|
+
props.payload.data.content = text.value = content.slice(0, cursorPosition.value) + '${' + currentDevice.deviceName + '.' + row.name + '}' + unit + content.slice(cursorPosition.value)
|
|
250
|
+
} else {
|
|
251
|
+
props.payload.data.content = text.value = content + '${' + currentDevice.deviceName + '.' + row.name + '}' + unit
|
|
252
|
+
}
|
|
253
|
+
// 查找所有${}
|
|
254
|
+
const matches = content.match(defaultMatch)
|
|
255
|
+
const index = matches?.length || 0
|
|
256
|
+
props.payload.data.fields.push({
|
|
257
|
+
index: index,
|
|
258
|
+
deviceName: currentDevice.deviceName,
|
|
259
|
+
deviceCode: currentDevice.deviceCode,
|
|
260
|
+
field: row.dataField,
|
|
261
|
+
fieldName: row.name,
|
|
262
|
+
})
|
|
263
|
+
props.payload.label = replace(props.payload.data.content)
|
|
264
|
+
console.log(props.payload.data.content, props.payload.data.fields)
|
|
265
|
+
})
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const text = ref(props.payload.data.content || null) // 文本内容
|
|
269
|
+
const background = ref(props.payload.attrs.body.fill || null) // 背景颜色
|
|
270
|
+
const stroke = ref(props.payload.attrs.body.stroke || null) // 边框颜色
|
|
271
|
+
const strokeWidth = ref(props.payload.attrs.body.strokeWidth || null) // 边框宽度
|
|
272
|
+
const rx = ref(props.payload.attrs.body.rx || null) // 圆角
|
|
273
|
+
const ry = ref(props.payload.attrs.body.ry || null) // 圆角
|
|
274
|
+
const color = ref(props.payload.attrs.text.fill || null) // 文字颜色
|
|
275
|
+
const size = ref(props.payload.attrs.text.fontSize || null) // 文字大小
|
|
276
|
+
const textAnchor = ref(props.payload.attrs.label?.textAnchor || null) // 文字对齐方式
|
|
277
|
+
const x = ref(props.payload.attrs.label?.x || null) // x轴偏移
|
|
278
|
+
const y = ref(props.payload.attrs.label?.y || null)
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* 编辑文字
|
|
282
|
+
*/
|
|
283
|
+
const changeText = () => {
|
|
284
|
+
props.payload.attr('body/fill', background.value)
|
|
285
|
+
props.payload.attr('body/stroke', stroke.value)
|
|
286
|
+
props.payload.attr('body/strokeWidth', strokeWidth.value)
|
|
287
|
+
props.payload.attr('body/rx', rx.value)
|
|
288
|
+
props.payload.attr('body/ry', ry.value)
|
|
289
|
+
props.payload.attr('text/fill', color.value)
|
|
290
|
+
props.payload.attr('text/fontSize', size.value)
|
|
291
|
+
props.payload.attr('label/textAnchor', textAnchor.value)
|
|
292
|
+
props.payload.attr('label/x', x.value)
|
|
293
|
+
props.payload.attr('label/y', y.value)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const inputRef = ref(null)
|
|
297
|
+
const forbiddenRegex = /[\$\{|\}]/g;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* 编辑内容
|
|
301
|
+
*/
|
|
302
|
+
const changeContent = (currentValue) => {
|
|
303
|
+
if (forbiddenRegex.test(currentValue)) {
|
|
304
|
+
text.value = text.value.slice(0, -1)
|
|
305
|
+
}
|
|
306
|
+
const content = props.payload.data.content
|
|
307
|
+
|
|
308
|
+
if (currentValue.length < content.length) {
|
|
309
|
+
const {deleted, start, end} = getDeletedSubstring(content, currentValue);
|
|
310
|
+
if (deleted === '}') {
|
|
311
|
+
// 找到前面的"${" 删除
|
|
312
|
+
const startIndex = content.lastIndexOf('${', start)
|
|
313
|
+
const deleteContent = content.substring(startIndex, start) + '}'
|
|
314
|
+
text.value = content.replace(deleteContent, '')
|
|
315
|
+
// 字符串去掉'${'和'}'
|
|
316
|
+
const matchedContent = deleteContent.replace(/[${}]/g, '')
|
|
317
|
+
props.payload.data.fields = props.payload.data.fields.filter(item => {
|
|
318
|
+
return item.deviceName + '.' + item.fieldName !== matchedContent
|
|
319
|
+
})
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// 正常更新
|
|
324
|
+
props.payload.data.content = text.value;
|
|
325
|
+
props.payload.label = replace(text.value);
|
|
326
|
+
console.log(props.payload.data.content, props.payload.data.fields);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const getDeletedSubstring = (oldStr, newStr) => {
|
|
330
|
+
let i = 0;
|
|
331
|
+
let j = 0;
|
|
332
|
+
|
|
333
|
+
// 找到第一个不相同的字符位置
|
|
334
|
+
while (i < oldStr.length && j < newStr.length && oldStr[i] === newStr[j]) {
|
|
335
|
+
i++;
|
|
336
|
+
j++;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// 如果新字符串已经结束,则后续都是被删除的内容
|
|
340
|
+
if (j === newStr.length && i < oldStr.length) {
|
|
341
|
+
return {
|
|
342
|
+
deleted: oldStr.slice(i),
|
|
343
|
+
start: i,
|
|
344
|
+
end: oldStr.length
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// 向后尝试匹配剩余部分,找到最短删除范围
|
|
349
|
+
let k = oldStr.length - 1;
|
|
350
|
+
let l = newStr.length - 1;
|
|
351
|
+
|
|
352
|
+
while (k > i && l > j && oldStr[k] === newStr[l]) {
|
|
353
|
+
k--;
|
|
354
|
+
l--;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const deleted = oldStr.slice(i, k);
|
|
358
|
+
return {
|
|
359
|
+
deleted,
|
|
360
|
+
start: i,
|
|
361
|
+
end: k
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// 记录光标位置
|
|
366
|
+
const cursorPosition = ref(null)
|
|
367
|
+
|
|
368
|
+
const leaveInput = () => {
|
|
369
|
+
const inputElement = inputRef.value?.$refs.textarea;
|
|
370
|
+
cursorPosition.value = inputElement.selectionStart;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
const ports = ref([]) // 连接桩数据
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* 获取连接桩数据
|
|
378
|
+
*/
|
|
379
|
+
const getPorts = () => {
|
|
380
|
+
ports.value = JSON.parse(JSON.stringify(props.payload.getPorts().map((item) => {
|
|
381
|
+
return {
|
|
382
|
+
id: item.id,
|
|
383
|
+
attrs: item.attrs,
|
|
384
|
+
args: {
|
|
385
|
+
x: Number(item.args.x.replace('%', '')),
|
|
386
|
+
y: Number(item.args.y.replace('%', ''))
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
})))
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* 添加连接桩
|
|
394
|
+
*/
|
|
395
|
+
const addPorts = () => {
|
|
396
|
+
const port = portOption
|
|
397
|
+
port.attrs.text.text = `${props.payload.getPorts().length + 1}`
|
|
398
|
+
port.args.x = '50%'
|
|
399
|
+
port.args.y = '50%'
|
|
400
|
+
props.payload.addPorts([
|
|
401
|
+
{
|
|
402
|
+
group: 'ports',
|
|
403
|
+
...port
|
|
404
|
+
},
|
|
405
|
+
])
|
|
406
|
+
getPorts()
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* 显示连接桩
|
|
411
|
+
*/
|
|
412
|
+
const showPort = () => {
|
|
413
|
+
showPorts("#drawing-board", true)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* 修改连接桩
|
|
418
|
+
* @param id
|
|
419
|
+
* @param key
|
|
420
|
+
* @param value
|
|
421
|
+
*/
|
|
422
|
+
const changePorts = (id, key, value) => {
|
|
423
|
+
props.payload.portProp(id, 'args/' + key, value + '%')
|
|
424
|
+
getPorts()
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* 删除连接桩
|
|
429
|
+
* @param id
|
|
430
|
+
*/
|
|
431
|
+
const deletePort = (id) => {
|
|
432
|
+
props.payload.removePort(id)
|
|
433
|
+
getPorts()
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
onMounted(() => {
|
|
438
|
+
getPorts()
|
|
439
|
+
getDevices()
|
|
440
|
+
|
|
441
|
+
nextTick(() => {
|
|
442
|
+
document.addEventListener('selectionchange', () => {
|
|
443
|
+
if (!inputRef.value) {
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
const inputElement = inputRef.value?.$refs.textarea;
|
|
447
|
+
const cursorPosition = inputElement.selectionStart;
|
|
448
|
+
const content = text.value;
|
|
449
|
+
const regex = /\$\{.*?\}/g;
|
|
450
|
+
let match;
|
|
451
|
+
|
|
452
|
+
while ((match = regex.exec(content)) !== null) {
|
|
453
|
+
const start = match.index;
|
|
454
|
+
const end = regex.lastIndex;
|
|
455
|
+
|
|
456
|
+
if (cursorPosition > start && cursorPosition < end) {
|
|
457
|
+
console.log('光标位于字段:', match[0]);
|
|
458
|
+
// 设置光标到往后的第一个}符号后面
|
|
459
|
+
inputElement.setSelectionRange(end, end);
|
|
460
|
+
return true; // 光标在 ${...} 内
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
console.log('光标不在任何字段内');
|
|
464
|
+
return false;
|
|
465
|
+
})
|
|
466
|
+
})
|
|
467
|
+
})
|
|
468
|
+
</script>
|
|
469
|
+
|
|
470
|
+
<style scoped lang="scss">
|
|
471
|
+
@use "../../styles/editor.scss";
|
|
472
|
+
</style>
|