vue-wiring-diagram 1.1.21 → 1.1.23
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 +6235 -5903
- package/dist/vue-wiring-diagram.umd.js +29 -29
- 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 -0
- 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 -124
- package/packages/components/portsOptions.js +21 -21
- package/packages/components/preview/index.vue +399 -347
- package/packages/components/settings.js +262 -262
- package/packages/components/text-control/index.vue +457 -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,124 +1,290 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Author: HuaYJ
|
|
3
|
-
* @Date: 2024/11/5 11:35
|
|
4
|
-
*/
|
|
5
|
-
<template>
|
|
6
|
-
<div class="control-box">
|
|
7
|
-
<el-collapse v-model="activeName" accordion>
|
|
8
|
-
<el-collapse-item title="
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</
|
|
26
|
-
</el-
|
|
27
|
-
<el-
|
|
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
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @Author: HuaYJ
|
|
3
|
+
* @Date: 2024/11/5 11:35
|
|
4
|
+
*/
|
|
5
|
+
<template>
|
|
6
|
+
<div class="control-box">
|
|
7
|
+
<el-collapse v-model="activeName" accordion>
|
|
8
|
+
<el-collapse-item title="图片设置" name="1">
|
|
9
|
+
<div class="row-column">
|
|
10
|
+
<el-row :gutter="20">
|
|
11
|
+
<el-col :span="12">
|
|
12
|
+
<div class="row-label">参数设置</div>
|
|
13
|
+
</el-col>
|
|
14
|
+
<el-col :span="12">
|
|
15
|
+
<el-select v-model="deviceCode" placeholder="请选择设备" @change="checkDevice" size="small"
|
|
16
|
+
filterable clearable>
|
|
17
|
+
<el-option v-for="item in deviceList" :key="item.deviceCode" :label="item.deviceName"
|
|
18
|
+
:value="item.deviceCode"/>
|
|
19
|
+
</el-select>
|
|
20
|
+
<el-select v-model="fieldCode" placeholder="请选择字段" @change="checkField" size="small"
|
|
21
|
+
filterable clearable style="margin-top: 10px">
|
|
22
|
+
<el-option v-for="item in fieldList" :key="item.dataField" :label="item.name"
|
|
23
|
+
:value="item.dataField"/>
|
|
24
|
+
</el-select>
|
|
25
|
+
</el-col>
|
|
26
|
+
</el-row>
|
|
27
|
+
<el-row :gutter="20">
|
|
28
|
+
<el-col :span="12">
|
|
29
|
+
<div class="row-label">条件配置</div>
|
|
30
|
+
</el-col>
|
|
31
|
+
<el-col :span="12">
|
|
32
|
+
<el-switch v-model="isCondition" :active-value="true" :inactive-value="false" size="small"
|
|
33
|
+
@change="changeCondition"/>
|
|
34
|
+
<el-button type="primary" size="small" @click="showCondition" style="margin-left: 10px">
|
|
35
|
+
配置
|
|
36
|
+
</el-button>
|
|
37
|
+
</el-col>
|
|
38
|
+
</el-row>
|
|
39
|
+
</div>
|
|
40
|
+
</el-collapse-item>
|
|
41
|
+
<el-collapse-item title="连接桩设置" name="3">
|
|
42
|
+
<el-button type="primary" @click="addPorts" size="small">添加连接桩</el-button>
|
|
43
|
+
<el-button type="primary" @click="showPort" size="small">显示连接桩</el-button>
|
|
44
|
+
<el-table :data="ports" border size="small" style="margin-top: 10px;">
|
|
45
|
+
<el-table-column label="ID" width="50" align="center">
|
|
46
|
+
<template v-slot="{row}">
|
|
47
|
+
{{ row.attrs.text.text }}
|
|
48
|
+
</template>
|
|
49
|
+
</el-table-column>
|
|
50
|
+
<el-table-column label="x" width="100" align="center">
|
|
51
|
+
<template v-slot="{row}">
|
|
52
|
+
<el-slider v-model="row.args.x" :min="0" :max="100" :step="1" @input="(e) => changePorts(row.id, 'x', e)"/>
|
|
53
|
+
</template>
|
|
54
|
+
</el-table-column>
|
|
55
|
+
<el-table-column label="y" width="100" align="center">
|
|
56
|
+
<template v-slot="{row}">
|
|
57
|
+
<el-slider v-model="row.args.y" :min="0" :max="100" :step="1" @input="(e) => changePorts(row.id, 'y', e)"/>
|
|
58
|
+
</template>
|
|
59
|
+
</el-table-column>
|
|
60
|
+
<el-table-column label="操作" width="70" align="center">
|
|
61
|
+
<template v-slot="{row}">
|
|
62
|
+
<el-button type="danger" size="small" @click="deletePort(row.id)">
|
|
63
|
+
<el-icon>
|
|
64
|
+
<delete-filled/>
|
|
65
|
+
</el-icon>
|
|
66
|
+
</el-button>
|
|
67
|
+
</template>
|
|
68
|
+
</el-table-column>
|
|
69
|
+
</el-table>
|
|
70
|
+
</el-collapse-item>
|
|
71
|
+
</el-collapse>
|
|
72
|
+
|
|
73
|
+
<!-- 条件配置弹窗 -->
|
|
74
|
+
<el-dialog v-model="dialogCondition.show" width="550px" title="条件配置" :show-close="false"
|
|
75
|
+
:close-on-click-modal="false"
|
|
76
|
+
:close-on-press-escape="false">
|
|
77
|
+
<image-condition v-if="dialogCondition.show" :payload="dialogCondition.payload" type="image"
|
|
78
|
+
@close="closeCondition"></image-condition>
|
|
79
|
+
</el-dialog>
|
|
80
|
+
</div>
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
<script setup>
|
|
84
|
+
|
|
85
|
+
import {onMounted, reactive, ref} from "vue";
|
|
86
|
+
import {showPorts, getDeviceList, getFieldList} from "../common.js";
|
|
87
|
+
import {DeleteFilled} from "@element-plus/icons-vue";
|
|
88
|
+
import {portOption} from "../settings.js";
|
|
89
|
+
import ImageCondition from "./image-condition.vue";
|
|
90
|
+
|
|
91
|
+
const props = defineProps({
|
|
92
|
+
payload: Object,
|
|
93
|
+
itemId: {
|
|
94
|
+
type: String,
|
|
95
|
+
default: ''
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
// 确保图片节点 data 结构存在,避免写入时 data 为 undefined 抛错
|
|
100
|
+
const ensureImageData = () => {
|
|
101
|
+
if (!props.payload.data) {
|
|
102
|
+
props.payload.data = {
|
|
103
|
+
type: 'image',
|
|
104
|
+
isCondition: false,
|
|
105
|
+
fields: [],
|
|
106
|
+
condition: []
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
if (typeof props.payload.data.type === 'undefined') props.payload.data.type = 'image'
|
|
110
|
+
if (typeof props.payload.data.isCondition === 'undefined') props.payload.data.isCondition = false
|
|
111
|
+
if (!Array.isArray(props.payload.data.fields)) props.payload.data.fields = []
|
|
112
|
+
if (!Array.isArray(props.payload.data.condition)) props.payload.data.condition = []
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
ensureImageData()
|
|
116
|
+
|
|
117
|
+
const activeName = ref('1')
|
|
118
|
+
|
|
119
|
+
const ports = ref([]) // 连接桩数据
|
|
120
|
+
|
|
121
|
+
// 设备相关
|
|
122
|
+
const deviceList = ref([]) // 设备列表
|
|
123
|
+
const deviceCode = ref(props.payload.data?.fields?.[0]?.deviceCode ?? '') // 设备编码
|
|
124
|
+
const fieldCode = ref(props.payload.data?.fields?.[0]?.field ?? '') // 字段编码
|
|
125
|
+
const fieldList = ref([]) // 字段列表
|
|
126
|
+
|
|
127
|
+
let currentDevice = reactive({}) // 当前设备信息
|
|
128
|
+
|
|
129
|
+
// 条件相关
|
|
130
|
+
const isCondition = ref(props.payload.data?.isCondition ?? false) // 条件线是否开启
|
|
131
|
+
const dialogCondition = reactive({
|
|
132
|
+
show: false,
|
|
133
|
+
payload: null
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* 获取设备列表
|
|
138
|
+
*/
|
|
139
|
+
const getDevices = async () => {
|
|
140
|
+
deviceList.value = await getDeviceList(props.itemId)
|
|
141
|
+
if (deviceCode.value) {
|
|
142
|
+
checkDevice()
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 监听设备编码变化
|
|
148
|
+
*/
|
|
149
|
+
const checkDevice = () => {
|
|
150
|
+
ensureImageData()
|
|
151
|
+
currentDevice = deviceList.value.find(item => item.deviceCode === deviceCode.value)
|
|
152
|
+
if (currentDevice) {
|
|
153
|
+
getFields()
|
|
154
|
+
props.payload.data.fields = [{
|
|
155
|
+
index: 0,
|
|
156
|
+
deviceName: currentDevice.deviceName,
|
|
157
|
+
deviceCode: currentDevice.deviceCode,
|
|
158
|
+
field: fieldCode.value ?? '',
|
|
159
|
+
}]
|
|
160
|
+
fieldCode.value = props.payload.data.fields[0].field
|
|
161
|
+
} else {
|
|
162
|
+
fieldCode.value = ''
|
|
163
|
+
props.payload.data.fields = []
|
|
164
|
+
}
|
|
165
|
+
console.log('图片配置', props.payload)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 获取字段列表
|
|
170
|
+
*/
|
|
171
|
+
const getFields = async () => {
|
|
172
|
+
if (!currentDevice?.deviceCode) return
|
|
173
|
+
fieldList.value = await getFieldList(currentDevice.deviceCode)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* 监听字段编码变化
|
|
178
|
+
*/
|
|
179
|
+
const checkField = () => {
|
|
180
|
+
ensureImageData()
|
|
181
|
+
props.payload.data.fields = [{
|
|
182
|
+
index: 0,
|
|
183
|
+
deviceName: currentDevice?.deviceName ?? '',
|
|
184
|
+
deviceCode: currentDevice?.deviceCode ?? '',
|
|
185
|
+
field: fieldCode.value ?? '',
|
|
186
|
+
}]
|
|
187
|
+
console.log('图片配置', props.payload)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* 条件线改变
|
|
192
|
+
*/
|
|
193
|
+
const changeCondition = () => {
|
|
194
|
+
ensureImageData()
|
|
195
|
+
props.payload.data.isCondition = isCondition.value
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* 条件线配置显示
|
|
200
|
+
*/
|
|
201
|
+
const showCondition = () => {
|
|
202
|
+
ensureImageData()
|
|
203
|
+
dialogCondition.show = true
|
|
204
|
+
dialogCondition.payload = props.payload.data.condition ?? []
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 条件线配置关闭
|
|
209
|
+
* @param condition
|
|
210
|
+
*/
|
|
211
|
+
const closeCondition = (condition) => {
|
|
212
|
+
dialogCondition.show = false
|
|
213
|
+
dialogCondition.payload = null
|
|
214
|
+
if (condition) {
|
|
215
|
+
ensureImageData()
|
|
216
|
+
props.payload.data.condition = condition
|
|
217
|
+
}
|
|
218
|
+
console.log('图片条件配置', props.payload.data)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* 获取连接桩数据
|
|
223
|
+
*/
|
|
224
|
+
const getPorts = () => {
|
|
225
|
+
ports.value = JSON.parse(JSON.stringify(props.payload.getPorts().map((item) => {
|
|
226
|
+
return {
|
|
227
|
+
id: item.id,
|
|
228
|
+
attrs: item.attrs,
|
|
229
|
+
args: {
|
|
230
|
+
x: Number(item.args.x.replace('%', '')),
|
|
231
|
+
y: Number(item.args.y.replace('%', ''))
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
})))
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* 添加连接桩
|
|
239
|
+
*/
|
|
240
|
+
const addPorts = () => {
|
|
241
|
+
const port = portOption
|
|
242
|
+
port.attrs.text.text = `${props.payload.getPorts().length + 1}`
|
|
243
|
+
port.args.x = '50%'
|
|
244
|
+
port.args.y = '50%'
|
|
245
|
+
props.payload.addPorts([
|
|
246
|
+
{
|
|
247
|
+
group: 'ports',
|
|
248
|
+
...port
|
|
249
|
+
},
|
|
250
|
+
])
|
|
251
|
+
getPorts()
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* 显示连接桩
|
|
256
|
+
*/
|
|
257
|
+
const showPort = () => {
|
|
258
|
+
showPorts("#drawing-board",true)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* 修改连接桩
|
|
263
|
+
* @param id
|
|
264
|
+
* @param key
|
|
265
|
+
* @param value
|
|
266
|
+
*/
|
|
267
|
+
const changePorts = (id, key, value) => {
|
|
268
|
+
props.payload.portProp(id, 'args/' + key, value + '%')
|
|
269
|
+
getPorts()
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* 删除连接桩
|
|
274
|
+
* @param id
|
|
275
|
+
*/
|
|
276
|
+
const deletePort = (id) => {
|
|
277
|
+
props.payload.removePort(id)
|
|
278
|
+
getPorts()
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
onMounted(() => {
|
|
282
|
+
ensureImageData()
|
|
283
|
+
getPorts()
|
|
284
|
+
getDevices()
|
|
285
|
+
})
|
|
286
|
+
</script>
|
|
287
|
+
|
|
288
|
+
<style scoped lang="scss">
|
|
289
|
+
@use "../../styles/editor.scss";
|
|
290
|
+
</style>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export const portsOptions = {
|
|
2
|
-
groups: {
|
|
3
|
-
ports: {
|
|
4
|
-
position: 'absolute',
|
|
5
|
-
args: {
|
|
6
|
-
x: 0,
|
|
7
|
-
y: 0,
|
|
8
|
-
},
|
|
9
|
-
attrs: {
|
|
10
|
-
circle: {
|
|
11
|
-
magnet: true,
|
|
12
|
-
stroke: '#8f8f8f',
|
|
13
|
-
r: 4,
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
label: {
|
|
17
|
-
position: 'top',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
export const portsOptions = {
|
|
2
|
+
groups: {
|
|
3
|
+
ports: {
|
|
4
|
+
position: 'absolute',
|
|
5
|
+
args: {
|
|
6
|
+
x: 0,
|
|
7
|
+
y: 0,
|
|
8
|
+
},
|
|
9
|
+
attrs: {
|
|
10
|
+
circle: {
|
|
11
|
+
magnet: true,
|
|
12
|
+
stroke: '#8f8f8f',
|
|
13
|
+
r: 4,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
label: {
|
|
17
|
+
position: 'top',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
}
|