/** * Created by Mai on 2017/4/1. */ var ration_glj = { createNew: function (project) { // 用户定义private方法 var tools = {}; // 所有通过this访问的属性,都不应在此单元外部进行写入操作 var ration_glj = function (proj) { this.gljTree = cacheTree.createNew(this); // this.project = proj; this.datas = []; var sourceType = ModuleNames.ration_glj; this.getSourceType = function () { return sourceType; } proj.registerModule(ModuleNames.ration_glj, this); }; // 从后台获取数据 /*glj.prototype.pullData = function (){ this.project.pullData( '/glj/getData', {projectID: this.project.ID}, function(result){ if (result.error ===0){ this.loadDatas(result.data); } else { // to do: 错误处理需要细化 alert(result.message); } }, function (){}//to do: 错误处理需要细化 ) };*/ // prototype用于定义public方法 ration_glj.prototype.loadData = function (datas) { this.datas = datas; }; ration_glj.prototype.getGljArrByRation = function (ration) { if (ration.type == rationType.gljRation){ let glj = JSON.parse(JSON.stringify(ration)); glj.type = glj.subType; glj.quantity = 1; return [glj]; } else{ let result = this.datas.filter(function (data) { return data.rationID === ration.ID; }) result = gljOprObj.combineWithProjectGlj(result); return result; } }; ration_glj.prototype.getGatherGljArrByRations = function (rations, needOneBill, billQuantity) { 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) { o[i] = (obj[i] instanceof Date) ? new Date(obj[i].getTime()) : (typeof obj[i] === "object" ? clone(obj[i]) : obj[i]); } return o; } let findGlj = function (sourceGlj, gljArr) { for (let glj of gljArr) { if (glj.projectGLJID === sourceGlj.projectGLJID) { return glj; } } return null; } for (let ration of rations) { if (ration.type == rationType.volumePrice || ration.type == rationType.gljRation){ result.push(ration); } else{ let rationGljs = this.getGljArrByRation(ration); for (let glj of rationGljs) { let sameGlj = findGlj(glj, result); if (!sameGlj) { sameGlj = clone(glj); sameGlj.quantity = (sameGlj.quantity * ration.quantity).toDecimal(4); result.push(sameGlj); } else { sameGlj.quantity = sameGlj.quantity + (glj.quantity * ration.quantity).toDecimal(4); sameGlj.totalQuantity = (parseFloat(sameGlj.totalQuantity) + parseFloat(glj.totalQuantity)).toDecimal(4); } } } } result = gljOprObj.combineWithProjectGlj(result); if (!needOneBill) return result; // 上面取的是清单下所有工料机的总量,我要算清单单价,所以要取单位清单的工料机数量,所以下面要除以清单数量。 let oneBill = JSON.parse(JSON.stringify(result)); for (let glj of oneBill){ if (glj.type == rationType.volumePrice){ // 量价、工料机形式的定额要进行数据变换才能参与基数计算。 glj.type = glj.subType; glj.basePrice = glj.marketUnitFee; glj.marketPrice = glj.marketUnitFee; glj.adjustPrice = glj.marketUnitFee; } else if (glj.type == rationType.gljRation){ glj.type = glj.subType; }; glj.quantity = (glj.quantity / billQuantity).toDecimal(decimalObj.glj.quantity); }; return oneBill; } // 提交数据后返回数据处理 ration_glj.prototype.doAfterUpdate = function (err, data) { var me = this; if (!err) { if (data.updateTpye == 'ut_update') { me.refreshAfterUpdate(data); } else if (data.updateTpye == 'ut_delete') { me.refreshAfterDelete(data); } else { me.refreshAfterSave(data); } } projectObj.project.projectGLJ.loadData(); }; ration_glj.prototype.getDataByID = function (ID) { return _.find(this.datas,{'ID':ID}); }; ration_glj.prototype.refreshAfterSave = function (data) { let me = projectObj.project.ration_glj; let neRecodes = []; if (data) { // neRecodes=data.newRecords;//原来是显示和缓存分开的,后来发现会导致数据不一致的问题所以改成统一的了,这里也只是会作为显示。 neRecodes = data.showDatas; gljOprObj.sheetData = neRecodes; me.addDatasToList(neRecodes); } project.projectGLJ.loadData(function () { gljOprObj.showRationGLJSheetData(true); //add to mainTree; me.addToMainTree(neRecodes); let rationID = neRecodes[0].rationID; let node = project.mainTree.nodes['id_' + rationID]; if(isDef(node)){ project.calcProgram.calcAndSave(node); } if (activeSubSheetIs(subSheetIndex.ssiCalcProgram)) { calcProgramObj.showData(node, false); } }); }; ration_glj.prototype.getGljByRationID = function(rationID){ return _.filter(this.datas, {'rationID': rationID}); }; ration_glj.prototype.addDatasToList = function (datas) { let me = projectObj.project.ration_glj; if(datas&&datas.length>0){ if (me.datas && Array.isArray(me.datas)) { me.datas = me.datas.concat(datas); } else { me.datas = datas; } } }; ration_glj.prototype.addToMainTree = function (datas) { datas = sortRationGLJ(datas); for (let data of datas) { if (this.needShowToTree(data)) { gljOprObj.setGLJPrice(data); this.transferToNodeData(data); let parentNode = _.find(projectObj.project.mainTree.items, function (n) {//找父节点 return n.sourceType == ModuleNames.ration && n.data.ID == data.rationID; }); if (parentNode) { let nextNodeID = null; if (parentNode.children.length > 0) { for (let br of parentNode.children) { if (compareRationGLJ(data, br.data)) {//如果有兄弟节点则找到添加位置。 nextNodeID = br.getID(); } } } nextNodeID = nextNodeID ? nextNodeID : parentNode.tree.rootID(); let newNode = projectObj.project.mainTree.insert(parentNode.getID(), nextNodeID,data.ID); newNode.source = data; newNode.sourceType = this.getSourceType(); newNode.data = data; ProjectController.syncDisplayNewRationGljNode(projectObj.mainController, newNode); } } } }; ration_glj.prototype.removeNodeByRation = function(ration,controller){//删除主材或设备节点 let glj_list = _.filter(projectObj.project.ration_glj.datas,{'rationID':ration.ID}); let deleteNodes = []; for(let rg of glj_list){ if(this.needShowToTree(rg)){ let r_node = projectObj.project.mainTree.getNodeByID(rg.ID); deleteNodes.push(r_node); } } if(deleteNodes.length > 0){ let rowIndex = deleteNodes[0].serialNo(); if(controller.tree.m_delete(deleteNodes)){ TREE_SHEET_HELPER.massOperationSheet(controller.sheet, function () { let rowCount = deleteNodes.length; controller.sheet.deleteRows(rowIndex, rowCount); }); } } }; ration_glj.prototype.refreshAfterUpdate = function (data) { var me = this; var rationID=null; if (data.quantityRefresh) { data.glj_result.forEach(function (item) { rationID = me.refreshEachItme(item.doc, item.query); }) } else { rationID = me.refreshEachItme(data.doc, data.query); } gljOprObj.showRationGLJSheetData(true); 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) => { return glj.ID == query.ID; }) /*var sheet_index= _.findIndex(gljOprObj.sheetData,(sd)=>{ return sd.ID==query.ID; })*/ _.forEach(doc, function (n, key) { glj_list[glj_index][key] = n; }); 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); _.remove(gljOprObj.sheetData, data.query); gljOprObj.showRationGLJSheetData(); projectObj.project.projectGLJ.loadData(); var rationNode = null; var next = null; var selected = projectObj.project.mainTree.selected; if (selected.sourceType == ModuleNames.ration) { //如果选中的是定额,说明是右键删除工料机操作,如果选中的是定额工料机,则说明是在造价书主界面中点击了删除按钮 rationNode = selected; } else if (selected.sourceType == ModuleNames.ration_glj) { rationNode = selected.parent; next = true; } rationNode.data.adjustState = data.adjustState; projectObj.mainController.refreshTreeNode([rationNode]); for (let o of oldData) { if (this.needShowToTree(o)) { let node = me.findGLJNodeByID(o.ID); //找到对应的树节点 projectObj.mainController.deleteNode(node, next); } } }; // CSL,2017.05.09 ration_glj.prototype.modifyQuantity = function (data, newQuantity) { this.project.beginUpdate('modifyQuantity'); data.quantity = newQuantity; data.customQuantity = newQuantity; data.updateType = 'ut_update'; this.project.push(this.getSourceType, data); this.project.endUpdate(); }; ration_glj.prototype.modifyPrice = function (data, newPrice) { this.project.beginUpdate('modifyPrice'); data.price = newPrice; data.updateType = 'ut_update'; this.project.push(this.getSourceType, data); this.project.endUpdate(); }; ration_glj.prototype.deleteGLJ = function (data) { this.project.beginUpdate('deleteGLJ'); data.customQuantity = 0; data.quantity = 0; data.rationItemQuantity = 0; data.updateType = 'ut_update'; this.project.push(this.getSourceType, data); this.project.endUpdate(); }; ration_glj.prototype.addRationGLJ = function (newRation, data) { var souceTypeList = []; var criteriaDataList = []; if (data.hasOwnProperty('rationGljList') && data.rationGljList.length > 0) { let criteria = {}; criteria.ration_glj_list = []; for (let i = 0; i < data.rationGljList.length; i++) { let temdata = data.rationGljList[i]; let newGLJ = {}; newGLJ.projectID = parseInt(newRation.projectID); newGLJ.GLJID = temdata.gljId; newGLJ.rationID = newRation.ID; newGLJ.billsItemID = newRation.billsItemID, newGLJ.rationItemQuantity = temdata.consumeAmt; newGLJ.quantity = temdata.consumeAmt; newGLJ.glj_repository_id = data.rationRepId; criteria.ration_glj_list.push(newGLJ); } criteria.updateType = 'ut_create'; souceTypeList.push(this.getSourceType()); criteriaDataList.push(criteria); } var ration_coe = projectObj.project.ration_coe; var rationCoeData = ration_coe.getRationCoedata(newRation, data); souceTypeList.push(ration_coe.getSourceType()); criteriaDataList.push(rationCoeData); project.pushNow('addRationGLJAndRationCoe', souceTypeList, criteriaDataList); }; ration_glj.prototype.getDeleteDataByRation = function (rationData) { var updateData = []; updateData.push({ 'deleteType': 'RATION', 'updateType': 'ut_delete', 'updateData': {'ID': rationData.ID, 'projectID': rationData.projectID} }); return updateData; }; ration_glj.prototype.getDeleteDataByBills = function (datas) { var updateData = []; datas.forEach(function (deleteData) { if (deleteData.type == 'delete') { var billData = deleteData.data; updateData.push({ 'deleteType': 'BILL', 'updateType': 'ut_delete', 'updateData': {'ID': billData.ID, 'projectID': billData.projectID} }); } }) return updateData; }; ration_glj.prototype.deleteByRation = function (ration) { var 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++) { if (deleteData[i].type == 'delete') { var billID = deleteData[i].data.ID; var raList = _.filter(rationList, (ration) => { return ration.billsItemID == billID; }); deleteRationList = deleteRationList.concat(raList); } } for (var i = 0; i < deleteRationList.length; i++) { this.deleteByRation(deleteRationList[i]); projectObj.project.ration_coe.deleteByRation(deleteRationList[i]); projectObj.project.quantity_detail.deleteByRation(deleteRationList[i]); projectObj.project.ration_installation.deleteByRation(deleteRationList[i]); projectObj.project.Ration.datas.splice(projectObj.project.Ration.datas.indexOf(deleteRationList[i]), 1); } } ration_glj.prototype.updataOrdelete = function (row) { var updateData = null; if (row.rationItemQuantity == 0) { updateData = this.getUpdateData('ut_delete', { 'ID': row.ID, 'projectID': row.projectID }, {rationID: row.rationID}); project.pushNow('updateRationGLJ', [this.getSourceType()], updateData) } else { this.updateRationGLJByEdit(row, 'customQuantity', 0); //('ut_update',{'ID': row.ID, 'projectID': row.projectID},{'quantity':0,'customQuantity':0}); } }; ration_glj.prototype.getUpdateData = function (type, query, doc, callfunction) { var updateData = []; var newobj = { 'updateType': type, 'query': query, } if (doc) { newobj['doc'] = doc; } if (callfunction) { newobj['updateFunction'] = callfunction; } updateData.push(newobj); return updateData; }; ration_glj.prototype.updateRationGLJByEdit = function (recode, updateField, newval, node) { var me = this; $.bootstrapLoading.start(); var callback = function (data) { let initShow = false;//是否需要表格初始化显示 if (updateField == 'customQuantity') { me.refreshAfterQuantityUpdate(data, node); } else { var doc = data.doc; for (var key in doc) { recode[key] = doc[key]; } if (data.hasOwnProperty('adjustState')) {//更新定额调整状态 me.updateRationAdjustState(data.adjustState, recode.rationID, node); } if (recode.subList && recode.subList.length > 0) { initShow = true; } if (node) {//如果不是在造价书页面直接编辑,则不用刷新 if (updateField == "type" && !(newval == gljType.MAIN_MATERIAL || newval == gljType.EQUIPMENT)) {//如果改变类型后不是主材或设备,则在造价书树中移除 projectObj.mainController.deleteNode(node, true); } } } if (initShow == false) {//不需要初始化,只需耍新当前显示就可以了 gljOprObj.showRationGLJSheetData(); } projectObj.project.projectGLJ.loadData(function () {//等项目工料机加载完成后再给用户编辑 me.refreshTreeNodeIfNeeded(recode);//刷新造价书上的树节点(如果需要) me.reCalcWhenGLJChange(recode);//触发计算定额以及父节点 if (initShow == true) { gljOprObj.refreshView(); } $.bootstrapLoading.end(); }); } var query = { 'ID': recode.ID, 'projectID': recode.projectID, 'rationID': recode.rationID }; var priceInfo = { base_price: recode.basePrice, market_price: recode.marketPrice } var doc = {}; doc[updateField] = newval; if (updateField == "type") { doc.shortName = projectObj.project.projectGLJ.getShortNameByID(newval); } CommonAjax.post("/rationGlj/updateRationGLJByEdit", { query: query, doc: doc, priceInfo: priceInfo }, callback, function (err) { $.bootstrapLoading.end(); }); } ration_glj.prototype.refreshAfterQuantityUpdate = function (data, node) { var me = this; data.glj_result.forEach(function (item) { me.refreshEachItme(item.doc, item.query); }) me.updateRationAdjustState(data.adjustState, data.rationID, node); }; ration_glj.prototype.updateRationAdjustState = function (adjustState, rationID, rnode) { var nodes = []; var node = _.find(projectObj.project.mainTree.items, function (n) { return n.sourceType == ModuleNames.ration && n.data.ID == rationID; }) if (node) { node.data.adjustState = adjustState; nodes.push(node); } if (rnode) { nodes.push(rnode); } projectObj.mainController.refreshTreeNode(nodes); }; ration_glj.prototype.getGLJData = function (cb) { CommonAjax.get('/rationGlj/getGLJData', function (data) { cb(data); }) }; ration_glj.prototype.insertGLJAsRation = function (GLJSelection, selected, callback) { let gljList = []; let allGLJ = gljOprObj.AllRecode; let billsItemID = null, serialNo = 0,selectedSerialNo = null,nextNodeID = null, parentNodeID = null, billNode = null; let children = []; if (selected.sourceType === project.Bills.getSourceType()) { billsItemID = selected.data.ID; parentNodeID = selected.getID(); nextNodeID = selected.tree.rootID(); billNode = selected; } else { billsItemID = selected.data.billsItemID; serialNo = selected.data.serialNo; selectedSerialNo = selected.data.serialNo; nextNodeID = selected.getNextSiblingID(); parentNodeID = selected.getParentID(); billNode = selected.parent; } 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, gljLibKeyArray); 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, materialType:glj.materialType, materialCoe:glj.materialCoe, repositoryId: glj.repositoryId }; if (glj.hasOwnProperty("compilationId")) { new_glj.from = "cpt"; if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改名称、规格、型号等保存到补充工料机库的 new_glj.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号 } } if(optionsOprObj.getOption(optionsOprObj.optionsTypes.GENERALOPTS, 'rationQuanACToBillsQuan')){//需要根据清单转换工程量 new_glj.quantityEXP="QDL"; if(billNode.data.quantity){ new_glj.quantity = scMathUtil.roundForObj(billNode.data.quantity/FilterNumberFromUnit(glj.unit),getDecimal("glj.quantity")); new_glj.contain = scMathUtil.roundForObj(new_glj.quantity/billNode.data.quantity,6); } } 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; CommonAjax.post("/ration/insertGLJAsRation", postData, function (data) { // 更新兄弟节点的序列号 if (selectedSerialNo != null) { let selectIndex = _.findIndex(children, {"serialNo": selectedSerialNo}); if (selectIndex + 1 < children.length) { for (let i = selectIndex + 1; i < children.length; i++) { children[i].serialNo += gljList.length; } } } callback(parentNodeID,nextNodeID,data); }, function () { $.bootstrapLoading.end(); }); }; ration_glj.prototype.addGLJByLib = function (GLJSelection, ration, callback) { var gljList = []; var allGLJ = gljOprObj.AllRecode; GLJSelection.sort(); _.forEach(GLJSelection, function (g) { var glj = _.find(allGLJ, function (item) { var i_key = gljOprObj.getIndex(item, gljLibKeyArray); return i_key == g; }); var ration_glj = { projectID: ration.projectID, GLJID: glj.ID, rationID: ration.ID, billsItemID: ration.billsItemID, rationItemQuantity: 0, quantity: 0, name: glj.name, code: glj.code, original_code: glj.code, unit: glj.unit, specs: glj.specs, basePrice: glj.basePrice, shortName: glj.shortName, type: glj.gljType, adjCoe: glj.adjCoe, createType: 'add', materialType:glj.materialType, materialCoe:glj.materialCoe, repositoryId: glj.repositoryId } if (glj.hasOwnProperty("compilationId")) { ration_glj.from = "cpt"; if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改名称、规格、型号等保存到补充工料机库的 ration_glj.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号 } } gljList.push(ration_glj); }); $.bootstrapLoading.start(); CommonAjax.post("/rationGlj/addGLJ", gljList, callback, function () { $.bootstrapLoading.end(); }); }; 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); return i_key == selectCode; }); if (selectCode == gljOprObj.getIndex(oldData, gljKeyArray)) { return callback(null); } if (oldData.createType != 'replace') { oldData.rcode = oldData.code; oldData.createType = 'replace'; } oldData.GLJID = glj.ID; oldData.name = glj.name; oldData.code = glj.code; oldData.original_code = glj.code; oldData.unit = glj.unit; oldData.specs = glj.specs; oldData.basePrice = glj.basePrice; oldData.repositoryId = glj.repositoryId; oldData.materialType = glj.materialType; oldData. materialCoe = glj.materialCoe; if (glj.hasOwnProperty("compilationId")) { oldData.from = "cpt"; if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改包称、规格、型号等保存到补充工料机库的 oldData.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号 } } else { oldData.from = "std"; } $.bootstrapLoading.start(); CommonAjax.post("/rationGlj/replaceGLJ", oldData, callback, function () { $.bootstrapLoading.end(); }); }; ration_glj.prototype.mReplaceGLJ = function (selectCode, oldData, callback) { var allGLJ = gljOprObj.AllRecode; var glj = _.find(allGLJ, function (item) { var i_key = gljOprObj.getIndex(item, gljLibKeyArray); return i_key == selectCode; }); if (selectCode == gljOprObj.getIndex(oldData, gljKeyArray)) { return callback(null); } var query = { projectID: oldData.projectID, code: oldData.code, name: oldData.name, unit: oldData.unit, type: oldData.type } if (oldData.specs && oldData.specs != '') { query.specs = oldData.specs; } var doc = { GLJID: glj.ID, createType: 'replace', rationItemQuantity: 0, name: glj.name, code: glj.code, original_code: glj.code, unit: glj.unit, specs: glj.specs, type: glj.gljType, basePrice: glj.basePrice, repositoryId: glj.repositoryId, materialType: glj.materialType, //三材类别 materialCoe: glj.materialCoe, projectID: oldData.projectID } if (oldData.createType == 'replace') { doc.rcode = oldData.rcode; } else { doc.rcode = oldData.code; } if (glj.hasOwnProperty("compilationId")) { doc.from = "cpt"; if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改包称、规格、型号等保存到补充工料机库的 doc.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号 } } else { doc.from = "std"; } $.bootstrapLoading.start(); CommonAjax.post("/rationGlj/mReplaceGLJ", {query: query, doc: doc}, callback, function () { $.bootstrapLoading.end(); }); }; ration_glj.prototype.getMainAndEquGLJ = function (rationID) { var gljList = _.filter(this.datas, function (n) { return n.rationID == rationID && (n.type == gljType.MAIN_MATERIAL || n.type == gljType.EQUIPMENT) }); gljList = sortRationGLJ(gljList); return gljOprObj.combineWithProjectGlj(gljList); }; ration_glj.prototype.transferToNodeData = function (data) { data.contain=scMathUtil.roundForObj(data.quantity,getDecimal('glj.quantity')); data.subType = data.type; data.marketUnitFee = data.marketPrice; }; 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}); if (glj) { if(projectObj.project.projectGLJ.isEstimateType(glj.type)){ ration.isEstimate = glj.is_evaluate; } ration = gljOprObj.setGLJPrice(ration,glj); ration.basePrice = glj.unit_price.base_price; ration.marketUnitFee = glj.unit_price.market_price; ration.isAdd = glj.unit_price.is_add; var connect_index = gljOprObj.getIndex(glj, gljKeyArray); if (mixRatioMap.hasOwnProperty(connect_index)) { var mixRatios = gljOprObj.getMixRationShowDatas(mixRatioMap[connect_index], projectGljs); ration.subList = mixRatios; } } } return ration; }; 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); if (newval) { fieldName = "marketPrice"; projectObj.project.projectGLJ.updatePriceFromRG(node.data, fieldName, newval); return; } } else { if(fieldName == "contain"){ if(value==null){ value=""; }else { var decimal = getDecimal("glj.quantity"); value = number_util.checkNumberValue(value, decimal); fieldName="customQuantity";//填入自定义消耗 } } if (value !== undefined && value !== null) { if (fieldName == "subType") { node.data.subType = value; fieldName = "type";//转换成更新工料机类型 } this.updateRationGLJByEdit(node.data, fieldName, value, node); return; } } } // node.data.subType = value; projectObj.mainController.refreshTreeNode([node]); }; ration_glj.prototype.refreshTreeNodeIfNeeded = function (data) { if (this.needShowToTree(data)) { this.transferToNodeData(data); gljOprObj.refreshTreeNode({"type": ModuleNames.ration_glj, "ID": data.ID}); } }; ration_glj.prototype.needShowToTree = function (data) { if ((data.type == gljType.MAIN_MATERIAL || data.type == gljType.EQUIPMENT) && projectInfoObj.projectInfo.property.displaySetting.disPlayMainMaterial == true) { return true } return false }; ration_glj.prototype.findGLJNodeByID = function (ID) { return projectObj.project.mainTree.findNode(ID); }; ration_glj.prototype.findRationNodeByID = function (ID) { return projectObj.project.mainTree.findNode(ID); }; ration_glj.prototype.reCalcWhenGLJChange = function (ration_glj) {//当改变定额工料机时,重新计算定额以及其父节点 let node = this.findRationNodeByID(ration_glj.rationID); if (node) { node.changed = true; project.calcProgram.calcAndSave(node); } }; return new ration_glj(project); } };