mbzm_view.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. /**
  2. * Created by zhang on 2018/11/26.
  3. */
  4. let mbzm_obj={
  5. spread:null,
  6. nodeChanged:false,
  7. datas:[],
  8. locateMap:{
  9. INMEASURE:1,
  10. INFBFX:2,
  11. AFTERRATION:3
  12. },
  13. setting:{
  14. header: [
  15. {headerName: "编码", headerWidth: 130, dataCode: "code", dataType: "String", formatter: "@"},
  16. {headerName: "模板类别", headerWidth: 260, dataCode: "name", dataType: "String", hAlign: "left"},
  17. {headerName: "系数", headerWidth: 65, dataCode: "coe", dataType: "Number",validator:"number"},
  18. {headerName: "单位", headerWidth: 45, dataCode: "unit", dataType: "String", hAlign: "center",getText:'forUnit'},
  19. {headerName: "工程量", headerWidth: 65, dataCode: "quantity", dataType: "Number",validator:"number"},
  20. {headerName: "关联类别", headerWidth: 100, dataCode: "type", dataType: "String"},
  21. {headerName: "清单位置", headerWidth: 200, dataCode: "position", hAlign: "left", dataType: "String",cellType:'selectButton',getText:'forPosition'},
  22. ],
  23. view: {
  24. lockColumns:["code","name","unit","type"],
  25. rowHeaderWidth:25
  26. },
  27. getText:{
  28. forPosition:function (item) {
  29. let createL = $('#createLocation').val();
  30. if(createL == mbzm_obj.locateMap.INMEASURE) return mbzm_obj.getDisplayText(item.billID,item.billsLocation);
  31. if(createL == mbzm_obj.locateMap.INFBFX) return mbzm_obj.getDisplayText(item.fxID,"");
  32. return ""
  33. },
  34. forUnit:function (item) {//这里显示的单位是去掉定额单位前面的数字的结果
  35. return item.unit &&_.isString(item.unit)?item.unit.replace(/^\d+/,""):""
  36. }
  37. }
  38. },
  39. getDisplayText:function (billID,position) {
  40. if(billID && billID!=''){
  41. let node = projectObj.project.mainTree.getNodeByID(billID);
  42. if(node){
  43. let code = node.data.code?node.data.code:"";
  44. let name = node.data.name?node.data.name:"";
  45. return code +" "+name;
  46. }
  47. }
  48. return position;
  49. },
  50. //当点击应用的时候才保存数据
  51. initSpread:function () {
  52. this.spread = SheetDataHelper.createNewSpread($("#mbzmSpread")[0]);
  53. sheetCommonObj.spreadDefaultStyle(this.spread);
  54. this.sheet = this.spread.getSheet(0);
  55. sheetCommonObj.initSheet(this.sheet, this.setting);
  56. this.sheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onSheetValueChange);
  57. this.spread.bind(GC.Spread.Sheets.Events.ButtonClicked, installationFeeObj.onPositionButtonClick);//共用一个位置选择器
  58. this.sheet.name('ration_template');
  59. },
  60. refresh:function () {
  61. let total = $('#mbzmSpread').parent().height();
  62. let b_height = $('#mbzmSpread').prev('.col-12').height();
  63. $('#mbzmSpread').css('height',total- b_height);
  64. this.spread?this.spread.refresh():this.initSpread();
  65. },
  66. refreshSheetData:function () {
  67. sheetCommonObj.showData(this.sheet, this.setting,this.datas);
  68. },
  69. showMBZMData:function(node){
  70. let selected = node?node:projectObj.project.mainTree.selected;
  71. if(this.nodeChanged == true){//选中的行改变了才做初始化,刷新当前缓存, 在project_view 中treeSelectedChanged方法里设置
  72. let datas = [];
  73. $("#createLocation").val(this.locateMap.INMEASURE);//初始化
  74. if(selected&&selected.sourceType == ModuleNames.ration){
  75. let ration = selected.data;
  76. let template = projectObj.project.ration_template.getTemplateByRationID(ration.ID);
  77. if(template) {
  78. $("#createLocation").val(template.createLocation);
  79. let pcol = _.findIndex(this.setting.header,{dataCode:"position"});
  80. this.setting.header[pcol].visible = template.createLocation == 3?false:true;
  81. datas = _.cloneDeep(template.templateList);
  82. }
  83. }
  84. this.datas = datas;
  85. this.nodeChanged = false;//这里要恢复成false 应为调用gljObj.refresh() 方法也会进到这里来,这时节点应是没有改变的
  86. }
  87. sheetCommonObj.showData(this.sheet, this.setting,this.datas);
  88. this.sheet.setRowCount(this.datas.length);
  89. },
  90. onSheetValueChange:function (e,info) {
  91. let me = mbzm_obj;
  92. let selected = projectObj.project.mainTree.selected;
  93. let row = info.row, col = info.col;
  94. let dataCode = me.setting.header[col].dataCode;
  95. let recode = me.datas[row], value = info.newValue;
  96. if (info.newValue === undefined) {
  97. return;
  98. }
  99. if (value && !sheetCommonObj.checkData(col, me.setting, value)) {
  100. alert('输入的数据类型不对,请重新输入!');
  101. me.refreshSheetData();
  102. return;
  103. }
  104. if (dataCode === 'coe') {//默认为0,可输入数值,输入数值后,后面的工程量=混凝土子目工程量*系数。
  105. let rationQuantity = selected.data.quantity;
  106. rationQuantity = rationQuantity?scMathUtil.roundForObj(rationQuantity, getDecimal('ration.quantity')):0;
  107. value = scMathUtil.roundForObj(value, getDecimal('process'));
  108. recode["quantity"] = scMathUtil.roundForObj(rationQuantity * value, getDecimal('ration.quantity'))+"";
  109. }
  110. if (dataCode === 'quantity') {//定额默认显示为0,可输入数值,输入数值后,则清空前面的系数列
  111. value = scMathUtil.roundForObj(value, getDecimal('ration.quantity'))+"";
  112. recode["coe"] = "0";
  113. }
  114. recode[dataCode] = value;
  115. me.refreshSheetData();
  116. },
  117. updatePosition:function (recode) {
  118. let selection = this.sheet.getSelections()[0];
  119. let selectedItem =this.datas[selection.row];
  120. let updateField = $("#createLocation").val()==this.locateMap.INMEASURE?"billID":"fxID";
  121. if(selectedItem[updateField] == recode.ID) return;
  122. selectedItem[updateField] = recode.ID;
  123. if($("#createLocation").val()==this.locateMap.INMEASURE)selectedItem.billsLocation = recode.code;
  124. this.refreshSheetData();
  125. },
  126. applyTemplate:function () {//应用清单模板
  127. let selected = projectObj.project.mainTree.selected;
  128. let template = projectObj.project.ration_template.getTemplateByRationID(selected.data.ID);
  129. let createLocation = $("#createLocation").val();
  130. let rations = {update:[],create:[]},bills={update:[],create:[]};
  131. if(this.datas.length <= 0) return;
  132. for(let d of this.datas){
  133. if(gljUtil.isDef(d.quantity)&& parseFloat(d.quantity)>0){
  134. if(this.positionChecking(createLocation,d) == false){//清单位置检查
  135. alert(`请选择${d.code}生成的清单位置`);
  136. return;
  137. }
  138. this.getNodeUpdateData(d,selected.data.ID,createLocation,rations,bills);
  139. }
  140. }
  141. let ration_template={type:ModuleNames.ration_template,data:{ID:template.ID, createLocation:createLocation, templateList:this.datas}};
  142. let data = {
  143. ration_template:ration_template,
  144. rations:rations,
  145. bills:bills
  146. };
  147. console.log(data);
  148. $.bootstrapLoading.start();
  149. CommonAjax.post('/ration/applyTemplate',data,function (result) {
  150. let refreshNodes = projectObj.project.updateNodesCache(result.updateDatas);//更新要update的前端缓存,并返回要刷新的树节点
  151. let nodeDatas = {ration:{add:[]}, bills:{add:[]}};
  152. if(result.rationResult){
  153. for(let rr of result.rationResult){
  154. nodeDatas.ration.add.push(rr.ration);//定额datas数据的push在addNodes里面做
  155. projectObj.project.Ration.addSubListOfRation(rr);//添加定额子项缓存
  156. }
  157. }
  158. //对于新插入的清单:
  159. if(result.billsResult.length > 0){
  160. nodeDatas.bills.add = result.billsResult;
  161. }
  162. let calRations = ProjectController.addNewNodes(nodeDatas);
  163. if(refreshNodes.length > 0){
  164. for(let r of refreshNodes){
  165. if(r.sourceType == ModuleNames.ration){
  166. calRations.push(r);
  167. if(r.data.quantityEXP =="MBGCL" ) projectObj.project.quantity_detail.cleanQuantityDetail(r,true);
  168. }
  169. }
  170. projectObj.mainController.refreshTreeNode(refreshNodes, false);
  171. }
  172. projectObj.project.projectGLJ.loadData(function () {
  173. $.bootstrapLoading.end();
  174. cbTools.refreshFormulaNodes();
  175. //更新计算程序模板,并进行重新计算
  176. projectObj.project.calcProgram.calcNodesAndSave(calRations,function () {
  177. installationFeeObj.calcInstallationFee();
  178. });
  179. });
  180. console.log(result);
  181. })
  182. },
  183. positionChecking(type,data){//这个要之后再测试一下
  184. let validate = true;
  185. if(type == mbzm_obj.locateMap.INMEASURE){
  186. if(!_.isEmpty(data.billID)){
  187. let node = projectObj.project.mainTree.getNodeByID(data.billID);
  188. if(!node) validate = false;//ID有值,但是找不到,说明清单已经被删除
  189. }else if(_.isEmpty(data.billsLocation)){
  190. validate = false
  191. }
  192. }else if(type == mbzm_obj.locateMap.INFBFX){
  193. if(_.isEmpty(data.fxID)) {
  194. validate = false;
  195. }else {
  196. let node = projectObj.project.mainTree.getNodeByID(data.fxID);
  197. if(!node) validate = false;//ID有值,但是找不到,说明分项已经被删除
  198. }
  199. }
  200. return validate
  201. },
  202. getNodeUpdateData:function(data,referenceRationID,type,rations,bills){
  203. let quantity = this.getQuantity(data);//工程量要经过转换
  204. let mainRation = projectObj.project.mainTree.getNodeByID(referenceRationID);
  205. let billsID="";
  206. //先检查要更新的定额是否已经存在
  207. let ration = this.getExistRation(data,referenceRationID,type);
  208. if(ration) {//如果存在,则比较清耗量、工程量表达式是否一致
  209. let tem = this.getRationData(ration,data,quantity);//取更新信息
  210. if(tem){//如果不一致,则需要更新
  211. rations.update.push(tem);
  212. }
  213. //在定额存在的情况下,不用往下执行了
  214. return;
  215. }
  216. //定额不存在的情况下
  217. if(type == mbzm_obj.locateMap.AFTERRATION) {//如果是生成在主定额后面的位置
  218. this.createNewRationAfterMain(data,mainRation,quantity,rations);
  219. }
  220. if(type == mbzm_obj.locateMap.INMEASURE){//生成在措施项目下
  221. this.createNewRationInMeasure(data,mainRation,quantity,rations,bills);
  222. }else {
  223. this.createNewRationInFBFX(data,mainRation,quantity,rations,bills);
  224. }
  225. },
  226. getRationData:function (ration,data,quantity) {
  227. let tem = {};
  228. if (ration.quantity + "" != quantity) tem.quantity = quantity;
  229. if (gljUtil.isDef(data.coe) && data.coe != "0"&&ration.quantityEXP != "MBGCL") {
  230. tem.isFromDetail = 0;
  231. tem.quantityEXP = "MBGCL";
  232. }
  233. if(!_.isEmpty(tem)) {
  234. tem.projectID = ration.projectID;
  235. tem.ID = ration.ID;
  236. return tem;
  237. }
  238. return null;
  239. },
  240. createNewRationAfterMain:function (data,mainRation,quantity,rations) {
  241. //生成新的定额
  242. let newID = uuid.v1();
  243. let serialNo = mainRation.data.serialNo+1;
  244. //如果已经有正要生成的定额,则取这个序号再加1
  245. if(rations.create.length > 0){
  246. serialNo = rations.create[rations.create.length -1].newData.serialNo + 1
  247. }
  248. let n_ration = this.createNewRationData(data,newID,mainRation.data.ID,mainRation.data.billsItemID,serialNo,quantity,mainRation.data.libID);
  249. rations.create.push(n_ration);
  250. //处理其它兄弟节点的序号
  251. let br = projectObj.project.Ration.getBillsSortRation();
  252. for(let i = mainRation.data.serialNo;i<br.length;i++){
  253. if(rations.update.length > 0){//如果update列表中有数据,要更新那里的序列号
  254. let u = _.find(rations.update,{'ID':br[i].ID});
  255. if(u){
  256. u.serialNo += 1;
  257. continue;
  258. }
  259. }
  260. rations.update.push({ID:br[i].ID,projectID:br[i].projectID,serialNo:br[i].serialNo+1})
  261. }
  262. },
  263. createNewRationInMeasure:function (data,mainRation,quantity,rations,bills) {
  264. let controller = projectObj.mainController;
  265. let billsID="";
  266. if(!_.isEmpty(data.billID)&&projectObj.project.mainTree.getNodeByID(data.billID)){
  267. billsID = data.billID;
  268. }else {//剩下的就是没找到的
  269. let rootNode = projectObj.project.Bills.getMeasureNode(controller);
  270. let leaveNodes = projectObj.mainController.tree.getLeavesNodes(rootNode.source);
  271. for(let n of leaveNodes){
  272. if (!(n.data.calcBase&&n.data.calcBase!="")&& n.data.code&&(n.data.code ==data.billsLocation||n.data.code.indexOf(data.billsLocation) != -1)){//没有使用基数计算的清单
  273. billsID = n.data.ID;
  274. break;
  275. }
  276. }
  277. if(billsID == ""){//还是没有找到的情况下,先查找是不是已经生成过了
  278. if(bills.create.length > 0){
  279. let t_b = _.find(bills.create,{"billsLocation":data.billsLocation});
  280. if(t_b) billsID = t_b.ID;
  281. }
  282. }
  283. if(billsID == ""){//也没有生成过的情况下,要自动生成清单
  284. let parentNode = projectObj.project.Bills.getAutoParentNode("措施费用");
  285. billsID = uuid.v1();
  286. let newBill = {
  287. ID:billsID,
  288. projectID: parseInt(projectObj.project.ID()),
  289. ParentID:parentNode.data.ID,
  290. NextSiblingID:-1,
  291. code:projectObj.project.Bills.newFormatCode(data.billsLocation),
  292. type:billType.BILL,
  293. billsLibId:projectInfoObj.projectInfo.engineeringInfo.bill_lib[0].id,//projectInfoObj.projectInfo.engineeringInfo.billsGuidance_lib
  294. billsLocation : data.billsLocation//这个是用来在后端查找清单信息
  295. };
  296. let existB = projectObj.project.Bills.sameStdCodeBillsData(data.billsLocation);//对于多单位的清单
  297. if (existB) {
  298. newBill.unit = existB.unit;
  299. }
  300. //将这个节点的上一节点的NextSiblingID设置为这个新清单
  301. //先看有没有刚生成的清单,有的话直接修改最后一个清单的NextSiblingID即可
  302. let lastIndex = this.getLastIndex(bills.create,"ParentID",parentNode.data.ID);
  303. if(bills.create.length > 0 && lastIndex!=-1){
  304. bills.create[lastIndex].NextSiblingID = newBill.ID;
  305. }else if(parentNode.children.length > 0){//如果新生的没有找到的话,查看父节点下是否有子节点
  306. let pre = parentNode.children[parentNode.children.length-1];
  307. bills.update.push({ projectID:newBill.projectID,ID:pre.data.ID, NextSiblingID:newBill.ID});
  308. }
  309. bills.create.push(newBill);
  310. }
  311. }
  312. //生成定额
  313. let newID = uuid.v1();
  314. let serialNo = 1;
  315. serialNo = this.checkAndGetSerialNo(serialNo,billsID,rations);
  316. //先查看刚生成的定额中有没有相同父清单,有的话取最后的一个序列号加1
  317. let n_ration = this.createNewRationData(data,newID,mainRation.data.ID,billsID,serialNo,quantity,mainRation.data.libID);
  318. rations.create.push(n_ration);
  319. },
  320. createNewRationInFBFX:function (data,mainRation,quantity,rations,bills) {
  321. let billsID = "";
  322. let parentNode = projectObj.project.mainTree.getNodeByID(data.fxID);
  323. //分部分项这里,如果没选择位置,或者选择后又删除了,是无法到这一步的,所以不用像生成在清单那里做很多检查
  324. if(!_.isEmpty(data.fxID)&&parentNode){
  325. billsID = data.fxID;
  326. }
  327. if(billsID !=""){
  328. //生成定额
  329. let newID = uuid.v1();
  330. let serialNo = 1;
  331. serialNo = this.checkAndGetSerialNo(serialNo,billsID,rations);
  332. let n_ration = this.createNewRationData(data,newID,mainRation.data.ID,billsID,serialNo,quantity,mainRation.data.libID,true);
  333. rations.create.push(n_ration);
  334. }
  335. },
  336. getLastIndex:function (arrays,key,value) {
  337. let index = -1;
  338. for (let i = 0;i<arrays.length;i++) {
  339. if(arrays[i][key] == value){
  340. index = i;
  341. }
  342. }
  343. return index;
  344. },
  345. checkAndGetSerialNo:function (sNo,billsID,rations) {
  346. let serialNo = sNo;
  347. //先查看刚生成的定额中有没有相同父清单,有的话取最后的一个序列号加1
  348. let last_ration = this.getLastBrotherNewRation(billsID,rations.create);
  349. if(last_ration){
  350. serialNo = last_ration.serialNo +1;
  351. }else {
  352. let parentBillsNode = projectObj.project.mainTree.getNodeByID(billsID);
  353. if(parentBillsNode && parentBillsNode.children.length > 0){//如果能找到则说明已经存在的清单
  354. serialNo = parentBillsNode.children[parentBillsNode.children.length - 1].data.serialNo + 1
  355. }
  356. }
  357. return serialNo
  358. },
  359. getLastBrotherNewRation:function(billsItemID,rations){
  360. let newData = null;
  361. for(let tem of rations){
  362. if(tem.newData.billsItemID == billsItemID) newData = tem.newData;
  363. }
  364. return newData;
  365. },
  366. createNewRationData:function (data,newID,referenceRationID,billsID,serialNo,quantity,libID,isFBFX) {
  367. let newData = projectObj.project.Ration.getTempRationData(newID,billsID,serialNo,rationType.ration);
  368. newData.referenceRationID = referenceRationID;
  369. newData.quantity = quantity;
  370. newData.quantityEXP = gljUtil.isDef(data.coe) && data.coe != "0"?"MBGCL":quantity+"";
  371. let temRation = this.getDefaultRationCreateData(newData,data.code,libID,isFBFX);
  372. return temRation;
  373. },
  374. getDefaultRationCreateData:function(newData,code,libID,isFBFX){
  375. let itemQuery = {userID: userID, rationRepId: libID, code: code};
  376. let needInstall = false;
  377. if(projectObj.project.isInstall()) {//如果是安装工程,要看需不需要生成安装增加费
  378. needInstall = isFBFX;//在分部分项插入的定额才需要定额安装增加费
  379. }
  380. return{itemQuery:itemQuery,newData:newData,defaultLibID: rationLibObj.getDefaultStdRationLibID(),calQuantity:false,brUpdate:[],needInstall:needInstall}
  381. },
  382. getQuantity:function (data) {//取最新的消耗量,需经过转换
  383. if(data.unit){
  384. let times = parseInt(data.unit);
  385. if(!isNaN(times)){
  386. return scMathUtil.roundForObj(parseFloat(data.quantity)/times,getDecimal("ration.quantity"))+""
  387. }
  388. }
  389. return data.quantity
  390. },
  391. getExistRation:function (data,referenceRationID,type) {
  392. let temRation = null;
  393. //先检查要更新的定额是否已经存在
  394. let rations =_.filter(projectObj.project.Ration.datas,{'referenceRationID':referenceRationID,'code':data.code});
  395. for(let r of rations){
  396. if(type == mbzm_obj.locateMap.AFTERRATION){//如果是生成在主定额后面的位置
  397. let mainRationNode = projectObj.project.mainTree.getNodeByID(referenceRationID);
  398. if(r.billsItemID == mainRationNode.data.billsItemID){//如果清单ID相同, 说明是兄弟节点,位置相同
  399. temRation = r;
  400. break;
  401. }
  402. }
  403. let billsNode = projectObj.project.mainTree.getNodeByID(r.billsItemID);
  404. if(billsNode){//将父清单与要生成的清单比较,看是否一致
  405. if(type == mbzm_obj.locateMap.INMEASURE && billsNode.data.type ==billType.BILL){
  406. if(!_.isEmpty(data.billID)){
  407. //说明生成位置已经有定额了,只需更新消耗量就好
  408. if(data.billID == r.billsItemID){
  409. temRation = r;
  410. break;
  411. }
  412. }else if(!_.isEmpty(data.billsLocation)){//按清单编号到找对应的位置
  413. if(billsNode.data.code && billsNode.data.code.indexOf(data.billsLocation)!=-1) {
  414. temRation = r;
  415. break;
  416. }
  417. }
  418. }else if(type == mbzm_obj.locateMap.INFBFX && (billsNode.data.type ==billType.FX||billsNode.data.type ==billType.BX)){
  419. if(!_.isEmpty(data.fxID) && data.fxID == r.billsItemID){//分项、补项下有对应的定额
  420. temRation = r;
  421. break;
  422. }
  423. }
  424. }
  425. }
  426. return temRation;
  427. },
  428. hasReferenceRation:function (node) {
  429. if(node.sourceType == ModuleNames.ration){
  430. let template = projectObj.project.ration_template.getTemplateByRationID(node.data.ID);
  431. if(template){
  432. let ration = _.find(projectObj.project.Ration.datas,{'referenceRationID':node.data.ID});
  433. if(ration) return true;
  434. }
  435. }
  436. return false;
  437. },
  438. deleteReferenceRation:function (mainNodes,updateNodes) {
  439. let refNode = [];
  440. for(let m of mainNodes){
  441. if(this.hasReferenceRation(m)){
  442. let rations = _.filter(projectObj.project.Ration.datas,{'referenceRationID':m.data.ID});
  443. for(let r of rations){
  444. let temNode = projectObj.project.mainTree.getNodeByID(r.ID);
  445. if(temNode && updateNodes.indexOf(temNode) == -1){//能找到该节点,并且节点不在已经删除的列表中
  446. refNode.push(temNode);
  447. updateNodes.push(temNode);
  448. projectObj.mainController.tree.getAllSubNode(temNode,updateNodes)//添加显示到造价书页面的主材、设备节点
  449. }
  450. }
  451. }
  452. }
  453. return refNode;
  454. }
  455. };
  456. $('#createLocation').change(function(){
  457. let me = mbzm_obj;
  458. let pcol = _.findIndex(me.setting.header,{dataCode:"position"});
  459. me.setting.header[pcol].visible = $(this).val() == mbzm_obj.locateMap.AFTERRATION?false:true;
  460. me.refreshSheetData();
  461. });
  462. $('#next_mbzm').click(function () {
  463. let mainSheet = projectObj.mainSpread.getActiveSheet();
  464. let selection = mainSheet.getSelections()[0];
  465. let node = projectObj.project.mainTree.selected;
  466. let index = node.serialNo();
  467. let next = null;
  468. for(let i = index+1;i< projectObj.project.mainTree.items.length;i++){
  469. let temNode = projectObj.project.mainTree.items[i];
  470. if(temNode && temNode.sourceType == ModuleNames.ration){
  471. let template = projectObj.project.ration_template.getTemplateByRationID(temNode.data.ID);
  472. if(template) {
  473. next = temNode;
  474. break;
  475. }
  476. }
  477. }
  478. if(next){
  479. let row = next.serialNo();
  480. let col = selection.col?selection.col:0;
  481. mainSheet.setSelection(row, col, selection.rowCount, selection.colCount);
  482. projectObj.mainController.setTreeSelected(next);
  483. mainSheet.showRow(row, GC.Spread.Sheets.VerticalPosition.center);
  484. }
  485. });
  486. $('#apply_mbzm').click(function () {
  487. mbzm_obj.applyTemplate();
  488. });