|
@@ -194,7 +194,7 @@ var ration_glj = {
|
|
|
projectObj.mainController.refreshTreeNode([rationNode]);
|
|
|
for(let o of oldData){
|
|
|
if(this.needShowToTree(o)){
|
|
|
- let node = me.findTreeNodeByID(o.ID); //找到对应的树节点
|
|
|
+ let node = me.findGLJNodeByID(o.ID); //找到对应的树节点
|
|
|
projectObj.mainController.deleteNode(node,next);
|
|
|
}
|
|
|
}
|
|
@@ -353,6 +353,7 @@ var ration_glj = {
|
|
|
if(initShow==false){//不需要初始化,只需耍新当前显示就可以了
|
|
|
gljOprObj.showRationGLJSheetData();
|
|
|
}
|
|
|
+ me.reCalcWhenGLJChange(recode);//触发计算定额以及父节点
|
|
|
projectObj.project.projectGLJ.loadData(function () {//等项目工料机加载完成后再给用户编辑
|
|
|
if(initShow==true){
|
|
|
gljOprObj.refreshView();
|
|
@@ -372,7 +373,7 @@ var ration_glj = {
|
|
|
var doc = {};
|
|
|
doc[updateField]=newval;
|
|
|
if(updateField=="type"){
|
|
|
- doc.shortName = gljTypeMap[newval];
|
|
|
+ doc.shortName = projectObj.project.projectGLJ.getShortNameByID[newval];
|
|
|
}
|
|
|
CommonAjax.post("/rationGlj/updateRationGLJByEdit",{query:query,doc:doc,priceInfo:priceInfo},callback,function (err) {
|
|
|
$.bootstrapLoading.end();
|
|
@@ -404,6 +405,100 @@ var ration_glj = {
|
|
|
cb(data);
|
|
|
})
|
|
|
};
|
|
|
+ ration_glj.prototype.insertGLJAsRation = function (GLJSelection,selected,callback) {
|
|
|
+ let gljList = [];
|
|
|
+ let allGLJ=gljOprObj.AllRecode;
|
|
|
+ let billsItemID = null;
|
|
|
+ let serialNo=0;
|
|
|
+ let selectedSerialNo=null;
|
|
|
+ let nextNodeID=null;
|
|
|
+ let parentNodeID=null;
|
|
|
+ let children = [];
|
|
|
+ if(selected.sourceType === project.Bills.getSourceType()){
|
|
|
+ billsItemID = selected.data.ID;
|
|
|
+ parentNodeID = selected.getID();
|
|
|
+ nextNodeID = selected.tree.rootID();
|
|
|
+ }else {
|
|
|
+ billsItemID = selected.data.billsItemID;
|
|
|
+ serialNo = selected.data.serialNo;
|
|
|
+ selectedSerialNo=selected.data.serialNo;
|
|
|
+ nextNodeID= selected.getNextSiblingID();
|
|
|
+ parentNodeID=selected.getParentID();
|
|
|
+ }
|
|
|
+ children = project.Ration.getBillsSortRation(billsItemID);
|
|
|
+ serialNo==0?serialNo=children.length:"";
|
|
|
+ for(let con_key of GLJSelection){
|
|
|
+ var glj=_.find(allGLJ,function (item) {
|
|
|
+ let i_key = gljOprObj.getIndex(item,['code','name','specs','unit','gljType']);
|
|
|
+ return i_key ==con_key;
|
|
|
+ });
|
|
|
+ if(glj){
|
|
|
+ serialNo+=1;
|
|
|
+ let new_glj = {
|
|
|
+ ID:project.Ration.getNewRationID(),
|
|
|
+ projectID:parseInt(project.ID()),
|
|
|
+ billsItemID:billsItemID,
|
|
|
+ type:rationType.gljRation,
|
|
|
+ code : glj.code,
|
|
|
+ name :glj.name,
|
|
|
+ quantity:0,
|
|
|
+ unit:glj.unit,
|
|
|
+ specs:glj.specs,
|
|
|
+ subType:glj.gljType,
|
|
|
+ basePrice:glj.basePrice,
|
|
|
+ original_code:glj.code,
|
|
|
+ shortName:glj.shortName,
|
|
|
+ serialNo:serialNo,
|
|
|
+ GLJID:glj.ID,
|
|
|
+ adjCoe:glj.adjCoe,
|
|
|
+ repositoryId:glj.repositoryId
|
|
|
+ }
|
|
|
+ if(glj.hasOwnProperty("compilationId")){
|
|
|
+ new_glj.from="cpt";
|
|
|
+ if(glj.code.indexOf('-')!=-1){//这条工料机是用户通过修改名称、规格、型号等保存到补充工料机库的
|
|
|
+ new_glj.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gljList.push(new_glj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(gljList.length==0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let postData = {
|
|
|
+ gljList:gljList,
|
|
|
+ projectID:parseInt(project.ID()),
|
|
|
+ billsItemID:billsItemID,
|
|
|
+ rationCount:project.Ration.maxRationID()
|
|
|
+ }
|
|
|
+ selectedSerialNo==null?"":postData.selectedSerialNo = selectedSerialNo;
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ CommonAjax.post("/ration/insertGLJAsRation",postData,function (data) {
|
|
|
+ console.log(data);
|
|
|
+ // 更新兄弟节点的序列号
|
|
|
+ if(selectedSerialNo!=null&&selectedSerialNo<children.length){
|
|
|
+ for(let i = selectedSerialNo;i<children.length;i++){
|
|
|
+ children[i].serialNo+=gljList.length;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(let r_glj of data){
|
|
|
+ r_glj.marketUnitFee = r_glj.marketPrice;
|
|
|
+ r_glj.quantity =r_glj.quantity+"";
|
|
|
+ project.Ration.datas.push(r_glj);
|
|
|
+ let newNode = project.mainTree.insert(parentNodeID,nextNodeID);
|
|
|
+ newNode.source = r_glj;
|
|
|
+ newNode.sourceType = project.Ration.getSourceType();
|
|
|
+ newNode.data = r_glj;
|
|
|
+ ProjectController.syncDisplayNewNode(projectObj.mainController, newNode);
|
|
|
+ }
|
|
|
+ callback();
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ },function () {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ };
|
|
|
ration_glj.prototype.addGLJByLib=function (GLJSelection,ration,callback) {
|
|
|
var gljList=[];
|
|
|
var allGLJ=gljOprObj.AllRecode;
|
|
@@ -546,8 +641,6 @@ var ration_glj = {
|
|
|
data.marketUnitFee = data.marketPrice;
|
|
|
};
|
|
|
ration_glj.prototype.updateFromMainSpread=function (value,node,fieldName) {
|
|
|
- console.log(fieldName);
|
|
|
- console.log(value);
|
|
|
if(node.data[fieldName]===value){
|
|
|
return;
|
|
|
}
|
|
@@ -584,12 +677,25 @@ var ration_glj = {
|
|
|
}
|
|
|
return false
|
|
|
};
|
|
|
- ration_glj.prototype.findTreeNodeByID = function (ID) {
|
|
|
+ ration_glj.prototype.findGLJNodeByID = function (ID) {
|
|
|
let node = _.find(projectObj.project.mainTree.items,function (n) {//找到对应的树节点
|
|
|
return n.sourceType==ModuleNames.ration_glj &&n.data.ID==ID;
|
|
|
});
|
|
|
return node;
|
|
|
- }
|
|
|
+ };
|
|
|
+ ration_glj.prototype.findRationNodeByID = function (ID) {
|
|
|
+ let node = _.find(projectObj.project.mainTree.items,function (n) {//找到对应定额的树节点
|
|
|
+ return n.sourceType==ModuleNames.ration &&n.data.ID==ID;
|
|
|
+ });
|
|
|
+ return node;
|
|
|
+ };
|
|
|
+ ration_glj.prototype.reCalcWhenGLJChange = function (ration_glj) {//当改变定额工料机时,重新计算定额以及期父节点
|
|
|
+ let node = this.findRationNodeByID(ration_glj.rationID);
|
|
|
+ if(node){
|
|
|
+ project.calcProgram.calculate(node);
|
|
|
+ project.calcProgram.saveNode(node);
|
|
|
+ }
|
|
|
+ };
|
|
|
return new ration_glj(project);
|
|
|
}
|
|
|
};
|