!199 feat 新增大屏组件批量复制功能,提升用户体验。

Merge pull request !199 from luoxuancong/dev
This commit is contained in:
Foming
2025-04-06 04:07:27 +00:00
committed by Gitee
2 changed files with 50 additions and 11 deletions

View File

@@ -295,16 +295,55 @@ const mixin = {
}, },
// 复制 // 复制
copylayer() { copylayer() {
const obj = this.deepClone(this.widgets[this.rightClickIndex]); if (this.selectedWidgets.length === 1) {
obj.value.position.top += 40; // 复制的元素向右下角偏移一点 // 单选复制
obj.value.position.left += 40; const obj = this.deepClone(this.widgets[this.rightClickIndex]);
obj.value.widgetId = Number(Math.random().toString().substr(2)).toString( obj.value.position.top += 40; // 复制的元素向右下角偏移一点
36 obj.value.position.left += 40;
); obj.value.widgetId = Number(
this.widgets.splice(this.widgets.length, 0, obj); Math.random()
this.$nextTick(() => { .toString()
this.layerClick(this.widgets.length - 1); // 复制后定位到最新的组件 .substr(2)
}); ).toString(36);
this.widgets.splice(this.widgets.length, 0, obj);
this.$nextTick(() => {
this.layerClick(this.widgets.length - 1); // 复制后定位到最新的组件
});
} else {
// 多选复制
this.handleMouseDown();
const selectedWidgets = [];
const selectedWidgetsDom = [];
this.widgets.filter(c => {
this.selectedWidgets.filter(d => {
if (c.value.widgetId === d.value.widgetId) {
selectedWidgets.push(c)
selectedWidgetsDom.push(d)
}
})
})
this.selectedWidgets = [];
selectedWidgets.map((sw, index) => {
const newSw = this.deepClone(sw)
newSw.value.position.left += 100;
newSw.value.widgetId = Number(
Math.random()
.toString()
.substr(2)
).toString(36);
this.widgets.push(newSw);
this.$nextTick(() => {
this.$refs.widgets.map(select => {
if (select.value.widgetId === newSw.value.widgetId) {
this.$nextTick(() => {
select.$refs.draggable.setActive(true);
this.selectedWidgets.push(select);
});
}
})
})
})
}
}, },
// 置顶 // 置顶
istopLayer() { istopLayer() {

View File

@@ -16,7 +16,7 @@
<div class="contentmenu__item" @click="noLockLayer" name="singleSelect"> <div class="contentmenu__item" @click="noLockLayer" name="singleSelect">
<i class="iconfont iconfuzhi1"></i> 解除锁定 <i class="iconfont iconfuzhi1"></i> 解除锁定
</div> </div>
<div class="contentmenu__item" @click="copyLayer" name="singleSelect"> <div class="contentmenu__item" @click="copyLayer">
<i class="iconfont iconfuzhi1"></i> 复制图层 <i class="iconfont iconfuzhi1"></i> 复制图层
</div> </div>
<div class="contentmenu__item" @click="istopLayer" name="singleSelect"> <div class="contentmenu__item" @click="istopLayer" name="singleSelect">