vue-wiring-diagram 1.1.25 → 1.1.27

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 (32) hide show
  1. package/README.md +93 -93
  2. package/dist/style.css +1 -1
  3. package/dist/vue-wiring-diagram.es.js +6762 -6756
  4. package/dist/vue-wiring-diagram.umd.js +37 -37
  5. package/package.json +1 -1
  6. package/packages/components/Shortcuts.vue +31 -31
  7. package/packages/components/baseShape.js +62 -62
  8. package/packages/components/common.js +123 -105
  9. package/packages/components/edge-control/arrow-line.vue +292 -292
  10. package/packages/components/edge-control/condition.vue +110 -110
  11. package/packages/components/edge-control/default-line.vue +156 -156
  12. package/packages/components/edge-control/index.vue +94 -94
  13. package/packages/components/edge-control/pipe-line.vue +395 -354
  14. package/packages/components/editor/index.vue +590 -590
  15. package/packages/components/enums.js +80 -80
  16. package/packages/components/graph-control/index.vue +121 -121
  17. package/packages/components/image-control/group-form.vue +114 -114
  18. package/packages/components/image-control/image-condition.vue +117 -117
  19. package/packages/components/image-control/image-form.vue +184 -184
  20. package/packages/components/image-control/image-management.vue +213 -213
  21. package/packages/components/image-control/index.vue +290 -290
  22. package/packages/components/portsOptions.js +21 -21
  23. package/packages/components/preview/index.vue +410 -400
  24. package/packages/components/settings.js +262 -262
  25. package/packages/components/text-control/index.vue +472 -457
  26. package/packages/components/tools.js +256 -256
  27. package/packages/http.js +104 -104
  28. package/packages/index.js +43 -43
  29. package/packages/styles/animation.scss +27 -27
  30. package/packages/styles/dialog.scss +4 -4
  31. package/packages/styles/editor.scss +165 -165
  32. package/packages/styles/elPath.scss +267 -257
