Commit 9a0b5563 by 高源

动作集更名为actions

parent bd64c77f
...@@ -172,7 +172,7 @@ export default { ...@@ -172,7 +172,7 @@ export default {
actionAll: [{ actionAll: [{
name: '根目录', name: '根目录',
Kvid: 123123, Kvid: 123123,
children: [] actions: []
}], }],
actionConfigs: {} actionConfigs: {}
...@@ -309,7 +309,7 @@ export default { ...@@ -309,7 +309,7 @@ export default {
this.dynamicTagObj.actionName = '新建动作' this.dynamicTagObj.actionName = '新建动作'
this.dynamicTagObj.actionType = this.actionType this.dynamicTagObj.actionType = this.actionType
this.dynamicTagObj.tagId = this.tagId++ this.dynamicTagObj.tagId = this.tagId++
this.Kvid = Math.floor(Math.random() * 100001); this.Kvid = Math.floor(Math.random() * 100000001);
this.dynamicTagObj.actionConfigs = this.actionConfigs this.dynamicTagObj.actionConfigs = this.actionConfigs
this.dynamicTagObj.Kvid = this.Kvid this.dynamicTagObj.Kvid = this.Kvid
if (this.parentKvid != null) { if (this.parentKvid != null) {
...@@ -343,31 +343,31 @@ export default { ...@@ -343,31 +343,31 @@ export default {
this.isChildrenTree = true this.isChildrenTree = true
console.log(activeItem) console.log(activeItem)
let activeParentItem = this.findObjectByKvid(this.treeNode, activeItem.parentKvid); let activeParentItem = this.findObjectByKvid(this.treeNode, activeItem.parentKvid);
activeItem.children = [] activeItem.actions = []
if (activeParentItem == null) { if (activeParentItem == null) {
console.log('已经有容器了') console.log('已经有容器了')
// if (this.actionAll[0].children.length > 0) return // if (this.actionAll[0].actions.length > 0) return
let obj = {} let obj = {}
obj.name = activeItem.actionName obj.name = activeItem.actionName
obj.Kvid = activeItem.Kvid obj.Kvid = activeItem.Kvid
obj.children = [] obj.actions = []
console.log(this.treeNode) console.log(this.treeNode)
for (let i = 0; i < this.treeNode.length; i++) { for (let i = 0; i < this.treeNode.length; i++) {
this.actionAll[0].children.push(this.treeNode[i]) this.actionAll[0].actions.push(this.treeNode[i])
} }
this.actionAll.push(obj) this.actionAll.push(obj)
this.findOrPushObject(this.actionAll[0].children, obj) this.findOrPushObject(this.actionAll[0].actions, obj)
} else { } else {
// this.actionType = '' // this.actionType = ''
// this.actionName = '' // this.actionName = ''
let obj = {} let obj = {}
obj.name = activeItem.actionName obj.name = activeItem.actionName
obj.Kvid = activeItem.Kvid obj.Kvid = activeItem.Kvid
obj.children = [] obj.actions = []
for (let i = 0; i < activeItem.children.length; i++) { for (let i = 0; i < activeItem.actions.length; i++) {
obj.children.push(activeItem.children[i]) obj.actions.push(activeItem.actions[i])
} }
this.childrenTreeNode = obj.children this.childrenTreeNode = obj.actions
this.findOrPushObject(this.actionAll, obj) this.findOrPushObject(this.actionAll, obj)
// console.log(this.actionAll) // console.log(this.actionAll)
} }
...@@ -407,7 +407,7 @@ export default { ...@@ -407,7 +407,7 @@ export default {
// console.log(this.treeNode) // console.log(this.treeNode)
} else { } else {
this.childrenTreeNode = [] this.childrenTreeNode = []
this.childrenTreeNode = activeItem.children this.childrenTreeNode = activeItem.actions
this.isChildrenTree = true this.isChildrenTree = true
this.parentKvid = item.Kvid this.parentKvid = item.Kvid
this.isShowAction = false this.isShowAction = false
...@@ -426,12 +426,12 @@ export default { ...@@ -426,12 +426,12 @@ export default {
let obj = {} let obj = {}
obj.name = item.actionName obj.name = item.actionName
obj.Kvid = item.Kvid obj.Kvid = item.Kvid
obj.children = [] obj.actions = []
for (let i = 0; i < _this.treeNode.length; i++) { for (let i = 0; i < _this.treeNode.length; i++) {
_this.actionAll[0].children.push(_this.treeNode[i]) _this.actionAll[0].actions.push(_this.treeNode[i])
} }
_this.actionAll.push(obj) _this.actionAll.push(obj)
_this.findOrPushObject(_this.actionAll[0].children, obj) _this.findOrPushObject(_this.actionAll[0].actions, obj)
_this.childrenTreeNode = [] _this.childrenTreeNode = []
_this.isChildrenTree = true _this.isChildrenTree = true
} else { } else {
...@@ -441,10 +441,10 @@ export default { ...@@ -441,10 +441,10 @@ export default {
let obj = {} let obj = {}
obj.name = item.actionName obj.name = item.actionName
obj.Kvid = item.Kvid obj.Kvid = item.Kvid
obj.children = [] obj.actions = []
for (let i = 0; i < item.children.length; i++) { for (let i = 0; i < item.actions.length; i++) {
obj.children.push(item.children[i]) obj.actions.push(item.actions[i])
_this.childrenTreeNode.push(item.children[i]) _this.childrenTreeNode.push(item.actions[i])
} }
_this.findOrPushObject(_this.actionAll, obj) _this.findOrPushObject(_this.actionAll, obj)
_this.isChildrenTree = true _this.isChildrenTree = true
...@@ -455,10 +455,10 @@ export default { ...@@ -455,10 +455,10 @@ export default {
_this.isShowAction = true _this.isShowAction = true
} }
_this.Kvid = item.Kvid _this.Kvid = item.Kvid
if (item.children != undefined && item.children.length > 0) { if (item.actions != undefined && item.actions.length > 0) {
_this.childrenTreeNode = [] _this.childrenTreeNode = []
for (let i = 0; i < item.children.length; i++) { for (let i = 0; i < item.actions.length; i++) {
_this.childrenTreeNode.push(item.children[i]) _this.childrenTreeNode.push(item.actions[i])
} }
_this.isChildrenTree = true _this.isChildrenTree = true
} }
...@@ -475,11 +475,11 @@ export default { ...@@ -475,11 +475,11 @@ export default {
for (let i = 0; i < filteredArray.length; i++) { for (let i = 0; i < filteredArray.length; i++) {
_this.childrenTreeNode.push(filteredArray[i]) _this.childrenTreeNode.push(filteredArray[i])
} }
let activeItem = _this.findObjectByKvid(_this.actionAll[0].children, tag.Kvid); let activeItem = _this.findObjectByKvid(_this.actionAll[0].actions, tag.Kvid);
let activeParentItem = null let activeParentItem = null
// 根目录下处理 // 根目录下处理
if (activeItem !== null) { if (activeItem !== null) {
activeParentItem = _this.findObjectByKvid(_this.actionAll[0].children, activeItem.parentKvid); activeParentItem = _this.findObjectByKvid(_this.actionAll[0].actions, activeItem.parentKvid);
} else { } else {
let filteredArray = _this.treeNode.filter(item => item.Kvid !== tag.Kvid); let filteredArray = _this.treeNode.filter(item => item.Kvid !== tag.Kvid);
_this.treeNode = [] _this.treeNode = []
...@@ -494,10 +494,10 @@ export default { ...@@ -494,10 +494,10 @@ export default {
_this.childrenTreeNode.push(filteredArray[i]) _this.childrenTreeNode.push(filteredArray[i])
} }
} else { } else {
let filteredArray = activeParentItem.children.filter(item => item.Kvid !== tag.Kvid); let filteredArray = activeParentItem.actions.filter(item => item.Kvid !== tag.Kvid);
activeParentItem.children = [] activeParentItem.actions = []
for (let i = 0; i < filteredArray.length; i++) { for (let i = 0; i < filteredArray.length; i++) {
activeParentItem.children.push(filteredArray[i]) activeParentItem.actions.push(filteredArray[i])
} }
} }
} else if (_this.treeNode.length > 0 && _this.isChildrenTree == false) { } else if (_this.treeNode.length > 0 && _this.isChildrenTree == false) {
...@@ -533,21 +533,21 @@ export default { ...@@ -533,21 +533,21 @@ export default {
_this.childrenTreeNode = [] _this.childrenTreeNode = []
// 递归函数,用于在树的每一级中查找合适的父节点并添加数据 // 递归函数,用于在树的每一级中查找合适的父节点并添加数据
function addToNode (node, parentKvid, newData, childTree) { function addToNode (node, parentKvid, newData, childTree) {
if (node.children == undefined) { if (node.actions == undefined) {
node.children = [] node.actions = []
} }
// 如果当前节点的 kvid 等于 parentKvid,将 newData 添加到当前节点的 children // 如果当前节点的 kvid 等于 parentKvid,将 newData 添加到当前节点的 actions
if (node.Kvid === parentKvid) { if (node.Kvid === parentKvid) {
node.children.push(newData); node.actions.push(newData);
// _this.isChildrenTree = childTree // _this.isChildrenTree = childTree
for (let i = 0; i < node.children.length; i++) { for (let i = 0; i < node.actions.length; i++) {
_this.childrenTreeNode.push(node.children[i]) _this.childrenTreeNode.push(node.actions[i])
} }
return true; // 表示数据已添加成功 return true; // 表示数据已添加成功
} }
// 递归查找子节点 // 递归查找子节点
for (var i = 0; i < node.children.length; i++) { for (var i = 0; i < node.actions.length; i++) {
if (addToNode(node.children[i], parentKvid, newData)) { if (addToNode(node.actions[i], parentKvid, newData)) {
return true; // 如果子节点中添加成功,返回 true return true; // 如果子节点中添加成功,返回 true
} }
} }
...@@ -573,8 +573,8 @@ export default { ...@@ -573,8 +573,8 @@ export default {
if (activeParentsItem == null) { if (activeParentsItem == null) {
this.childrenTreeNode = this.treeNode this.childrenTreeNode = this.treeNode
} else { } else {
for (let i = 0; i < activeParentsItem.children.length; i++) { for (let i = 0; i < activeParentsItem.actions.length; i++) {
this.childrenTreeNode.push(activeParentsItem.children[i]) this.childrenTreeNode.push(activeParentsItem.actions[i])
} }
this.Kvid = activeParentItem.Kvid this.Kvid = activeParentItem.Kvid
} }
...@@ -598,10 +598,10 @@ export default { ...@@ -598,10 +598,10 @@ export default {
if (node.Kvid === parentKvid) { if (node.Kvid === parentKvid) {
return [node]; // 找到匹配的节点,返回包含该节点的数组 return [node]; // 找到匹配的节点,返回包含该节点的数组
} }
if (node.children && node.children.length > 0) { if (node.actions && node.actions.length > 0) {
var result = _this.findHierarchyByParentKvid(node.children, parentKvid); var result = _this.findHierarchyByParentKvid(node.actions, parentKvid);
if (result.length > 0) { if (result.length > 0) {
return node.children; // 将当前节点与子级层级连接起来 return node.actions; // 将当前节点与子级层级连接起来
} }
} }
} }
...@@ -615,8 +615,8 @@ export default { ...@@ -615,8 +615,8 @@ export default {
if (obj.Kvid === kvid) { if (obj.Kvid === kvid) {
return obj; // 如果当前对象的 kvid 等于目标 kvid,返回当前对象 return obj; // 如果当前对象的 kvid 等于目标 kvid,返回当前对象
} }
if (obj.children && obj.children.length > 0) { if (obj.actions && obj.actions.length > 0) {
var result = _this.findObjectByKvid(obj.children, kvid); // 递归查找子级数组中的对象 var result = _this.findObjectByKvid(obj.actions, kvid); // 递归查找子级数组中的对象
if (result) { if (result) {
return result; // 如果在子级数组中找到了目标对象,返回结果 return result; // 如果在子级数组中找到了目标对象,返回结果
} }
...@@ -648,9 +648,9 @@ export default { ...@@ -648,9 +648,9 @@ export default {
// console.log(this.childrenTreeNode) // console.log(this.childrenTreeNode)
let activeParentItem = this.findObjectByKvid(this.treeNode, this.childrenTreeNode[0].parentKvid); let activeParentItem = this.findObjectByKvid(this.treeNode, this.childrenTreeNode[0].parentKvid);
if (activeParentItem != null) { if (activeParentItem != null) {
activeParentItem.children = [] activeParentItem.actions = []
for (let i = 0; i < this.childrenTreeNode.length; i++) { for (let i = 0; i < this.childrenTreeNode.length; i++) {
activeParentItem.children.push(this.childrenTreeNode[i]) activeParentItem.actions.push(this.childrenTreeNode[i])
} }
} }
// 拖拽完最终结果 // 拖拽完最终结果
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment