MCPcopy Create free account
hub / github.com/MankaiHuang/screen-visualization / cannelGroup

Function cannelGroup

public/iframe/lib/js/mixinsGroup.js:19–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17 this.sendMsg('setLayerNowId', null, { elementId: null })
18 },
19 cannelGroup () {
20 // 取消成组
21 // 根据nowGroupId 的parentId查找当前选中的组的父组 然后解散当前组
22 if (!this.nowGroupId) return;
23 const nowGroup = this.findGroupForId(this.nowGroupId)
24 const { parentId } = nowGroup.property
25 const newSpreadTemplate = []
26 const find = (node, parentLeft, parentTop) => {
27 // 查找当前组下所有组件并解散
28 const { left, top } = node.property // 当前组的 left top 解散之后要将此数据加入到他的children组件中 保持left top 正确
29 const nowParentLeft = left + parentLeft
30 const nowParentTop = top + parentTop
31 node.property.children.forEach(item => {
32 const { type, children } = item.property
33 if (type !== 'group') {
34 item.property.left += nowParentLeft // 累加传给子组
35 item.property.top += nowParentTop
36 parentId && (item.property.groupId = parentId) // 有父组 则将groupId加入父组
37 newSpreadTemplate.push(item)
38 } else if (children.length > 0) {
39 find(item, nowParentLeft, nowParentTop)
40 }
41 })
42 }
43 find(nowGroup, 0, 0)
44 if (parentId) {
45 const parentGroup = this.findGroupForId(parentId)
46 parentGroup && parentGroup.property.children.push(...newSpreadTemplate)
47 } else {
48 this.templateList.push(...newSpreadTemplate)
49 }
50 nowGroup.property.children = []
51 this.isHaveChildren(this.nowGroupId) // 删除当前组
52 this.$nextTick(() => {
53 newSpreadTemplate.forEach(item => {
54 this.enableDrag(item)
55 item.isLoading = this.guid()
56 })
57 })
58 this.sendMsg('group', 'group', this.templateList) // 更新图层
59 this.Toast('取消成组成功!', 'success')
60 this.isGroupMenu = false
61 },
62
63 getChildGroupProperty (template) {
64 // 获取下级的属性

Callers

nothing calls this directly

Calls 1

findFunction · 0.70

Tested by

no test coverage detected