ration_glj.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. /**
  2. * Created by Mai on 2017/4/1.
  3. */
  4. var ration_glj = {
  5. createNew: function (project) {
  6. // 用户定义private方法
  7. var tools = {};
  8. // 所有通过this访问的属性,都不应在此单元外部进行写入操作
  9. var ration_glj = function (proj) {
  10. this.gljTree = cacheTree.createNew(this);
  11. // this.project = proj;
  12. this.datas = [];
  13. var sourceType = ModuleNames.ration_glj;
  14. this.getSourceType = function () {
  15. return sourceType;
  16. }
  17. proj.registerModule(ModuleNames.ration_glj, this);
  18. };
  19. // 从后台获取数据
  20. /*glj.prototype.pullData = function (){
  21. this.project.pullData(
  22. '/glj/getData',
  23. {projectID: this.project.ID},
  24. function(result){
  25. if (result.error ===0){
  26. this.loadDatas(result.data);
  27. }
  28. else {
  29. // to do: 错误处理需要细化
  30. alert(result.message);
  31. }
  32. },
  33. function (){}//to do: 错误处理需要细化
  34. )
  35. };*/
  36. // prototype用于定义public方法
  37. ration_glj.prototype.loadData = function (datas) {
  38. this.datas = datas;
  39. };
  40. ration_glj.prototype.getGljArrByRation = function (rationID) {
  41. let result = this.datas.filter(function (data) {
  42. return data.rationID === rationID;
  43. })
  44. result = gljOprObj.combineWithProjectGlj(result);
  45. return result;
  46. };
  47. ration_glj.prototype.getGatherGljArrByRations = function (rations) {
  48. let result = [];
  49. let clone = function (obj) {
  50. if (obj === null) return null;
  51. var o = Object.prototype.toString.apply(obj) === "[object Array]" ? [] : {};
  52. for (var i in obj) {
  53. o[i] = (obj[i] instanceof Date) ? new Date(obj[i].getTime()) : (typeof obj[i] === "object" ? clone(obj[i]) : obj[i]);
  54. }
  55. return o;
  56. }
  57. let findGlj = function (sourceGlj, gljArr) {
  58. for (let glj of gljArr) {
  59. if (glj.projectGLJID === sourceGlj.projectGLJID) {
  60. return glj;
  61. }
  62. }
  63. return null;
  64. }
  65. for (let ration of rations) {
  66. let rationGljs = this.getGljArrByRation(ration.ID);
  67. for (let glj of rationGljs) {
  68. let sameGlj = findGlj(glj, result);
  69. if (!sameGlj) {
  70. sameGlj = clone(glj);
  71. sameGlj.quantity = (sameGlj.quantity * ration.quantity).toDecimal(4);
  72. result.push(sameGlj);
  73. } else {
  74. sameGlj.quantity = sameGlj.quantity + (glj.quantity * ration.quantity).toDecimal(4);
  75. }
  76. }
  77. };
  78. result = gljOprObj.combineWithProjectGlj(result);
  79. return result;
  80. }
  81. // 提交数据后返回数据处理
  82. ration_glj.prototype.doAfterUpdate = function(err, data){
  83. var me = this;
  84. if(!err){
  85. if(data.updateTpye=='ut_update'){
  86. me.refreshAfterUpdate(data);
  87. }else if(data.updateTpye=='ut_delete'){
  88. me.refreshAfterDelete(data);
  89. } else {
  90. me.refreshAfterSave(data);
  91. }
  92. }
  93. projectObj.project.projectGLJ.loadData();
  94. };
  95. ration_glj.prototype.refreshAfterSave=function(data){
  96. let me = projectObj.project.ration_glj;
  97. let neRecodes=[];
  98. if(data){
  99. // neRecodes=data.newRecords;//原来是显示和缓存分开的,后来发现会导致数据不一致的问题所以改成统一的了,这里也只是会作为显示。
  100. neRecodes = data.showDatas;
  101. gljOprObj.sheetData=neRecodes;
  102. }
  103. if(me.datas&&Array.isArray(me.datas)){
  104. if(data){
  105. me.datas = me.datas.concat(neRecodes);
  106. }
  107. }else {
  108. me.datas = neRecodes;
  109. }
  110. gljOprObj.showRationGLJSheetData(true);
  111. //add to mainTree;
  112. me.addToMainTree(neRecodes);
  113. let node = project.mainTree.selected;
  114. project.calcProgram.calculate(node);
  115. project.calcProgram.saveNode(node);
  116. if (activeSubSheetIs(subSheetIndex.ssiCalcProgram)) {
  117. calcProgramObj.showData(node, false);
  118. };
  119. };
  120. ration_glj.prototype.addToMainTree = function (datas) {
  121. datas = sortRationGLJ(datas);
  122. for(let data of datas){
  123. if(this.needShowToTree(data)){
  124. this.transferToNodeData(data);
  125. let parentNode = _.find(projectObj.project.mainTree.items,function (n) {//找父节点
  126. return n.sourceType==ModuleNames.ration &&n.data.ID==data.rationID;
  127. });
  128. if(parentNode){
  129. let nextNodeID=null;
  130. if(parentNode.children.length>0){
  131. for(let br of parentNode.children){
  132. if(compareRationGLJ(data,br.data)){//如果有兄弟节点则找到添加位置。
  133. nextNodeID = br.getID();
  134. }
  135. }
  136. }
  137. nextNodeID = nextNodeID?nextNodeID:parentNode.tree.rootID();
  138. let newNode = projectObj.project.mainTree.insert(parentNode.getID(),nextNodeID);
  139. newNode.source = data;
  140. newNode.sourceType = this.getSourceType();
  141. newNode.data = data;
  142. ProjectController.syncDisplayNewRationGljNode(projectObj.mainController,newNode);
  143. }
  144. }
  145. }
  146. };
  147. ration_glj.prototype.refreshAfterUpdate=function(data){
  148. var me = this;
  149. if(data.quantityRefresh){
  150. data.glj_result.forEach(function (item) {
  151. me.refreshEachItme(item.doc,item.query);
  152. })
  153. }else {
  154. me.refreshEachItme(data.doc,data.query);
  155. }
  156. gljOprObj.showRationGLJSheetData(true);
  157. };
  158. ration_glj.prototype.refreshEachItme = function (doc,query) {
  159. var glj_list = projectObj.project.ration_glj.datas;
  160. var glj_index= _.findIndex(glj_list,(glj)=>{
  161. return glj.ID==query.ID;
  162. })
  163. var sheet_index= _.findIndex(gljOprObj.sheetData,(sd)=>{
  164. return sd.ID==query.ID;
  165. })
  166. _.forEach(doc, function(n, key) {
  167. glj_list[glj_index][key] = n;
  168. });
  169. return glj_list[glj_index].rationID;
  170. };
  171. ration_glj.prototype.refreshAfterDelete=function(data){
  172. var me = projectObj.project.ration_glj;
  173. var glj_list = me.datas;
  174. var oldData = _.remove(glj_list,data.query);
  175. _.remove(gljOprObj.sheetData,data.query);
  176. gljOprObj.showRationGLJSheetData();
  177. projectObj.project.projectGLJ.loadData();
  178. var rationNode = null;
  179. var next = null;
  180. var selected = projectObj.project.mainTree.selected;
  181. if(selected.sourceType==ModuleNames.ration){ //如果选中的是定额,说明是右键删除工料机操作,如果选中的是定额工料机,则说明是在造价书主界面中点击了删除按钮
  182. rationNode= selected;
  183. }else if(selected.sourceType==ModuleNames.ration_glj){
  184. rationNode = selected.parent;
  185. next = true;
  186. }
  187. rationNode.data.adjustState=data.adjustState;
  188. projectObj.mainController.refreshTreeNode([rationNode]);
  189. for(let o of oldData){
  190. if(this.needShowToTree(o)){
  191. let node = me.findTreeNodeByID(o.ID); //找到对应的树节点
  192. projectObj.mainController.deleteNode(node,next);
  193. }
  194. }
  195. };
  196. // CSL,2017.05.09
  197. ration_glj.prototype.modifyQuantity = function (data, newQuantity) {
  198. this.project.beginUpdate('modifyQuantity');
  199. data.quantity = newQuantity;
  200. data.customQuantity = newQuantity;
  201. data.updateType = 'ut_update';
  202. this.project.push(this.getSourceType, data);
  203. this.project.endUpdate();
  204. };
  205. ration_glj.prototype.modifyPrice = function (data, newPrice) {
  206. this.project.beginUpdate('modifyPrice');
  207. data.price = newPrice;
  208. data.updateType = 'ut_update';
  209. this.project.push(this.getSourceType, data);
  210. this.project.endUpdate();
  211. };
  212. ration_glj.prototype.deleteGLJ = function (data) {
  213. this.project.beginUpdate('deleteGLJ');
  214. data.customQuantity = 0;
  215. data.quantity = 0;
  216. data.rationItemQuantity = 0;
  217. data.updateType = 'ut_update';
  218. this.project.push(this.getSourceType, data);
  219. this.project.endUpdate();
  220. };
  221. ration_glj.prototype.addRationGLJ = function (newRation,data) {
  222. var souceTypeList=[];
  223. var criteriaDataList = [];
  224. if(data.hasOwnProperty('rationGljList')&&data.rationGljList.length>0){
  225. let criteria= {};
  226. criteria.ration_glj_list = [];
  227. for(let i=0;i<data.rationGljList.length;i++){
  228. let temdata = data.rationGljList[i];
  229. let newGLJ = {};
  230. newGLJ.projectID = parseInt(newRation.projectID);
  231. newGLJ.GLJID = temdata.gljId;
  232. newGLJ.rationID = newRation.ID;
  233. newGLJ.billsItemID=newRation.billsItemID,
  234. newGLJ.rationItemQuantity= temdata.consumeAmt;
  235. newGLJ.quantity=temdata.consumeAmt;
  236. newGLJ.glj_repository_id=data.rationRepId;
  237. criteria.ration_glj_list.push(newGLJ);
  238. }
  239. criteria.updateType = 'ut_create';
  240. souceTypeList.push(this.getSourceType());
  241. criteriaDataList.push(criteria);
  242. }
  243. var ration_coe = projectObj.project.ration_coe;
  244. var rationCoeData = ration_coe.getRationCoedata(newRation,data);
  245. souceTypeList.push(ration_coe.getSourceType());
  246. criteriaDataList.push(rationCoeData);
  247. project.pushNow('addRationGLJAndRationCoe',souceTypeList,criteriaDataList);
  248. };
  249. ration_glj.prototype.getDeleteDataByRation=function(rationData){
  250. var updateData = [];
  251. updateData.push({'deleteType':'RATION','updateType': 'ut_delete', 'updateData': {'ID': rationData.ID, 'projectID': rationData.projectID}});
  252. return updateData;
  253. };
  254. ration_glj.prototype.getDeleteDataByBills=function(datas){
  255. var updateData = [];
  256. datas.forEach(function (deleteData) {
  257. if(deleteData.type=='delete'){
  258. var billData = deleteData.data;
  259. updateData.push({'deleteType':'BILL','updateType': 'ut_delete', 'updateData': {'ID': billData.ID, 'projectID': billData.projectID}});
  260. }
  261. })
  262. return updateData;
  263. };
  264. ration_glj.prototype.deleteByRation = function(ration){
  265. var glj_list = projectObj.project.ration_glj.datas;
  266. var newList =_.filter(glj_list,(glj)=>{
  267. return glj.rationID!=ration.ID;
  268. });
  269. if(newList!=undefined){
  270. projectObj.project.ration_glj.datas = newList;
  271. }
  272. };
  273. ration_glj.prototype.deleteByBills=function(deleteData){
  274. var rationList = projectObj.project.Ration.datas;
  275. var deleteRationList = [];
  276. for(var i=0;i<deleteData.length;i++){
  277. if(deleteData[i].type=='delete'){
  278. var billID = deleteData[i].data.ID;
  279. var raList =_.filter(rationList,(ration)=>{
  280. return ration.billsItemID==billID;
  281. });
  282. deleteRationList = deleteRationList.concat(raList);
  283. }
  284. }
  285. for(var i=0;i<deleteRationList.length;i++){
  286. this.deleteByRation(deleteRationList[i]);
  287. projectObj.project.ration_coe.deleteByRation(deleteRationList[i]);
  288. projectObj.project.quantity_detail.deleteByRation(deleteRationList[i]);
  289. projectObj.project.Ration.datas.splice(projectObj.project.Ration.datas.indexOf(deleteRationList[i]), 1);
  290. }
  291. }
  292. ration_glj.prototype.updataOrdelete=function(row){
  293. var updateData = null;
  294. if(row.rationItemQuantity==0){
  295. updateData=this.getUpdateData('ut_delete',{'ID': row.ID, 'projectID': row.projectID},{rationID:row.rationID});
  296. project.pushNow('updateRationGLJ',[this.getSourceType()],updateData)
  297. }else {
  298. this.customQuantityUpdate(row,0,0);//('ut_update',{'ID': row.ID, 'projectID': row.projectID},{'quantity':0,'customQuantity':0});
  299. }
  300. };
  301. ration_glj.prototype.getUpdateData=function(type,query,doc,callfunction){
  302. var updateData = [];
  303. var newobj = {
  304. 'updateType': type,
  305. 'query': query,
  306. }
  307. if(doc){
  308. newobj['doc']=doc;
  309. }
  310. if(callfunction){
  311. newobj['updateFunction']=callfunction;
  312. }
  313. updateData.push(newobj);
  314. return updateData;
  315. };
  316. ration_glj.prototype.updateRationGLJByEdit=function (recode,updateField,newval,node) {
  317. var me=this;
  318. $.bootstrapLoading.start();
  319. var callback=function (data) {
  320. let initShow = false;//是否需要表格初始化显示
  321. if(updateField=='customQuantity'){
  322. me.refreshAfterQuantityUpdate(data,node);
  323. }else {
  324. var doc = data.doc;
  325. for(var key in doc){
  326. recode[key] = doc[key];
  327. }
  328. if(data.hasOwnProperty('adjustState')){//更新定额调整状态
  329. me.updateRationAdjustState(data.adjustState,recode.rationID,node);
  330. }
  331. if(recode.subList&&recode.subList.length>0){
  332. initShow = true;
  333. }
  334. if(node){//如果不是在造价书页面直接编辑,则不用刷新
  335. if(updateField=="type"&&!(newval == gljType.MAIN_MATERIAL||newval==gljType.EQUIPMENT)){//如果改变类型后不是主材或设备,则在造价书树中移除
  336. projectObj.mainController.deleteNode(node,true);
  337. }else {
  338. me.refreshTreeNodeIfNeeded(recode);
  339. }
  340. }
  341. }
  342. if(initShow==false){//不需要初始化,只需耍新当前显示就可以了
  343. gljOprObj.showRationGLJSheetData();
  344. }
  345. projectObj.project.projectGLJ.loadData(function () {//等项目工料机加载完成后再给用户编辑
  346. if(initShow==true){
  347. gljOprObj.refreshView();
  348. }
  349. $.bootstrapLoading.end();
  350. });
  351. }
  352. var query = {
  353. 'ID':recode.ID,
  354. 'projectID': recode.projectID,
  355. 'rationID':recode.rationID
  356. };
  357. var priceInfo={
  358. base_price: recode.basePrice,
  359. market_price: recode.marketPrice
  360. }
  361. var doc = {};
  362. doc[updateField]=newval;
  363. if(updateField=="type"){
  364. doc.shortName = gljTypeMap[newval];
  365. }
  366. CommonAjax.post("/rationGlj/updateRationGLJByEdit",{query:query,doc:doc,priceInfo:priceInfo},callback,function (err) {
  367. $.bootstrapLoading.end();
  368. });
  369. }
  370. ration_glj.prototype.refreshAfterQuantityUpdate=function (data,node) {
  371. var me=this;
  372. data.glj_result.forEach(function (item) {
  373. me.refreshEachItme(item.doc,item.query);
  374. })
  375. me.updateRationAdjustState(data.adjustState,data.rationID,node);
  376. };
  377. ration_glj.prototype.updateRationAdjustState=function(adjustState,rationID,rnode){
  378. var nodes=[];
  379. var node = _.find(projectObj.project.mainTree.items,function (n) {
  380. return n.sourceType==ModuleNames.ration&&n.data.ID==rationID;
  381. })
  382. if(node){
  383. node.data.adjustState=adjustState;
  384. nodes.push(node);
  385. }
  386. if(rnode){
  387. nodes.push(rnode);
  388. }
  389. projectObj.mainController.refreshTreeNode(nodes);
  390. };
  391. ration_glj.prototype.getGLJData = function(cb){
  392. CommonAjax.get('/rationGlj/getGLJData', function (data) {
  393. cb(data);
  394. })
  395. };
  396. ration_glj.prototype.addGLJByLib=function (GLJSelection,ration,callback) {
  397. var gljList=[];
  398. var allGLJ=gljOprObj.AllRecode;
  399. GLJSelection.sort();
  400. _.forEach(GLJSelection,function (g) {
  401. var glj=_.find(allGLJ,function (item) {
  402. var i_key = gljOprObj.getIndex(item,['code','name','specs','unit','gljType']);
  403. return i_key ==g;
  404. });
  405. var ration_glj ={
  406. projectID:ration.projectID,
  407. GLJID:glj.ID,
  408. rationID:ration.ID,
  409. billsItemID:ration.billsItemID,
  410. rationItemQuantity:0,
  411. quantity:0,
  412. name:glj.name,
  413. code:glj.code,
  414. original_code:glj.code,
  415. unit:glj.unit,
  416. specs:glj.specs,
  417. basePrice:glj.basePrice,
  418. shortName:glj.shortName,
  419. type:glj.gljType,
  420. adjCoe:glj.adjCoe,
  421. createType:'add',
  422. repositoryId:glj.repositoryId
  423. }
  424. if(glj.hasOwnProperty("compilationId")){
  425. ration_glj.from="cpt";
  426. if(glj.code.indexOf('-')!=-1){//这条工料机是用户通过修改名称、规格、型号等保存到补充工料机库的
  427. ration_glj.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
  428. }
  429. }
  430. gljList.push(ration_glj);
  431. });
  432. $.bootstrapLoading.start();
  433. CommonAjax.post("/rationGlj/addGLJ",gljList,callback,function () {
  434. $.bootstrapLoading.end();
  435. });
  436. };
  437. ration_glj.prototype.replaceGLJ=function (selectCode,oldData,callback) {
  438. var allGLJ=gljOprObj.AllRecode;
  439. var glj=_.find(allGLJ,function (item) {
  440. var i_key = gljOprObj.getIndex(item,['code','name','specs','unit','gljType']);
  441. return i_key ==selectCode;
  442. });
  443. if(selectCode==gljOprObj.getIndex(oldData,['code','name','specs','unit','type'])){
  444. return callback(null);
  445. }
  446. if(oldData.createType!='replace'){
  447. oldData.rcode=oldData.code;
  448. oldData.createType='replace';
  449. }
  450. oldData.GLJID=glj.ID;
  451. oldData.rationItemQuantity=0;
  452. oldData.name=glj.name;
  453. oldData.code=glj.code;
  454. oldData.original_code=glj.code;
  455. oldData.unit=glj.unit;
  456. oldData.specs=glj.specs;
  457. oldData.basePrice=glj.basePrice;
  458. oldData.repositoryId=glj.repositoryId;
  459. if(glj.hasOwnProperty("compilationId")){
  460. oldData.from="cpt";
  461. if(glj.code.indexOf('-')!=-1){//这条工料机是用户通过修改包称、规格、型号等保存到补充工料机库的
  462. oldData.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
  463. }
  464. }else {
  465. oldData.from="std";
  466. }
  467. $.bootstrapLoading.start();
  468. CommonAjax.post("/rationGlj/replaceGLJ",oldData,callback,function () {
  469. $.bootstrapLoading.end();
  470. });
  471. };
  472. ration_glj.prototype.mReplaceGLJ=function (selectCode,oldData,callback) {
  473. var allGLJ=gljOprObj.AllRecode;
  474. var glj=_.find(allGLJ,function (item) {
  475. var i_key = gljOprObj.getIndex(item,['code','name','specs','unit','gljType']);
  476. return i_key ==selectCode;
  477. });
  478. if(selectCode== gljOprObj.getIndex(oldData,['code','name','specs','unit','type'])){
  479. return callback(null);
  480. }
  481. var query={
  482. projectID:oldData.projectID,
  483. code:oldData.code,
  484. name:oldData.name,
  485. unit:oldData.unit,
  486. type:oldData.type
  487. }
  488. if(oldData.specs&&oldData.specs!=''){
  489. query.specs=oldData.specs;
  490. }
  491. var doc={
  492. GLJID:glj.ID,
  493. createType:'replace',
  494. rationItemQuantity:0,
  495. name:glj.name,
  496. code:glj.code,
  497. original_code:glj.code,
  498. unit:glj.unit,
  499. specs:glj.specs,
  500. type:glj.gljType,
  501. basePrice:glj.basePrice,
  502. repositoryId:glj.repositoryId,
  503. projectID:oldData.projectID
  504. }
  505. if(oldData.createType=='replace'){
  506. doc.rcode=oldData.rcode;
  507. }else {
  508. doc.rcode=oldData.code;
  509. }
  510. if(glj.hasOwnProperty("compilationId")){
  511. doc.from="cpt";
  512. if(glj.code.indexOf('-')!=-1){//这条工料机是用户通过修改包称、规格、型号等保存到补充工料机库的
  513. doc.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
  514. }
  515. }else {
  516. doc.from="std";
  517. }
  518. $.bootstrapLoading.start();
  519. CommonAjax.post("/rationGlj/mReplaceGLJ",{query:query,doc:doc},callback,function () {
  520. $.bootstrapLoading.end();
  521. });
  522. };
  523. ration_glj.prototype.getMainAndEquGLJ = function (rationID) {
  524. var gljList = _.filter(this.datas,function (n) {
  525. return n.rationID == rationID&&(n.type==gljType.MAIN_MATERIAL||n.type==gljType.EQUIPMENT)
  526. });
  527. gljList = sortRationGLJ(gljList);
  528. return gljOprObj.combineWithProjectGlj(gljList);
  529. };
  530. ration_glj.prototype.transferToNodeData = function (data) {
  531. data.subType = data.type;
  532. data.marketUnitFee = data.marketPrice;
  533. };
  534. ration_glj.prototype.updateFromMainSpread=function (value,node,fieldName) {
  535. console.log(fieldName);
  536. console.log(value);
  537. if(node.data[fieldName]===value){
  538. return;
  539. }
  540. if(fieldName=="marketUnitFee"){
  541. var decimal =getDecimal("glj.unitPrice");
  542. var newval = number_util.checkNumberValue(value,decimal);
  543. if(newval){
  544. fieldName="marketPrice";
  545. projectObj.project.projectGLJ.updatePriceFromRG(node.data,fieldName,newval);
  546. return;
  547. }
  548. }else {
  549. if(value!==undefined&&value!==null){
  550. if(fieldName=="subType"){
  551. node.data.subType = value;
  552. fieldName = "type";//转换成更新工料机类型
  553. }
  554. this.updateRationGLJByEdit(node.data,fieldName,value,node);
  555. return;
  556. }
  557. }
  558. // node.data.subType = value;
  559. projectObj.mainController.refreshTreeNode([node]);
  560. };
  561. ration_glj.prototype.refreshTreeNodeIfNeeded=function (data) {
  562. if(this.needShowToTree(data)){
  563. this.transferToNodeData(data);
  564. gljOprObj.refreshTreeNode({"type":ModuleNames.ration_glj,"ID":data.ID});
  565. }
  566. };
  567. ration_glj.prototype.needShowToTree=function(data){
  568. if((data.type == gljType.MAIN_MATERIAL||data.type==gljType.EQUIPMENT)&&projectInfoObj.projectInfo.property.displaySetting.disPlayMainMaterial==true){
  569. return true
  570. }
  571. return false
  572. };
  573. ration_glj.prototype.findTreeNodeByID = function (ID) {
  574. let node = _.find(projectObj.project.mainTree.items,function (n) {//找到对应的树节点
  575. return n.sourceType==ModuleNames.ration_glj &&n.data.ID==ID;
  576. });
  577. return node;
  578. }
  579. return new ration_glj(project);
  580. }
  581. };