vue-wiring-diagram 1.1.20 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-wiring-diagram",
3
- "version": "1.1.20",
3
+ "version": "1.1.21",
4
4
  "description": "A Vue 3.x component for wiring diagram",
5
5
  "type": "module",
6
6
  "main": "dist/vue-wiring-diagram.umd.js",
@@ -3,110 +3,124 @@
3
3
  * @Date: 2025/4/9 14:13
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">颜色</div>
13
- </el-col>
14
- <el-col :span="12">
15
- <el-color-picker v-model="stroke" :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">粗细</div>
21
- </el-col>
22
- <el-col :span="12">
23
- <el-input-number v-model="strokeWidth" size="small" controls-position="right" @change="changeLine" :min="1" :max="10"
24
- :step="1"/>
25
- </el-col>
26
- </el-row>
27
- </div>
28
- </el-collapse-item>
29
- <el-collapse-item title="箭头设置" name="1">
30
- <div class="row-column">
31
- <el-row :gutter="20">
32
- <el-col :span="12">
33
- <div class="row-label">箭头数量</div>
34
- </el-col>
35
- <el-col :span="12">
36
- <el-input-number v-model="arrowNumber" size="small" controls-position="right" @change="changeLine" :min="1" :max="20"
37
- :step="1"/>
38
- </el-col>
39
- </el-row>
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-color-picker v-model="fill" :show-alpha="true" size="small" @change="changeLine"/>
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="direction" size="small" @change="changeLine">
54
- <el-option v-for="item in arrowDirection" :key="item.value" :label="item.label" :value="item.value"/>
55
- </el-select>
56
- </el-col>
57
- </el-row>
58
- <el-row :gutter="20">
59
- <el-col :span="12">
60
- <div class="row-label">默认箭头动作</div>
61
- </el-col>
62
- <el-col :span="12">
63
- <el-switch v-model="animation" :active-value="FLASHING" active-text="闪烁" :inactive-value="STOP" inactive-text="静止" size="small"
64
- @change="changeLine"/>
65
- </el-col>
66
- </el-row>
67
- <el-row :gutter="20">
68
- <el-col :span="12">
69
- <div class="row-label">默认箭头显示</div>
70
- </el-col>
71
- <el-col :span="12">
72
- <el-switch v-model="display" active-value="block" active-text="显示" inactive-value="none" inactive-text="隐藏" size="small"
73
- @change="changeLine"/>
74
- </el-col>
75
- </el-row>
76
- </div>
77
- </el-collapse-item>
78
- <el-collapse-item title="动态设置" name="2">
79
- <div class="row-column">
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-select v-model="deviceCode" placeholder="请选择设备" @change="checkDevice" size="small" filterable clearable>
86
- <el-option v-for="item in deviceList" :key="item.deviceCode" :label="item.deviceName" :value="item.deviceCode"/>
87
- </el-select>
88
- <el-select v-model="fieldCode" placeholder="请选择字段" @change="checkField" size="small" filterable clearable style="margin-top: 10px">
89
- <el-option v-for="item in fieldList" :key="item.dataField" :label="item.name" :value="item.dataField"/>
90
- </el-select>
91
- </el-col>
92
- </el-row>
93
- <el-row :gutter="20">
94
- <el-col :span="12">
95
- <div class="row-label">条件配置</div>
96
- </el-col>
97
- <el-col :span="12">
98
- <el-switch v-model="isCondition" :active-value="true" :inactive-value="false" size="small" @change="changeCondition"/>
99
- <el-button type="primary" size="small" @click="showCondition" style="margin-left: 10px">配置</el-button>
100
- </el-col>
101
- </el-row>
102
- </div>
103
- </el-collapse-item>
104
- </el-collapse>
105
- <el-dialog v-model="dialogCondition.show" width="900px" title="条件配置" :show-close="false" :close-on-click-modal="false"
106
- :close-on-press-escape="false">
107
- <condition v-if="dialogCondition.show" :payload="dialogCondition.payload" type="arrow" @close="closeCondition"></condition>
108
- </el-dialog>
109
- </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">颜色</div>
13
+ </el-col>
14
+ <el-col :span="12">
15
+ <el-color-picker v-model="stroke" :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">粗细</div>
21
+ </el-col>
22
+ <el-col :span="12">
23
+ <el-input-number v-model="strokeWidth" size="small" controls-position="right"
24
+ @change="changeLine" :min="1" :max="10"
25
+ :step="1"/>
26
+ </el-col>
27
+ </el-row>
28
+ </div>
29
+ </el-collapse-item>
30
+ <el-collapse-item title="箭头设置" name="1">
31
+ <div class="row-column">
32
+ <el-row :gutter="20">
33
+ <el-col :span="12">
34
+ <div class="row-label">箭头数量</div>
35
+ </el-col>
36
+ <el-col :span="12">
37
+ <el-input-number v-model="arrowNumber" size="small" controls-position="right"
38
+ @change="changeLine" :min="1" :max="20"
39
+ :step="1"/>
40
+ </el-col>
41
+ </el-row>
42
+ <el-row :gutter="20">
43
+ <el-col :span="12">
44
+ <div class="row-label">箭头颜色</div>
45
+ </el-col>
46
+ <el-col :span="12">
47
+ <el-color-picker v-model="fill" :show-alpha="true" size="small" @change="changeLine"/>
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="direction" size="small" @change="changeLine">
56
+ <el-option v-for="item in arrowDirection" :key="item.value" :label="item.label"
57
+ :value="item.value"/>
58
+ </el-select>
59
+ </el-col>
60
+ </el-row>
61
+ <el-row :gutter="20">
62
+ <el-col :span="12">
63
+ <div class="row-label">默认箭头动作</div>
64
+ </el-col>
65
+ <el-col :span="12">
66
+ <el-switch v-model="animation" :active-value="FLASHING" active-text="闪烁"
67
+ :inactive-value="STOP" inactive-text="静止" size="small"
68
+ @change="changeLine"/>
69
+ </el-col>
70
+ </el-row>
71
+ <el-row :gutter="20">
72
+ <el-col :span="12">
73
+ <div class="row-label">默认箭头显示</div>
74
+ </el-col>
75
+ <el-col :span="12">
76
+ <el-switch v-model="display" active-value="block" active-text="显示" inactive-value="none"
77
+ inactive-text="隐藏" size="small"
78
+ @change="changeLine"/>
79
+ </el-col>
80
+ </el-row>
81
+ </div>
82
+ </el-collapse-item>
83
+ <el-collapse-item title="动态设置" 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="deviceCode" placeholder="请选择设备" @change="checkDevice" size="small"
91
+ filterable clearable>
92
+ <el-option v-for="item in deviceList" :key="item.deviceCode" :label="item.deviceName"
93
+ :value="item.deviceCode"/>
94
+ </el-select>
95
+ <el-select v-model="fieldCode" placeholder="请选择字段" @change="checkField" size="small"
96
+ filterable clearable style="margin-top: 10px">
97
+ <el-option v-for="item in fieldList" :key="item.dataField" :label="item.name"
98
+ :value="item.dataField"/>
99
+ </el-select>
100
+ </el-col>
101
+ </el-row>
102
+ <el-row :gutter="20">
103
+ <el-col :span="12">
104
+ <div class="row-label">条件配置</div>
105
+ </el-col>
106
+ <el-col :span="12">
107
+ <el-switch v-model="isCondition" :active-value="true" :inactive-value="false" size="small"
108
+ @change="changeCondition"/>
109
+ <el-button type="primary" size="small" @click="showCondition" style="margin-left: 10px">
110
+ 配置
111
+ </el-button>
112
+ </el-col>
113
+ </el-row>
114
+ </div>
115
+ </el-collapse-item>
116
+ </el-collapse>
117
+ <el-dialog v-model="dialogCondition.show" width="900px" title="条件配置" :show-close="false"
118
+ :close-on-click-modal="false"
119
+ :close-on-press-escape="false">
120
+ <condition v-if="dialogCondition.show" :payload="dialogCondition.payload" type="arrow"
121
+ @close="closeCondition"></condition>
122
+ </el-dialog>
123
+ </div>
110
124
  </template>
