|
@@ -1,17 +1,17 @@
|
|
|
/**
|
|
|
* Created by Mai on 2017/4/1.
|
|
|
*/
|
|
|
-var ration_glj = {
|
|
|
+let ration_glj = {
|
|
|
createNew: function (project) {
|
|
|
// 用户定义private方法
|
|
|
- var tools = {};
|
|
|
+ let tools = {};
|
|
|
|
|
|
// 所有通过this访问的属性,都不应在此单元外部进行写入操作
|
|
|
- var ration_glj = function (proj) {
|
|
|
+ let ration_glj = function (proj) {
|
|
|
this.gljTree = cacheTree.createNew(this);
|
|
|
// this.project = proj;
|
|
|
this.datas = [];
|
|
|
- var sourceType = ModuleNames.ration_glj;
|
|
|
+ let sourceType = ModuleNames.ration_glj;
|
|
|
this.getSourceType = function () {
|
|
|
return sourceType;
|
|
|
}
|
|
@@ -65,9 +65,8 @@ var ration_glj = {
|
|
|
let result = [];
|
|
|
let clone = function (obj) {
|
|
|
if (obj === null) return null;
|
|
|
-
|
|
|
- var o = Object.prototype.toString.apply(obj) === "[object Array]" ? [] : {};
|
|
|
- for (var i in obj) {
|
|
|
+ let o = Object.prototype.toString.apply(obj) === "[object Array]" ? [] : {};
|
|
|
+ for (let i in obj) {
|
|
|
o[i] = (obj[i] instanceof Date) ? new Date(obj[i].getTime()) : (typeof obj[i] === "object" ? clone(obj[i]) : obj[i]);
|
|
|
}
|
|
|
return o;
|
|
@@ -132,7 +131,7 @@ var ration_glj = {
|
|
|
|
|
|
// 提交数据后返回数据处理
|
|
|
ration_glj.prototype.doAfterUpdate = function (err, data) {
|
|
|
- var me = this;
|
|
|
+ let me = this;
|
|
|
if (!err) {
|
|
|
if (data.updateTpye == 'ut_update') {
|
|
|
me.refreshAfterUpdate(data);
|
|
@@ -230,8 +229,8 @@ var ration_glj = {
|
|
|
};
|
|
|
|
|
|
ration_glj.prototype.refreshAfterUpdate = function (data) {
|
|
|
- var me = this;
|
|
|
- var rationID=null;
|
|
|
+ let me = this;
|
|
|
+ let rationID=null;
|
|
|
if (data.quantityRefresh) {
|
|
|
data.glj_result.forEach(function (item) {
|
|
|
rationID = me.refreshEachItme(item.doc, item.query);
|
|
@@ -243,8 +242,8 @@ var ration_glj = {
|
|
|
this.reCalcWhenGLJChange({rationID:rationID});
|
|
|
};
|
|
|
ration_glj.prototype.refreshEachItme = function (doc, query) {
|
|
|
- var glj_list = projectObj.project.ration_glj.datas;
|
|
|
- var glj_index = _.findIndex(glj_list, (glj) => {
|
|
|
+ let glj_list = projectObj.project.ration_glj.datas;
|
|
|
+ let glj_index = _.findIndex(glj_list, (glj) => {
|
|
|
return glj.ID == query.ID;
|
|
|
})
|
|
|
/*var sheet_index= _.findIndex(gljOprObj.sheetData,(sd)=>{
|
|
@@ -256,15 +255,15 @@ var ration_glj = {
|
|
|
return glj_list[glj_index].rationID;
|
|
|
};
|
|
|
ration_glj.prototype.refreshAfterDelete = function (data) {
|
|
|
- var me = projectObj.project.ration_glj;
|
|
|
- var glj_list = me.datas;
|
|
|
- var oldData = _.remove(glj_list, data.query);
|
|
|
+ let me = projectObj.project.ration_glj;
|
|
|
+ let glj_list = me.datas;
|
|
|
+ let oldData = _.remove(glj_list, data.query);
|
|
|
_.remove(gljOprObj.sheetData, data.query);
|
|
|
gljOprObj.showRationGLJSheetData();
|
|
|
projectObj.project.projectGLJ.loadData();
|
|
|
- var rationNode = null;
|
|
|
- var next = null;
|
|
|
- var selected = projectObj.project.mainTree.selected;
|
|
|
+ let rationNode = null;
|
|
|
+ let next = null;
|
|
|
+ let selected = projectObj.project.mainTree.selected;
|
|
|
if (selected.sourceType == ModuleNames.ration) { //如果选中的是定额,说明是右键删除工料机操作,如果选中的是定额工料机,则说明是在造价书主界面中点击了删除按钮
|
|
|
rationNode = selected;
|
|
|
} else if (selected.sourceType == ModuleNames.ration_glj) {
|
|
@@ -311,8 +310,8 @@ var ration_glj = {
|
|
|
this.project.endUpdate();
|
|
|
};
|
|
|
ration_glj.prototype.addRationGLJ = function (newRation, data) {
|
|
|
- var souceTypeList = [];
|
|
|
- var criteriaDataList = [];
|
|
|
+ let souceTypeList = [];
|
|
|
+ let criteriaDataList = [];
|
|
|
if (data.hasOwnProperty('rationGljList') && data.rationGljList.length > 0) {
|
|
|
let criteria = {};
|
|
|
criteria.ration_glj_list = [];
|
|
@@ -322,8 +321,8 @@ var ration_glj = {
|
|
|
newGLJ.projectID = parseInt(newRation.projectID);
|
|
|
newGLJ.GLJID = temdata.gljId;
|
|
|
newGLJ.rationID = newRation.ID;
|
|
|
- newGLJ.billsItemID = newRation.billsItemID,
|
|
|
- newGLJ.rationItemQuantity = temdata.consumeAmt;
|
|
|
+ newGLJ.billsItemID = newRation.billsItemID;
|
|
|
+ newGLJ.rationItemQuantity = temdata.consumeAmt;
|
|
|
newGLJ.quantity = temdata.consumeAmt;
|
|
|
newGLJ.glj_repository_id = data.rationRepId;
|
|
|
criteria.ration_glj_list.push(newGLJ);
|
|
@@ -332,8 +331,8 @@ var ration_glj = {
|
|
|
souceTypeList.push(this.getSourceType());
|
|
|
criteriaDataList.push(criteria);
|
|
|
}
|
|
|
- var ration_coe = projectObj.project.ration_coe;
|
|
|
- var rationCoeData = ration_coe.getRationCoedata(newRation, data);
|
|
|
+ let ration_coe = projectObj.project.ration_coe;
|
|
|
+ let rationCoeData = ration_coe.getRationCoedata(newRation, data);
|
|
|
souceTypeList.push(ration_coe.getSourceType());
|
|
|
criteriaDataList.push(rationCoeData);
|
|
|
project.pushNow('addRationGLJAndRationCoe', souceTypeList, criteriaDataList);
|
|
@@ -341,7 +340,7 @@ var ration_glj = {
|
|
|
};
|
|
|
|
|
|
ration_glj.prototype.getDeleteDataByRation = function (rationData) {
|
|
|
- var updateData = [];
|
|
|
+ let updateData = [];
|
|
|
updateData.push({
|
|
|
'deleteType': 'RATION',
|
|
|
'updateType': 'ut_delete',
|
|
@@ -350,10 +349,10 @@ var ration_glj = {
|
|
|
return updateData;
|
|
|
};
|
|
|
ration_glj.prototype.getDeleteDataByBills = function (datas) {
|
|
|
- var updateData = [];
|
|
|
+ let updateData = [];
|
|
|
datas.forEach(function (deleteData) {
|
|
|
if (deleteData.type == 'delete') {
|
|
|
- var billData = deleteData.data;
|
|
|
+ let billData = deleteData.data;
|
|
|
updateData.push({
|
|
|
'deleteType': 'BILL',
|
|
|
'updateType': 'ut_delete',
|
|
@@ -364,22 +363,22 @@ var ration_glj = {
|
|
|
return updateData;
|
|
|
};
|
|
|
ration_glj.prototype.deleteByRation = function (ration) {
|
|
|
- var glj_list = projectObj.project.ration_glj.datas;
|
|
|
+ let glj_list = projectObj.project.ration_glj.datas;
|
|
|
_.remove(glj_list,{'rationID':ration.ID});
|
|
|
};
|
|
|
ration_glj.prototype.deleteByBills = function (deleteData) {
|
|
|
- var rationList = projectObj.project.Ration.datas;
|
|
|
- var deleteRationList = [];
|
|
|
- for (var i = 0; i < deleteData.length; i++) {
|
|
|
+ let rationList = projectObj.project.Ration.datas;
|
|
|
+ let deleteRationList = [];
|
|
|
+ for (let i = 0; i < deleteData.length; i++) {
|
|
|
if (deleteData[i].type == 'delete') {
|
|
|
- var billID = deleteData[i].data.ID;
|
|
|
- var raList = _.filter(rationList, (ration) => {
|
|
|
+ let billID = deleteData[i].data.ID;
|
|
|
+ let raList = _.filter(rationList, (ration) => {
|
|
|
return ration.billsItemID == billID;
|
|
|
});
|
|
|
deleteRationList = deleteRationList.concat(raList);
|
|
|
}
|
|
|
}
|
|
|
- for (var i = 0; i < deleteRationList.length; i++) {
|
|
|
+ for (let i = 0; i < deleteRationList.length; i++) {
|
|
|
this.deleteByRation(deleteRationList[i]);
|
|
|
projectObj.project.ration_coe.deleteByRation(deleteRationList[i]);
|
|
|
projectObj.project.quantity_detail.deleteByRation(deleteRationList[i]);
|
|
@@ -389,7 +388,7 @@ var ration_glj = {
|
|
|
}
|
|
|
|
|
|
ration_glj.prototype.updataOrdelete = function (row) {
|
|
|
- var updateData = null;
|
|
|
+ let updateData = null;
|
|
|
if (row.rationItemQuantity == 0) {
|
|
|
updateData = this.getUpdateData('ut_delete', {
|
|
|
'ID': row.ID,
|
|
@@ -402,8 +401,8 @@ var ration_glj = {
|
|
|
}
|
|
|
};
|
|
|
ration_glj.prototype.getUpdateData = function (type, query, doc, callfunction) {
|
|
|
- var updateData = [];
|
|
|
- var newobj = {
|
|
|
+ let updateData = [];
|
|
|
+ let newobj = {
|
|
|
'updateType': type,
|
|
|
'query': query,
|
|
|
}
|
|
@@ -440,8 +439,8 @@ var ration_glj = {
|
|
|
if (updateField == 'customQuantity') {
|
|
|
me.refreshAfterQuantityUpdate(data, node);
|
|
|
} else {
|
|
|
- var doc = data.doc;
|
|
|
- for (var key in doc) {
|
|
|
+ let doc = data.doc;
|
|
|
+ for (let key in doc) {
|
|
|
recode[key] = doc[key];
|
|
|
}
|
|
|
me.refreshRationAfterEdit(data,recode.rationID, node);//更新名称和定额调整状态
|
|
@@ -468,11 +467,8 @@ var ration_glj = {
|
|
|
$.bootstrapLoading.end();
|
|
|
});
|
|
|
};
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
ration_glj.prototype.refreshAfterQuantityUpdate = function (data, node) {
|
|
|
- var me = this;
|
|
|
+ let me = this;
|
|
|
data.glj_result.forEach(function (item) {
|
|
|
me.refreshEachItme(item.doc, item.query);
|
|
|
});
|
|
@@ -523,7 +519,7 @@ var ration_glj = {
|
|
|
children = project.Ration.getBillsSortRation(billsItemID);
|
|
|
serialNo == 0 ? serialNo = children.length : "";
|
|
|
for (let con_key of GLJSelection) {
|
|
|
- var glj = _.find(allGLJ, function (item) {
|
|
|
+ let glj = _.find(allGLJ, function (item) {
|
|
|
let i_key = gljOprObj.getIndex(item, gljLibKeyArray);
|
|
|
return i_key == con_key;
|
|
|
});
|
|
@@ -595,15 +591,15 @@ var ration_glj = {
|
|
|
|
|
|
};
|
|
|
ration_glj.prototype.addGLJByLib = function (GLJSelection, ration, callback) {
|
|
|
- var gljList = [];
|
|
|
- var allGLJ = gljOprObj.AllRecode;
|
|
|
+ let gljList = [];
|
|
|
+ let allGLJ = gljOprObj.AllRecode;
|
|
|
GLJSelection.sort();
|
|
|
_.forEach(GLJSelection, function (g) {
|
|
|
- var glj = _.find(allGLJ, function (item) {
|
|
|
- var i_key = gljOprObj.getIndex(item, gljLibKeyArray);
|
|
|
+ let glj = _.find(allGLJ, function (item) {
|
|
|
+ let i_key = gljOprObj.getIndex(item, gljLibKeyArray);
|
|
|
return i_key == g;
|
|
|
});
|
|
|
- var ration_glj = {
|
|
|
+ let ration_glj = {
|
|
|
projectID: ration.projectID,
|
|
|
GLJID: glj.ID,
|
|
|
rationID: ration.ID,
|
|
@@ -664,16 +660,16 @@ var ration_glj = {
|
|
|
CommonAjax.post("/rationGlj/replaceGLJ", recode, function (result) {
|
|
|
if (result) {
|
|
|
//result.adjustState;
|
|
|
- var glj_list = me.datas;
|
|
|
- var data = result.data;
|
|
|
- var list_index = _.findIndex(glj_list, {'ID': data.ID});
|
|
|
+ let glj_list = me.datas;
|
|
|
+ let data = result.data;
|
|
|
+ let list_index = _.findIndex(glj_list, {'ID': data.ID});
|
|
|
let rationNode = projectObj.project.mainTree.findNode(data.rationID);
|
|
|
- var nodes = [rationNode];
|
|
|
+ let nodes = [rationNode];
|
|
|
glj_list[list_index] = data;
|
|
|
project.projectGLJ.loadData(function () {//加载完项目工料机再计算
|
|
|
gljOprObj.refreshView();
|
|
|
if (project.ration_glj.needShowToTree(data)) {//当替换的是主材或设备时,刷新对应的树节点
|
|
|
- var node = project.ration_glj.findGLJNodeByID(data.ID);
|
|
|
+ let node = project.ration_glj.findGLJNodeByID(data.ID);
|
|
|
if (node) {
|
|
|
project.ration_glj.transferToNodeData(data);
|
|
|
node.source = data;
|
|
@@ -696,9 +692,9 @@ var ration_glj = {
|
|
|
};
|
|
|
|
|
|
ration_glj.prototype.replaceGLJ = function (selectCode, oldData, callback) {
|
|
|
- var allGLJ = gljOprObj.AllRecode;
|
|
|
- var glj = _.find(allGLJ, function (item) {
|
|
|
- var i_key = gljOprObj.getIndex(item, gljLibKeyArray);
|
|
|
+ let allGLJ = gljOprObj.AllRecode;
|
|
|
+ let glj = _.find(allGLJ, function (item) {
|
|
|
+ let i_key = gljOprObj.getIndex(item, gljLibKeyArray);
|
|
|
return i_key == selectCode;
|
|
|
});
|
|
|
if (selectCode == gljOprObj.getIndex(oldData, gljKeyArray)) {
|
|
@@ -809,7 +805,7 @@ var ration_glj = {
|
|
|
};
|
|
|
|
|
|
ration_glj.prototype.getMainAndEquGLJ = function (rationID) {
|
|
|
- var gljList = _.filter(this.datas, function (n) {
|
|
|
+ let gljList = _.filter(this.datas, function (n) {
|
|
|
return n.rationID == rationID && (n.type == gljType.MAIN_MATERIAL || n.type == gljType.EQUIPMENT)
|
|
|
});
|
|
|
gljList = sortRationGLJ(gljList);
|
|
@@ -821,19 +817,19 @@ var ration_glj = {
|
|
|
};
|
|
|
ration_glj.prototype.combineRationAndGLJ = function (ration) {
|
|
|
if (ration) {
|
|
|
- var projectGLJData = projectObj.project.projectGLJ.datas;
|
|
|
- var projectGljs = projectGLJData.gljList;
|
|
|
- var mixRatioMap = projectGLJData.mixRatioMap;
|
|
|
- var glj = _.find(projectGljs, {'id': ration.projectGLJID});
|
|
|
+ let projectGLJData = projectObj.project.projectGLJ.datas;
|
|
|
+ let projectGljs = projectGLJData.gljList;
|
|
|
+ let mixRatioMap = projectGLJData.mixRatioMap;
|
|
|
+ let glj = _.find(projectGljs, {'id': ration.projectGLJID});
|
|
|
if (glj) {
|
|
|
if(projectObj.project.projectGLJ.isEstimateType(glj.type)){
|
|
|
ration.isEstimate = glj.is_evaluate;
|
|
|
}
|
|
|
ration = gljOprObj.setGLJPrice(ration,glj);
|
|
|
ration.isAdd = glj.unit_price.is_add;
|
|
|
- var connect_index = gljOprObj.getIndex(glj, gljKeyArray);
|
|
|
+ let connect_index = gljOprObj.getIndex(glj, gljKeyArray);
|
|
|
if (mixRatioMap.hasOwnProperty(connect_index)) {
|
|
|
- var mixRatios = gljOprObj.getMixRationShowDatas(mixRatioMap[connect_index], projectGljs);
|
|
|
+ let mixRatios = gljOprObj.getMixRationShowDatas(mixRatioMap[connect_index], projectGljs);
|
|
|
ration.subList = mixRatios;
|
|
|
}
|
|
|
}
|
|
@@ -843,8 +839,8 @@ var ration_glj = {
|
|
|
ration_glj.prototype.updateFromMainSpread = function (value, node, fieldName) {
|
|
|
if (node.data[fieldName] !== value) {
|
|
|
if (fieldName == "marketUnitFee") {
|
|
|
- var decimal = getDecimal("glj.unitPrice");
|
|
|
- var newval = number_util.checkNumberValue(value, decimal);
|
|
|
+ let decimal = getDecimal("glj.unitPrice");
|
|
|
+ let newval = number_util.checkNumberValue(value, decimal);
|
|
|
if (newval) {
|
|
|
fieldName = "marketPrice";
|
|
|
projectObj.project.projectGLJ.updatePriceFromRG(node.data, fieldName, newval);
|
|
@@ -856,7 +852,7 @@ var ration_glj = {
|
|
|
if(value==null){
|
|
|
value="";
|
|
|
}else {
|
|
|
- var decimal = getDecimal("glj.quantity");
|
|
|
+ let decimal = getDecimal("glj.quantity");
|
|
|
value = number_util.checkNumberValue(value, decimal);
|
|
|
fieldName="customQuantity";//填入自定义消耗
|
|
|
}
|