zydx-plus 1.36.641 → 1.36.642
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
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<button :disabled="!nodeData" @click="add">添加节点</button>
|
|
11
11
|
<button :disabled="delDisabled" @click="del">删除节点</button>
|
|
12
12
|
<button :disabled="!nodeData && !lines" @click="style">设置样式</button>
|
|
13
|
-
<button @click="dots"
|
|
13
|
+
<button :class="{'del-line-btn': lines}" @click="lines ? delLine() : dots($event)">{{ lines ? '删除关联线' : '关联线' }}</button>
|
|
14
14
|
<button :disabled="undoDisabled" @click="undo">上一步</button>
|
|
15
15
|
<button :disabled="forwardDisabled" @click="redo">下一步</button>
|
|
16
16
|
<button @click="download">下载图片</button>
|
|
@@ -164,10 +164,13 @@ export default {
|
|
|
164
164
|
})
|
|
165
165
|
// 监听窗口尺寸变化,全屏/退出或窗口缩放时重绘画布
|
|
166
166
|
window.addEventListener('resize', this.handleWindowResize)
|
|
167
|
+
// 注册删除快捷键(Delete / Backspace)
|
|
168
|
+
window.addEventListener('keydown', this.handleKeydown)
|
|
167
169
|
},
|
|
168
170
|
beforeUnmount() {
|
|
169
171
|
// 移除窗口事件监听,避免内存泄漏
|
|
170
172
|
window.removeEventListener('resize', this.handleWindowResize)
|
|
173
|
+
window.removeEventListener('keydown', this.handleKeydown)
|
|
171
174
|
},
|
|
172
175
|
methods: {
|
|
173
176
|
// ===== 全屏相关 =====
|
|
@@ -325,6 +328,32 @@ export default {
|
|
|
325
328
|
this.recordHistory()
|
|
326
329
|
}
|
|
327
330
|
},
|
|
331
|
+
// 删除关联线:移除当前选中的关联线,并同步数据、记录历史
|
|
332
|
+
delLine() {
|
|
333
|
+
if(!this.lines) return
|
|
334
|
+
const index = this.nodes.lines.findIndex(x => x.id === this.lines.id)
|
|
335
|
+
if(index > -1) this.nodes.lines.splice(index, 1)
|
|
336
|
+
this.graphInstance.removeLineById(this.lines.id)
|
|
337
|
+
this.lines = null
|
|
338
|
+
this.lineStatus = false
|
|
339
|
+
this.recordHistory()
|
|
340
|
+
},
|
|
341
|
+
// 删除快捷键:选中关联线按 Delete/Backspace 删除线;选中节点删除节点
|
|
342
|
+
handleKeydown(e) {
|
|
343
|
+
if (this.readOnly) return
|
|
344
|
+
// 正在文本编辑(输入框聚焦)时不触发删除,避免误删
|
|
345
|
+
const ae = document.activeElement
|
|
346
|
+
const tag = (ae && ae.tagName) || ''
|
|
347
|
+
if (tag === 'INPUT' || tag === 'TEXTAREA') return
|
|
348
|
+
if (e.key === 'Delete' || e.key === 'Backspace') {
|
|
349
|
+
e.preventDefault()
|
|
350
|
+
if (this.lines) {
|
|
351
|
+
this.delLine()
|
|
352
|
+
} else if (this.nodeData && !this.delDisabled) {
|
|
353
|
+
this.del()
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
},
|
|
328
357
|
// 设置样式
|
|
329
358
|
style() {
|
|
330
359
|
if(this.lines) this.lineStatus = true
|
|
@@ -419,6 +448,11 @@ export default {
|
|
|
419
448
|
widthUpdate() {
|
|
420
449
|
if(!this.nodeData || this.readOnly) return
|
|
421
450
|
const node = this.graphInstance.getNodeById(this.nodeData.id)
|
|
451
|
+
if (!node) {
|
|
452
|
+
// 节点已被删除,清空选中态避免后续访问 undefined 的属性
|
|
453
|
+
this.nodeData = null
|
|
454
|
+
return
|
|
455
|
+
}
|
|
422
456
|
this.nodeUpdate(node, {type: 'width', value: node.width})
|
|
423
457
|
this.nodeUpdate(node, {type: 'height', value: node.height})
|
|
424
458
|
},
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
<div class="style-list">
|
|
25
25
|
<div class="node-left padd">
|
|
26
26
|
<span>文字颜色</span>
|
|
27
|
-
<div @click="colorTap($event,'fontColor')" class="node-back-color"></div>
|
|
27
|
+
<div @click="colorTap($event,'fontColor')" class="node-back-color" :style="{backgroundColor: fontColorVal}"></div>
|
|
28
28
|
</div>
|
|
29
29
|
</div>
|
|
30
30
|
<div class="style-list">
|
|
31
31
|
<div class="node-left padd">
|
|
32
32
|
<span>线颜色</span>
|
|
33
|
-
<div @click="colorTap($event,'color')" class="node-back-color"></div>
|
|
33
|
+
<div @click="colorTap($event,'color')" class="node-back-color" :style="{backgroundColor: lineColorVal}"></div>
|
|
34
34
|
</div>
|
|
35
35
|
</div>
|
|
36
36
|
<div class="back-col" :style="{top: top + 'px'}" v-if="colorShow">
|
|
@@ -67,6 +67,11 @@ export default {
|
|
|
67
67
|
type: '',
|
|
68
68
|
color: 'rgba(84,150,136,1)',
|
|
69
69
|
text: '',
|
|
70
|
+
// ===== 颜色色块预览(随 node 数据/实时选取变化) =====
|
|
71
|
+
/** 当前文字颜色 */
|
|
72
|
+
fontColorVal: 'rgba(64, 158, 255, 1)',
|
|
73
|
+
/** 当前线颜色 */
|
|
74
|
+
lineColorVal: 'rgba(95,176,253,1)',
|
|
70
75
|
styleLine: [
|
|
71
76
|
{label: "直线", value: '1'},
|
|
72
77
|
{label: "鱼尾", value: '3'},
|
|
@@ -98,6 +103,9 @@ export default {
|
|
|
98
103
|
this.styleValue = this.node.lineWidth || '2'
|
|
99
104
|
this.text = this.node.text || ''
|
|
100
105
|
this.styleValue = this.node.lineShape.toString() || '1'
|
|
106
|
+
// 从连线数据中回填文字/线颜色到色块预览
|
|
107
|
+
this.fontColorVal = this.node.fontColor || 'rgba(64, 158, 255, 1)'
|
|
108
|
+
this.lineColorVal = this.node.color || 'rgba(95,176,253,1)'
|
|
101
109
|
if(this.type === 'fontColor') this.color = this.node.fontColor || 'rgba(64, 158, 255, 1)'
|
|
102
110
|
if(this.type === 'color') this.color = this.node.color || 'rgba(95,176,253,1)'
|
|
103
111
|
},
|
|
@@ -146,6 +154,9 @@ export default {
|
|
|
146
154
|
this.colorShow = false
|
|
147
155
|
},
|
|
148
156
|
rgba(v) {
|
|
157
|
+
// 实时更新对应色块预览
|
|
158
|
+
if (this.type === 'fontColor') this.fontColorVal = v.rgba
|
|
159
|
+
if (this.type === 'color') this.lineColorVal = v.rgba
|
|
149
160
|
this.$emit('select', {type: this.type, value: v.rgba})
|
|
150
161
|
},
|
|
151
162
|
}
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
<div class="style-list">
|
|
37
37
|
<div class="node-left">
|
|
38
38
|
<span>颜色</span>
|
|
39
|
-
<div @click="colorTap($event,'borderColor')" class="backColor"></div>
|
|
39
|
+
<div @click="colorTap($event,'borderColor')" class="backColor" :style="{backgroundColor: borderColorVal}"></div>
|
|
40
40
|
</div>
|
|
41
41
|
<div class="node-left padd">
|
|
42
42
|
<span>宽度</span>
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
<div class="style-list">
|
|
52
52
|
<div class="node-left">
|
|
53
53
|
<span>颜色</span>
|
|
54
|
-
<div @click="colorTap($event,'color')" class="backColor"></div>
|
|
54
|
+
<div @click="colorTap($event,'color')" class="backColor" :style="{backgroundColor: bgColorVal}"></div>
|
|
55
55
|
</div>
|
|
56
56
|
</div>
|
|
57
57
|
</div>
|
|
@@ -155,6 +155,12 @@ export default {
|
|
|
155
155
|
/** 当前边框宽度 */
|
|
156
156
|
styleValue: '0',
|
|
157
157
|
|
|
158
|
+
// ===== 颜色色块预览(随 node 数据/实时选取变化) =====
|
|
159
|
+
/** 当前边框颜色 */
|
|
160
|
+
borderColorVal: 'rgba(64, 158, 255, 1)',
|
|
161
|
+
/** 当前背景颜色 */
|
|
162
|
+
bgColorVal: 'rgba(64, 158, 255, 1)',
|
|
163
|
+
|
|
158
164
|
// ===== 形状选项 =====
|
|
159
165
|
optionShape: [
|
|
160
166
|
{label: "圆形", value: '0'},
|
|
@@ -187,6 +193,12 @@ export default {
|
|
|
187
193
|
emits: ['update:open', 'select'],
|
|
188
194
|
|
|
189
195
|
watch: {
|
|
196
|
+
node: {
|
|
197
|
+
handler(val) {
|
|
198
|
+
console.log(val)
|
|
199
|
+
},
|
|
200
|
+
deep: true
|
|
201
|
+
},
|
|
190
202
|
/**
|
|
191
203
|
* 监听弹窗打开/关闭
|
|
192
204
|
* 打开时从 node 中回填当前样式值;关闭时隐藏颜色选择器
|
|
@@ -206,6 +218,9 @@ export default {
|
|
|
206
218
|
this.scribeAct = this.node.textDecoration === 'underline'
|
|
207
219
|
this.styleValue = this.node.borderWidth || '0'
|
|
208
220
|
this.shapeValue = this.node.nodeShape || '0'
|
|
221
|
+
// 从节点数据回填边框/背景颜色到色块预览
|
|
222
|
+
this.borderColorVal = this.node.borderColor || 'rgba(64, 158, 255, 1)'
|
|
223
|
+
this.bgColorVal = this.node.color || 'rgba(64, 158, 255, 1)'
|
|
209
224
|
// 根据当前颜色编辑类型初始化颜色值
|
|
210
225
|
if (this.type === 'fontColor') this.color = this.node.fontColor || 'rgba(255, 255, 255, 1)'
|
|
211
226
|
if (this.type === 'borderColor') this.color = this.node.borderColor || 'rgba(64, 158, 255, 1)'
|
|
@@ -306,6 +321,9 @@ export default {
|
|
|
306
321
|
* @param {{rgba: string}} v - 颜色选择器输出的 rgba 值
|
|
307
322
|
*/
|
|
308
323
|
rgba(v) {
|
|
324
|
+
// 实时更新对应色块预览
|
|
325
|
+
if (this.type === 'borderColor') this.borderColorVal = v.rgba
|
|
326
|
+
if (this.type === 'color') this.bgColorVal = v.rgba
|
|
309
327
|
this.$emit('select', {type: this.type, value: v.rgba})
|
|
310
328
|
},
|
|
311
329
|
|