111
125
 
112
126
  <script setup>
@@ -118,9 +132,13 @@ import {getDeviceList, getFieldList} from "packages/components/common.js";
118
132
  import Condition from "packages/components/edge-control/condition.vue";
119
133
 
120
134
  const props = defineProps({
121
- payload: {
122
- type: Object
123
- }
135
+ payload: {
136
+ type: Object,
137
+ itemId: {
138
+ type: String,
139
+ default: ''
140
+ }
141
+ }
124
142
  })
125
143
 
126
144
  const activeName = ref('0')
@@ -142,30 +160,30 @@ const display = ref(props.payload.attrs.arrow.display)
142
160
  * 修改线段样式
143
161
  */
144
162
  const changeLine = () => {
145
- props.payload.attr('line/stroke', stroke.value)
146
- props.payload.attr('line/strokeWidth', strokeWidth.value)
147
- props.payload.attr('arrow/fill', fill.value)
148
- props.payload.attr('arrow/stroke', fill.value)
149
- // 箭头数量
150
- if (arrowNumber.value !== oldArrowNumber) {
151
- props.payload.markup = props.payload.markup.slice(0, 1)
152
- for (let i = 0; i < arrowNumber.value; i++) {
153
- props.payload.markup.push({
154
- tagName: 'path',
155
- groupSelector: 'arrow',
156
- selector: 'arrow' + (i + 1),
157
- })
158
- props.payload.attr('arrow' + (i + 1), {
159
- atConnectionRatio: (1 / (arrowNumber.value + 1)) * (i + 1),
160
- })
163
+ props.payload.attr('line/stroke', stroke.value)
164
+ props.payload.attr('line/strokeWidth', strokeWidth.value)
165
+ props.payload.attr('arrow/fill', fill.value)
166
+ props.payload.attr('arrow/stroke', fill.value)
167
+ // 箭头数量
168
+ if (arrowNumber.value !== oldArrowNumber) {
169
+ props.payload.markup = props.payload.markup.slice(0, 1)
170
+ for (let i = 0; i < arrowNumber.value; i++) {
171
+ props.payload.markup.push({
172
+ tagName: 'path',
173
+ groupSelector: 'arrow',
174
+ selector: 'arrow' + (i + 1),
175
+ })
176
+ props.payload.attr('arrow' + (i + 1), {
177
+ atConnectionRatio: (1 / (arrowNumber.value + 1)) * (i + 1),
178
+ })
179
+ }
161
180
  }
162
- }
163
- props.payload.attr('arrow/d', direction.value === ARROWFORWARD ? arrowForward : arrowBackward)
164
- props.payload.attr('arrow/style/animation', animation.value === FLASHING ? 'flashing 2s infinite linear' : '')
165
- props.payload.attr('arrow/display', display.value)
166
- console.log(props.payload.markup)
167
- lineOptions.markup = props.payload.markup
168
- lineOptions.attrs = props.payload.attrs
181
+ props.payload.attr('arrow/d', direction.value === ARROWFORWARD ? arrowForward : arrowBackward)
182
+ props.payload.attr('arrow/style/animation', animation.value === FLASHING ? 'flashing 2s infinite linear' : '')
183
+ props.payload.attr('arrow/display', display.value)
184
+ console.log(props.payload.markup)
185
+ lineOptions.markup = props.payload.markup
186
+ lineOptions.attrs = props.payload.attrs
169
187
  }
170
188
 
171
189
  const deviceList = ref([]) // 设备列表
@@ -176,10 +194,10 @@ const fieldCode = ref(props.payload.data?.fields?.[0]?.field ?? '') // 字段编
176
194
  * 获取设备列表
177
195
  */
178
196
  const getDevices = async () => {
179
- deviceList.value = await getDeviceList()
180
- if (deviceCode.value) {
181
- checkDevice()
182
- }
197
+ deviceList.value = await getDeviceList(props.itemId)
198
+ if (deviceCode.value) {
199
+ checkDevice()
200
+ }
183
201
  }
184
202
 
185
203
  let currentDevice = reactive({}) // 当前设备信息
@@ -188,21 +206,21 @@ let currentDevice = reactive({}) // 当前设备信息
188
206
  * 监听设备编码变化
189
207
  */
190
208
  const checkDevice = () => {
191
- currentDevice = deviceList.value.find(item => item.deviceCode === deviceCode.value)
192
- if (currentDevice) {
193
- getFields()
194
- props.payload.data.fields = [{
195
- index: 0,
196
- deviceName: currentDevice.deviceName,
197
- deviceCode: currentDevice.deviceCode,
198
- field: fieldCode.value ?? '',
199
- }]
200
- fieldCode.value = props.payload.data.fields[0].field
201
- } else {
202
- fieldCode.value = ''
203
- props.payload.data.fields = []
204
- }
205
- console.log('箭头线-配置', props.payload)
209
+ currentDevice = deviceList.value.find(item => item.deviceCode === deviceCode.value)
210
+ if (currentDevice) {
211
+ getFields()
212
+ props.payload.data.fields = [{
213
+ index: 0,
214
+ deviceName: currentDevice.deviceName,
215
+ deviceCode: currentDevice.deviceCode,
216
+ field: fieldCode.value ?? '',
217
+ }]
218
+ fieldCode.value = props.payload.data.fields[0].field
219
+ } else {
220
+ fieldCode.value = ''
221
+ props.payload.data.fields = []
222
+ }
223
+ console.log('箭头线-配置', props.payload)
206
224
  }
207
225
 
208
226
  const fieldList = ref([])
@@ -211,20 +229,20 @@ const fieldList = ref([])
211
229
  * 获取字段列表
212
230
  */
213
231
  const getFields = async () => {
214
- fieldList.value = await getFieldList(currentDevice.deviceCode)
232
+ fieldList.value = await getFieldList(currentDevice.deviceCode)
215
233
  }
216
234
 
217
235
  /**
218
236
  * 监听字段编码变化
219
237
  */
220
238
  const checkField = () => {
221
- props.payload.data.fields = [{
222
- index: 0,
223
- deviceName: currentDevice.deviceName,
224
- deviceCode: currentDevice.deviceCode,
225
- field: fieldCode.value ?? '',
226
- }]
227
- console.log('箭头线-配置', props.payload)
239
+ props.payload.data.fields = [{
240
+ index: 0,
241
+ deviceName: currentDevice.deviceName,
242
+ deviceCode: currentDevice.deviceCode,
243
+ field: fieldCode.value ?? '',
244
+ }]
245
+ console.log('箭头线-配置', props.payload)
228
246
  }
229
247
 
230
248
  // 条件线是否开启
@@ -234,21 +252,21 @@ const isCondition = ref(props.payload.data.isCondition ?? false)
234
252
  * 条件线改变
235
253
  */
236
254
  const changeCondition = () => {
237
- props.payload.data.isCondition = isCondition.value
255
+ props.payload.data.isCondition = isCondition.value
238
256
  }
239
257
 
240
258
  // 条件线配置
241
259
  const dialogCondition = reactive({
242
- show: false,
243
- payload: null
260
+ show: false,
261
+ payload: null
244
262
  })
245
263
 
246
264
  /**
247
265
  * 条件线配置显示
248
266
  */
249
267
  const showCondition = () => {
250
- dialogCondition.show = true
251
- dialogCondition.payload = props.payload.data.condition ?? []
268
+ dialogCondition.show = true
269
+ dialogCondition.payload = props.payload.data.condition ?? []
252
270
  }
253
271
 
254
272
  /**
@@ -256,16 +274,16 @@ const showCondition = () => {
256
274
  * @param condition
257
275
  */
258
276
  const closeCondition = (condition) => {
259
- dialogCondition.show = false
260
- dialogCondition.payload = null
261
- if (condition) {
262
- props.payload.data.condition = condition
263
- }
264
- console.log('条件线', props.payload.data)
277
+ dialogCondition.show = false
278
+ dialogCondition.payload = null
279
+ if (condition) {
280
+ props.payload.data.condition = condition
281
+ }
282
+ console.log('条件线', props.payload.data)
265
283
  }
266
284
 
267
285
  onMounted(() => {
268
- getDevices()
286
+ getDevices()
269
287
  })
270
288
  </script>
271
289
 
@@ -3,22 +3,22 @@
3
3
  * @Date: 2025/4/9 09:22
4
4
  */
5
5
  <template>
6
- <div class="container">
7
- <div class="row-column" style="padding:5px 1px 10px">
8
- <el-row :gutter="20">
9
- <el-col :span="12">
10
- <div class="row-label">线段类型</div>
11
- </el-col>
12
- <el-col :span="12">
13
- <el-select v-model="type" placeholder="请选择线段类型" clearable size="small" @change="changeType">
14
- <el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value">
15
- </el-option>
16
- </el-select>
17
- </el-col>
18
- </el-row>
6
+ <div class="container">
7
+ <div class="row-column" style="padding:5px 1px 10px">
8
+ <el-row :gutter="20">
9
+ <el-col :span="12">
10
+ <div class="row-label">线段类型</div>
11
+ </el-col>
12
+ <el-col :span="12">
13
+ <el-select v-model="type" placeholder="请选择线段类型" clearable size="small" @change="changeType">
14
+ <el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value">
15
+ </el-option>
16
+ </el-select>
17
+ </el-col>
18
+ </el-row>
19
+ </div>
20
+ <component :is="component" :payload="payload" :itemId="itemId"></component>
19
21
  </div>
20
- <component :is="component" :payload="payload"></component>
21
- </div>
22
22
  </template>
23
23
 
24
24
  <script setup>
@@ -30,7 +30,11 @@ import PipeLine from "packages/components/edge-control/pipe-line.vue";
30
30
  import ArrowLine from "packages/components/edge-control/arrow-line.vue";
31
31
 
32
32
  const props = defineProps({
33
- payload: Object
33
+ payload: Object,
34
+ itemId: {
35
+ type: String,
36
+ default: ''
37
+ }
34
38
  })
35
39
 
36
40
  // 线段类型
@@ -40,23 +44,23 @@ const type = ref(props.payload.data.type)
40
44
  * 更改线段类型
41
45
  */
42
46
  const changeType = () => {
43
- props.payload.data.type = type.value
44
- if (type.value === LINE) {
45
- lineOptions.attrs = defaultLine.attrs
46
- lineOptions.markup = defaultLine.markup
47
- }
48
- if (type.value === PIPE) {
49
- lineOptions.attrs = pipeOptions.attrs
50
- lineOptions.markup = pipeOptions.markup
51
- }
52
- if (type.value === ARROW) {
53
- lineOptions.attrs = arrowOptions.attrs
54
- lineOptions.markup = arrowOptions.markup
55
- }
56
- props.payload.attrs = null
57
- props.payload.attr(lineOptions.attrs)
58
- props.payload.markup = lineOptions.markup
59
- setComponent()
47
+ props.payload.data.type = type.value
48
+ if (type.value === LINE) {
49
+ lineOptions.attrs = defaultLine.attrs
50
+ lineOptions.markup = defaultLine.markup
51
+ }
52
+ if (type.value === PIPE) {
53
+ lineOptions.attrs = pipeOptions.attrs
54
+ lineOptions.markup = pipeOptions.markup
55
+ }
56
+ if (type.value === ARROW) {
57
+ lineOptions.attrs = arrowOptions.attrs
58
+ lineOptions.markup = arrowOptions.markup
59
+ }
60
+ props.payload.attrs = null
61
+ props.payload.attr(lineOptions.attrs)
62
+ props.payload.markup = lineOptions.markup
63
+ setComponent()
60
64
  }
61
65
 
62
66
  // 组件
@@ -66,20 +70,20 @@ const component = shallowRef(null)
66
70
  * 设置组件
67
71
  */
68
72
  const setComponent = () => {
69
- component.value = null
70
- if (type.value === LINE) {
71
- component.value = DefaultLine
72
- }
73
- if (type.value === PIPE) {
74
- component.value = PipeLine
75
- }
76
- if (type.value === ARROW) {
77
- component.value = ArrowLine
78
- }
73
+ component.value = null
74
+ if (type.value === LINE) {
75
+ component.value = DefaultLine
76
+ }
77
+ if (type.value === PIPE) {
78
+ component.value = PipeLine
79
+ }
80
+ if (type.value === ARROW) {
81
+ component.value = ArrowLine
82
+ }
79
83
  }
80
84
 
81
85
  onMounted(() => {
82
- setComponent()
86
+ setComponent()
83
87
  })
84
88
 
85
89
  </script>