vue-wiring-diagram 1.1.26 → 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.
- package/dist/style.css +1 -1
- package/dist/vue-wiring-diagram.es.js +5754 -5761
- package/dist/vue-wiring-diagram.umd.js +39 -39
- package/package.json +1 -1
- package/packages/components/common.js +19 -1
- package/packages/components/edge-control/pipe-line.vue +96 -55
- package/packages/components/preview/index.vue +36 -25
- package/packages/components/text-control/index.vue +1 -1
- package/packages/styles/elPath.scss +10 -0
package/package.json
CHANGED
|
@@ -36,6 +36,24 @@ export const getDeviceList = (itemId) => {
|
|
|
36
36
|
})
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* 获取设备列表
|
|
41
|
+
* @param itemId
|
|
42
|
+
* @returns {Promise<unknown>}
|
|
43
|
+
*/
|
|
44
|
+
export const getKGDeviceList = (itemId) => {
|
|
45
|
+
return get('/template/getDiField', {itemIds: itemId}).then(res => {
|
|
46
|
+
if (res?.isOk) {
|
|
47
|
+
return res.data.map(item => {
|
|
48
|
+
return {
|
|
49
|
+
id:item.deviceCode + item.field,
|
|
50
|
+
...item
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
39
57
|
/**
|
|
40
58
|
* 获取字段列表
|
|
41
59
|
* @param deviceCode
|
|
@@ -58,7 +76,7 @@ export const getFieldList = (deviceCode) => {
|
|
|
58
76
|
export const getData = (id) => {
|
|
59
77
|
return get('/template/selectOne', {id: id}).then(res => {
|
|
60
78
|
if (res?.isOk) {
|
|
61
|
-
const data = JSON.parse(res.data
|
|
79
|
+
const data = JSON.parse(res.data?.remark ?? '{}')
|
|
62
80
|
if(data === null) {
|
|
63
81
|
return null
|
|
64
82
|
}
|
|
@@ -62,33 +62,54 @@
|
|
|
62
62
|
</el-row>
|
|
63
63
|
<el-row :gutter="20">
|
|
64
64
|
<el-col :span="12">
|
|
65
|
-
<div class="row-label"
|
|
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>
|
|
65
|
+
<div class="row-label">是否开启动态流向配置</div>
|
|
83
66
|
</el-col>
|
|
84
67
|
<el-col :span="12">
|
|
85
68
|
<el-switch v-model="isCondition" :active-value="true" :inactive-value="false" size="small"
|
|
86
69
|
@change="changeCondition"/>
|
|
87
|
-
<el-button type="primary" size="small" @click="showCondition" style="margin-left: 10px">
|
|
88
|
-
|
|
89
|
-
|
|
70
|
+
<!-- <el-button type="primary" size="small" @click="showCondition" style="margin-left: 10px">
|
|
71
|
+
配置
|
|
72
|
+
</el-button>-->
|
|
90
73
|
</el-col>
|
|
91
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>
|
|
92
113
|
</div>
|
|
93
114
|
</el-collapse-item>
|
|
94
115
|
<el-collapse-item title="箭头1设置" name="2">
|
|
@@ -186,12 +207,12 @@
|
|
|
186
207
|
</div>
|
|
187
208
|
</el-collapse-item>
|
|
188
209
|
</el-collapse>
|
|
189
|
-
<el-dialog v-model="dialogCondition.show" width="500px" title="条件配置" :show-close="false"
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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>-->
|
|
195
216
|
</div>
|
|
196
217
|
</template>
|
|
197
218
|
|
|
@@ -199,9 +220,9 @@
|
|
|
199
220
|
import {onMounted, reactive, ref} from "vue";
|
|
200
221
|
import {lineOptions} from "../settings.js";
|
|
201
222
|
import {setPipeDirection} from "packages/components/tools.js";
|
|
202
|
-
import {arrowList, directionList, STOP, typeList} from "packages/components/enums.js";
|
|
223
|
+
import {arrowList, directionList, FORWARD_PIPE, STOP, typeList} from "packages/components/enums.js";
|
|
203
224
|
import Condition from "packages/components/edge-control/condition.vue";
|
|
204
|
-
import {getDeviceList, getFieldList} from "packages/components/common.js";
|
|
225
|
+
import {getDeviceList, getFieldList, getKGDeviceList} from "packages/components/common.js";
|
|
205
226
|
|
|
206
227
|
const props = defineProps({
|
|
207
228
|
payload: Object,
|
|
@@ -255,69 +276,90 @@ const isCondition = ref(props.payload.data.isCondition ?? false)
|
|
|
255
276
|
*/
|
|
256
277
|
const changeCondition = () => {
|
|
257
278
|
props.payload.data.isCondition = isCondition.value
|
|
279
|
+
props.payload.data.direction = direction.value
|
|
258
280
|
}
|
|
259
281
|
|
|
260
282
|
// 条件线配置
|
|
261
|
-
const dialogCondition = reactive({
|
|
283
|
+
/*const dialogCondition = reactive({
|
|
262
284
|
show: false,
|
|
263
285
|
payload: null
|
|
264
|
-
})
|
|
286
|
+
})*/
|
|
265
287
|
|
|
266
288
|
/**
|
|
267
289
|
* 条件线配置显示
|
|
268
290
|
*/
|
|
269
|
-
const showCondition = () => {
|
|
291
|
+
/*const showCondition = () => {
|
|
270
292
|
dialogCondition.show = true
|
|
271
293
|
dialogCondition.payload = props.payload.data.condition ?? []
|
|
272
|
-
}
|
|
294
|
+
}*/
|
|
273
295
|
|
|
274
296
|
/**
|
|
275
297
|
* 条件线配置关闭
|
|
276
298
|
* @param condition
|
|
277
299
|
*/
|
|
278
|
-
const closeCondition = (condition) => {
|
|
300
|
+
/*const closeCondition = (condition) => {
|
|
279
301
|
dialogCondition.show = false
|
|
280
302
|
dialogCondition.payload = null
|
|
281
303
|
if (condition) {
|
|
282
304
|
props.payload.data.condition = condition
|
|
283
305
|
}
|
|
284
306
|
console.log('条件线', props.payload.data)
|
|
285
|
-
}
|
|
307
|
+
}*/
|
|
286
308
|
|
|
287
309
|
const deviceList = ref([]) // 设备列表
|
|
288
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) // 流向
|
|
289
313
|
const fieldCode = ref(props.payload.data?.fields?.[0]?.field ?? '') // 字段编码
|
|
290
314
|
|
|
291
315
|
/**
|
|
292
316
|
* 获取设备列表
|
|
293
317
|
*/
|
|
294
318
|
const getDevices = async () => {
|
|
295
|
-
deviceList.value = await
|
|
319
|
+
deviceList.value = await getKGDeviceList(props.itemId)
|
|
296
320
|
if (deviceCode.value) {
|
|
297
321
|
checkDevice()
|
|
298
322
|
}
|
|
299
323
|
}
|
|
300
324
|
|
|
325
|
+
/**
|
|
326
|
+
* 改变流向
|
|
327
|
+
* @param value
|
|
328
|
+
*/
|
|
329
|
+
const changeDirection = (value) => {
|
|
330
|
+
direction.value = value
|
|
331
|
+
props.payload.data.direction = value
|
|
332
|
+
}
|
|
333
|
+
|
|
301
334
|
let currentDevice = reactive({}) // 当前设备信息
|
|
302
335
|
|
|
303
336
|
/**
|
|
304
337
|
* 监听设备编码变化
|
|
305
338
|
*/
|
|
306
339
|
const checkDevice = () => {
|
|
307
|
-
currentDevice = deviceList.value.find(item => item.deviceCode === deviceCode.value)
|
|
308
|
-
if (currentDevice) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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
|
+
})
|
|
321
363
|
console.log('管道配置', props.payload)
|
|
322
364
|
}
|
|
323
365
|
|
|
@@ -326,22 +368,21 @@ const fieldList = ref([])
|
|
|
326
368
|
/**
|
|
327
369
|
* 获取字段列表
|
|
328
370
|
*/
|
|
329
|
-
const getFields = async () => {
|
|
371
|
+
/*const getFields = async () => {
|
|
330
372
|
fieldList.value = await getFieldList(currentDevice.deviceCode)
|
|
331
|
-
}
|
|
373
|
+
}*/
|
|
332
374
|
|
|
333
375
|
/**
|
|
334
376
|
* 监听字段编码变化
|
|
335
377
|
*/
|
|
336
|
-
const checkField = () => {
|
|
378
|
+
/*const checkField = () => {
|
|
337
379
|
props.payload.data.fields = [{
|
|
338
|
-
index: 0,
|
|
339
380
|
deviceName: currentDevice.deviceName,
|
|
340
381
|
deviceCode: currentDevice.deviceCode,
|
|
341
382
|
field: fieldCode.value ?? '',
|
|
342
383
|
}]
|
|
343
384
|
console.log('管道配置', props.payload)
|
|
344
|
-
}
|
|
385
|
+
}*/
|
|
345
386
|
|
|
346
387
|
onMounted(() => {
|
|
347
388
|
getDevices()
|
|
@@ -134,7 +134,7 @@ const loading = ref(false)
|
|
|
134
134
|
* 刷新数据
|
|
135
135
|
*/
|
|
136
136
|
const refreshData = () => {
|
|
137
|
-
cells.value = graph.value.getCells().filter(cell => cell?.data?.type === 'text' || cell?.data?.type === 'pipe' || cell?.data?.type === 'arrow' || cell?.data?.type
|
|
137
|
+
cells.value = graph.value.getCells().filter(cell => cell?.data?.type === 'text' || cell?.data?.type === 'pipe' || cell?.data?.type === 'arrow' || cell?.data?.type === 'image')
|
|
138
138
|
cells.value.forEach(item => {
|
|
139
139
|
if (item?.data?.fields?.length) {
|
|
140
140
|
allFields.value.push({id: item?.id, fields: item?.data.fields})
|
|
@@ -211,8 +211,8 @@ const setRealData = (realData) => {
|
|
|
211
211
|
cell.label = replaceAllTemplateLiteralsWithArray(cell.data.content, item.fields)
|
|
212
212
|
}
|
|
213
213
|
if (cell.data.type === 'pipe') {
|
|
214
|
-
console.log('管道详情', cell, item.fields
|
|
215
|
-
setPipe(cell, item.fields
|
|
214
|
+
console.log('管道详情', cell, item.fields)
|
|
215
|
+
setPipe(cell, item.fields)
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
if (cell.data.type === 'arrow') {
|
|
@@ -248,27 +248,38 @@ const replaceAllTemplateLiteralsWithArray = (str, fields) => {
|
|
|
248
248
|
/**
|
|
249
249
|
* 设置管道
|
|
250
250
|
* @param cell
|
|
251
|
-
* @param
|
|
251
|
+
* @param fields
|
|
252
252
|
*/
|
|
253
|
-
const setPipe = (cell,
|
|
253
|
+
const setPipe = (cell, fields) => {
|
|
254
|
+
console.log(cell, fields)
|
|
254
255
|
if (!cell.data.isCondition) {
|
|
255
256
|
return false
|
|
256
257
|
}
|
|
257
|
-
console.log('进入设置管道阶段start:', cell)
|
|
258
|
-
|
|
259
|
-
for (let i = 0; i < cell.data.condition.length; i++) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
258
|
+
// console.log('进入设置管道阶段start:', cell)
|
|
259
|
+
// if (cell.data.condition.length) {
|
|
260
|
+
// for (let i = 0; i < cell.data.condition.length; i++) {
|
|
261
|
+
// console.log('┌──────单个设置管道阶段start:───────┐')
|
|
262
|
+
// console.log('条件:', cell.data.condition[i])
|
|
263
|
+
// console.log('判断条件是否通过:', Number(fields[0].value) > cell.data.condition[i].min && Number(fields[0].value) < cell.data.condition[i].max)
|
|
264
|
+
// if (Number(fields[0].value) > cell.data.condition[i].min && Number(fields[0].value) < cell.data.condition[i].max) {
|
|
265
|
+
// console.log('管道条件判断设置的动画:', setPipeDirection(cell.data.condition[i].direction))
|
|
266
|
+
// cell.attr('pipe/style/animation', setPipeDirection(cell.data.condition[i].dirßection))
|
|
267
|
+
// console.log('设置过后的属性:', cell)
|
|
268
|
+
// console.log('└────────单个条件结束判断────────┘')
|
|
269
|
+
// return false
|
|
270
|
+
// }
|
|
271
|
+
// console.log('└─────────单个条件结束判断───────┘')
|
|
272
|
+
// }
|
|
273
|
+
// }
|
|
274
|
+
console.log('┌────────单个设置管道开始判断────────┐')
|
|
275
|
+
console.log(fields.some(item => item?.value1 == 1))
|
|
276
|
+
console.log(cell.data)
|
|
277
|
+
cell.attr('pipe/style/animation', fields.some(item => {
|
|
278
|
+
console.log('判断条件是否通过:', item?.value1 == 1, item.value1, item)
|
|
279
|
+
return item?.value1 == 1
|
|
280
|
+
}) ? setPipeDirection(cell.data.direction) : '')
|
|
281
|
+
console.log('设置过后的属性:', cell)
|
|
282
|
+
console.log('└────────单个设置管道结束判断────────┘')
|
|
272
283
|
}
|
|
273
284
|
/**
|
|
274
285
|
* 设置箭头
|
|
@@ -302,20 +313,20 @@ const setImage = (cell, fields) => {
|
|
|
302
313
|
console.log('进入设置图片阶段:', cell)
|
|
303
314
|
console.log('图片条件判断设置:', cell.data.condition)
|
|
304
315
|
console.log('设备字段数据:', fields)
|
|
305
|
-
|
|
316
|
+
|
|
306
317
|
// 如果没有字段数据,直接返回
|
|
307
318
|
if (!fields || fields.length === 0) {
|
|
308
319
|
return false
|
|
309
320
|
}
|
|
310
|
-
|
|
321
|
+
|
|
311
322
|
// 获取设备值(图片目前只支持单设备)
|
|
312
323
|
const field = fields[0]
|
|
313
324
|
const value = Number(field.value)
|
|
314
|
-
|
|
325
|
+
|
|
315
326
|
// 根据条件判断更换图片
|
|
316
327
|
for (let i = 0; i < cell.data.condition.length; i++) {
|
|
317
328
|
const condition = cell.data.condition[i]
|
|
318
|
-
console.log(cell.data,'cell.data55555555');
|
|
329
|
+
console.log(cell.data, 'cell.data55555555');
|
|
319
330
|
if (value > condition.min && value < condition.max) {
|
|
320
331
|
if (condition.imageUrl) {
|
|
321
332
|
console.log('更换图片为:', setSunCloudImageUrl(condition?.imageUrl))
|
|
@@ -324,7 +335,7 @@ const setImage = (cell, fields) => {
|
|
|
324
335
|
return false
|
|
325
336
|
}
|
|
326
337
|
}
|
|
327
|
-
|
|
338
|
+
|
|
328
339
|
console.log('未匹配到条件,保持原图片')
|
|
329
340
|
}
|
|
330
341
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<el-option v-for="item in deviceList" :key="item.deviceCode" :label="item.deviceName"
|
|
17
17
|
:value="item.deviceCode"/>
|
|
18
18
|
</el-select>
|
|
19
|
-
<el-input v-model="deviceName" placeholder="
|
|
19
|
+
<el-input v-model="deviceName" placeholder="请输入字段名称" clearable style="margin-top: 5px"/>
|
|
20
20
|
<el-table :data="filterFieldList" border style="margin-top: 20px;" size="small" height="500"
|
|
21
21
|
@row-click="checkField">
|
|
22
22
|
<el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
|