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.
Files changed (32) hide show
  1. package/README.md +93 -93
  2. package/dist/style.css +1 -1
  3. package/dist/vue-wiring-diagram.es.js +6235 -5903
  4. package/dist/vue-wiring-diagram.umd.js +29 -29
  5. package/package.json +1 -1
  6. package/packages/components/Shortcuts.vue +31 -31
  7. package/packages/components/baseShape.js +62 -62
  8. package/packages/components/common.js +105 -105
  9. package/packages/components/edge-control/arrow-line.vue +292 -292
  10. package/packages/components/edge-control/condition.vue +110 -110
  11. package/packages/components/edge-control/default-line.vue +156 -156
  12. package/packages/components/edge-control/index.vue +94 -94
  13. package/packages/components/edge-control/pipe-line.vue +354 -354
  14. package/packages/components/editor/index.vue +590 -590
  15. package/packages/components/enums.js +80 -80
  16. package/packages/components/graph-control/index.vue +121 -121
  17. package/packages/components/image-control/group-form.vue +114 -114
  18. package/packages/components/image-control/image-condition.vue +117 -0
  19. package/packages/components/image-control/image-form.vue +184 -184
  20. package/packages/components/image-control/image-management.vue +213 -213
  21. package/packages/components/image-control/index.vue +290 -124
  22. package/packages/components/portsOptions.js +21 -21
  23. package/packages/components/preview/index.vue +399 -347
  24. package/packages/components/settings.js +262 -262
  25. package/packages/components/text-control/index.vue +457 -457
  26. package/packages/components/tools.js +256 -256
  27. package/packages/http.js +104 -104
  28. package/packages/index.js +43 -43
  29. package/packages/styles/animation.scss +27 -27
  30. package/packages/styles/dialog.scss +4 -4
  31. package/packages/styles/editor.scss +165 -165
  32. package/packages/styles/elPath.scss +257 -257
