locate_view.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. /**
  2. * Created by zhang on 2018/11/16.
  3. */
  4. let locateObject={
  5. bills_setting:{
  6. header:[
  7. {headerName: "编码", headerWidth: 120, dataCode: "code", dataType: "String"},
  8. {headerName: "项目名称", headerWidth: 100, dataCode: "name", dataType: "String"},
  9. {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
  10. {headerName: "工程量", headerWidth: 65, dataCode: "quantity", dataType: "Number", hAlign: "right"},
  11. {headerName: "综合单价", headerWidth: 65, dataCode: "unitPrice", dataType: "Number", hAlign: "right"},
  12. {headerName: "综合合价", headerWidth: 65, dataCode: "totalPrice", dataType: "Number", hAlign: "right"}
  13. ],
  14. view: {
  15. lockColumns: [0,1,2,3,4,5],
  16. colHeaderHeight:30
  17. }
  18. },
  19. ration_setting:{
  20. header:[
  21. {headerName: "定额编码", headerWidth: 100, dataCode: "code", dataType: "String"},
  22. {headerName: "定额名称", headerWidth: 180, dataCode: "name", dataType: "String"},
  23. {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
  24. {headerName: "工程量", headerWidth: 65, dataCode: "quantity", dataType: "Number", hAlign: "right",decimalField: "ration.quantity"}
  25. ],
  26. view: {
  27. lockColumns: [0,1,2,3],
  28. colHeaderHeight:30
  29. }
  30. },
  31. ration_glj_setting:{
  32. header:[
  33. {headerName: "编码", headerWidth: 120, dataCode: "code", dataType: "String"},
  34. {headerName: "名称", headerWidth: 80, dataCode: "name", dataType: "String"},
  35. {headerName: "规格型号", headerWidth: 80, dataCode: "specs", dataType: "String"},
  36. {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
  37. {headerName: "市场价", headerWidth: 65, dataCode: "marketPrice", dataType: "Number", hAlign: "right"}
  38. ],
  39. view: {
  40. lockColumns: [0,1,2,3,4],
  41. colHeaderHeight:30
  42. }
  43. },
  44. datas:[],
  45. bookMarkSetting:{
  46. header:[
  47. {headerName: "编码", headerWidth: 120, dataCode: "code", dataType: "String"},
  48. {headerName: "书签名称", headerWidth: 200, dataCode: "name", dataType: "String"},
  49. ],
  50. view: {
  51. lockColumns: [0,1],
  52. colHeaderHeight:30
  53. }
  54. },
  55. bookmarkDatas:[],
  56. seletedNodeID:null,//右键设置书签时选中的节点ID临时存储
  57. //为了兼容旧项目,这里给个默认值
  58. bookmarkPropertySetting:{
  59. settingList :[
  60. {background:"E2F2C5",describe:""},
  61. {background:"F9E2CF",describe:""},
  62. {background:"F2EFD9",describe:"hehe"},
  63. {background:"F5D1DA",describe:""},
  64. {background:"E3E3E3",describe:""},
  65. {background:"B6F3F2",describe:""},
  66. {background:"ECE0F5",describe:""}
  67. ],
  68. selected:"E2F2C5"
  69. },
  70. initMainSpread:function(){
  71. if(!this.mainSpread){
  72. this.mainSpread = SheetDataHelper.createNewSpread($("#locate_result")[0],3);
  73. sheetCommonObj.spreadDefaultStyle(this.mainSpread);
  74. this.initMainSheet();
  75. }else {
  76. this.mainSpread.refresh();
  77. }
  78. },
  79. initMainSheet:function () {
  80. //初始化清单表格
  81. sheetCommonObj.initSheet(this.mainSpread .getSheet(0),this.bills_setting);
  82. this.mainSpread .getSheet(0).setRowCount(0);
  83. //初始化定额表格
  84. sheetCommonObj.initSheet(this.mainSpread .getSheet(1),this.ration_setting);
  85. this.mainSpread .getSheet(1).setRowCount(0);
  86. //初始化人材机表格
  87. sheetCommonObj.initSheet(this.mainSpread.getSheet(2),this.ration_glj_setting);
  88. this.mainSpread .getSheet(2).setRowCount(0);
  89. this.mainSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick,this.onSheetDoubleClick);
  90. this.mainSpread .getSheet(2).bind(GC.Spread.Sheets.Events.SelectionChanged,this.gljSelectionChange);
  91. },
  92. initSubSpread:function () {
  93. if(!this.subSpread){
  94. this.subSpread = SheetDataHelper.createNewSpread($("#locate_sub")[0]);
  95. sheetCommonObj.spreadDefaultStyle(this.subSpread);
  96. this.initSubSheet();
  97. this.subSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick,this.onSheetDoubleClick);
  98. }else {
  99. this.subSpread.refresh();
  100. }
  101. },
  102. initBookmarkSpread:function(){
  103. if(!this.bookmarkSpread){
  104. this.bookmarkSpread = SheetDataHelper.createNewSpread($("#bookmarkSpread")[0]);
  105. sheetCommonObj.spreadDefaultStyle(this.bookmarkSpread);
  106. this.initBookmarkSheet();
  107. this.bookmarkSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick,this.onSheetDoubleClick);
  108. if(!projectReadOnly) this.initBookmarkRightClick();
  109. }else {
  110. this.bookmarkSpread.refresh();
  111. }
  112. this.showBookmarkDatas();
  113. },
  114. refreshWorkBook: function () {
  115. if (this.mainSpread) this.mainSpread.refresh();
  116. if (this.subSpread) this.subSpread.refresh();
  117. if (this.bookmarkSpread) this.bookmarkSpread.refresh();
  118. },
  119. initSubSheet:function () {
  120. this.subSheet = this.subSpread .getSheet(0);
  121. sheetCommonObj.initSheet( this.subSheet, this.ration_setting);
  122. this.subSheet.setRowCount(0);
  123. this.subSheet.name('locate_sub');
  124. },
  125. initBookmarkSheet:function () {
  126. this.bookmarkSheet = this.bookmarkSpread .getSheet(0);
  127. sheetCommonObj.initSheet( this.bookmarkSheet, this.bookMarkSetting);
  128. this.bookmarkSheet.setRowCount(0);
  129. this.bookmarkSheet.name('bookmark');
  130. this.bookmarkSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.bookmarkSelectionChange);
  131. },
  132. initOutstanding:function () {
  133. if(!projectObj.project.property.locateSetting) return;
  134. let outstd = projectObj.project.property.locateSetting;
  135. $("#outstanding").prop("checked",outstd.outstanding);
  136. $("#outInp").val(parseFloat(outstd.outInp));
  137. },
  138. initBookmarkSetting:function () {
  139. $("#bookmarkSettingList").empty();
  140. let setting = projectObj.project.property.bookmarkSetting?projectObj.project.property.bookmarkSetting:this.bookmarkPropertySetting;
  141. for(let s of setting.settingList){
  142. let b = `<div class="input-group input-group-sm mb-2" style="width:200px">
  143. <div class="input-group-prepend">
  144. <span class="input-group-text " style="background: #${s.background}">&nbsp;&nbsp;&nbsp;&nbsp;</span>
  145. </div>
  146. <input type="text" class="form-control" id="${s.background}" placeholder="描述" value="${s.describe}">
  147. </div>`;
  148. $("#bookmarkSettingList").append(b);
  149. $("#"+s.background).bind('focus', bookmarkSelected);
  150. }
  151. },
  152. showMainData:function (datas,setting) {
  153. sheetCommonObj.showData(this.mainSpread.getActiveSheet(),setting,datas);
  154. this.mainSpread.getActiveSheet().setRowCount(datas.length);
  155. },
  156. showSubRateDatas:function () {
  157. this.subRationDatas = this.getSubRationDatas();
  158. sheetCommonObj.showData(this.subSheet,this.ration_setting,this.subRationDatas);
  159. this.subSheet.setRowCount(this.subRationDatas.length);
  160. },
  161. showBookmarkDatas:function(refresh = false){
  162. let sheet = this.bookmarkSheet;
  163. let sel = sheet.getSelections()[0];
  164. let oldData = sel.row<this.bookmarkDatas.length?this.bookmarkDatas[sel.row]:null;
  165. this.bookmarkDatas = this.getBookmarkDatas();
  166. sheetCommonObj.showData(sheet, this.bookMarkSetting,this.bookmarkDatas);
  167. let selectedID = null;
  168. let focus = false;
  169. if(oldData) selectedID = oldData.ID;
  170. if(this.seletedNodeID && refresh == false){
  171. selectedID = this.seletedNodeID;
  172. this.seletedNodeID = null;
  173. focus = true;
  174. }
  175. sel.row = selectedID?_.findIndex(this.bookmarkDatas,{'ID':selectedID}):0;
  176. sheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
  177. sheet.setRowCount(this.bookmarkDatas.length);
  178. if(sel.row!=-1) sheet.showRow(sel.row, GC.Spread.Sheets.VerticalPosition.bottom);
  179. this.showAnnotation(sel.row,focus);
  180. },
  181. getBookmarkDatas:function(){
  182. let datas = [];
  183. let nodes = projectObj.project.mainTree.items;
  184. for(let n of nodes){
  185. if(!_.isEmpty(n.data.bookmarkBackground)){
  186. let tem = {
  187. ID:n.data.ID,
  188. code:n.data.code,
  189. type:n.sourceType,
  190. name:n.data.name,
  191. bookmarkAnnotation:n.data.bookmarkAnnotation,
  192. bgColour:"#"+n.data.bookmarkBackground
  193. };
  194. datas.push(tem);
  195. }
  196. }
  197. return datas;
  198. },
  199. getSubRationDatas:function () {
  200. let datas = [];
  201. let sheet = this.mainSpread.getActiveSheet();
  202. let oldSel = sheet.getSelections()[0];
  203. if(this.gljDatas && this.gljDatas.length > 0){
  204. let glj = this.gljDatas[oldSel.row];
  205. if(!glj) return datas;
  206. let nodes = projectObj.project.projectGLJ.getImpactRationNodes([glj.reference]);
  207. for(let n of nodes){
  208. datas.push(this.getShowRationDatas(n.data));
  209. }
  210. }
  211. return datas;
  212. },
  213. refreshView: function (options, refreshWorkBook) {
  214. let me = this;
  215. let mainHeight = $(window).height()-$(".header").height()-$(".toolsbar").height()-$("#searchPanel").height();
  216. let subHeight = 0;
  217. if(options == "bookmark"){
  218. loadHeight(getBookmarkResize());
  219. }else {
  220. $('#locateTopDiv').height(mainHeight);
  221. $('#locate_result').height(mainHeight);
  222. $('#locateBottomDiv').height(subHeight);
  223. $('#locate_sub').height(subHeight - 7);
  224. if(options == "ration_glj"){
  225. loadHeight(getLocateLibResize());
  226. }
  227. }
  228. if (refreshWorkBook) {
  229. me.refreshWorkBook();
  230. }
  231. function loadHeight(libResize) {
  232. SlideResize.loadVerticalHeight(libResize.eleObj.module, libResize.eleObj, libResize.limit, function () {
  233. locateObject.refreshWorkBook();
  234. });
  235. }
  236. },
  237. init:function () {
  238. let me = this;
  239. let options = $("input[name='content_type']:checked").val();
  240. let callback = function () {
  241. me.refreshView(options, false);
  242. me.initMainSpread();
  243. me.initSubSpread();
  244. me.initBookmarkSpread();
  245. };
  246. if(options == 'bookmark'){
  247. $("#aboutLocateDiv").hide();
  248. $("#outstandingOptions").hide();
  249. me.initBookmarkSetting();
  250. $("#aboutBookmarkDiv").show(0,callback);
  251. }else {
  252. $("#aboutBookmarkDiv").hide();
  253. $("#aboutLocateDiv").show(0,function () {
  254. if(options == "bills") me.initOutstanding();
  255. options == "bills"?$("#outstandingOptions").show(0,callback):$("#outstandingOptions").hide(0,callback);
  256. });
  257. }
  258. },
  259. findRecodes:function () {
  260. let options = $("input[name='content_type']:checked").val();
  261. let keyword = $("#locateInput").val();
  262. switch (options){
  263. case "bills":
  264. this.billsDatas = this.findBills(keyword);
  265. this.showMainData(this.billsDatas,this.bills_setting);
  266. break;
  267. case "ration":
  268. this.rationDatas = this.findRations(keyword);
  269. this.showMainData(this.rationDatas,this.ration_setting);
  270. break;
  271. case "ration_glj":
  272. this.gljDatas = this.findGLJs(keyword);
  273. this.showMainData(this.gljDatas,this.ration_glj_setting);
  274. this.showSubRateDatas();
  275. break;
  276. }
  277. },
  278. onshow:function () {
  279. locateObject.init();
  280. },
  281. matchItem:function (keyword,i) {//true 匹配上,false匹配失败
  282. let match = false;
  283. if(keyword && keyword !="") {//如果keyword为空,匹配所有
  284. if (i.code && i.code.indexOf(keyword) != -1) match = true;
  285. if (i.name && i.name.indexOf(keyword) != -1) match = true;
  286. if(match == false) return false
  287. }
  288. return true;
  289. },
  290. findGLJs:function(keyword){
  291. let datas = [];
  292. let gljList = projectObj.project.projectGLJ.datas.gljList;
  293. gljList = sortProjectGLJ(gljList);
  294. for(let glj of gljList){
  295. // if(glj.quantity == 0 || glj.quantity == '0') continue; 2019-07-01 需求改成消耗量为0也显示
  296. let match = this.matchItem(keyword,glj);
  297. if(match == false) continue;
  298. let data = getGLJDatas(glj);
  299. gljOprObj.setGLJPrice(data,glj);
  300. datas.push(data);
  301. }
  302. return datas;
  303. function getGLJDatas(tem) {
  304. return{
  305. ID:tem.id,
  306. name:tem.name,
  307. code:tem.code,
  308. unit:tem.unit,
  309. specs:tem.specs,
  310. reference:tem
  311. }
  312. }
  313. },
  314. findRations:function (keyword) {
  315. let datas = [];
  316. let items = projectObj.project.mainTree.items;
  317. for(let i of items){
  318. if(i.sourceType == ModuleNames.ration){
  319. let match = this.matchItem(keyword,i.data);
  320. if(match == false) continue;
  321. let bills = this.getShowRationDatas(i.data);
  322. datas.push(bills);
  323. }
  324. }
  325. return datas;
  326. },
  327. getShowRationDatas:function(data){
  328. return{
  329. ID:data.ID,
  330. name:data.name,
  331. code:data.code,
  332. unit:data.unit,
  333. quantity:data.quantity
  334. }
  335. },
  336. findBills:function(keyword){
  337. let datas = [],priceMap={};
  338. let items = projectObj.project.mainTree.items;
  339. for(let i of items){
  340. if(i.sourceType == ModuleNames.bills){
  341. let match = this.matchItem(keyword,i.data);
  342. if(match == false) continue;
  343. let bills = getBillData(i.data);
  344. priceMap = setPriceMap(bills,priceMap);
  345. datas.push(bills);
  346. }
  347. }
  348. setBgColour(datas,priceMap);
  349. datas = _.sortByAll(datas,['code']);
  350. return datas;
  351. function setBgColour(bills,map) {
  352. let outStd = $("#outstanding").prop("checked");
  353. let outInp = $("#outInp").val();
  354. if(outStd == true && outInp && outInp!=""){
  355. for(let b of bills){
  356. if(b.code && b.code.length >= 9){
  357. let key = b.code.substr(0,9);
  358. if(map[key] && map[key].count > 1){
  359. let avg = map[key].total/map[key].count;
  360. let unitPrice = b.unitPrice?parseFloat(b.unitPrice):0;
  361. if(unitPrice ==0 ) continue;
  362. if(Math.abs(unitPrice - avg)/avg * 100 >= parseFloat(outInp)) b.bgColour = "#FFFACD"
  363. }
  364. }
  365. }
  366. }
  367. }
  368. function setPriceMap (bills,map) {
  369. if(bills.code && bills.code.length >= 9){
  370. let key = bills.code.substr(0,9);
  371. let unitPrice = bills.unitPrice?parseFloat(bills.unitPrice):0;
  372. if(map[key]){
  373. map[key].total += unitPrice;
  374. map[key].count ++;
  375. }else {
  376. map[key] = {total:unitPrice,count:1}
  377. }
  378. }
  379. return map;
  380. }
  381. function getBillData(data) {
  382. return{
  383. ID:data.ID,
  384. name:data.name,
  385. code:data.code,
  386. unit:data.unit,
  387. quantity:data.quantity,
  388. unitPrice:data.feesIndex&&data.feesIndex.common?data.feesIndex.common.unitFee:"",
  389. totalPrice:data.feesIndex&&data.feesIndex.common?data.feesIndex.common.totalFee:"",
  390. bgColour:"white"
  391. }
  392. }
  393. },
  394. onSheetDoubleClick:function (e,args) {
  395. let me = locateObject;
  396. let options = $("input[name='content_type']:checked").val();
  397. let sheetName = args.sheet.name()
  398. if(options == "ration_glj"&&sheetName != "locate_sub" ) return;
  399. let datas = options == "bills"? me.billsDatas:me.rationDatas;
  400. if( args.sheet.name() == "locate_sub") datas = me.subRationDatas;
  401. if(args.sheet.name() == "bookmark") datas = me.bookmarkDatas;
  402. me.locateNode(datas[args.row].ID);
  403. },
  404. gljSelectionChange:function (e,args) {
  405. let me = locateObject;
  406. let newSel = args.newSelections[0];
  407. let oldSel = args.oldSelections?args.oldSelections[0]:{};
  408. if(newSel.row != oldSel.row){
  409. me.showSubRateDatas();
  410. }
  411. },
  412. bookmarkSelectionChange:function (e,args) {
  413. let me = locateObject;
  414. let newSel = args.newSelections[0];
  415. let oldSel = args.oldSelections?args.oldSelections[0]:{};
  416. if(newSel.row != oldSel.row){
  417. me.showAnnotation(newSel.row);
  418. }
  419. },
  420. showAnnotation:function (row,focus = false) {
  421. let me = locateObject;
  422. let recode = me.bookmarkDatas[row];
  423. if(recode){
  424. $("#annotationTextarea").val(recode.bookmarkAnnotation);
  425. $("#bookmarkNodeID").val(recode.ID);
  426. $("#bookmarkNodeType").val(recode.type);
  427. if(focus) $("#annotationTextarea").focus();
  428. }
  429. },
  430. locateNode:function (ID) {
  431. let node = projectObj.project.mainTree.findNode(ID);
  432. if(node) projectObj.loadFocusLocation(node.serialNo(),1);
  433. },
  434. updateProjectProperty:function(fieldID,property){
  435. let updateData = {type:ModuleNames.project,data:{'ID' : projectObj.project.ID()}};//,'property.locateSetting':outstd
  436. updateData.data["property."+fieldID] = property;
  437. $.bootstrapLoading.start();
  438. projectObj.project.updateNodes([updateData],function () {
  439. $.bootstrapLoading.end();
  440. projectObj.project.property[fieldID] = property;
  441. });
  442. },
  443. updateOutStanding:function (outstanding,outInp) {
  444. let outstd = {outstanding:outstanding,outInp:outInp};
  445. this.updateProjectProperty('locateSetting',outstd);
  446. },
  447. updateBookmarkSetting:function () {
  448. let setting = projectObj.project.property.bookmarkSetting?projectObj.project.property.bookmarkSetting:locateObject.bookmarkPropertySetting;
  449. for(let s of setting.settingList){
  450. s.describe = $("#"+s.background).val();
  451. }
  452. setting.selected = $("#bookmarkSelected").val();
  453. this.updateProjectProperty("bookmarkSetting",setting);
  454. },
  455. setOrCancelBookmark:function(node){
  456. $("#bookmark").prop("checked", true);
  457. let setting = projectObj.project.property.bookmarkSetting?projectObj.project.property.bookmarkSetting:locateObject.bookmarkPropertySetting;
  458. let background = null;
  459. if(_.isEmpty(node.data.bookmarkBackground)) background = setting.selected;
  460. let updateData = {type:node.sourceType,data:{'ID' : node.data.ID,bookmarkBackground:background}};
  461. if(background == null) updateData.data.bookmarkAnnotation = null;
  462. $.bootstrapLoading.start();
  463. projectObj.project.updateNodes([updateData],function () {
  464. $.bootstrapLoading.end();
  465. node.data.bookmarkBackground = background;
  466. projectObj.mainController.refreshTreeNode([node]);
  467. locateObject.seletedNodeID = node.data.ID;
  468. //如果没有打开,自动打开书签批注设置
  469. $('#locate').is(':visible')?locateObject.init():$("#locateTab").click();
  470. });
  471. },
  472. initBookmarkRightClick:function(){
  473. //如果当前行是无组成物的“普通材料”、“绿化苗木”、“外购砼构件”、“商品混凝土”、“商品砂浆”,则右键“添加计算材料”按钮有效。
  474. let me = this;
  475. $.contextMenu({
  476. selector: '#bookmarkSpread',
  477. build: function ($trigger, e) {
  478. me.rightClickTarget = SheetDataHelper.safeRightClickSelection($trigger, e, me.bookmarkSpread);
  479. return me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.viewport ||
  480. me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
  481. },
  482. items: {
  483. "deleteBookmark": {
  484. name: "删除书签批注",
  485. icon: 'fa-remove',
  486. disabled: function () {
  487. return me.bookmarkDatas.length == 0;
  488. },
  489. callback: function (key, opt) {
  490. me.deleteSelectedBookmark();
  491. }
  492. },
  493. "deleteAllBookmarks": {
  494. name: "删除所有书签批注",
  495. icon: 'fa-remove',
  496. disabled: function () {
  497. return me.bookmarkDatas.length == 0;
  498. },
  499. callback: function (key, opt) {
  500. me.deleteBookmarkByDatas(me.bookmarkDatas);
  501. }
  502. }
  503. }
  504. });
  505. },
  506. deleteSelectedBookmark:function () {
  507. let sel = this.bookmarkSheet.getSelections()[0];
  508. if(sel.row != -1 && this.bookmarkDatas.length>sel.row){
  509. let record = this.bookmarkDatas[sel.row];
  510. this.deleteBookmarkByDatas([record]);
  511. }
  512. },
  513. deleteBookmarkByDatas:function(datas){
  514. let postDatas = [];
  515. for(let d of datas){
  516. let tem = {
  517. type:d.type,
  518. data:{
  519. 'ID':d.ID,
  520. 'bookmarkAnnotation':null,
  521. 'bookmarkBackground':null
  522. }
  523. };
  524. postDatas.push(tem);
  525. }
  526. this.updateBookmarkNodes(postDatas);
  527. },
  528. updateBookmarkNodes:function (postDatas,refreshsNode = true) {
  529. $.bootstrapLoading.start();
  530. projectObj.project.updateNodes(postDatas,function () {
  531. $.bootstrapLoading.end();
  532. let nodes = [];
  533. for(let p of postDatas){
  534. let node = projectObj.project.mainTree.findNode(p.data.ID);
  535. if(!node) continue;
  536. for(let key in p.data){
  537. if(key == 'ID') continue;
  538. node.data[key] = p.data[key];
  539. }
  540. nodes.push(node);
  541. }
  542. locateObject.showBookmarkDatas();
  543. if(refreshsNode) projectObj.mainController.refreshTreeNode(nodes);
  544. });
  545. }
  546. };
  547. $("#locate_btn").click(function () {
  548. locateObject.findRecodes();
  549. });
  550. //回车键搜索
  551. $('#locateInput').bind('keypress', function (event) {
  552. if(event.keyCode === 13){
  553. $(this).blur();
  554. locateObject.findRecodes();
  555. }
  556. });
  557. $("input[name='content_type']").each(function(){
  558. $(this).click(function(){
  559. let options = $(this).val();
  560. switch (options){
  561. case "bills":
  562. locateObject.mainSpread.setActiveSheetIndex(0);
  563. break;
  564. case "ration":
  565. locateObject.mainSpread.setActiveSheetIndex(1);
  566. break;
  567. case "ration_glj":
  568. locateObject.mainSpread.setActiveSheetIndex(2);
  569. break;
  570. }
  571. locateObject.init();
  572. });
  573. });
  574. $('#outInp').change(function(){
  575. let me = locateObject;
  576. let process = getDecimal('process');
  577. var newVal = $(this).val();
  578. let outInp = scMathUtil.roundForObj(newVal,process);
  579. let outStd = $("#outstanding").prop("checked");
  580. me.updateOutStanding(outStd,outInp);
  581. });
  582. $('#outstanding').change(function(){
  583. let me = locateObject;
  584. let outInp = $("#outInp").val();
  585. let outStd = $("#outstanding").prop("checked");
  586. me.updateOutStanding(outStd,scMathUtil.roundForObj(outInp,getDecimal('process')));
  587. });
  588. $("#annotationTextarea").change(function(){
  589. let updateData = {type:$("#bookmarkNodeType").val(),data:{'ID' :$("#bookmarkNodeID").val(),'bookmarkAnnotation':$(this).val()}};
  590. let node = projectObj.project.mainTree.findNode($("#bookmarkNodeID").val());
  591. if(!node) return;
  592. locateObject.updateBookmarkNodes([updateData],false);
  593. });
  594. $('#bookmarkSettingDropdown').on('shown.bs.dropdown', function showDropdown() {
  595. locateObject.initBookmarkSetting();
  596. let setting = projectObj.project.property.bookmarkSetting?projectObj.project.property.bookmarkSetting:locateObject.bookmarkPropertySetting;
  597. $("#"+setting.selected).focus();
  598. });
  599. $("#bookmarkSettingConfirm").click(function () {
  600. locateObject.updateBookmarkSetting();
  601. $("#bookmarkSettingDropdown").click();
  602. });
  603. function bookmarkSelected() {
  604. $("#bookmarkSelected").val($(this)[0].id);
  605. }