|
@@ -9,7 +9,8 @@ var dbController = {
|
|
|
if(controller.tree.items.length === 0){
|
|
|
controller.tree.maxNodeID(0);
|
|
|
let newNodeId = controller.tree.newNodeID();
|
|
|
- billsAjax.createBills(userAccount, billsLibId, newNodeId, -1 , -1, null, function(){
|
|
|
+ let sectionInfo = {first: null, second: null, third: null};
|
|
|
+ billsAjax.createBills(userAccount, billsLibId, newNodeId, -1 , -1, null, sectionInfo, function(){
|
|
|
controller.insert();
|
|
|
controller.tree.selected.jobs = new Array();
|
|
|
controller.tree.selected.items = new Array();
|
|
@@ -25,7 +26,8 @@ var dbController = {
|
|
|
var updateId = node.getID(), createpid = node.getParentID(), createnid = node.getNextSiblingID();
|
|
|
let newNodeId = controller.tree.newNodeID();
|
|
|
let updatePreData = {ID: updateId, NextSiblingID: newNodeId};
|
|
|
- billsAjax.createBills(userAccount, billsLibId, newNodeId, createpid, createnid, updatePreData, function(){
|
|
|
+ let sectionInfo = tools.getSectionInfo(node);
|
|
|
+ billsAjax.createBills(userAccount, billsLibId, newNodeId, createpid, createnid, updatePreData, sectionInfo, function(){
|
|
|
controller.insert();
|
|
|
controller.tree.selected.jobs = new Array();
|
|
|
controller.tree.selected.items = new Array();
|
|
@@ -40,7 +42,8 @@ var dbController = {
|
|
|
let updateId = updateNode.getID();
|
|
|
let newNodeId = controller.tree.newNodeID();
|
|
|
let updatePreData = {ID: updateId, NextSiblingID: newNodeId};
|
|
|
- billsAjax.createBills(userAccount, billsLibId, newNodeId, -1, -1, updatePreData, function(){
|
|
|
+ let sectionInfo = tools.getSectionInfo(node);
|
|
|
+ billsAjax.createBills(userAccount, billsLibId, newNodeId, -1, -1, updatePreData, sectionInfo, function(){
|
|
|
controller.insert();
|
|
|
controller.tree.selected.jobs = new Array();
|
|
|
controller.tree.selected.items = new Array();
|
|
@@ -68,10 +71,12 @@ var dbController = {
|
|
|
//node
|
|
|
if(node){
|
|
|
if(node.parent){
|
|
|
+ let oprSectionInfo = tools.getSectionInfo(node.parent);
|
|
|
let updateA = {
|
|
|
ID: node.getID(),
|
|
|
ParentID: node.parent.getParentID(),
|
|
|
NextSiblingID: node.parent.getNextSiblingID(),
|
|
|
+ sectionInfo: oprSectionInfo,
|
|
|
type: 'oprNode'
|
|
|
};
|
|
|
updateData.push(updateA);
|
|
@@ -83,10 +88,21 @@ var dbController = {
|
|
|
}
|
|
|
updateData.push(updateB);
|
|
|
if(node.nextSibling){
|
|
|
+ let nextSectionInfo = tools.getSectionInfo(node.parent);
|
|
|
+ if(!tools.isDef(nextSectionInfo.first)){
|
|
|
+ nextSectionInfo.first = node.getID();
|
|
|
+ }
|
|
|
+ else if(!tools.isDef(nextSectionInfo.second)){
|
|
|
+ nextSectionInfo.second = node.getID();
|
|
|
+ }
|
|
|
+ else if(!tools.isDef(nextSectionInfo.third)){
|
|
|
+ nextSectionInfo.third = node.getID();
|
|
|
+ }
|
|
|
getNextSibling(node);
|
|
|
let updateC = {
|
|
|
ID: ids,
|
|
|
ParentID: node.getID(),
|
|
|
+ sectionInfo: nextSectionInfo,
|
|
|
type: 'nextSiblingNode'
|
|
|
}
|
|
|
updateData.push(updateC);
|
|
@@ -117,6 +133,16 @@ var dbController = {
|
|
|
var updateData = [];
|
|
|
if(node){
|
|
|
if(node.preSibling){
|
|
|
+ let oprSectionInfo = tools.getSectionInfo(node.preSibling);
|
|
|
+ if(!tools.isDef(oprSectionInfo.first)){
|
|
|
+ oprSectionInfo.first = node.preSibling.getID();
|
|
|
+ }
|
|
|
+ else if(!tools.isDef(oprSectionInfo.second)){
|
|
|
+ oprSectionInfo.second = node.preSibling.getID();
|
|
|
+ }
|
|
|
+ else if(!tools.isDef(oprSectionInfo.third)){
|
|
|
+ oprSectionInfo.third = node.preSibling.getID();
|
|
|
+ }
|
|
|
var updateA = {
|
|
|
ID: node.preSibling.getID(),
|
|
|
NextSiblingID: node.getNextSiblingID(),
|
|
@@ -126,6 +152,7 @@ var dbController = {
|
|
|
ID: node.getID(),
|
|
|
ParentID: node.preSibling.getID(),
|
|
|
NextSiblingID: -1,
|
|
|
+ sectionInfo: oprSectionInfo,
|
|
|
type: 'oprNode'
|
|
|
};
|
|
|
updateData.push(updateA);
|
|
@@ -138,6 +165,24 @@ var dbController = {
|
|
|
}
|
|
|
updateData.push(updateC);
|
|
|
}
|
|
|
+ //更新子节点sectionInfo
|
|
|
+ let childSectionInfo = {first: oprSectionInfo.first, second: oprSectionInfo.second, third: oprSectionInfo.third};
|
|
|
+ if(!tools.isDef(childSectionInfo.first)){
|
|
|
+ childSectionInfo.first = node.getID();
|
|
|
+ }
|
|
|
+ else if(!tools.isDef(childSectionInfo.second)){
|
|
|
+ childSectionInfo.second = node.getID();
|
|
|
+ }
|
|
|
+ else if(!tools.isDef(childSectionInfo.third)){
|
|
|
+ childSectionInfo.third = node.getID();
|
|
|
+ }
|
|
|
+ for(let i = 0, len = node.children.length; i < len; i++){
|
|
|
+ updateData.push({
|
|
|
+ ID: node.children[i].getID(),
|
|
|
+ sectionInfo: childSectionInfo,
|
|
|
+ type: 'oprChildren'
|
|
|
+ })
|
|
|
+ }
|
|
|
billsAjax.downLevel(userAccount, billsLibId, updateData, function(){
|
|
|
tools.btnAction(btn);
|
|
|
btn.attr('doing', 'false');
|
|
@@ -1382,8 +1427,33 @@ var tools = {
|
|
|
}
|
|
|
}
|
|
|
return conformDatas;
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
+ isDef: function (v) {
|
|
|
+ return v !== undefined && v !== null;
|
|
|
+ },
|
|
|
|
|
|
+ getSectionInfo: function (node) {
|
|
|
+ let parentIDs = [];
|
|
|
+ let sectionInfo = {first: null, second: null, third: null};
|
|
|
+ getParent(node);
|
|
|
+ if(this.isDef(parentIDs[parentIDs.length - 1])){
|
|
|
+ sectionInfo.first = parentIDs[parentIDs.length - 1];
|
|
|
+ }
|
|
|
+ if(this.isDef(parentIDs[parentIDs.length - 2])){
|
|
|
+ sectionInfo.second = parentIDs[parentIDs.length - 2];
|
|
|
+ }
|
|
|
+ if(this.isDef(parentIDs[parentIDs.length - 3])){
|
|
|
+ sectionInfo.third = parentIDs[parentIDs.length - 3];
|
|
|
+ }
|
|
|
+ return sectionInfo;
|
|
|
+ function getParent(node){
|
|
|
+ if(node.parent){
|
|
|
+ parentIDs.push(node.parent.data.ID);
|
|
|
+ getParent(node.parent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
let pasteController = {
|