mbzm_view.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  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. sheetCommonObj.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,false);//添加定额子项缓存
  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.calcQuantity();
  176. $.bootstrapLoading.end();
  177. cbTools.refreshFormulaNodes();
  178. //更新计算程序模板,并进行重新计算
  179. projectObj.project.calcProgram.calcNodesAndSave(calRations,function () {
  180. installationFeeObj.calcInstallationFee();
  181. });
  182. mbzm_obj.showApplySuccess();
  183. })
  184. },
  185. showApplySuccess:function () {
  186. $(".applySuccess").show();
  187. setTimeout(function () {
  188. $(".applySuccess").hide();
  189. },1500)
  190. },
  191. positionChecking(type,data){//这个要之后再测试一下
  192. let validate = true;
  193. if(type == mbzm_obj.locateMap.INMEASURE){
  194. if(!_.isEmpty(data.billID)){
  195. let node = projectObj.project.mainTree.getNodeByID(data.billID);
  196. if(!node) validate = false;//ID有值,但是找不到,说明清单已经被删除
  197. }else if(_.isEmpty(data.billsLocation)){
  198. validate = false
  199. }
  200. }else if(type == mbzm_obj.locateMap.INFBFX){
  201. if(_.isEmpty(data.fxID)) {
  202. validate = false;
  203. }else {
  204. let node = projectObj.project.mainTree.getNodeByID(data.fxID);
  205. if(!node) validate = false;//ID有值,但是找不到,说明分项已经被删除
  206. }
  207. }
  208. return validate
  209. },
  210. getNodeUpdateData:function(data,referenceRationID,type,rations,bills){
  211. let quantity = this.getQuantity(data);//工程量要经过转换
  212. let mainRation = projectObj.project.mainTree.getNodeByID(referenceRationID);
  213. let billsID="";
  214. //先检查要更新的定额是否已经存在
  215. let ration = this.getExistRation(data,referenceRationID,type);
  216. if(ration) {//如果存在,则比较清耗量、工程量表达式是否一致
  217. let tem = this.getRationData(ration,data,quantity);//取更新信息
  218. if(tem){//如果不一致,则需要更新
  219. rations.update.push(tem);
  220. }
  221. //在定额存在的情况下,不用往下执行了
  222. return;
  223. }
  224. //定额不存在的情况下
  225. if(type == mbzm_obj.locateMap.AFTERRATION) {//如果是生成在主定额后面的位置
  226. this.createNewRationAfterMain(data,mainRation,quantity,rations);
  227. }
  228. if(type == mbzm_obj.locateMap.INMEASURE){//生成在措施项目下
  229. this.createNewRationInMeasure(data,mainRation,quantity,rations,bills);
  230. }else {
  231. this.createNewRationInFBFX(data,mainRation,quantity,rations,bills);
  232. }
  233. },
  234. getRationData:function (ration,data,quantity) {
  235. let tem = {};
  236. if (ration.quantity + "" != quantity) tem.quantity = quantity;
  237. if (gljUtil.isDef(data.coe) && data.coe != "0"&&ration.quantityEXP != "MBGCL") {
  238. tem.isFromDetail = 0;
  239. tem.quantityEXP = "MBGCL";
  240. }
  241. if(!_.isEmpty(tem)) {
  242. tem.projectID = ration.projectID;
  243. tem.ID = ration.ID;
  244. return tem;
  245. }
  246. return null;
  247. },
  248. createNewRationAfterMain:function (data,mainRation,quantity,rations) {
  249. //生成新的定额
  250. let newID = uuid.v1();
  251. let serialNo = mainRation.data.serialNo+1;
  252. //如果已经有正要生成的定额,则取这个序号再加1
  253. if(rations.create.length > 0){
  254. serialNo = rations.create[rations.create.length -1].newData.serialNo + 1
  255. }
  256. let n_ration = this.createNewRationData(data,newID,mainRation.data.ID,mainRation.data.billsItemID,serialNo,quantity,mainRation.data.libID);
  257. rations.create.push(n_ration);
  258. //处理其它兄弟节点的序号
  259. let br = projectObj.project.Ration.getBillsSortRation();
  260. for(let i = mainRation.data.serialNo;i<br.length;i++){
  261. if(rations.update.length > 0){//如果update列表中有数据,要更新那里的序列号
  262. let u = _.find(rations.update,{'ID':br[i].ID});
  263. if(u){
  264. u.serialNo += 1;
  265. continue;
  266. }
  267. }
  268. rations.update.push({ID:br[i].ID,projectID:br[i].projectID,serialNo:br[i].serialNo+1})
  269. }
  270. },
  271. createNewRationInMeasure:function (data,mainRation,quantity,rations,bills) {
  272. let controller = projectObj.mainController;
  273. let billsID="";
  274. if(!_.isEmpty(data.billID)&&projectObj.project.mainTree.getNodeByID(data.billID)){
  275. billsID = data.billID;
  276. }else {//剩下的就是没找到的
  277. let rootNode = projectObj.project.Bills.getMeasureNode(controller);
  278. let leaveNodes = projectObj.mainController.tree.getLeavesNodes(rootNode.source);
  279. for(let n of leaveNodes){
  280. if (!(n.data.calcBase&&n.data.calcBase!="")&& n.data.code&&(n.data.code ==data.billsLocation||n.data.code.indexOf(data.billsLocation) != -1)){//没有使用基数计算的清单
  281. billsID = n.data.ID;
  282. break;
  283. }
  284. }
  285. if(billsID == ""){//还是没有找到的情况下,先查找是不是已经生成过了
  286. if(bills.create.length > 0){
  287. let t_b = _.find(bills.create,{"billsLocation":data.billsLocation});
  288. if(t_b) billsID = t_b.ID;
  289. }
  290. }
  291. if(billsID == ""){//也没有生成过的情况下,要自动生成清单
  292. //2018-12-19 对于新生成的清单,根据新清单编码的前6位去查询有没有完全匹配的清单,有的话将这一节点做为新清单的父项清单
  293. let subNodes=[];
  294. //默认没有找到编码匹配的就挂在技术措施项目下
  295. let parentNode = projectObj.project.Bills.getAutoParentNode("措施费用");
  296. if(data.billsLocation.length >= 6){
  297. projectObj.mainController.tree.getAllSubNode(rootNode,subNodes);
  298. let tem_code = data.billsLocation.substr(0,6);
  299. let n_parentNode = _.find(subNodes,function (n) {
  300. return n.data.code == tem_code;
  301. });
  302. if(n_parentNode) parentNode = n_parentNode;
  303. }
  304. billsID = uuid.v1();
  305. let newBill = {
  306. ID:billsID,
  307. projectID: parseInt(projectObj.project.ID()),
  308. ParentID:parentNode.data.ID,
  309. NextSiblingID:-1,
  310. code:projectObj.project.Bills.newFormatCode(data.billsLocation),
  311. type:billType.BILL,
  312. billsLibId:projectObj.project.projectInfo.engineeringInfo.bill_lib[0].id,//projectObj.project.projectInfo.engineeringInfo.billsGuidance_lib
  313. billsLocation : data.billsLocation//这个是用来在后端查找清单信息
  314. };
  315. let existB = projectObj.project.Bills.sameStdCodeBillsData(data.billsLocation);//对于多单位的清单
  316. if (existB) {
  317. newBill.unit = existB.unit;
  318. }
  319. //将这个节点的上一节点的NextSiblingID设置为这个新清单
  320. //先看有没有刚生成的清单,有的话直接修改最后一个清单的NextSiblingID即可
  321. let lastIndex = this.getLastIndex(bills.create,"ParentID",parentNode.data.ID);
  322. if(bills.create.length > 0 && lastIndex!=-1){
  323. bills.create[lastIndex].NextSiblingID = newBill.ID;
  324. }else if(parentNode.children.length > 0){//如果新生的没有找到的话,查看父节点下是否有子节点
  325. let pre = parentNode.children[parentNode.children.length-1];
  326. bills.update.push({ projectID:newBill.projectID,ID:pre.data.ID, NextSiblingID:newBill.ID});
  327. }
  328. bills.create.push(newBill);
  329. }
  330. }
  331. //生成定额
  332. let newID = uuid.v1();
  333. let serialNo = 1;
  334. serialNo = this.checkAndGetSerialNo(serialNo,billsID,rations);
  335. //先查看刚生成的定额中有没有相同父清单,有的话取最后的一个序列号加1
  336. let n_ration = this.createNewRationData(data,newID,mainRation.data.ID,billsID,serialNo,quantity,mainRation.data.libID);
  337. rations.create.push(n_ration);
  338. },
  339. createNewRationInFBFX:function (data,mainRation,quantity,rations,bills) {
  340. let billsID = "";
  341. let parentNode = projectObj.project.mainTree.getNodeByID(data.fxID);
  342. //分部分项这里,如果没选择位置,或者选择后又删除了,是无法到这一步的,所以不用像生成在清单那里做很多检查
  343. if(!_.isEmpty(data.fxID)&&parentNode){
  344. billsID = data.fxID;
  345. }
  346. if(billsID !=""){
  347. //生成定额
  348. let newID = uuid.v1();
  349. let serialNo = 1;
  350. serialNo = this.checkAndGetSerialNo(serialNo,billsID,rations);
  351. let n_ration = this.createNewRationData(data,newID,mainRation.data.ID,billsID,serialNo,quantity,mainRation.data.libID,true);
  352. rations.create.push(n_ration);
  353. }
  354. },
  355. getLastIndex:function (arrays,key,value) {
  356. let index = -1;
  357. for (let i = 0;i<arrays.length;i++) {
  358. if(arrays[i][key] == value){
  359. index = i;
  360. }
  361. }
  362. return index;
  363. },
  364. checkAndGetSerialNo:function (sNo,billsID,rations) {
  365. let serialNo = sNo;
  366. //先查看刚生成的定额中有没有相同父清单,有的话取最后的一个序列号加1
  367. let last_ration = this.getLastBrotherNewRation(billsID,rations.create);
  368. if(last_ration){
  369. serialNo = last_ration.serialNo +1;
  370. }else {
  371. let parentBillsNode = projectObj.project.mainTree.getNodeByID(billsID);
  372. if(parentBillsNode && parentBillsNode.children.length > 0){//如果能找到则说明已经存在的清单
  373. serialNo = parentBillsNode.children[parentBillsNode.children.length - 1].data.serialNo + 1
  374. }
  375. }
  376. return serialNo
  377. },
  378. getLastBrotherNewRation:function(billsItemID,rations){
  379. let newData = null;
  380. for(let tem of rations){
  381. if(tem.newData.billsItemID == billsItemID) newData = tem.newData;
  382. }
  383. return newData;
  384. },
  385. createNewRationData:function (data,newID,referenceRationID,billsID,serialNo,quantity,libID,isFBFX) {
  386. let newData = projectObj.project.Ration.getTempRationData(newID,billsID,serialNo,rationType.ration);
  387. newData.referenceRationID = referenceRationID;
  388. newData.quantity = quantity;
  389. newData.quantityEXP = gljUtil.isDef(data.coe) && data.coe != "0"?"MBGCL":quantity+"";
  390. let temRation = this.getDefaultRationCreateData(newData,data.code,libID,isFBFX);
  391. return temRation;
  392. },
  393. getDefaultRationCreateData:function(newData,code,libID,isFBFX){
  394. let itemQuery = {userID: userID, rationRepId: libID, code: code};
  395. let needInstall = false;
  396. if(projectObj.project.isInstall()) {//如果是安装工程,要看需不需要生成安装增加费
  397. needInstall = isFBFX;//在分部分项插入的定额才需要定额安装增加费
  398. }
  399. return{itemQuery:itemQuery,newData:newData,defaultLibID: rationLibObj.getDefaultStdRationLibID(),calQuantity:false,brUpdate:[],needInstall:needInstall}
  400. },
  401. getQuantity:function (data) {//取最新的消耗量,需经过转换
  402. if(data.unit){
  403. let times = parseInt(data.unit);
  404. if(!isNaN(times)){
  405. return scMathUtil.roundForObj(parseFloat(data.quantity)/times,getDecimal("ration.quantity"))+""
  406. }
  407. }
  408. return data.quantity
  409. },
  410. getExistRation:function (data,referenceRationID,type) {
  411. let temRation = null;
  412. //先检查要更新的定额是否已经存在
  413. let rations =_.filter(projectObj.project.Ration.datas,{'referenceRationID':referenceRationID,'code':data.code});
  414. for(let r of rations){
  415. if(type == mbzm_obj.locateMap.AFTERRATION){//如果是生成在主定额后面的位置
  416. let mainRationNode = projectObj.project.mainTree.getNodeByID(referenceRationID);
  417. if(r.billsItemID == mainRationNode.data.billsItemID){//如果清单ID相同, 说明是兄弟节点,位置相同
  418. temRation = r;
  419. break;
  420. }
  421. }
  422. let billsNode = projectObj.project.mainTree.getNodeByID(r.billsItemID);
  423. if(billsNode){//将父清单与要生成的清单比较,看是否一致
  424. if(type == mbzm_obj.locateMap.INMEASURE && billsNode.data.type ==billType.BILL){
  425. if(!_.isEmpty(data.billID)){
  426. //说明生成位置已经有定额了,只需更新消耗量就好
  427. if(data.billID == r.billsItemID){
  428. temRation = r;
  429. break;
  430. }
  431. }else if(!_.isEmpty(data.billsLocation)){//按清单编号到找对应的位置
  432. if(billsNode.data.code && billsNode.data.code.indexOf(data.billsLocation)!=-1) {
  433. temRation = r;
  434. break;
  435. }
  436. }
  437. }else if(type == mbzm_obj.locateMap.INFBFX && (billsNode.data.type ==billType.FX||billsNode.data.type ==billType.BX)){
  438. if(!_.isEmpty(data.fxID) && data.fxID == r.billsItemID){//分项、补项下有对应的定额
  439. temRation = r;
  440. break;
  441. }
  442. }
  443. }
  444. }
  445. return temRation;
  446. },
  447. hasReferenceRation:function (node) {
  448. if(node.sourceType == ModuleNames.ration){
  449. let template = projectObj.project.ration_template.getTemplateByRationID(node.data.ID);
  450. if(template){
  451. let ration = _.find(projectObj.project.Ration.datas,{'referenceRationID':node.data.ID});
  452. if(ration) return true;
  453. }
  454. }
  455. return false;
  456. },
  457. deleteReferenceRation:function (mainNodes,updateNodes) {
  458. let refNode = [];
  459. for(let m of mainNodes){
  460. if(this.hasReferenceRation(m)){
  461. let rations = _.filter(projectObj.project.Ration.datas,{'referenceRationID':m.data.ID});
  462. for(let r of rations){
  463. let temNode = projectObj.project.mainTree.getNodeByID(r.ID);
  464. if(temNode && updateNodes.indexOf(temNode) == -1){//能找到该节点,并且节点不在已经删除的列表中
  465. refNode.push(temNode);
  466. updateNodes.push(temNode);
  467. projectObj.mainController.tree.getAllSubNode(temNode,updateNodes)//添加显示到造价书页面的主材、设备节点
  468. }
  469. }
  470. }
  471. }
  472. return refNode;
  473. }
  474. };
  475. $('#createLocation').change(function(){
  476. let me = mbzm_obj;
  477. let pcol = _.findIndex(me.setting.header,{dataCode:"position"});
  478. me.setting.header[pcol].visible = $(this).val() == mbzm_obj.locateMap.AFTERRATION?false:true;
  479. me.refreshSheetData();
  480. });
  481. $('#next_mbzm').click(function () {
  482. if (projectReadOnly) {
  483. return;
  484. }
  485. let mainSheet = projectObj.mainSpread.getActiveSheet();
  486. let selection = mainSheet.getSelections()[0];
  487. let node = projectObj.project.mainTree.selected;
  488. let index = node.serialNo();
  489. let next = null;
  490. for(let i = index+1;i< projectObj.project.mainTree.items.length;i++){
  491. let temNode = projectObj.project.mainTree.items[i];
  492. if(temNode && temNode.sourceType == ModuleNames.ration){
  493. let template = projectObj.project.ration_template.getTemplateByRationID(temNode.data.ID);
  494. if(template) {
  495. next = temNode;
  496. break;
  497. }
  498. }
  499. }
  500. if(next){
  501. let row = next.serialNo();
  502. let col = selection.col?selection.col:0;
  503. mainSheet.setSelection(row, col, selection.rowCount, selection.colCount);
  504. projectObj.mainController.setTreeSelected(next);
  505. mainSheet.showRow(row, GC.Spread.Sheets.VerticalPosition.center);
  506. }
  507. });
  508. $('#apply_mbzm').click(function () {
  509. if(projectReadOnly) return;
  510. mbzm_obj.applyTemplate();
  511. });