mbzm_view.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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 subNodes=[];
  289. //默认没有找到编码匹配的就挂在技术措施项目下
  290. let parentNode = projectObj.project.Bills.getAutoParentNode("措施费用");
  291. if(data.billsLocation.length >= 6){
  292. projectObj.mainController.tree.getAllSubNode(rootNode,subNodes);
  293. let tem_code = data.billsLocation.substr(0,6);
  294. let n_parentNode = _.find(subNodes,function (n) {
  295. return n.data.code == tem_code;
  296. });
  297. if(n_parentNode) parentNode = n_parentNode;
  298. }
  299. billsID = uuid.v1();
  300. let newBill = {
  301. ID:billsID,
  302. projectID: parseInt(projectObj.project.ID()),
  303. ParentID:parentNode.data.ID,
  304. NextSiblingID:-1,
  305. code:projectObj.project.Bills.newFormatCode(data.billsLocation),
  306. type:billType.BILL,
  307. billsLibId:projectInfoObj.projectInfo.engineeringInfo.bill_lib[0].id,//projectInfoObj.projectInfo.engineeringInfo.billsGuidance_lib
  308. billsLocation : data.billsLocation//这个是用来在后端查找清单信息
  309. };
  310. let existB = projectObj.project.Bills.sameStdCodeBillsData(data.billsLocation);//对于多单位的清单
  311. if (existB) {
  312. newBill.unit = existB.unit;
  313. }
  314. //将这个节点的上一节点的NextSiblingID设置为这个新清单
  315. //先看有没有刚生成的清单,有的话直接修改最后一个清单的NextSiblingID即可
  316. let lastIndex = this.getLastIndex(bills.create,"ParentID",parentNode.data.ID);
  317. if(bills.create.length > 0 && lastIndex!=-1){
  318. bills.create[lastIndex].NextSiblingID = newBill.ID;
  319. }else if(parentNode.children.length > 0){//如果新生的没有找到的话,查看父节点下是否有子节点
  320. let pre = parentNode.children[parentNode.children.length-1];
  321. bills.update.push({ projectID:newBill.projectID,ID:pre.data.ID, NextSiblingID:newBill.ID});
  322. }
  323. bills.create.push(newBill);
  324. }
  325. }
  326. //生成定额
  327. let newID = uuid.v1();
  328. let serialNo = 1;
  329. serialNo = this.checkAndGetSerialNo(serialNo,billsID,rations);
  330. //先查看刚生成的定额中有没有相同父清单,有的话取最后的一个序列号加1
  331. let n_ration = this.createNewRationData(data,newID,mainRation.data.ID,billsID,serialNo,quantity,mainRation.data.libID);
  332. rations.create.push(n_ration);
  333. },
  334. createNewRationInFBFX:function (data,mainRation,quantity,rations,bills) {
  335. let billsID = "";
  336. let parentNode = projectObj.project.mainTree.getNodeByID(data.fxID);
  337. //分部分项这里,如果没选择位置,或者选择后又删除了,是无法到这一步的,所以不用像生成在清单那里做很多检查
  338. if(!_.isEmpty(data.fxID)&&parentNode){
  339. billsID = data.fxID;
  340. }
  341. if(billsID !=""){
  342. //生成定额
  343. let newID = uuid.v1();
  344. let serialNo = 1;
  345. serialNo = this.checkAndGetSerialNo(serialNo,billsID,rations);
  346. let n_ration = this.createNewRationData(data,newID,mainRation.data.ID,billsID,serialNo,quantity,mainRation.data.libID,true);
  347. rations.create.push(n_ration);
  348. }
  349. },
  350. getLastIndex:function (arrays,key,value) {
  351. let index = -1;
  352. for (let i = 0;i<arrays.length;i++) {
  353. if(arrays[i][key] == value){
  354. index = i;
  355. }
  356. }
  357. return index;
  358. },
  359. checkAndGetSerialNo:function (sNo,billsID,rations) {
  360. let serialNo = sNo;
  361. //先查看刚生成的定额中有没有相同父清单,有的话取最后的一个序列号加1
  362. let last_ration = this.getLastBrotherNewRation(billsID,rations.create);
  363. if(last_ration){
  364. serialNo = last_ration.serialNo +1;
  365. }else {
  366. let parentBillsNode = projectObj.project.mainTree.getNodeByID(billsID);
  367. if(parentBillsNode && parentBillsNode.children.length > 0){//如果能找到则说明已经存在的清单
  368. serialNo = parentBillsNode.children[parentBillsNode.children.length - 1].data.serialNo + 1
  369. }
  370. }
  371. return serialNo
  372. },
  373. getLastBrotherNewRation:function(billsItemID,rations){
  374. let newData = null;
  375. for(let tem of rations){
  376. if(tem.newData.billsItemID == billsItemID) newData = tem.newData;
  377. }
  378. return newData;
  379. },
  380. createNewRationData:function (data,newID,referenceRationID,billsID,serialNo,quantity,libID,isFBFX) {
  381. let newData = projectObj.project.Ration.getTempRationData(newID,billsID,serialNo,rationType.ration);
  382. newData.referenceRationID = referenceRationID;
  383. newData.quantity = quantity;
  384. newData.quantityEXP = gljUtil.isDef(data.coe) && data.coe != "0"?"MBGCL":quantity+"";
  385. let temRation = this.getDefaultRationCreateData(newData,data.code,libID,isFBFX);
  386. return temRation;
  387. },
  388. getDefaultRationCreateData:function(newData,code,libID,isFBFX){
  389. let itemQuery = {userID: userID, rationRepId: libID, code: code};
  390. let needInstall = false;
  391. if(projectObj.project.isInstall()) {//如果是安装工程,要看需不需要生成安装增加费
  392. needInstall = isFBFX;//在分部分项插入的定额才需要定额安装增加费
  393. }
  394. return{itemQuery:itemQuery,newData:newData,defaultLibID: rationLibObj.getDefaultStdRationLibID(),calQuantity:false,brUpdate:[],needInstall:needInstall}
  395. },
  396. getQuantity:function (data) {//取最新的消耗量,需经过转换
  397. if(data.unit){
  398. let times = parseInt(data.unit);
  399. if(!isNaN(times)){
  400. return scMathUtil.roundForObj(parseFloat(data.quantity)/times,getDecimal("ration.quantity"))+""
  401. }
  402. }
  403. return data.quantity
  404. },
  405. getExistRation:function (data,referenceRationID,type) {
  406. let temRation = null;
  407. //先检查要更新的定额是否已经存在
  408. let rations =_.filter(projectObj.project.Ration.datas,{'referenceRationID':referenceRationID,'code':data.code});
  409. for(let r of rations){
  410. if(type == mbzm_obj.locateMap.AFTERRATION){//如果是生成在主定额后面的位置
  411. let mainRationNode = projectObj.project.mainTree.getNodeByID(referenceRationID);
  412. if(r.billsItemID == mainRationNode.data.billsItemID){//如果清单ID相同, 说明是兄弟节点,位置相同
  413. temRation = r;
  414. break;
  415. }
  416. }
  417. let billsNode = projectObj.project.mainTree.getNodeByID(r.billsItemID);
  418. if(billsNode){//将父清单与要生成的清单比较,看是否一致
  419. if(type == mbzm_obj.locateMap.INMEASURE && billsNode.data.type ==billType.BILL){
  420. if(!_.isEmpty(data.billID)){
  421. //说明生成位置已经有定额了,只需更新消耗量就好
  422. if(data.billID == r.billsItemID){
  423. temRation = r;
  424. break;
  425. }
  426. }else if(!_.isEmpty(data.billsLocation)){//按清单编号到找对应的位置
  427. if(billsNode.data.code && billsNode.data.code.indexOf(data.billsLocation)!=-1) {
  428. temRation = r;
  429. break;
  430. }
  431. }
  432. }else if(type == mbzm_obj.locateMap.INFBFX && (billsNode.data.type ==billType.FX||billsNode.data.type ==billType.BX)){
  433. if(!_.isEmpty(data.fxID) && data.fxID == r.billsItemID){//分项、补项下有对应的定额
  434. temRation = r;
  435. break;
  436. }
  437. }
  438. }
  439. }
  440. return temRation;
  441. },
  442. hasReferenceRation:function (node) {
  443. if(node.sourceType == ModuleNames.ration){
  444. let template = projectObj.project.ration_template.getTemplateByRationID(node.data.ID);
  445. if(template){
  446. let ration = _.find(projectObj.project.Ration.datas,{'referenceRationID':node.data.ID});
  447. if(ration) return true;
  448. }
  449. }
  450. return false;
  451. },
  452. deleteReferenceRation:function (mainNodes,updateNodes) {
  453. let refNode = [];
  454. for(let m of mainNodes){
  455. if(this.hasReferenceRation(m)){
  456. let rations = _.filter(projectObj.project.Ration.datas,{'referenceRationID':m.data.ID});
  457. for(let r of rations){
  458. let temNode = projectObj.project.mainTree.getNodeByID(r.ID);
  459. if(temNode && updateNodes.indexOf(temNode) == -1){//能找到该节点,并且节点不在已经删除的列表中
  460. refNode.push(temNode);
  461. updateNodes.push(temNode);
  462. projectObj.mainController.tree.getAllSubNode(temNode,updateNodes)//添加显示到造价书页面的主材、设备节点
  463. }
  464. }
  465. }
  466. }
  467. return refNode;
  468. }
  469. };
  470. $('#createLocation').change(function(){
  471. let me = mbzm_obj;
  472. let pcol = _.findIndex(me.setting.header,{dataCode:"position"});
  473. me.setting.header[pcol].visible = $(this).val() == mbzm_obj.locateMap.AFTERRATION?false:true;
  474. me.refreshSheetData();
  475. });
  476. $('#next_mbzm').click(function () {
  477. if (projectReadOnly) {
  478. return;
  479. }
  480. let mainSheet = projectObj.mainSpread.getActiveSheet();
  481. let selection = mainSheet.getSelections()[0];
  482. let node = projectObj.project.mainTree.selected;
  483. let index = node.serialNo();
  484. let next = null;
  485. for(let i = index+1;i< projectObj.project.mainTree.items.length;i++){
  486. let temNode = projectObj.project.mainTree.items[i];
  487. if(temNode && temNode.sourceType == ModuleNames.ration){
  488. let template = projectObj.project.ration_template.getTemplateByRationID(temNode.data.ID);
  489. if(template) {
  490. next = temNode;
  491. break;
  492. }
  493. }
  494. }
  495. if(next){
  496. let row = next.serialNo();
  497. let col = selection.col?selection.col:0;
  498. mainSheet.setSelection(row, col, selection.rowCount, selection.colCount);
  499. projectObj.mainController.setTreeSelected(next);
  500. mainSheet.showRow(row, GC.Spread.Sheets.VerticalPosition.center);
  501. }
  502. });
  503. $('#apply_mbzm').click(function () {
  504. if(projectReadOnly) return;
  505. mbzm_obj.applyTemplate();
  506. });