|
@@ -68,6 +68,7 @@ var dbController = {
|
|
|
var updateData = [];
|
|
|
let selNodes = tools.getSameDepthNodes(controller);
|
|
|
let nextSiblings = [];
|
|
|
+ let toUpSectionNodes = [];
|
|
|
let getNextSibling = function(node){
|
|
|
if(node.nextSibling){
|
|
|
nextSiblingIds.push(node.getNextSiblingID());
|
|
@@ -105,40 +106,10 @@ var dbController = {
|
|
|
updateData.push({
|
|
|
ID: nextSiblingIds,
|
|
|
ParentID: lastSelNode.getID(),
|
|
|
- sectionInfo: nextSectionInfo,
|
|
|
+ //sectionInfo: nextSectionInfo,
|
|
|
type: 'nextSiblingNode'
|
|
|
});
|
|
|
//nextSibling children
|
|
|
- for(let nextSibling of nextSiblings){
|
|
|
- let nextChildSectionInfo = {first: nextSectionInfo.first, second: nextSectionInfo.second, third: nextSectionInfo.third};
|
|
|
- let nextCFlag = false;
|
|
|
- let nullNextCInfo = tools.sectionInfoNull(nextChildSectionInfo);
|
|
|
- if(nullNextCInfo){
|
|
|
- nextChildSectionInfo[nullNextCInfo] = nextSibling.getID();
|
|
|
- nextCFlag = true;
|
|
|
- }
|
|
|
- if(nextCFlag){
|
|
|
- let nextCIds = [];
|
|
|
- for(let nextChild of nextSibling.children){
|
|
|
- nextCIds.push(nextChild.getID());
|
|
|
- //nextSibling grandChildren
|
|
|
- let nextGChildSectionInfo = {first: nextChildSectionInfo.first, second: nextChildSectionInfo.second, third: nextChildSectionInfo.third};
|
|
|
- let nextGCFlag = false;
|
|
|
- if(!tools.isDef(nextChildSectionInfo.third)){
|
|
|
- nextGChildSectionInfo.third = nextChild.getID();
|
|
|
- nextGCFlag = true;
|
|
|
- }
|
|
|
- if(nextGCFlag){
|
|
|
- let nextGCIds = [];
|
|
|
- for(let nextGChild of nextChild.children){
|
|
|
- nextGCIds.push(nextGChild.getID());
|
|
|
- }
|
|
|
- updateData.push({ID: nextGCIds, ParentID: nextChild.getID(), sectionInfo: nextGChildSectionInfo, type: 'nextSiblingNode'});
|
|
|
- }
|
|
|
- }
|
|
|
- updateData.push({ID: nextCIds, ParentID: nextSibling.getID(), sectionInfo: nextChildSectionInfo, type: 'nextSiblingNode'});
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
//更新选中节点
|
|
|
console.log(selNodes);
|
|
@@ -153,49 +124,43 @@ var dbController = {
|
|
|
type: 'oprNode'
|
|
|
});
|
|
|
//update node children and grandchildren sectionInfo
|
|
|
- let nullOprSectionInfo = tools.sectionInfoNull(oprSectionInfo);
|
|
|
- if(nullOprSectionInfo){
|
|
|
- let oprChildSectionInfo = {first: oprSectionInfo.first, second: oprSectionInfo.second, third: oprSectionInfo.third};
|
|
|
- oprChildSectionInfo[nullOprSectionInfo] = selNode.getID();
|
|
|
- let oprChildIds = [];
|
|
|
- for(let oprChild of selNode.children){
|
|
|
- oprChildIds.push(oprChild.getID());
|
|
|
- let nullOprCSectionInfo = tools.sectionInfoNull(oprChildSectionInfo);
|
|
|
- if(nullOprCSectionInfo){
|
|
|
- let oprGCSectionInfo = {first: oprChildSectionInfo.first, second: oprChildSectionInfo.second, third: oprChildSectionInfo.third};
|
|
|
- oprGCSectionInfo[nullOprCSectionInfo] = oprChild.getID();
|
|
|
- let oprGCIds = [];
|
|
|
- for(let oprGChild of oprChild.children){
|
|
|
- oprGCIds.push(oprGChild.getID());
|
|
|
- }
|
|
|
- if(oprGCIds.length > 0){
|
|
|
- updateData.push({ID: oprGCIds, ParentID: oprChild.getID(), sectionInfo: oprGCSectionInfo, type: 'nextSiblingNode'});
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(oprChildIds.length > 0){
|
|
|
- updateData.push({ID: oprChildIds, ParentID: selNode.getID(), sectionInfo: oprChildSectionInfo, type: 'nextSiblingNode'});
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
+ //get updateSectionInfo nodes
|
|
|
+ toUpSectionNodes = toUpSectionNodes.concat(selNodes);//选中的节点
|
|
|
+ //选中节点的所有子节点
|
|
|
+ toUpSectionNodes = toUpSectionNodes.concat(tools.getChildrenNodes(selNodes));
|
|
|
+ //后兄弟节点
|
|
|
+ toUpSectionNodes = toUpSectionNodes.concat(nextSiblings);
|
|
|
+ //所有后兄弟节点的所有子节点
|
|
|
+ toUpSectionNodes = toUpSectionNodes.concat(tools.getChildrenNodes(nextSiblings));
|
|
|
+
|
|
|
billsAjax.upLevel(userAccount, billsLibId, updateData, function(){
|
|
|
- tools.btnAction(btn);
|
|
|
- btn.attr('doing', 'false');
|
|
|
+ //tools.btnAction(btn);
|
|
|
+ //btn.attr('doing', 'false');
|
|
|
for(let upLevelNode of selNodes){
|
|
|
controller.setTreeSelected(upLevelNode);
|
|
|
controller.upLevel();
|
|
|
}
|
|
|
sheetBillsDatas = tools.getsheetDatas(controller.sheet, 'bills', controller);
|
|
|
controller.sheet.getParent().focus(true);
|
|
|
+ //updateSectionInfo
|
|
|
+ if(toUpSectionNodes.length > 0){
|
|
|
+ billsAjax.updateSectionInfo(tools.getUpdateSectionData(toUpSectionNodes), function () {
|
|
|
+ tools.btnAction(btn);
|
|
|
+ btn.attr('doing', 'false');
|
|
|
+ });
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
downLevel: function(controller, btn){
|
|
|
tools.btnClose(btn);
|
|
|
btn.attr('doing', 'true');
|
|
|
var updateData = [];
|
|
|
let selNodes = tools.getSameDepthNodes(controller);
|
|
|
+ let toUpSectionNodes = [];
|
|
|
if(selNodes.length > 0){
|
|
|
//选中的第一个节点有前节点,则可降级
|
|
|
let firstPreSibling = selNodes[0].preSibling;
|
|
@@ -215,57 +180,36 @@ var dbController = {
|
|
|
}
|
|
|
for(let i = 0; i < selNodes.length; i++){
|
|
|
let selNode = selNodes[i];
|
|
|
- //更新选中的节点(第一层)
|
|
|
- let oprSectionInfo = tools.getSectionInfo(firstPreSibling);
|
|
|
- let nullOprSectionInfo = tools.sectionInfoNull(oprSectionInfo);
|
|
|
- if(nullOprSectionInfo){
|
|
|
- oprSectionInfo[nullOprSectionInfo] = firstPreSibling.getID();
|
|
|
- }
|
|
|
+ //更新选中的节点
|
|
|
updateData.push({
|
|
|
ID: selNode.getID(),
|
|
|
ParentID: firstPreSibling.getID(),
|
|
|
NextSiblingID: i === selNodes.length - 1 ? -1 : selNode.getNextSiblingID(),
|
|
|
- sectionInfo: oprSectionInfo,
|
|
|
type: 'oprNode'});
|
|
|
- //更新选中节点的子节点(第二层)
|
|
|
- let childSectionInfo = {first: oprSectionInfo.first, second: oprSectionInfo.second, third: oprSectionInfo.third};
|
|
|
- let updateChildFlag = false;
|
|
|
- let nullChildSection = tools.sectionInfoNull(childSectionInfo);
|
|
|
- if(nullChildSection){
|
|
|
- childSectionInfo[nullChildSection] = selNode.getID();
|
|
|
- updateChildFlag = true;
|
|
|
- }
|
|
|
- if(updateChildFlag){
|
|
|
- for(let child of selNode.children){
|
|
|
- updateData.push({
|
|
|
- ID: child.getID(),
|
|
|
- sectionInfo: childSectionInfo,
|
|
|
- type: 'oprChildren'
|
|
|
- });
|
|
|
- //更新选中节点的孙子节点(第三层)
|
|
|
- let gChildSectionInfo = {first: childSectionInfo.first, second: childSectionInfo.second, third: childSectionInfo.third};
|
|
|
- let updateGChildFlag = false;
|
|
|
- if(!tools.isDef(gChildSectionInfo.third)){
|
|
|
- gChildSectionInfo.third = child.getID();
|
|
|
- updateGChildFlag = true;
|
|
|
- }
|
|
|
- if(updateGChildFlag){
|
|
|
- for(let grandChild of child.children){
|
|
|
- updateData.push({ID: grandChild.getID(), sectionInfo: gChildSectionInfo, type: 'oprChildren'});
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
+
|
|
|
+ //get updateSectionInfo nodes
|
|
|
+ //选中的节点
|
|
|
+ toUpSectionNodes = toUpSectionNodes.concat(selNodes);
|
|
|
+ //选中节点的所有子节点
|
|
|
+ toUpSectionNodes = toUpSectionNodes.concat(tools.getChildrenNodes(selNodes));
|
|
|
+
|
|
|
billsAjax.downLevel(userAccount, billsLibId, updateData, function(){
|
|
|
- tools.btnAction(btn);
|
|
|
- btn.attr('doing', 'false');
|
|
|
+ //tools.btnAction(btn);
|
|
|
+ //btn.attr('doing', 'false');
|
|
|
for(let downNode of selNodes){
|
|
|
controller.setTreeSelected(downNode);
|
|
|
controller.downLevel();
|
|
|
}
|
|
|
sheetBillsDatas = tools.getsheetDatas(controller.sheet, 'bills', controller);
|
|
|
controller.sheet.getParent().focus(true);
|
|
|
+ //update sectionInfo
|
|
|
+ if(toUpSectionNodes.length > 0){
|
|
|
+ billsAjax.updateSectionInfo(tools.getUpdateSectionData(toUpSectionNodes), function () {
|
|
|
+ tools.btnAction(btn);
|
|
|
+ btn.attr('doing', 'false');
|
|
|
+ });
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -1543,6 +1487,32 @@ var tools = {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ getUpdateSectionData: function (nodes) {
|
|
|
+ let rst = [];
|
|
|
+ for(let node of nodes){
|
|
|
+ rst.push({ID: node.getID(), sectionInfo: tools.getSectionInfo(node)});
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ },
|
|
|
+
|
|
|
+ //获取节点底下所有子节点
|
|
|
+ getChildrenNodes: function (nodes) {
|
|
|
+ let rst = [];
|
|
|
+ for(let node of nodes){
|
|
|
+ getChild(node.children);
|
|
|
+ }
|
|
|
+ function getChild(ns){
|
|
|
+ rst = rst.concat(ns);
|
|
|
+ for(let n of ns){
|
|
|
+ if(n.children.length > 0){
|
|
|
+ getChild(n.children);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ },
|
|
|
+
|
|
|
getSameDepthNodes: function(controller){
|
|
|
const items = controller.tree.items;
|
|
|
let rst = [];
|