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