|
@@ -24,23 +24,59 @@ ProjectController = {
|
|
|
addBills: function (project, sheetController, std) {
|
|
|
if (!project || !sheetController) { return null; }
|
|
|
let target = project.getParentTarget(project.mainTree.selected, 'sourceType', project.Bills.getSourceType());
|
|
|
- let newSource = null, newNode = null, parentID, nextSiblingID;
|
|
|
+ let newSource = null, newNode = null, parentID, nextSiblingID, nodeParentID, nodeNextSiblingID;
|
|
|
if (target) {
|
|
|
- console.log(target.depth());
|
|
|
+ if(target.depth() === 0){
|
|
|
+ parentID = target.source.getID();
|
|
|
+ nextSiblingID = project.Bills.tree.setting.rootId;
|
|
|
+ nodeParentID = target.getID();
|
|
|
+ nodeNextSiblingID = project.mainTree.rootID();
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ parentID = target.source.getParentID();
|
|
|
+ nextSiblingID = target.source.getNextSiblingID();
|
|
|
+ nodeParentID = target.getParentID();
|
|
|
+ nodeNextSiblingID = target.getNextSiblingID();
|
|
|
+ }
|
|
|
parentID = target.depth() === 0 ? target.source.getID() : target.source.getParentID();
|
|
|
nextSiblingID = target.depth() === 0 ? project.Bills.tree.setting.rootId : target.source.getNextSiblingID();
|
|
|
|
|
|
if (std) {
|
|
|
+ let fixedNode = getRootFixedNode(target);
|
|
|
+ if(!isFlag(fixedNode.data) || (fixedNode.data.flagsIndex.fixed.flag !== fixedFlag.SUB_ENGINERRING && fixedNode.data.flagsIndex.fixed.flag !== fixedFlag.MEASURE)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //焦点行属于分部分项
|
|
|
+ if(fixedNode.data.flagsIndex.fixed.flag === fixedFlag.SUB_ENGINERRING){
|
|
|
+ std.type = billType.FX;
|
|
|
+ //焦点行是分部分项
|
|
|
+ let subType = getSubType(target);
|
|
|
+ if(target.sourceType === project.Bills.getSourceType() && target.data.type === billType.DXFY && subType === billType.FB){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //焦点行是分部
|
|
|
+ else if(target.sourceType === project.Bills.getSourceType() && target.data.type === billType.FB){
|
|
|
+ if(!subType || subType === billType.FX){
|
|
|
+ parentID = target.source.getID();
|
|
|
+ nextSiblingID = project.Bills.tree.setting.rootId;
|
|
|
+ nodeParentID = target.getID();
|
|
|
+ nodeNextSiblingID = project.mainTree.rootID();
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ std.type = billType.BILL;
|
|
|
+ }
|
|
|
+
|
|
|
let newCode = project.Bills.newFormatCode(std.code);
|
|
|
newSource = project.Bills.insertStdBills(parentID, nextSiblingID, std, newCode);
|
|
|
} else {
|
|
|
newSource = project.Bills.insertBills(parentID, nextSiblingID);
|
|
|
}
|
|
|
- if (target.depth() === 0) {
|
|
|
- newNode = project.mainTree.insert(target.getID(), project.mainTree.rootID())
|
|
|
- } else {
|
|
|
- newNode = project.mainTree.insert(target.getParentID(), target.getNextSiblingID());
|
|
|
- }
|
|
|
+ newNode = project.mainTree.insert(nodeParentID, nodeNextSiblingID);
|
|
|
} else {
|
|
|
alert('不可添加清单');
|
|
|
}
|
|
@@ -52,6 +88,17 @@ ProjectController = {
|
|
|
|
|
|
this.syncDisplayNewNode(sheetController, newNode);
|
|
|
}
|
|
|
+ function getSubType(node){
|
|
|
+ for(let sub of node.children){
|
|
|
+ if(sub.sourceType === project.Bills.getSourceType() && sub.data.type === billType.FB){
|
|
|
+ return billType.FB;
|
|
|
+ }
|
|
|
+ else if(sub.sourceType === project.Bills.getSourceType() && sub.data.type === billType.FX){
|
|
|
+ return billType.FX;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
},
|
|
|
addRootBill:function (project, sheetController) {//添加大项费用
|
|
|
if (!project || !sheetController) { return null; }
|
|
@@ -109,6 +156,9 @@ ProjectController = {
|
|
|
} else if (selected.data.calcBase&&selected.data.calcBase!="") {
|
|
|
alert('当前有基数计算不能插入定额/量价/工料机。');
|
|
|
} else {
|
|
|
+ if(selected.data.type === billType.FB){
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (std) {
|
|
|
newSource = project.Ration.insertStdRation(selected.source.getID(), null, std);
|
|
|
project.ration_glj.addRationGLJ(newSource,std);
|