|
|
@@ -69,78 +69,66 @@ var projectObj = {
|
|
|
}
|
|
|
};
|
|
|
let selected = tree.selected, that = projectObj;
|
|
|
-
|
|
|
- let canUpLevel = function (node) {
|
|
|
- if(!node){
|
|
|
- return false;
|
|
|
- }
|
|
|
- if(projectObj.project.isBillsLocked()== true && projectObj.project.withinBillsLocked(node)){
|
|
|
+ const validNodes = projectObj.mainController.getValidNodesWithinSelection();
|
|
|
+ const canUpLevel = function (nodes) {
|
|
|
+ if (!nodes.length || projectObj.project.isBillsLocked()) {
|
|
|
return false;
|
|
|
}
|
|
|
- if(node.depth()<=1){//焦点行是树结构的第一/二层节点,灰显。
|
|
|
+ const firstNode = nodes[0];
|
|
|
+ const lastNode = nodes[nodes.length - 1];
|
|
|
+ if (firstNode.depth() <= 1) { // 首节点是树结构的第一/二层节点,灰显。
|
|
|
return false;
|
|
|
}
|
|
|
- if(node.sourceType !== that.project.Bills.getSourceType()){//焦点行是定额/量价/工料机,灰显。
|
|
|
+ if (firstNode.sourceType !== commonConstants.SourceType.BILLS) { // 首节点是定额/量价/工料机,灰显。
|
|
|
return false;
|
|
|
- }else {
|
|
|
- if(node.data.type == billType.FX || node.data.type == billType.BX){//是分项,或者补项灰显。
|
|
|
- return false;
|
|
|
- }
|
|
|
- if(node.data.type == billType.FB&&node.nextSibling&&node.children.length>0){//焦点行是分部有后兄弟,有子项.
|
|
|
- if(node.children[0].data.type==billType.FX || node.children[0].data.type==billType.BX){ //焦点行子项是分项
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- if(node.data.type == billType.BILL &&node.nextSibling){//焦点行是清单有后兄弟
|
|
|
- if(node.data.calcBase&&node.data.calcBase!=""){//有基数计算
|
|
|
+ } else {
|
|
|
+ if (lastNode.data.type == billType.BILL && lastNode.nextSibling) { // 末节点是清单有后兄弟
|
|
|
+ if (lastNode.data.calcBase) { // 有基数计算
|
|
|
return false;
|
|
|
}
|
|
|
- if(node.children.length>0&&node.children[0].sourceType !== that.project.Bills.getSourceType()){//有子项,并且子项不是清单
|
|
|
+ if (lastNode.children.length > 0 && lastNode.children[0].sourceType !== commonConstants.SourceType.BILLS) { // 有子项,并且子项不是清单
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
- let canDownLevel = function (node) {//
|
|
|
- if(!node){
|
|
|
+ const canDownLevel = function (nodes) {
|
|
|
+ if (!nodes.length || projectObj.project.isBillsLocked()) {
|
|
|
return false;
|
|
|
}
|
|
|
- if(projectObj.project.isBillsLocked()== true && projectObj.project.withinBillsLocked(node)){
|
|
|
+ const firstNode = nodes[0];
|
|
|
+ if (firstNode.depth() === 0) {// 首节点是树结构的第一层节点,灰显。
|
|
|
return false;
|
|
|
}
|
|
|
- if(node.depth()==0){//焦点行是树结构的第一层节点,灰显。
|
|
|
+ if (firstNode.sourceType !== commonConstants.SourceType.BILLS) { // 首节点是定额/量价/工料机,灰显。
|
|
|
return false;
|
|
|
- }
|
|
|
- if(node.sourceType !== that.project.Bills.getSourceType()) {//焦点行是定额/量价/工料机,灰显。
|
|
|
- return false;
|
|
|
- }else {
|
|
|
- if(node.data.type == billType.FX || node.data.type == billType.BX){//是分项,灰显。
|
|
|
- return false;
|
|
|
- }
|
|
|
- if(!node.preSibling){//无前兄弟,灰显
|
|
|
+ } else {
|
|
|
+ const preNode = firstNode.preSibling;
|
|
|
+ if (!preNode) { // 首节点无前兄弟,灰显
|
|
|
return false;
|
|
|
- }else if(node.preSibling.data.calcBase&&node.preSibling.data.calcBase!=""){//前兄弟有基数计算
|
|
|
+ } else if (preNode.data.calcBase) { // 首节点前兄弟有基数计算
|
|
|
return false
|
|
|
}
|
|
|
- if(node.preSibling.children.length>0){//前兄弟有子项,子项是分项,灰显。
|
|
|
- if(node.data.type==billType.FB&&(node.preSibling.children[0].data.type==billType.FX||node.preSibling.children[0].data.type==billType.BX)){//焦点行是分部前兄弟有子项,子项是分项,灰显。
|
|
|
- return false;
|
|
|
- }
|
|
|
- if(node.data.type==billType.BILL&&node.preSibling.children[0].sourceType !== that.project.Bills.getSourceType()){//焦点行是清单,子项不是清单
|
|
|
+ if (preNode.children.length > 0) {//前兄弟有子项,子项是分项,灰显。
|
|
|
+ if (firstNode.data.type == billType.BILL && preNode.children[0].sourceType !== commonConstants.SourceType.BILLS) { // 首节点是清单,首节点前兄弟子项不是清单
|
|
|
return false
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
- let canUpMove = function (node) {
|
|
|
- if(node&&node.preSibling){//有前兄弟
|
|
|
- if(node.sourceType==that.project.Bills.getSourceType()){
|
|
|
- if(projectObj.project.isBillsLocked()== true && projectObj.project.withinBillsLocked(node)){
|
|
|
+ const canUpMove = function (nodes) {
|
|
|
+ if (!nodes.length) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const firstNode = nodes[0];
|
|
|
+ if (firstNode && firstNode.preSibling) {
|
|
|
+ if (firstNode.sourceType == commonConstants.SourceType.BILLS) {
|
|
|
+ if (projectObj.project.isBillsLocked()) {
|
|
|
return false;
|
|
|
}
|
|
|
- if(node.data.type == billType.DXFY&&node.data.isAdd!==1){
|
|
|
+ if (firstNode.data.type == billType.DXFY && firstNode.data.isAdd !== 1) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
@@ -148,13 +136,17 @@ var projectObj = {
|
|
|
}
|
|
|
return false
|
|
|
};
|
|
|
- let canDownMove = function (node) {
|
|
|
- if(node&&node.nextSibling){
|
|
|
- if(node.sourceType==that.project.Bills.getSourceType()){
|
|
|
- if(projectObj.project.isBillsLocked()== true && projectObj.project.withinBillsLocked(node)){
|
|
|
+ const canDownMove = function (nodes) {
|
|
|
+ if (!nodes.length) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const lastNode = nodes[nodes.length - 1];
|
|
|
+ if (lastNode && lastNode.nextSibling) {
|
|
|
+ if (lastNode.sourceType == commonConstants.SourceType.BILLS) {
|
|
|
+ if (projectObj.project.isBillsLocked()) {
|
|
|
return false;
|
|
|
}
|
|
|
- if(node.data.type == billType.DXFY&&node.data.isAdd!==1){
|
|
|
+ if (lastNode.data.type == billType.DXFY && lastNode.data.isAdd !== 1) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
@@ -165,10 +157,10 @@ var projectObj = {
|
|
|
|
|
|
setButtonValid(projectObj.project.Ration.canAdd(selected), $('#insertRation'));
|
|
|
setButtonValid(ifCanDelete(), $('#delete'));
|
|
|
- setButtonValid(canUpLevel(selected), $('#upLevel'));
|
|
|
- setButtonValid(canDownLevel(selected), $('#downLevel'));
|
|
|
- setButtonValid(canUpMove(selected) , $('#upMove'));
|
|
|
- setButtonValid(canDownMove(selected), $('#downMove'));
|
|
|
+ setButtonValid(canUpLevel(validNodes), $('#upLevel'));
|
|
|
+ setButtonValid(canDownLevel(validNodes), $('#downLevel'));
|
|
|
+ setButtonValid(canUpMove(validNodes), $('#upMove'));
|
|
|
+ setButtonValid(canDownMove(validNodes), $('#downMove'));
|
|
|
setButtonValid(!projectObj.project.isBillsLocked(), $('#ZLFB_btn'));
|
|
|
|
|
|
},
|
|
|
@@ -2128,26 +2120,34 @@ $('#delete').click(function () {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-$('#upLevel').click(function () {
|
|
|
- var controller = projectObj.mainController, project = projectObj.project;
|
|
|
- var selected = controller.tree.selected, orgParent = selected.parent;
|
|
|
- if (selected && selected.sourceType === project.Bills.getSourceType()) {
|
|
|
- project.Bills.upLevelBills(selected.source);
|
|
|
- controller.upLevel();
|
|
|
- controller.refreshTreeNode([orgParent, selected]);
|
|
|
- projectObj.project.calcProgram.calcNodesAndSave([selected,orgParent]);
|
|
|
- }
|
|
|
-});
|
|
|
-$('#downLevel').click(function () {
|
|
|
- var controller = projectObj.mainController, project = projectObj.project;
|
|
|
- var selected = controller.tree.selected;
|
|
|
- if (selected && selected.sourceType === project.Bills.getSourceType()) {
|
|
|
- project.Bills.downLevelBills(selected.source);
|
|
|
- controller.downLevel();
|
|
|
- controller.refreshTreeNode([selected.parent]);
|
|
|
- projectObj.converseCalculateBills(selected.parent);
|
|
|
- }
|
|
|
-});
|
|
|
+// TODO 造价书节点的升降级、上下移都是异步的,不等服务器响应直接进行前端更新的。有风险,后续可能需要改。
|
|
|
+// 节流,防止快速触发
|
|
|
+const throttleTime = 400;
|
|
|
+const throttleUpLevel = _.throttle(() => {
|
|
|
+ const controller = projectObj.mainController;
|
|
|
+ const project = projectObj.project;
|
|
|
+ const mainTreeNodes = controller.getValidNodesWithinSelection();
|
|
|
+ const billsNodes = mainTreeNodes.map(node => node.source);
|
|
|
+ const orgParent = mainTreeNodes[0].parent;
|
|
|
+ project.Bills.multiUpLevelBills(project.Bills.tree, billsNodes);
|
|
|
+ controller.multiUpLevel(mainTreeNodes);
|
|
|
+ const refreshNodes = [orgParent, ...mainTreeNodes];
|
|
|
+ controller.refreshTreeNode(refreshNodes);
|
|
|
+ projectObj.project.calcProgram.calcNodesAndSave(refreshNodes);
|
|
|
+}, throttleTime);
|
|
|
+$('#upLevel').click(throttleUpLevel);
|
|
|
+const throttleDownLevel = _.throttle(() => {
|
|
|
+ const controller = projectObj.mainController
|
|
|
+ const project = projectObj.project;
|
|
|
+ const mainTreeNodes = controller.getValidNodesWithinSelection();
|
|
|
+ const billsNodes = mainTreeNodes.map(node => node.source);
|
|
|
+ const orgParent = mainTreeNodes[0].parent;
|
|
|
+ project.Bills.multiDownLevelBills(project.Bills.tree, billsNodes);
|
|
|
+ controller.multiDownLevel(mainTreeNodes);
|
|
|
+ controller.refreshTreeNode([orgParent, ...mainTreeNodes]);
|
|
|
+ projectObj.converseCalculateBills(orgParent);
|
|
|
+}, throttleTime);
|
|
|
+$('#downLevel').click(throttleDownLevel);
|
|
|
$('#insertRation').click(function () {
|
|
|
// projectObj.project.Ration.addNewRation(null,rationType.ration);
|
|
|
// 连续点工具栏的插入定额按钮,显示树结构画线有问题。
|
|
|
@@ -2155,32 +2155,39 @@ $('#insertRation').click(function () {
|
|
|
//2020-01-08 要限制定额数量,所以还是要用等回传信息的方式插入定额
|
|
|
projectObj.project.Ration.addNewRation(null,rationType.ration,projectObj.selectColAndFocus,false);
|
|
|
});
|
|
|
-$('#upMove').click(function () {
|
|
|
- var controller = projectObj.mainController, project = projectObj.project;
|
|
|
- var selected = controller.tree.selected, pre = selected.preSibling, preSerialNo;
|
|
|
-
|
|
|
- if (selected.sourceType === project.Bills.getSourceType()) {
|
|
|
- project.Bills.upMoveBills(selected.source);
|
|
|
- controller.upMove();
|
|
|
- } else if (selected.sourceType === project.Ration.getSourceType()) {
|
|
|
- project.Ration.changePos(selected.source, selected.preSibling.source);
|
|
|
- controller.upMove();
|
|
|
+const throttleUpMove = _.throttle(() => {
|
|
|
+ const controller = projectObj.mainController
|
|
|
+ const project = projectObj.project;
|
|
|
+ const mainTreeNodes = controller.getValidNodesWithinSelection();
|
|
|
+ const sourceNodes = mainTreeNodes.map(node => node.source);
|
|
|
+ const firstNode = mainTreeNodes[0];
|
|
|
+ if (firstNode.sourceType === commonConstants.SourceType.BILLS) {
|
|
|
+ project.Bills.multiUpMoveBills(project.Bills.tree, sourceNodes);
|
|
|
+ controller.multiUpMove(mainTreeNodes);
|
|
|
+ } else if (firstNode.sourceType === commonConstants.SourceType.RATION) {
|
|
|
+ //project.Ration.changePos(selected.source, selected.preSibling.source);
|
|
|
+ project.Ration.changeMultiPos(mainTreeNodes[0].preSibling.source, sourceNodes);
|
|
|
+ controller.multiUpMove(mainTreeNodes);
|
|
|
};
|
|
|
-});
|
|
|
-$('#downMove').click(function () {
|
|
|
- var controller = projectObj.mainController, project = projectObj.project;
|
|
|
- var selected = controller.tree.selected, next, nextSerialNo;
|
|
|
-
|
|
|
- if (selected) {
|
|
|
- if (selected.sourceType === project.Bills.getSourceType()) {
|
|
|
- project.Bills.downMoveBills(selected.source);
|
|
|
- controller.downMove();
|
|
|
- } else if (selected.sourceType === project.Ration.getSourceType()) {
|
|
|
- project.Ration.changePos(selected.source, selected.nextSibling.source);
|
|
|
- controller.downMove();
|
|
|
- };
|
|
|
- }
|
|
|
-});
|
|
|
+}, throttleTime);
|
|
|
+$('#upMove').click(throttleUpMove);
|
|
|
+const throttleDownMove = _.throttle(() => {
|
|
|
+ const controller = projectObj.mainController
|
|
|
+ const project = projectObj.project;
|
|
|
+ const mainTreeNodes = controller.getValidNodesWithinSelection();
|
|
|
+ const sourceNodes = mainTreeNodes.map(node => node.source);
|
|
|
+ const firstNode = mainTreeNodes[0];
|
|
|
+ if (firstNode.sourceType === commonConstants.SourceType.BILLS) {
|
|
|
+ project.Bills.multiDownMoveBills(project.Bills.tree, sourceNodes);
|
|
|
+ controller.multiDownMove(mainTreeNodes);
|
|
|
+ } else if (firstNode.sourceType === commonConstants.SourceType.RATION) {
|
|
|
+ const nextSource = mainTreeNodes[mainTreeNodes.length - 1].nextSibling.source;
|
|
|
+ const reverseSource = [...sourceNodes].reverse();
|
|
|
+ project.Ration.changeMultiPos(nextSource, reverseSource);
|
|
|
+ controller.multiDownMove(mainTreeNodes);
|
|
|
+ };
|
|
|
+}, throttleTime);
|
|
|
+$('#downMove').click(throttleDownMove);
|
|
|
$("a[name='lockBills']").click(function () {//点击锁定/解锁清单
|
|
|
let lockBills = projectObj.project.projectInfo.property.lockBills;
|
|
|
lockBills = !lockBills;
|