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