locate_view.js 25 KB

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