|
@@ -146,7 +146,9 @@ var quantity_detail = {
|
|
|
me.cleanQuantityDetail();
|
|
|
}else {
|
|
|
data.newRecord?me.refreshAfterSave(data.newRecord):me.refreshAfterSave(data);
|
|
|
- data.node?gljOprObj.refreshTreeNode(data.node):"";
|
|
|
+ if(data.node){
|
|
|
+ me.refreshRationOrBillNodes(data.node);
|
|
|
+ }
|
|
|
//gljOprObj.detailSheet.setActiveCell(0,0);
|
|
|
//gljOprObj.detailSheet.clearSelection();
|
|
|
}
|
|
@@ -156,6 +158,19 @@ var quantity_detail = {
|
|
|
$.bootstrapLoading.end();
|
|
|
});
|
|
|
};
|
|
|
+ quantity_detail.prototype.refreshRationOrBillNodes=function(node){//工程量明细更新后触发定额或清单工程量改变,进行相应的更新
|
|
|
+ var nodes = gljOprObj.refreshTreeNode(node);
|
|
|
+ if(nodes.length>0){//触发计算
|
|
|
+ let newNode = nodes[0];
|
|
|
+ if(newNode.sourceType === project.Bills.getSourceType()){
|
|
|
+ console.log(newNode.data.quantity);
|
|
|
+ this.updateBillQuantity(newNode.data.quantity,newNode);
|
|
|
+ }else {//更新定额所使用的值要用还没转换前的
|
|
|
+ this.updateRationQuantity(node.data.r_quantity,newNode,newNode.data.quantityEXP);//to do 加上工程量表达式和含量更新
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
quantity_detail.prototype.insertQuantityDetail = function (row) {
|
|
|
var args = {
|
|
|
row:row,
|
|
@@ -175,7 +190,9 @@ var quantity_detail = {
|
|
|
$.bootstrapLoading.start();
|
|
|
var callback=function (result) {
|
|
|
me.refreshAfterDelete(result.data);
|
|
|
- result.node?gljOprObj.refreshTreeNode(result.node):"";
|
|
|
+ if(result.node){//触发计算
|
|
|
+ me.refreshRationOrBillNodes(result.node);
|
|
|
+ }
|
|
|
$.bootstrapLoading.end();
|
|
|
}
|
|
|
CommonAjax.post("/quantity_detail/deleteRecode",recode,callback,function () {
|
|
@@ -315,7 +332,9 @@ var quantity_detail = {
|
|
|
$.bootstrapLoading.start();
|
|
|
var callback = function (data) {
|
|
|
me.refreshAfterUpdate(data);
|
|
|
- data.node?gljOprObj.refreshTreeNode(data.node):"";
|
|
|
+ if(data.node){
|
|
|
+ me.refreshRationOrBillNodes(data.node);
|
|
|
+ }
|
|
|
$.bootstrapLoading.end();
|
|
|
}
|
|
|
CommonAjax.post(url,postData,callback,function () {
|
|
@@ -489,10 +508,9 @@ var quantity_detail = {
|
|
|
}
|
|
|
return validate;
|
|
|
};
|
|
|
- quantity_detail.prototype.autoTransformQuantity = function(value,node){
|
|
|
+ quantity_detail.prototype.autoTransformQuantity = function(value,node){//根据单位转换定额工程量
|
|
|
let data = node.data;
|
|
|
let option = optionsOprObj.getOption(optionsOprObj.optionsTypes.GENERALOPTS,'rationQuanACToRationUnit');
|
|
|
- console.log(option);
|
|
|
if(option==true&&node.sourceType === project.Ration.getSourceType()&&data.unit) {//还需加入判读是否转换
|
|
|
let times = parseInt(data.unit);
|
|
|
if (isNaN(times)) {
|
|
@@ -502,6 +520,98 @@ var quantity_detail = {
|
|
|
}
|
|
|
return value;
|
|
|
};
|
|
|
+ quantity_detail.prototype.reverseQuantity = function (value,node) {//根据单位反向运算出工程量
|
|
|
+ let data = node.data;
|
|
|
+ if(node.sourceType === project.Ration.getSourceType()&&data.unit){
|
|
|
+ let times = parseInt(data.unit);
|
|
|
+ if (isNaN(times)) {
|
|
|
+ times = 1
|
|
|
+ }
|
|
|
+ value = value * times;
|
|
|
+ }
|
|
|
+ return value
|
|
|
+ };
|
|
|
+ quantity_detail.prototype.editMainTreeNodeQuantity=function (value,node,fieldName) {
|
|
|
+ var me = this;
|
|
|
+ if(isNaN(value)){
|
|
|
+ alert("当前输入的数据类型不正确,请重新输入");
|
|
|
+ projectObj.mainController.refreshTreeNode([node]);
|
|
|
+ }else {
|
|
|
+ value=value?value:0;
|
|
|
+ setTimeout(function () {//spreadjs事件和提示窗口会有冲突,所以要用延时的方法
|
|
|
+ if(project.quantity_detail.quantityEditChecking(value,node,fieldName)){
|
|
|
+ node.data.isFromDetail=0;
|
|
|
+ project.quantity_detail.cleanQuantityDetail(node,true);
|
|
|
+ if(node.sourceType === project.Bills.getSourceType()){
|
|
|
+ me.updateBillQuantity(value,node);
|
|
|
+ }else {
|
|
|
+ me.updateRationQuantity(value,node);//to do 加上工程量表达式和含量更新
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ projectObj.mainController.refreshTreeNode([node]);
|
|
|
+ }
|
|
|
+ },100);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ quantity_detail.prototype.updateBillQuantity=function (value,node) {
|
|
|
+ value = scMathUtil.roundForObj(value,getDecimal("quantity",node));
|
|
|
+ node.data.quantity = value+"";
|
|
|
+ let needUpdateChildren = [];//需更新的子定额
|
|
|
+ let gljNodes=[];//当定额工程量改变时需刷新的子工料机
|
|
|
+ if(node.children.length>0){//如果有子项则
|
|
|
+ for(let rationNode of node.children){
|
|
|
+ let EXPString = rationNode.data.quantityEXP+"";
|
|
|
+ if(EXPString.indexOf("QDL")!=-1){//如果定额的工程量是通过计算出来的,则应该重新计算。
|
|
|
+ let tem_contain = scMathUtil.roundForObj(rationNode.data.contain,getDecimal("process"));
|
|
|
+ let tem_quantity = scMathUtil.roundForObj(value*tem_contain,getDecimal("quantity",rationNode));
|
|
|
+ rationNode.data.quantity = this.autoTransformQuantity(tem_quantity,rationNode);
|
|
|
+ rationNode.changed = true;
|
|
|
+ needUpdateChildren.push(rationNode);
|
|
|
+ if (rationNode.children.length>0){//如果有子工料机
|
|
|
+ gljNodes = gljNodes.concat(rationNode.children);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ let tem_contain=0;
|
|
|
+ if(value&&value!=0){
|
|
|
+ let children_quantity = scMathUtil.roundForObj(rationNode.data.quantity,getDecimal("quantity"),rationNode);
|
|
|
+ children_quantity = scMathUtil.roundForObj(this.reverseQuantity(children_quantity,rationNode),getDecimal("quantity",rationNode));
|
|
|
+ tem_contain =scMathUtil.roundForObj(children_quantity/value,getDecimal("process"));
|
|
|
+ }
|
|
|
+ rationNode.data.contain = tem_contain;
|
|
|
+ rationNode.changed = true;
|
|
|
+ needUpdateChildren.push(rationNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(needUpdateChildren.length>0){
|
|
|
+ project.calcProgram.calcRationsAndSave(needUpdateChildren);
|
|
|
+ }else {
|
|
|
+ node.changed = true;
|
|
|
+ project.calcProgram.calculate(node);
|
|
|
+ project.calcProgram.saveNode(node);
|
|
|
+ }
|
|
|
+ if(gljNodes.length>0){
|
|
|
+ projectObj.mainController.refreshTreeNode(gljNodes);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ quantity_detail.prototype.updateRationQuantity=function(value,node,quantityEXP){
|
|
|
+ node.data.quantityEXP = quantityEXP?quantityEXP:value;
|
|
|
+ value = scMathUtil.roundForObj(value,getDecimal("ration.quantity"));
|
|
|
+ if(node.parent.data.quantity&&node.parent.data.quantity!=0&&node.parent.data.quantity!=""){
|
|
|
+ var billQuantity = scMathUtil.roundForObj(node.parent.data.quantity,getDecimal("quantity",node.parent));
|
|
|
+ node.data.contain = scMathUtil.roundForObj(value/billQuantity,getDecimal("process"));
|
|
|
+ }else {
|
|
|
+ node.data.contain=0;
|
|
|
+ }
|
|
|
+ value = project.quantity_detail.autoTransformQuantity(value,node);
|
|
|
+ value = scMathUtil.roundForObj(value,decimalObj.decimal("quantity",node))
|
|
|
+ node.data.quantity=value;
|
|
|
+ node.changed = true;
|
|
|
+ project.calcProgram.calculate(node);
|
|
|
+ project.calcProgram.saveNode(node);
|
|
|
+ projectObj.mainController.refreshTreeNode(node.children);//刷新子工料机总消耗量
|
|
|
+ gljOprObj.showRationGLJSheetData();
|
|
|
+ };
|
|
|
quantity_detail.prototype.getDecimal=function (node) {
|
|
|
var decimal = 3;
|
|
|
if(node.sourceType === project.Bills.getSourceType()){
|