@@ -1,354 +1,395 @@
1
- /**
2
- * @Author: HuaYJ
3
- * @Date: 2024/10/24 09:42
4
- */
5
- <template>
6
- <div class="container">
7
- <el-collapse v-model="activeName" accordion>
8
- <el-collapse-item title="线段设置" name="0">
9
- <div class="row-column">
10
- <el-row :gutter="20">
11
- <el-col :span="12">
12
- <div class="row-label">颜色1</div>
13
- </el-col>
14
- <el-col :span="12">
15
- <el-color-picker v-model="stroke1" :show-alpha="true" size="small" @change="changeLine"/>
16
- </el-col>
17
- </el-row>
18
- <el-row :gutter="20">
19
- <el-col :span="12">
20
- <div class="row-label">颜色2</div>
21
- </el-col>
22
- <el-col :span="12">
23
- <el-color-picker v-model="stroke2" :show-alpha="true" size="small" @change="changeLine"/>
24
- </el-col>
25
- </el-row>
26
- <el-row :gutter="20">
27
- <el-col :span="12">
28
- <div class="row-label">粗细</div>
29
- </el-col>
30
- <el-col :span="12">
31
- <el-input-number v-model="strokeWidth" size="small" controls-position="right"
32
- @change="changeLine" :min="1" :max="10"
33
- :step="1"/>
34
- </el-col>
35
- </el-row>
36
- </div>
37
- </el-collapse-item>
38
- <el-collapse-item title="管道设置" name="1">
39
- <div class="row-column">
40
- <el-row :gutter="20">
41
- <el-col :span="12">
42
- <div class="row-label">管道间隔</div>
43
- </el-col>
44
- <el-col :span="12">
45
- <el-input-number v-model="strokeDasharray" size="small" controls-position="right"
46
- @change="changeLine" :min="5" :max="100"
47
- :step="1"/>
48
- </el-col>
49
- </el-row>
50
- <el-row :gutter="20">
51
- <el-col :span="12">
52
- <div class="row-label">默认流动方向</div>
53
- </el-col>
54
- <el-col :span="12">
55
- <el-select v-model="strokeDashoffset" placeholder="请选择管道方向" size="small"
56
- @change="changeLine">
57
- <el-option v-for="item in directionList" :key="item.value" :label="item.label"
58
- :value="item.value">
59
- </el-option>
60
- </el-select>
61
- </el-col>
62
- </el-row>
63
- <el-row :gutter="20">
64
- <el-col :span="12">
65
- <div class="row-label">参数设置</div>
66
- </el-col>
67
- <el-col :span="12">
68
- <el-select v-model="deviceCode" placeholder="请选择设备" @change="checkDevice" size="small"
69
- filterable clearable>
70
- <el-option v-for="item in deviceList" :key="item.deviceCode" :label="item.deviceName"
71
- :value="item.deviceCode"/>
72
- </el-select>
73
- <el-select v-model="fieldCode" placeholder="请选择字段" @change="checkField" size="small"
74
- filterable clearable style="margin-top: 10px">
75
- <el-option v-for="item in fieldList" :key="item.dataField" :label="item.name"
76
- :value="item.dataField"/>
77
- </el-select>
78
- </el-col>
79
- </el-row>
80
- <el-row :gutter="20">
81
- <el-col :span="12">
82
- <div class="row-label">条件配置</div>
83
- </el-col>
84
- <el-col :span="12">
85
- <el-switch v-model="isCondition" :active-value="true" :inactive-value="false" size="small"
86
- @change="changeCondition"/>
87
- <el-button type="primary" size="small" @click="showCondition" style="margin-left: 10px">
88
- 配置
89
- </el-button>
90
- </el-col>
91
- </el-row>
92
- </div>
93
- </el-collapse-item>
94
- <el-collapse-item title="箭头1设置" name="2">
95
- <div class="row-column">
96
- <el-row :gutter="20">
97
- <el-col :span="12">
98
- <div class="row-label">类型</div>
99
- </el-col>
100
- <el-col :span="12">
101
- <el-select v-model="sourceMarker.name" placeholder="请选择箭头类型" clearable size="small"
102
- @change="changeLine">
103
- <el-option v-for="item in arrowList" :key="item.value" :label="item.label"
104
- :value="item.value">
105
- </el-option>
106
- </el-select>
107
- </el-col>
108
- </el-row>
109
- <el-row :gutter="20">
110
- <el-col :span="12">
111
- <div class="row-label">宽</div>
112
- </el-col>
113
- <el-col :span="12">
114
- <el-input-number v-model="sourceMarker.args.width" size="small" controls-position="right"
115
- @change="changeLine" :min="0" :max="10"
116
- :step="1"/>
117
- </el-col>
118
- </el-row>
119
- <el-row :gutter="20">
120
- <el-col :span="12">
121
- <div class="row-label">高</div>
122
- </el-col>
123
- <el-col :span="12">
124
- <el-input-number v-model="sourceMarker.args.height" size="small" controls-position="right"
125
- @change="changeLine" :min="0" :max="10"
126
- :step="1"/>
127
- </el-col>
128
- </el-row>
129
- <el-row :gutter="20">
130
- <el-col :span="12">
131
- <div class="row-label">偏移</div>
132
- </el-col>
133
- <el-col :span="12">
134
- <el-input-number v-model="sourceMarker.args.offset" size="small" controls-position="right"
135
- @change="changeLine" :min="0" :max="10"
136
- :step="1"/>
137
- </el-col>
138
- </el-row>
139
- </div>
140
- </el-collapse-item>
141
- <el-collapse-item title="箭头2设置" name="3">
142
- <div class="row-column">
143
- <el-row :gutter="20">
144
- <el-col :span="12">
145
- <div class="row-label">类型</div>
146
- </el-col>
147
- <el-col :span="12">
148
- <el-select v-model="targetMarker.name" placeholder="请选择箭头类型" clearable size="small"
149
- @change="changeLine">
150
- <el-option v-for="item in arrowList" :key="item.value" :label="item.label"
151
- :value="item.value">
152
- </el-option>
153
- </el-select>
154
- </el-col>
155
- </el-row>
156
- <el-row :gutter="20">
157
- <el-col :span="12">
158
- <div class="row-label">宽</div>
159
- </el-col>
160
- <el-col :span="12">
161
- <el-input-number v-model="targetMarker.args.width" size="small" controls-position="right"
162
- @change="changeLine" :min="0" :max="10"
163
- :step="1"/>
164
- </el-col>
165
- </el-row>
166
- <el-row :gutter="20">
167
- <el-col :span="12">
168
- <div class="row-label">高</div>
169
- </el-col>
170
- <el-col :span="12">
171
- <el-input-number v-model="targetMarker.args.height" size="small" controls-position="right"
172
- @change="changeLine" :min="0" :max="10"
173
- :step="1"/>
174
- </el-col>
175
- </el-row>
176
- <el-row :gutter="20">
177
- <el-col :span="12">
178
- <div class="row-label">偏移</div>
179
- </el-col>
180
- <el-col :span="12">
181
- <el-input-number v-model="targetMarker.args.offset" size="small" controls-position="right"
182
- @change="changeLine" :min="0" :max="10"
183
- :step="1"/>
184
- </el-col>
185
- </el-row>
186
- </div>
187
- </el-collapse-item>
188
- </el-collapse>
189
- <el-dialog v-model="dialogCondition.show" width="500px" title="条件配置" :show-close="false"
190
- :close-on-click-modal="false"
191
- :close-on-press-escape="false">
192
- <condition v-if="dialogCondition.show" :payload="dialogCondition.payload" type="pipe"
193
- @close="closeCondition"></condition>
194
- </el-dialog>
195
- </div>
196
- </template>
197
-
198
- <script setup>
199
- import {onMounted, reactive, ref} from "vue";
200
- import {lineOptions} from "../settings.js";
201
- import {setPipeDirection} from "packages/components/tools.js";
202
- import {arrowList, directionList, STOP, typeList} from "packages/components/enums.js";
203
- import Condition from "packages/components/edge-control/condition.vue";
204
- import {getDeviceList, getFieldList} from "packages/components/common.js";
205
-
206
- const props = defineProps({
207
- payload: Object,
208
- itemId: {
209
- type: String,
210
- default: ''
211
- }
212
- })
213
-
214
- const activeName = ref('0')
215
-
216
- const stroke1 = ref(props.payload.attrs.line.stroke)
217
- const stroke2 = ref(props.payload.attrs.pipe.stroke)
218
- const strokeWidth = ref(props.payload.attrs.line.strokeWidth)
219
- const strokeDasharray = ref(props.payload.attrs.pipe.strokeDasharray)
220
- const strokeDashoffset = ref(props.payload.attrs.pipe?.style?.animation.split(' ')[0] ?? STOP)
221
- const sourceMarker = reactive({
222
- name: props.payload.attrs.pipe.sourceMarker?.name ?? null,
223
- args: props.payload.attrs.pipe.sourceMarker?.args ?? {}
224
- })
225
- const targetMarker = reactive({
226
- name: props.payload.attrs.pipe.targetMarker?.name ?? null,
227
- args: props.payload.attrs.pipe.targetMarker?.args ?? {}
228
- })
229
-
230
- /**
231
- * 线段属性改变
232
- */
233
- const changeLine = () => {
234
- props.payload.attr('line/stroke', stroke1.value)
235
- props.payload.attr('pipe/stroke', stroke2.value)
236
- props.payload.attr('line/strokeWidth', strokeWidth.value)
237
- props.payload.attr('pipe/strokeWidth', strokeWidth.value)
238
- props.payload.attr('pipe/strokeDasharray', strokeDasharray.value)
239
- props.payload.attr('pipe/sourceMarker/name', sourceMarker.name)
240
- props.payload.attr('pipe/sourceMarker/args', sourceMarker.args)
241
- props.payload.attr('pipe/targetMarker/name', targetMarker.name)
242
- props.payload.attr('pipe/targetMarker/args', targetMarker.args)
243
- props.payload.attr('pipe/style/animation', setPipeDirection(strokeDashoffset.value))
244
- lineOptions.markup = props.payload.markup
245
- lineOptions.attrs = props.payload.attrs
246
- console.log('线-基础配置', lineOptions)
247
- console.log('线-当前配置', props.payload)
248
- }
249
-
250
- // 条件线是否开启
251
- const isCondition = ref(props.payload.data.isCondition ?? false)
252
-
253
- /**
254
- * 条件线改变
255
- */
256
- const changeCondition = () => {
257
- props.payload.data.isCondition = isCondition.value
258
- }
259
-
260
- // 条件线配置
261
- const dialogCondition = reactive({
262
- show: false,
263
- payload: null
264
- })
265
-
266
- /**
267
- * 条件线配置显示
268
- */
269
- const showCondition = () => {
270
- dialogCondition.show = true
271
- dialogCondition.payload = props.payload.data.condition ?? []
272
- }
273
-
274
- /**
275
- * 条件线配置关闭
276
- * @param condition
277
- */
278
- const closeCondition = (condition) => {
279
- dialogCondition.show = false
280
- dialogCondition.payload = null
281
- if (condition) {
282
- props.payload.data.condition = condition
283
- }
284
- console.log('条件线', props.payload.data)
285
- }
286
-
287
- const deviceList = ref([]) // 设备列表
288
- const deviceCode = ref(props.payload.data?.fields?.[0]?.deviceCode ?? '') // 设备编码
289
- const fieldCode = ref(props.payload.data?.fields?.[0]?.field ?? '') // 字段编码
290
-
291
- /**
292
- * 获取设备列表
293
- */
294
- const getDevices = async () => {
295
- deviceList.value = await getDeviceList(props.itemId)
296
- if (deviceCode.value) {
297
- checkDevice()
298
- }
299
- }
300
-
301
- let currentDevice = reactive({}) // 当前设备信息
302
-
303
- /**
304
- * 监听设备编码变化
305
- */
306
- const checkDevice = () => {
307
- currentDevice = deviceList.value.find(item => item.deviceCode === deviceCode.value)
308
- if (currentDevice) {
309
- getFields()
310
- props.payload.data.fields = [{
311
- index: 0,
312
- deviceName: currentDevice.deviceName,
313
- deviceCode: currentDevice.deviceCode,
314
- field: fieldCode.value ?? '',
315
- }]
316
- fieldCode.value = props.payload.data.fields[0].field
317
- } else {
318
- fieldCode.value = ''
319
- props.payload.data.fields = []
320
- }
321
- console.log('管道配置', props.payload)
322
- }
323
-
324
- const fieldList = ref([])
325
-
326
- /**
327
- * 获取字段列表
328
- */
329
- const getFields = async () => {
330
- fieldList.value = await getFieldList(currentDevice.deviceCode)
331
- }
332
-
333
- /**
334
- * 监听字段编码变化
335
- */
336
- const checkField = () => {
337
- props.payload.data.fields = [{
338
- index: 0,
339
- deviceName: currentDevice.deviceName,
340
- deviceCode: currentDevice.deviceCode,
341
- field: fieldCode.value ?? '',
342
- }]
343
- console.log('管道配置', props.payload)
344
- }
345
-
346
- onMounted(() => {
347
- getDevices()
348
- })
349
- </script>
350
-
351
- <style scoped lang="scss">
352
- @use "../../styles/editor.scss";
353
-
354
- </style>
1
+ /**
2
+ * @Author: HuaYJ
3
+ * @Date: 2024/10/24 09:42
4
+ */
5
+ <template>
6
+ <div class="container">
7
+ <el-collapse v-model="activeName" accordion>
8
+ <el-collapse-item title="线段设置" name="0">
9
+ <div class="row-column">
10
+ <el-row :gutter="20">
11
+ <el-col :span="12">
12
+ <div class="row-label">颜色1</div>
13
+ </el-col>
14
+ <el-col :span="12">
15
+ <el-color-picker v-model="stroke1" :show-alpha="true" size="small" @change="changeLine"/>
16
+ </el-col>
17
+ </el-row>
18
+ <el-row :gutter="20">
19
+ <el-col :span="12">
20
+ <div class="row-label">颜色2</div>
21
+ </el-col>
22
+ <el-col :span="12">
23
+ <el-color-picker v-model="stroke2" :show-alpha="true" size="small" @change="changeLine"/>
24
+ </el-col>
25
+ </el-row>
26
+ <el-row :gutter="20">
27
+ <el-col :span="12">
28
+ <div class="row-label">粗细</div>
29
+ </el-col>
30
+ <el-col :span="12">
31
+ <el-input-number v-model="strokeWidth" size="small" controls-position="right"
32
+ @change="changeLine" :min="1" :max="10"
33
+ :step="1"/>
34
+ </el-col>
35
+ </el-row>
36
+ </div>
37
+ </el-collapse-item>
38
+ <el-collapse-item title="管道设置" name="1">
39
+ <div class="row-column">
40
+ <el-row :gutter="20">
41
+ <el-col :span="12">
42
+ <div class="row-label">管道间隔</div>
43
+ </el-col>
44
+ <el-col :span="12">
45
+ <el-input-number v-model="strokeDasharray" size="small" controls-position="right"
46
+ @change="changeLine" :min="5" :max="100"
47
+ :step="1"/>
48
+ </el-col>
49
+ </el-row>
50
+ <el-row :gutter="20">
51
+ <el-col :span="12">
52
+ <div class="row-label">默认流动方向</div>
53
+ </el-col>
54
+ <el-col :span="12">
55
+ <el-select v-model="strokeDashoffset" placeholder="请选择管道方向" size="small"
56
+ @change="changeLine">
57
+ <el-option v-for="item in directionList" :key="item.value" :label="item.label"
58
+ :value="item.value">
59
+ </el-option>
60
+ </el-select>
61
+ </el-col>
62
+ </el-row>
63
+ <el-row :gutter="20">
64
+ <el-col :span="12">
65
+ <div class="row-label">是否开启动态流向配置</div>
66
+ </el-col>
67
+ <el-col :span="12">
68
+ <el-switch v-model="isCondition" :active-value="true" :inactive-value="false" size="small"
69
+ @change="changeCondition"/>
70
+ <!-- <el-button type="primary" size="small" @click="showCondition" style="margin-left: 10px">
71
+ 配置
72
+ </el-button>-->
73
+ </el-col>
74
+ </el-row>
75
+ <transition name="el-zoom-in-top" mode="out-in">
76
+ <el-row :gutter="20" v-show="isCondition">
77
+ <el-col :span="12">
78
+ <div class="row-label">关联设备状态</div>
79
+ </el-col>
80
+ <el-col :span="12">
81
+ <!-- <el-select v-model="deviceCode" placeholder="请选择设备" @change="checkDevice" size="small"
82
+ filterable clearable>
83
+ <el-option v-for="item in deviceList" :key="item.deviceCode" :label="item.deviceName"
84
+ :value="item.deviceCode"/>
85
+ </el-select>
86
+ <el-select v-model="fieldCode" placeholder="请选择字段" @change="checkField" size="small"
87
+ filterable clearable style="margin-top: 10px">
88
+ <el-option v-for="item in fieldList" :key="item.dataField" :label="item.name"
89
+ :value="item.dataField"/>
90
+ </el-select>-->
91
+ <el-select v-model="deviceCodes" placeholder="请选择设备" multiple @change="checkDevice" size="small"
92
+ filterable clearable>
93
+ <el-option v-for="item in deviceList" :key="item.id" :label="item.deviceName"
94
+ :value="item.id"/>
95
+ </el-select>
96
+ </el-col>
97
+ </el-row>
98
+ </transition>
99
+ <transition name="el-zoom-in-top">
100
+ <el-row :gutter="20" v-show="isCondition">
101
+ <el-col :span="12">
102
+ <div class="row-label">流向设置</div>
103
+ </el-col>
104
+ <el-col :span="12">
105
+ <el-select v-model="direction" @change="changeDirection" size="small">
106
+ <el-option v-for="item in directionList" :key="item.value" :label="item.label"
107
+ :value="item.value">
108
+ </el-option>
109
+ </el-select>
110
+ </el-col>
111
+ </el-row>
112
+ </transition>
113
+ </div>
114
+ </el-collapse-item>
115
+ <el-collapse-item title="箭头1设置" name="2">
116
+ <div class="row-column">
117
+ <el-row :gutter="20">
118
+ <el-col :span="12">
119
+ <div class="row-label">类型</div>
120
+ </el-col>
121
+ <el-col :span="12">
122
+ <el-select v-model="sourceMarker.name" placeholder="请选择箭头类型" clearable size="small"
123
+ @change="changeLine">
124
+ <el-option v-for="item in arrowList" :key="item.value" :label="item.label"
125
+ :value="item.value">
126
+ </el-option>
127
+ </el-select>
128
+ </el-col>
129
+ </el-row>
130
+ <el-row :gutter="20">
131
+ <el-col :span="12">
132
+ <div class="row-label">宽</div>
133
+ </el-col>
134
+ <el-col :span="12">
135
+ <el-input-number v-model="sourceMarker.args.width" size="small" controls-position="right"
136
+ @change="changeLine" :min="0" :max="10"
137
+ :step="1"/>
138
+ </el-col>
139
+ </el-row>
140
+ <el-row :gutter="20">
141
+ <el-col :span="12">
142
+ <div class="row-label">高</div>
143
+ </el-col>
144
+ <el-col :span="12">
145
+ <el-input-number v-model="sourceMarker.args.height" size="small" controls-position="right"
146
+ @change="changeLine" :min="0" :max="10"
147
+ :step="1"/>
148
+ </el-col>
149
+ </el-row>
150
+ <el-row :gutter="20">
151
+ <el-col :span="12">
152
+ <div class="row-label">偏移</div>
153
+ </el-col>
154
+ <el-col :span="12">
155
+ <el-input-number v-model="sourceMarker.args.offset" size="small" controls-position="right"
156
+ @change="changeLine" :min="0" :max="10"
157
+ :step="1"/>
158
+ </el-col>
159
+ </el-row>
160
+ </div>
161
+ </el-collapse-item>
162
+ <el-collapse-item title="箭头2设置" name="3">
163
+ <div class="row-column">
164
+ <el-row :gutter="20">
165
+ <el-col :span="12">
166
+ <div class="row-label">类型</div>
167
+ </el-col>
168
+ <el-col :span="12">
169
+ <el-select v-model="targetMarker.name" placeholder="请选择箭头类型" clearable size="small"
170
+ @change="changeLine">
171
+ <el-option v-for="item in arrowList" :key="item.value" :label="item.label"
172
+ :value="item.value">
173
+ </el-option>
174
+ </el-select>
175
+ </el-col>
176
+ </el-row>
177
+ <el-row :gutter="20">
178
+ <el-col :span="12">
179
+ <div class="row-label">宽</div>
180
+ </el-col>
181
+ <el-col :span="12">
182
+ <el-input-number v-model="targetMarker.args.width" size="small" controls-position="right"
183
+ @change="changeLine" :min="0" :max="10"
184
+ :step="1"/>
185
+ </el-col>
186
+ </el-row>
187
+ <el-row :gutter="20">
188
+ <el-col :span="12">
189
+ <div class="row-label">高</div>
190
+ </el-col>
191
+ <el-col :span="12">
192
+ <el-input-number v-model="targetMarker.args.height" size="small" controls-position="right"
193
+ @change="changeLine" :min="0" :max="10"
194
+ :step="1"/>
195
+ </el-col>
196
+ </el-row>
197
+ <el-row :gutter="20">
198
+ <el-col :span="12">
199
+ <div class="row-label">偏移</div>
200
+ </el-col>
201
+ <el-col :span="12">
202
+ <el-input-number v-model="targetMarker.args.offset" size="small" controls-position="right"
203
+ @change="changeLine" :min="0" :max="10"
204
+ :step="1"/>
205
+ </el-col>
206
+ </el-row>
207
+ </div>
208
+ </el-collapse-item>
209
+ </el-collapse>
210
+ <!-- <el-dialog v-model="dialogCondition.show" width="500px" title="条件配置" :show-close="false"
211
+ :close-on-click-modal="false"
212
+ :close-on-press-escape="false">
213
+ <condition v-if="dialogCondition.show" :payload="dialogCondition.payload" type="pipe"
214
+ @close="closeCondition"></condition>
215
+ </el-dialog>-->
216
+ </div>
217
+ </template>
218
+
219
+ <script setup>
220
+ import {onMounted, reactive, ref} from "vue";
221
+ import {lineOptions} from "../settings.js";
222
+ import {setPipeDirection} from "packages/components/tools.js";
223
+ import {arrowList, directionList, FORWARD_PIPE, STOP, typeList} from "packages/components/enums.js";
224
+ import Condition from "packages/components/edge-control/condition.vue";
225
+ import {getDeviceList, getFieldList, getKGDeviceList} from "packages/components/common.js";
226
+
227
+ const props = defineProps({
228
+ payload: Object,
229
+ itemId: {
230
+ type: String,
231
+ default: ''
232
+ }
233
+ })
234
+
235
+ const activeName = ref('0')
236
+
237
+ const stroke1 = ref(props.payload.attrs.line.stroke)
238
+ const stroke2 = ref(props.payload.attrs.pipe.stroke)
239
+ const strokeWidth = ref(props.payload.attrs.line.strokeWidth)
240
+ const strokeDasharray = ref(props.payload.attrs.pipe.strokeDasharray)
241
+ const strokeDashoffset = ref(props.payload.attrs.pipe?.style?.animation.split(' ')[0] ?? STOP)
242
+ const sourceMarker = reactive({
243
+ name: props.payload.attrs.pipe.sourceMarker?.name ?? null,
244
+ args: props.payload.attrs.pipe.sourceMarker?.args ?? {}
245
+ })
246
+ const targetMarker = reactive({
247
+ name: props.payload.attrs.pipe.targetMarker?.name ?? null,
248
+ args: props.payload.attrs.pipe.targetMarker?.args ?? {}
249
+ })
250
+
251
+ /**
252
+ * 线段属性改变
253
+ */
254
+ const changeLine = () => {
255
+ props.payload.attr('line/stroke', stroke1.value)
256
+ props.payload.attr('pipe/stroke', stroke2.value)
257
+ props.payload.attr('line/strokeWidth', strokeWidth.value)
258
+ props.payload.attr('pipe/strokeWidth', strokeWidth.value)
259
+ props.payload.attr('pipe/strokeDasharray', strokeDasharray.value)
260
+ props.payload.attr('pipe/sourceMarker/name', sourceMarker.name)
261
+ props.payload.attr('pipe/sourceMarker/args', sourceMarker.args)
262
+ props.payload.attr('pipe/targetMarker/name', targetMarker.name)
263
+ props.payload.attr('pipe/targetMarker/args', targetMarker.args)
264
+ props.payload.attr('pipe/style/animation', setPipeDirection(strokeDashoffset.value))
265
+ lineOptions.markup = props.payload.markup
266
+ lineOptions.attrs = props.payload.attrs
267
+ console.log('线-基础配置', lineOptions)
268
+ console.log('线-当前配置', props.payload)
269
+ }
270
+
271
+ // 条件线是否开启
272
+ const isCondition = ref(props.payload.data.isCondition ?? false)
273
+
274
+ /**
275
+ * 条件线改变
276
+ */
277
+ const changeCondition = () => {
278
+ props.payload.data.isCondition = isCondition.value
279
+ props.payload.data.direction = direction.value
280
+ }
281
+
282
+ // 条件线配置
283
+ /*const dialogCondition = reactive({
284
+ show: false,
285
+ payload: null
286
+ })*/
287
+
288
+ /**
289
+ * 条件线配置显示
290
+ */
291
+ /*const showCondition = () => {
292
+ dialogCondition.show = true
293
+ dialogCondition.payload = props.payload.data.condition ?? []
294
+ }*/
295
+
296
+ /**
297
+ * 条件线配置关闭
298
+ * @param condition
299
+ */
300
+ /*const closeCondition = (condition) => {
301
+ dialogCondition.show = false
302
+ dialogCondition.payload = null
303
+ if (condition) {
304
+ props.payload.data.condition = condition
305
+ }
306
+ console.log('条件线', props.payload.data)
307
+ }*/
308
+
309
+ const deviceList = ref([]) // 设备列表
310
+ const deviceCode = ref(props.payload.data?.fields?.[0]?.deviceCode ?? '') // 设备编码
311
+ const deviceCodes = ref(props.payload.data?.fields?.map(item => item.deviceCode) ?? [])
312
+ const direction = ref(props.payload.data.direction ?? FORWARD_PIPE) // 流向
313
+ const fieldCode = ref(props.payload.data?.fields?.[0]?.field ?? '') // 字段编码
314
+
315
+ /**
316
+ * 获取设备列表
317
+ */
318
+ const getDevices = async () => {
319
+ deviceList.value = await getKGDeviceList(props.itemId)
320
+ if (deviceCode.value) {
321
+ checkDevice()
322
+ }
323
+ }
324
+
325
+ /**
326
+ * 改变流向
327
+ * @param value
328
+ */
329
+ const changeDirection = (value) => {
330
+ direction.value = value
331
+ props.payload.data.direction = value
332
+ }
333
+
334
+ let currentDevice = reactive({}) // 当前设备信息
335
+
336
+ /**
337
+ * 监听设备编码变化
338
+ */
339
+ const checkDevice = () => {
340
+ // currentDevice = deviceList.value.find(item => item.deviceCode === deviceCode.value)
341
+ // if (currentDevice) {
342
+ // getFields()
343
+ // props.payload.data.fields = [{
344
+ // deviceName: currentDevice.deviceName,
345
+ // deviceCode: currentDevice.deviceCode,
346
+ // field: fieldCode.value ?? '',
347
+ // }]
348
+ // fieldCode.value = props.payload.data.fields[0].field
349
+ // } else {
350
+ // fieldCode.value = ''
351
+ // props.payload.data.fields = []
352
+ // }
353
+
354
+ props.payload.data.fields = deviceCodes.value.map(item => {
355
+ const device = deviceList.value.find(v => v.deviceCode + v.field === item)
356
+ return {
357
+ deviceName: device.deviceName,
358
+ deviceCode: device.deviceCode,
359
+ field: device.field,
360
+ id: device.id
361
+ }
362
+ })
363
+ console.log('管道配置', props.payload)
364
+ }
365
+
366
+ const fieldList = ref([])
367
+
368
+ /**
369
+ * 获取字段列表
370
+ */
371
+ /*const getFields = async () => {
372
+ fieldList.value = await getFieldList(currentDevice.deviceCode)
373
+ }*/
374
+
375
+ /**
376
+ * 监听字段编码变化
377
+ */
378
+ /*const checkField = () => {
379
+ props.payload.data.fields = [{
380
+ deviceName: currentDevice.deviceName,
381
+ deviceCode: currentDevice.deviceCode,
382
+ field: fieldCode.value ?? '',
383
+ }]
384
+ console.log('管道配置', props.payload)
385
+ }*/
386
+
387
+ onMounted(() => {
388
+ getDevices()
389
+ })
390
+ </script>
391
+
392
+ <style scoped lang="scss">
393
+ @use "../../styles/editor.scss";
394
+
395
+ </style>