vue-wiring-diagram 1.0.19 → 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 +9156 -8227
- 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 +3 -3
- package/packages/components/enums.js +23 -3
- package/packages/components/image-control/image-management.vue +2 -2
- 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
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
</template>
|
|
65
65
|
|
|
66
66
|
<script setup>
|
|
67
|
-
import {
|
|
67
|
+
import {onMounted, reactive, ref, shallowRef} from "vue";
|
|
68
68
|
import moment from 'moment'
|
|
69
69
|
import {ElMessage, ElTooltip} from "element-plus";
|
|
70
70
|
import {getData, showPorts} from "../common.js";
|
|
@@ -82,7 +82,7 @@ import {portsOptions} from "../portsOptions.js";
|
|
|
82
82
|
import {Document, View, ArrowDown} from "@element-plus/icons-vue";
|
|
83
83
|
import WiringDiagramPreview from "../preview/index.vue";
|
|
84
84
|
import ImageManagement from "../image-control/image-management.vue";
|
|
85
|
-
import {get} from "packages/http.js";
|
|
85
|
+
import {get, instance} from "packages/http.js";
|
|
86
86
|
import {
|
|
87
87
|
clipboard,
|
|
88
88
|
keyboard,
|
|
@@ -291,7 +291,7 @@ const initStencil = () => {
|
|
|
291
291
|
const image = group?.pictureList.map(item => {
|
|
292
292
|
const nodeOption = {
|
|
293
293
|
shape: 'image',
|
|
294
|
-
imageUrl: item?.imageUrl,
|
|
294
|
+
imageUrl: instance.defaults.baseURL + item?.imageUrl,
|
|
295
295
|
ports: portsOptions,
|
|
296
296
|
width: 64,
|
|
297
297
|
height: 64,
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
export const LINE = 'line'
|
|
2
|
+
export const PIPE = 'pipe'
|
|
3
|
+
export const ARROW = 'arrow'
|
|
4
|
+
|
|
1
5
|
// 线类型
|
|
2
6
|
export const typeList = [{
|
|
3
7
|
label: '直线',
|
|
4
|
-
value:
|
|
8
|
+
value: LINE,
|
|
5
9
|
}, {
|
|
6
10
|
label: '管道',
|
|
7
|
-
value:
|
|
11
|
+
value: PIPE,
|
|
12
|
+
}, {
|
|
13
|
+
label: '箭头',
|
|
14
|
+
value: ARROW,
|
|
8
15
|
}]
|
|
9
16
|
|
|
10
17
|
// 箭头类型
|
|
@@ -53,8 +60,21 @@ export const directionList = [{
|
|
|
53
60
|
value: STOP,
|
|
54
61
|
}, {
|
|
55
62
|
label: '正向',
|
|
56
|
-
value: FORWARD_PIPE
|
|
63
|
+
value: FORWARD_PIPE,
|
|
57
64
|
}, {
|
|
58
65
|
label: '反向',
|
|
59
66
|
value: REVERSE_PIPE,
|
|
60
67
|
}]
|
|
68
|
+
|
|
69
|
+
export const FLASHING = 'flashing'
|
|
70
|
+
export const ARROWFORWARD = 'arrowForward'
|
|
71
|
+
export const ARROWBACKWORD = 'arrowBackward'
|
|
72
|
+
|
|
73
|
+
// 箭头方向
|
|
74
|
+
export const arrowDirection = [{
|
|
75
|
+
label: '正向',
|
|
76
|
+
value: ARROWFORWARD,
|
|
77
|
+
}, {
|
|
78
|
+
label: '反向',
|
|
79
|
+
value: ARROWBACKWORD,
|
|
80
|
+
}]
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<el-table-column label="名称" prop="imageName" align="center"></el-table-column>
|
|
15
15
|
<el-table-column label="图片" prop="imageUrl" align="center">
|
|
16
16
|
<template #default="scope">
|
|
17
|
-
<img :src="scope.row.imageUrl" alt="" style="width: 64px; height: 64px;">
|
|
17
|
+
<img :src="instance.defaults.baseURL + scope.row.imageUrl" alt="" style="width: 64px; height: 64px;">
|
|
18
18
|
</template>
|
|
19
19
|
</el-table-column>
|
|
20
20
|
<el-table-column label="排序" prop="sort" align="center"></el-table-column>
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
import {onMounted, reactive} from "vue";
|
|
63
63
|
import groupForm from "./group-form.vue";
|
|
64
64
|
import imageForm from "./image-form.vue";
|
|
65
|
-
import {get, del} from "../../http.js";
|
|
65
|
+
import {get, del, instance} from "../../http.js";
|
|
66
66
|
import {ElMessage, ElMessageBox} from "element-plus";
|
|
67
67
|
|
|
68
68
|
// 数据集
|
|
@@ -13,6 +13,8 @@ import {Graph} from "@antv/x6";
|
|
|
13
13
|
import {getData, getRealData, showPorts} from "../common.js";
|
|
14
14
|
import {ElMessage} from "element-plus";
|
|
15
15
|
import {defaultMatch, defaultText, setPipeDirection} from "packages/components/tools.js";
|
|
16
|
+
import {ARROWFORWARD, FLASHING} from "packages/components/enums.js";
|
|
17
|
+
import {arrowBackward, arrowForward} from "packages/components/settings.js";
|
|
16
18
|
|
|
17
19
|
defineOptions({
|
|
18
20
|
name: 'wiring-diagram-preview'
|
|
@@ -117,10 +119,10 @@ const allFields = ref([])
|
|
|
117
119
|
* 刷新数据
|
|
118
120
|
*/
|
|
119
121
|
const refreshData = () => {
|
|
120
|
-
cells.value = graph.value.getCells().filter(cell => cell?.data?.type === 'text' || cell?.data?.type === 'pipe')
|
|
122
|
+
cells.value = graph.value.getCells().filter(cell => cell?.data?.type === 'text' || cell?.data?.type === 'pipe' || cell?.data?.type === 'arrow')
|
|
121
123
|
cells.value.forEach(item => {
|
|
122
124
|
if (item?.data?.fields?.length) {
|
|
123
|
-
item
|
|
125
|
+
item?.data.fields.forEach(field => {
|
|
124
126
|
if (field.field) {
|
|
125
127
|
allFields.value.push({id: item?.id, fields: item?.data.fields})
|
|
126
128
|
}
|
|
@@ -163,13 +165,17 @@ const setFieldData = async () => {
|
|
|
163
165
|
|
|
164
166
|
realData?.forEach(item => {
|
|
165
167
|
const cell = graph.value.getCellById(item.id)
|
|
168
|
+
console.log('122222222',cell)
|
|
166
169
|
if (cell.data.type === 'text') {
|
|
167
170
|
cell.label = replaceAllTemplateLiteralsWithArray(cell.data.content, item.fields)
|
|
168
171
|
}
|
|
169
172
|
if (cell.data.type === 'pipe') {
|
|
170
173
|
console.log('管道详情', cell, item.fields?.[0].value)
|
|
171
174
|
setPipe(cell, item.fields?.[0].value)
|
|
172
|
-
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (cell.data.type === 'arrow') {
|
|
178
|
+
setArrow(cell, item.fields?.[0].value)
|
|
173
179
|
}
|
|
174
180
|
})
|
|
175
181
|
timer.value = setTimeout(() => {
|
|
@@ -185,7 +191,7 @@ const setFieldData = async () => {
|
|
|
185
191
|
*/
|
|
186
192
|
const replaceAllTemplateLiteralsWithArray = (str, fields) => {
|
|
187
193
|
let index = 0
|
|
188
|
-
return str.replace(defaultMatch, (
|
|
194
|
+
return str.replace(defaultMatch, () => {
|
|
189
195
|
const field = fields.find(item => item.index === index)
|
|
190
196
|
index++
|
|
191
197
|
if (field) {
|
|
@@ -202,17 +208,37 @@ const replaceAllTemplateLiteralsWithArray = (str, fields) => {
|
|
|
202
208
|
* @param value
|
|
203
209
|
*/
|
|
204
210
|
const setPipe = (cell, value) => {
|
|
205
|
-
if(!cell.data.isCondition) {
|
|
211
|
+
if (!cell.data.isCondition) {
|
|
206
212
|
return false
|
|
207
213
|
}
|
|
208
214
|
for (let i = 0; i < cell.data.condition.length; i++) {
|
|
209
|
-
if (value > cell.data.condition[i].min && value <= cell.data.condition[i].max) {
|
|
215
|
+
if (Number(value) > cell.data.condition[i].min && Number(value) <= cell.data.condition[i].max) {
|
|
210
216
|
cell.attr('line2/style/animation', setPipeDirection(cell.data.condition[i].direction))
|
|
211
217
|
return false
|
|
212
218
|
}
|
|
213
219
|
}
|
|
214
220
|
}
|
|
215
221
|
|
|
222
|
+
/**
|
|
223
|
+
* 设置箭头
|
|
224
|
+
* @param cell
|
|
225
|
+
* @param value
|
|
226
|
+
*/
|
|
227
|
+
const setArrow = (cell, value) => {
|
|
228
|
+
console.log(cell,value)
|
|
229
|
+
if (!cell.data.isCondition) {
|
|
230
|
+
return false
|
|
231
|
+
}
|
|
232
|
+
for (let i = 0; i < cell.data.condition.length; i++) {
|
|
233
|
+
if (Number(value) > cell.data.condition[i].min && Number(value) <= cell.data.condition[i].max) {
|
|
234
|
+
cell.attr('arrow/style/animation', cell.data.condition[i].animation === FLASHING ? 'flashing 2s infinite linear' : '')
|
|
235
|
+
cell.attr('arrow/d', cell.data.condition[i].direction === ARROWFORWARD ? arrowForward : arrowBackward)
|
|
236
|
+
cell.attr('arrow/display', cell.data.condition[i].display)
|
|
237
|
+
return false
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
216
242
|
/**
|
|
217
243
|
* \@description 画布自适应
|
|
218
244
|
*/
|
|
@@ -93,36 +93,136 @@ export const textOptions = {
|
|
|
93
93
|
},
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
// 默认线配置
|
|
97
|
+
export const defaultLine = {
|
|
98
|
+
markup: [
|
|
99
|
+
{
|
|
100
|
+
tagName: 'path',
|
|
101
|
+
selector: 'line',
|
|
102
|
+
groupSelector: 'lines'
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
attrs: {
|
|
106
|
+
wrap: {
|
|
107
|
+
strokeWidth: 10
|
|
108
|
+
},
|
|
109
|
+
lines: {
|
|
110
|
+
connection: true,
|
|
111
|
+
strokeLinejoin: 'round',
|
|
112
|
+
fill: 'none',
|
|
113
|
+
strokeWidth: 2,
|
|
114
|
+
},
|
|
115
|
+
line: {
|
|
116
|
+
stroke: '#ffffff',
|
|
117
|
+
strokeWidth: 1,
|
|
118
|
+
sourceMarker: {
|
|
119
|
+
args: {
|
|
120
|
+
width: 10,
|
|
121
|
+
height: 10,
|
|
122
|
+
offset: 0,
|
|
123
|
+
},
|
|
124
|
+
name: null
|
|
125
|
+
},
|
|
126
|
+
targetMarker: {
|
|
127
|
+
args: {
|
|
128
|
+
width: 10,
|
|
129
|
+
height: 10,
|
|
130
|
+
offset: 0,
|
|
131
|
+
},
|
|
132
|
+
name: null
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
}
|
|
136
|
+
}
|
|
96
137
|
|
|
97
|
-
//
|
|
98
|
-
export const
|
|
138
|
+
// 管道线配置
|
|
139
|
+
export const pipeOptions = {
|
|
99
140
|
markup: [
|
|
100
141
|
{
|
|
101
142
|
tagName: 'path',
|
|
102
|
-
selector: '
|
|
143
|
+
selector: 'line',
|
|
103
144
|
groupSelector: 'lines'
|
|
104
145
|
},
|
|
105
146
|
{
|
|
106
147
|
tagName: 'path',
|
|
107
|
-
selector: '
|
|
148
|
+
selector: 'pipe',
|
|
108
149
|
groupSelector: 'lines'
|
|
109
150
|
},
|
|
110
151
|
],
|
|
111
152
|
attrs: {
|
|
153
|
+
wrap: {
|
|
154
|
+
strokeWidth: 10
|
|
155
|
+
},
|
|
112
156
|
lines: {
|
|
113
157
|
connection: true,
|
|
114
158
|
strokeLinejoin: 'round',
|
|
115
159
|
fill: 'none',
|
|
116
160
|
strokeWidth: 2,
|
|
117
161
|
},
|
|
118
|
-
|
|
162
|
+
line: {
|
|
163
|
+
stroke: '#ffffff',
|
|
164
|
+
strokeWidth: 1,
|
|
165
|
+
targetMarker: null,
|
|
166
|
+
sourceMarker: null
|
|
167
|
+
},
|
|
168
|
+
pipe: {
|
|
119
169
|
stroke: '#2364DD',
|
|
120
170
|
strokeWidth: 1,
|
|
171
|
+
strokeDasharray: 5,
|
|
172
|
+
sourceMarker: {
|
|
173
|
+
args: {
|
|
174
|
+
width: 10,
|
|
175
|
+
height: 10,
|
|
176
|
+
offset: 0,
|
|
177
|
+
},
|
|
178
|
+
name: null
|
|
179
|
+
},
|
|
180
|
+
targetMarker: {
|
|
181
|
+
args: {
|
|
182
|
+
width: 10,
|
|
183
|
+
height: 10,
|
|
184
|
+
offset: 0,
|
|
185
|
+
},
|
|
186
|
+
name: null
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// 正向箭头
|
|
193
|
+
export const arrowForward = 'M 0 -6 8 0 0 6 z'
|
|
194
|
+
|
|
195
|
+
// 逆向箭头
|
|
196
|
+
export const arrowBackward = 'M 0 -6 -8 0 0 6 z'
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
// 箭头线配置
|
|
200
|
+
export const arrowOptions = {
|
|
201
|
+
attrs: {
|
|
202
|
+
wrap: {
|
|
203
|
+
strokeWidth: 10
|
|
204
|
+
},
|
|
205
|
+
arrow: {
|
|
206
|
+
d: arrowForward,
|
|
207
|
+
fill: '#ED8A19',
|
|
208
|
+
stroke: '#ED8A19',
|
|
209
|
+
style: {
|
|
210
|
+
animation: 'flashing 2s infinite linear'
|
|
211
|
+
},
|
|
212
|
+
display: 'block',
|
|
213
|
+
},
|
|
214
|
+
arrow1: {
|
|
215
|
+
atConnectionRatio: 0.5,
|
|
121
216
|
},
|
|
122
|
-
|
|
217
|
+
lines: {
|
|
218
|
+
connection: true,
|
|
219
|
+
strokeLinejoin: 'round',
|
|
220
|
+
fill: 'none',
|
|
221
|
+
strokeWidth: 2,
|
|
222
|
+
},
|
|
223
|
+
line: {
|
|
123
224
|
stroke: '#ffffff',
|
|
124
225
|
strokeWidth: 1,
|
|
125
|
-
strokeDasharray: 0,
|
|
126
226
|
sourceMarker: {
|
|
127
227
|
args: {
|
|
128
228
|
width: 10,
|
|
@@ -140,5 +240,23 @@ export const lineOptions = {
|
|
|
140
240
|
name: null
|
|
141
241
|
},
|
|
142
242
|
},
|
|
143
|
-
}
|
|
243
|
+
},
|
|
244
|
+
markup: [
|
|
245
|
+
{
|
|
246
|
+
tagName: 'path',
|
|
247
|
+
selector: 'line',
|
|
248
|
+
groupSelector: 'lines'
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
tagName: 'path',
|
|
252
|
+
groupSelector: 'arrow',
|
|
253
|
+
selector: 'arrow1',
|
|
254
|
+
},
|
|
255
|
+
]
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// 线配置
|
|
259
|
+
export const lineOptions = {
|
|
260
|
+
markup: arrowOptions.markup,
|
|
261
|
+
attrs: arrowOptions.attrs,
|
|
144
262
|
}
|
|
@@ -5,7 +5,7 @@ import {Clipboard} from "@antv/x6-plugin-clipboard";
|
|
|
5
5
|
import {History} from "@antv/x6-plugin-history";
|
|
6
6
|
import {Selection} from "@antv/x6-plugin-selection";
|
|
7
7
|
import {lineOptions} from "packages/components/settings.js";
|
|
8
|
-
import {STOP} from "packages/components/enums.js";
|
|
8
|
+
import {ARROWFORWARD, FLASHING, STOP} from "packages/components/enums.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* 图形变换
|
|
@@ -191,10 +191,16 @@ export const addLineTools = (cell) => {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
|
-
*
|
|
194
|
+
* 判断当前默认线的类型
|
|
195
195
|
*/
|
|
196
196
|
export const isLineOrPipe = () => {
|
|
197
|
-
|
|
197
|
+
if (lineOptions.attrs?.pipe) {
|
|
198
|
+
return 'pipe'
|
|
199
|
+
}
|
|
200
|
+
if (lineOptions.attrs?.arrow) {
|
|
201
|
+
return 'arrow'
|
|
202
|
+
}
|
|
203
|
+
return 'line'
|
|
198
204
|
}
|
|
199
205
|
|
|
200
206
|
/**
|
|
@@ -223,9 +229,18 @@ export const defaultText = '--'
|
|
|
223
229
|
// 默认匹配字符串
|
|
224
230
|
export const defaultMatch = /\$\{(.*?)\}/g
|
|
225
231
|
|
|
226
|
-
//
|
|
227
|
-
export const
|
|
232
|
+
// 默认条件管道单个配置
|
|
233
|
+
export const defaultPipeCondition = {
|
|
228
234
|
min: 0,
|
|
229
235
|
max: 0,
|
|
230
236
|
direction: STOP,
|
|
231
237
|
}
|
|
238
|
+
|
|
239
|
+
// 默认条件箭头线配置
|
|
240
|
+
export const defaultArrowCondition = {
|
|
241
|
+
min: 0,
|
|
242
|
+
max: 0,
|
|
243
|
+
animation: FLASHING,
|
|
244
|
+
direction: ARROWFORWARD,
|
|
245
|
+
display: 'block'
|
|
246
|
+
}
|