mbzm_view.js 25 KB

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