@@ -1,292 +1,292 @@
1
- /**
2
- * @Author: HuaYJ
3
- * @Date: 2025/4/9 14:13
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-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>
124
- </template>
125
-
126
- <script setup>
127
-
128
- import {onMounted, reactive, ref} from "vue";
129
- import {arrowBackward, arrowForward, lineOptions} from "packages/components/settings.js";
130
- import {ARROWBACKWORD, arrowDirection, ARROWFORWARD, FLASHING, STOP} from "packages/components/enums.js";
131
- import {getDeviceList, getFieldList} from "packages/components/common.js";
132
- import Condition from "packages/components/edge-control/condition.vue";
133
-
134
- const props = defineProps({
135
- payload: {
136
- type: Object,
137
- itemId: {
138
- type: String,
139
- default: ''
140
- }
141
- }
142
- })
143
-
144
- const activeName = ref('0')
145
-
146
- console.log(props.payload)
147
-
148
- const stroke = ref(props.payload.attrs.line.stroke) // 颜色
149
- const strokeWidth = ref(props.payload.attrs.line.strokeWidth) // 粗细
150
-
151
- const oldArrowNumber = props.payload.markup.length - 1 // 记录箭头数量
152
- const arrowNumber = ref(props.payload.markup.length - 1) // 箭头数量
153
-
154
- const fill = ref(props.payload.attrs.arrow.fill) // 箭头颜色
155
- const direction = ref(props.payload.attrs.arrow.d === arrowForward ? ARROWFORWARD : ARROWBACKWORD) // 箭头方向
156
- const animation = ref(props.payload.attrs.arrow.style.animation.split(' ')[0] === FLASHING ? FLASHING : STOP) // 箭头闪烁
157
- const display = ref(props.payload.attrs.arrow.display)
158
-
159
- /**
160
- * 修改线段样式
161
- */
162
- const changeLine = () => {
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
- }
180
- }
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
187
- }
188
-
189
- const deviceList = ref([]) // 设备列表
190
- const deviceCode = ref(props.payload.data?.fields?.[0]?.deviceCode ?? '') // 设备编码
191
- const fieldCode = ref(props.payload.data?.fields?.[0]?.field ?? '') // 字段编码
192
-
193
- /**
194
- * 获取设备列表
195
- */
196
- const getDevices = async () => {
197
- deviceList.value = await getDeviceList(props.itemId)
198
- if (deviceCode.value) {
199
- checkDevice()
200
- }
201
- }
202
-
203
- let currentDevice = reactive({}) // 当前设备信息
204
-
205
- /**
206
- * 监听设备编码变化
207
- */
208
- const checkDevice = () => {
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)
224
- }
225
-
226
- const fieldList = ref([])
227
-
228
- /**
229
- * 获取字段列表
230
- */
231
- const getFields = async () => {
232
- fieldList.value = await getFieldList(currentDevice.deviceCode)
233
- }
234
-
235
- /**
236
- * 监听字段编码变化
237
- */
238
- const checkField = () => {
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)
246
- }
247
-
248
- // 条件线是否开启
249
- const isCondition = ref(props.payload.data.isCondition ?? false)
250
-
251
- /**
252
- * 条件线改变
253
- */
254
- const changeCondition = () => {
255
- props.payload.data.isCondition = isCondition.value
256
- }
257
-
258
- // 条件线配置
259
- const dialogCondition = reactive({
260
- show: false,
261
- payload: null
262
- })
263
-
264
- /**
265
- * 条件线配置显示
266
- */
267
- const showCondition = () => {
268
- dialogCondition.show = true
269
- dialogCondition.payload = props.payload.data.condition ?? []
270
- }
271
-
272
- /**
273
- * 条件线配置关闭
274
- * @param condition
275
- */
276
- const closeCondition = (condition) => {
277
- dialogCondition.show = false
278
- dialogCondition.payload = null
279
- if (condition) {
280
- props.payload.data.condition = condition
281
- }
282
- console.log('条件线', props.payload.data)
283
- }
284
-
285
- onMounted(() => {
286
- getDevices()
287
- })
288
- </script>
289
-
290
- <style scoped lang="scss">
291
- @use "../../styles/editor.scss";
292
- </style>
1
+ /**
2
+ * @Author: HuaYJ
3
+ * @Date: 2025/4/9 14:13
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-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>
124
+ </template>
125
+
126
+ <script setup>
127
+
128
+ import {onMounted, reactive, ref} from "vue";
129
+ import {arrowBackward, arrowForward, lineOptions} from "packages/components/settings.js";
130
+ import {ARROWBACKWORD, arrowDirection, ARROWFORWARD, FLASHING, STOP} from "packages/components/enums.js";
131
+ import {getDeviceList, getFieldList} from "packages/components/common.js";
132
+ import Condition from "packages/components/edge-control/condition.vue";
133
+
134
+ const props = defineProps({
135
+ payload: {
136
+ type: Object,
137
+ itemId: {
138
+ type: String,
139
+ default: ''
140
+ }
141
+ }
142
+ })
143
+
144
+ const activeName = ref('0')
145
+
146
+ console.log(props.payload)
147
+
148
+ const stroke = ref(props.payload.attrs.line.stroke) // 颜色
149
+ const strokeWidth = ref(props.payload.attrs.line.strokeWidth) // 粗细
150
+
151
+ const oldArrowNumber = props.payload.markup.length - 1 // 记录箭头数量
152
+ const arrowNumber = ref(props.payload.markup.length - 1) // 箭头数量
153
+
154
+ const fill = ref(props.payload.attrs.arrow.fill) // 箭头颜色
155
+ const direction = ref(props.payload.attrs.arrow.d === arrowForward ? ARROWFORWARD : ARROWBACKWORD) // 箭头方向
156
+ const animation = ref(props.payload.attrs.arrow.style.animation.split(' ')[0] === FLASHING ? FLASHING : STOP) // 箭头闪烁
157
+ const display = ref(props.payload.attrs.arrow.display)
158
+
159
+ /**
160
+ * 修改线段样式
161
+ */
162
+ const changeLine = () => {
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
+ }
180
+ }
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
187
+ }
188
+
189
+ const deviceList = ref([]) // 设备列表
190
+ const deviceCode = ref(props.payload.data?.fields?.[0]?.deviceCode ?? '') // 设备编码
191
+ const fieldCode = ref(props.payload.data?.fields?.[0]?.field ?? '') // 字段编码
192
+
193
+ /**
194
+ * 获取设备列表
195
+ */
196
+ const getDevices = async () => {
197
+ deviceList.value = await getDeviceList(props.itemId)
198
+ if (deviceCode.value) {
199
+ checkDevice()
200
+ }
201
+ }
202
+
203
+ let currentDevice = reactive({}) // 当前设备信息
204
+
205
+ /**
206
+ * 监听设备编码变化
207
+ */
208
+ const checkDevice = () => {
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)
224
+ }
225
+
226
+ const fieldList = ref([])
227
+
228
+ /**
229
+ * 获取字段列表
230
+ */
231
+ const getFields = async () => {
232
+ fieldList.value = await getFieldList(currentDevice.deviceCode)
233
+ }
234
+
235
+ /**
236
+ * 监听字段编码变化
237
+ */
238
+ const checkField = () => {
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)
246
+ }
247
+
248
+ // 条件线是否开启
249
+ const isCondition = ref(props.payload.data.isCondition ?? false)
250
+
251
+ /**
252
+ * 条件线改变
253
+ */
254
+ const changeCondition = () => {
255
+ props.payload.data.isCondition = isCondition.value
256
+ }
257
+
258
+ // 条件线配置
259
+ const dialogCondition = reactive({
260
+ show: false,
261
+ payload: null
262
+ })
263
+
264
+ /**
265
+ * 条件线配置显示
266
+ */
267
+ const showCondition = () => {
268
+ dialogCondition.show = true
269
+ dialogCondition.payload = props.payload.data.condition ?? []
270
+ }
271
+
272
+ /**
273
+ * 条件线配置关闭
274
+ * @param condition
275
+ */
276
+ const closeCondition = (condition) => {
277
+ dialogCondition.show = false
278
+ dialogCondition.payload = null
279
+ if (condition) {
280
+ props.payload.data.condition = condition
281
+ }
282
+ console.log('条件线', props.payload.data)
283
+ }
284
+
285
+ onMounted(() => {
286
+ getDevices()
287
+ })
288
+ </script>
289
+
290
+ <style scoped lang="scss">
291
+ @use "../../styles/editor.scss";
292
+ </style>