vue-wiring-diagram 1.1.22 → 1.1.24

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 +5563 -5234
  4. package/dist/vue-wiring-diagram.umd.js +27 -27
  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 -355
  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,124 +1,290 @@
1
- /**
2
- * @Author: HuaYJ
3
- * @Date: 2024/11/5 11:35
4
- */
5
- <template>
6
- <div class="control-box">
7
- <el-collapse v-model="activeName" accordion>
8
- <el-collapse-item title="连接桩设置" name="3">
9
- <el-button type="primary" @click="addPorts" size="small">添加连接桩</el-button>
10
- <el-button type="primary" @click="showPort" size="small">显示连接桩</el-button>
11
- <el-table :data="ports" border size="small" style="margin-top: 10px;">
12
- <el-table-column label="ID" width="50" align="center">
13
- <template v-slot="{row}">
14
- {{ row.attrs.text.text }}
15
- </template>
16
- </el-table-column>
17
- <el-table-column label="x" width="100" align="center">
18
- <template v-slot="{row}">
19
- <el-slider v-model="row.args.x" :min="0" :max="100" :step="1" @input="(e) => changePorts(row.id, 'x', e)"/>
20
- </template>
21
- </el-table-column>
22
- <el-table-column label="y" width="100" align="center">
23
- <template v-slot="{row}">
24
- <el-slider v-model="row.args.y" :min="0" :max="100" :step="1" @input="(e) => changePorts(row.id, 'y', e)"/>
25
- </template>
26
- </el-table-column>
27
- <el-table-column label="操作" width="70" align="center">
28
- <template v-slot="{row}">
29
- <el-button type="danger" size="small" @click="deletePort(row.id)">
30
- <el-icon>
31
- <delete-filled/>
32
- </el-icon>
33
- </el-button>
34
- </template>
35
- </el-table-column>
36
- </el-table>
37
- </el-collapse-item>
38
- </el-collapse>
39
- </div>
40
- </template>
41
-
42
- <script setup>
43
-
44
- import {onMounted, ref} from "vue";
45
- import {showPorts} from "../common.js";
46
- import {DeleteFilled} from "@element-plus/icons-vue";
47
- import {portOption} from "../settings.js";
48
-
49
- const props = defineProps({
50
- payload: Object
51
- })
52
-
53
- const activeName = ref('3')
54
-
55
- const ports = ref([]) // 连接桩数据
56
-
57
- /**
58
- * 获取连接桩数据
59
- */
60
- const getPorts = () => {
61
- ports.value = JSON.parse(JSON.stringify(props.payload.getPorts().map((item) => {
62
- return {
63
- id: item.id,
64
- attrs: item.attrs,
65
- args: {
66
- x: Number(item.args.x.replace('%', '')),
67
- y: Number(item.args.y.replace('%', ''))
68
- }
69
- }
70
- })))
71
- }
72
-
73
- /**
74
- * 添加连接桩
75
- */
76
- const addPorts = () => {
77
- const port = portOption
78
- port.attrs.text.text = `${props.payload.getPorts().length + 1}`
79
- port.args.x = '50%'
80
- port.args.y = '50%'
81
- props.payload.addPorts([
82
- {
83
- group: 'ports',
84
- ...port
85
- },
86
- ])
87
- getPorts()
88
- }
89
-
90
- /**
91
- * 显示连接桩
92
- */
93
- const showPort = () => {
94
- showPorts("#drawing-board",true)
95
- }
96
-
97
- /**
98
- * 修改连接桩
99
- * @param id
100
- * @param key
101
- * @param value
102
- */
103
- const changePorts = (id, key, value) => {
104
- props.payload.portProp(id, 'args/' + key, value + '%')
105
- getPorts()
106
- }
107
-
108
- /**
109
- * 删除连接桩
110
- * @param id
111
- */
112
- const deletePort = (id) => {
113
- props.payload.removePort(id)
114
- getPorts()
115
- }
116
-
117
- onMounted(() => {
118
- getPorts()
119
- })
120
- </script>
121
-
122
- <style scoped lang="scss">
123
- @use "../../styles/editor.scss";
124
- </style>
1
+ /**
2
+ * @Author: HuaYJ
3
+ * @Date: 2024/11/5 11:35
4
+ */
5
+ <template>
6
+ <div class="control-box">
7
+ <el-collapse v-model="activeName" accordion>
8
+ <el-collapse-item title="图片设置" name="1">
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="deviceCode" placeholder="请选择设备" @change="checkDevice" size="small"
16
+ filterable clearable>
17
+ <el-option v-for="item in deviceList" :key="item.deviceCode" :label="item.deviceName"
18
+ :value="item.deviceCode"/>
19
+ </el-select>
20
+ <el-select v-model="fieldCode" placeholder="请选择字段" @change="checkField" size="small"
21
+ filterable clearable style="margin-top: 10px">
22
+ <el-option v-for="item in fieldList" :key="item.dataField" :label="item.name"
23
+ :value="item.dataField"/>
24
+ </el-select>
25
+ </el-col>
26
+ </el-row>
27
+ <el-row :gutter="20">
28
+ <el-col :span="12">
29
+ <div class="row-label">条件配置</div>
30
+ </el-col>
31
+ <el-col :span="12">
32
+ <el-switch v-model="isCondition" :active-value="true" :inactive-value="false" size="small"
33
+ @change="changeCondition"/>
34
+ <el-button type="primary" size="small" @click="showCondition" style="margin-left: 10px">
35
+ 配置
36
+ </el-button>
37
+ </el-col>
38
+ </el-row>
39
+ </div>
40
+ </el-collapse-item>
41
+ <el-collapse-item title="连接桩设置" name="3">
42
+ <el-button type="primary" @click="addPorts" size="small">添加连接桩</el-button>
43
+ <el-button type="primary" @click="showPort" size="small">显示连接桩</el-button>
44
+ <el-table :data="ports" border size="small" style="margin-top: 10px;">
45
+ <el-table-column label="ID" width="50" align="center">
46
+ <template v-slot="{row}">
47
+ {{ row.attrs.text.text }}
48
+ </template>
49
+ </el-table-column>
50
+ <el-table-column label="x" width="100" align="center">
51
+ <template v-slot="{row}">
52
+ <el-slider v-model="row.args.x" :min="0" :max="100" :step="1" @input="(e) => changePorts(row.id, 'x', e)"/>
53
+ </template>
54
+ </el-table-column>
55
+ <el-table-column label="y" width="100" align="center">
56
+ <template v-slot="{row}">
57
+ <el-slider v-model="row.args.y" :min="0" :max="100" :step="1" @input="(e) => changePorts(row.id, 'y', e)"/>
58
+ </template>
59
+ </el-table-column>
60
+ <el-table-column label="操作" width="70" align="center">
61
+ <template v-slot="{row}">
62
+ <el-button type="danger" size="small" @click="deletePort(row.id)">
63
+ <el-icon>
64
+ <delete-filled/>
65
+ </el-icon>
66
+ </el-button>
67
+ </template>
68
+ </el-table-column>
69
+ </el-table>
70
+ </el-collapse-item>
71
+ </el-collapse>
72
+
73
+ <!-- 条件配置弹窗 -->
74
+ <el-dialog v-model="dialogCondition.show" width="550px" title="条件配置" :show-close="false"
75
+ :close-on-click-modal="false"
76
+ :close-on-press-escape="false">
77
+ <image-condition v-if="dialogCondition.show" :payload="dialogCondition.payload" type="image"
78
+ @close="closeCondition"></image-condition>
79
+ </el-dialog>
80
+ </div>
81
+ </template>
82
+
83
+ <script setup>
84
+
85
+ import {onMounted, reactive, ref} from "vue";
86
+ import {showPorts, getDeviceList, getFieldList} from "../common.js";
87
+ import {DeleteFilled} from "@element-plus/icons-vue";
88
+ import {portOption} from "../settings.js";
89
+ import ImageCondition from "./image-condition.vue";
90
+
91
+ const props = defineProps({
92
+ payload: Object,
93
+ itemId: {
94
+ type: String,
95
+ default: ''
96
+ }
97
+ })
98
+
99
+ // 确保图片节点 data 结构存在,避免写入时 data 为 undefined 抛错
100
+ const ensureImageData = () => {
101
+ if (!props.payload.data) {
102
+ props.payload.data = {
103
+ type: 'image',
104
+ isCondition: false,
105
+ fields: [],
106
+ condition: []
107
+ }
108
+ } else {
109
+ if (typeof props.payload.data.type === 'undefined') props.payload.data.type = 'image'
110
+ if (typeof props.payload.data.isCondition === 'undefined') props.payload.data.isCondition = false
111
+ if (!Array.isArray(props.payload.data.fields)) props.payload.data.fields = []
112
+ if (!Array.isArray(props.payload.data.condition)) props.payload.data.condition = []
113
+ }
114
+ }
115
+ ensureImageData()
116
+
117
+ const activeName = ref('1')
118
+
119
+ const ports = ref([]) // 连接桩数据
120
+
121
+ // 设备相关
122
+ const deviceList = ref([]) // 设备列表
123
+ const deviceCode = ref(props.payload.data?.fields?.[0]?.deviceCode ?? '') // 设备编码
124
+ const fieldCode = ref(props.payload.data?.fields?.[0]?.field ?? '') // 字段编码
125
+ const fieldList = ref([]) // 字段列表
126
+
127
+ let currentDevice = reactive({}) // 当前设备信息
128
+
129
+ // 条件相关
130
+ const isCondition = ref(props.payload.data?.isCondition ?? false) // 条件线是否开启
131
+ const dialogCondition = reactive({
132
+ show: false,
133
+ payload: null
134
+ })
135
+
136
+ /**
137
+ * 获取设备列表
138
+ */
139
+ const getDevices = async () => {
140
+ deviceList.value = await getDeviceList(props.itemId)
141
+ if (deviceCode.value) {
142
+ checkDevice()
143
+ }
144
+ }
145
+
146
+ /**
147
+ * 监听设备编码变化
148
+ */
149
+ const checkDevice = () => {
150
+ ensureImageData()
151
+ currentDevice = deviceList.value.find(item => item.deviceCode === deviceCode.value)
152
+ if (currentDevice) {
153
+ getFields()
154
+ props.payload.data.fields = [{
155
+ index: 0,
156
+ deviceName: currentDevice.deviceName,
157
+ deviceCode: currentDevice.deviceCode,
158
+ field: fieldCode.value ?? '',
159
+ }]
160
+ fieldCode.value = props.payload.data.fields[0].field
161
+ } else {
162
+ fieldCode.value = ''
163
+ props.payload.data.fields = []
164
+ }
165
+ console.log('图片配置', props.payload)
166
+ }
167
+
168
+ /**
169
+ * 获取字段列表
170
+ */
171
+ const getFields = async () => {
172
+ if (!currentDevice?.deviceCode) return
173
+ fieldList.value = await getFieldList(currentDevice.deviceCode)
174
+ }
175
+
176
+ /**
177
+ * 监听字段编码变化
178
+ */
179
+ const checkField = () => {
180
+ ensureImageData()
181
+ props.payload.data.fields = [{
182
+ index: 0,
183
+ deviceName: currentDevice?.deviceName ?? '',
184
+ deviceCode: currentDevice?.deviceCode ?? '',
185
+ field: fieldCode.value ?? '',
186
+ }]
187
+ console.log('图片配置', props.payload)
188
+ }
189
+
190
+ /**
191
+ * 条件线改变
192
+ */
193
+ const changeCondition = () => {
194
+ ensureImageData()
195
+ props.payload.data.isCondition = isCondition.value
196
+ }
197
+
198
+ /**
199
+ * 条件线配置显示
200
+ */
201
+ const showCondition = () => {
202
+ ensureImageData()
203
+ dialogCondition.show = true
204
+ dialogCondition.payload = props.payload.data.condition ?? []
205
+ }
206
+
207
+ /**
208
+ * 条件线配置关闭
209
+ * @param condition
210
+ */
211
+ const closeCondition = (condition) => {
212
+ dialogCondition.show = false
213
+ dialogCondition.payload = null
214
+ if (condition) {
215
+ ensureImageData()
216
+ props.payload.data.condition = condition
217
+ }
218
+ console.log('图片条件配置', props.payload.data)
219
+ }
220
+
221
+ /**
222
+ * 获取连接桩数据
223
+ */
224
+ const getPorts = () => {
225
+ ports.value = JSON.parse(JSON.stringify(props.payload.getPorts().map((item) => {
226
+ return {
227
+ id: item.id,
228
+ attrs: item.attrs,
229
+ args: {
230
+ x: Number(item.args.x.replace('%', '')),
231
+ y: Number(item.args.y.replace('%', ''))
232
+ }
233
+ }
234
+ })))
235
+ }
236
+
237
+ /**
238
+ * 添加连接桩
239
+ */
240
+ const addPorts = () => {
241
+ const port = portOption
242
+ port.attrs.text.text = `${props.payload.getPorts().length + 1}`
243
+ port.args.x = '50%'
244
+ port.args.y = '50%'
245
+ props.payload.addPorts([
246
+ {
247
+ group: 'ports',
248
+ ...port
249
+ },
250
+ ])
251
+ getPorts()
252
+ }
253
+
254
+ /**
255
+ * 显示连接桩
256
+ */
257
+ const showPort = () => {
258
+ showPorts("#drawing-board",true)
259
+ }
260
+
261
+ /**
262
+ * 修改连接桩
263
+ * @param id
264
+ * @param key
265
+ * @param value
266
+ */
267
+ const changePorts = (id, key, value) => {
268
+ props.payload.portProp(id, 'args/' + key, value + '%')
269
+ getPorts()
270
+ }
271
+
272
+ /**
273
+ * 删除连接桩
274
+ * @param id
275
+ */
276
+ const deletePort = (id) => {
277
+ props.payload.removePort(id)
278
+ getPorts()
279
+ }
280
+
281
+ onMounted(() => {
282
+ ensureImageData()
283
+ getPorts()
284
+ getDevices()
285
+ })
286
+ </script>
287
+
288
+ <style scoped lang="scss">
289
+ @use "../../styles/editor.scss";
290
+ </style>
@@ -1,21 +1,21 @@
1
- export const portsOptions = {
2
- groups: {
3
- ports: {
4
- position: 'absolute',
5
- args: {
6
- x: 0,
7
- y: 0,
8
- },
9
- attrs: {
10
- circle: {
11
- magnet: true,
12
- stroke: '#8f8f8f',
13
- r: 4,
14
- },
15
- },
16
- label: {
17
- position: 'top',
18
- },
19
- },
20
- }
21
- }
1
+ export const portsOptions = {
2
+ groups: {
3
+ ports: {
4
+ position: 'absolute',
5
+ args: {
6
+ x: 0,
7
+ y: 0,
8
+ },
9
+ attrs: {
10
+ circle: {
11
+ magnet: true,
12
+ stroke: '#8f8f8f',
13
+ r: 4,
14
+ },
15
+ },
16
+ label: {
17
+ position: 'top',
18
+ },
19
+ },
20
+ }
21
+ }