vue-wiring-diagram 1.1.19 → 1.1.21

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