std_ration_lib.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /**
  2. * Standard Ration Lib
  3. * Created by Mai on 2017/5/16.
  4. */
  5. /*var rationChapterSpread, sectionRationsSpread;*/
  6. var rationLibObj = {
  7. doAfterGetRationTree: null, //获取章节树回调
  8. doAfterLoadGetRations: null, //获取章节树下定额后回调
  9. rationChapterSpread: null,
  10. sectionRationsSpread: null,
  11. resultSpread: null,
  12. rationChapterTreeController: null,
  13. refreshSettingForHint: function () {
  14. TREE_SHEET_HELPER.initSetting($('#stdSectionRations')[0], rationLibObj.sectionRationsSetting);
  15. },
  16. checkSpread: function () {
  17. if (!this.rationChapterSpread) {
  18. this.rationChapterSpread = SheetDataHelper.createNewSpread($('#stdRationChapter')[0]);
  19. sheetCommonObj.spreadDefaultStyle(this.rationChapterSpread);
  20. this.rationChapterSpread.getSheet(0).name('stdRationLib_chapter');
  21. this.rationChapterSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, this.onChapterSpreadCellDoubleClick);
  22. }
  23. if (!this.sectionRationsSpread) {
  24. this.sectionRationsSpread = SheetDataHelper.createNewSpread($('#stdSectionRations')[0]);
  25. sheetCommonObj.spreadDefaultStyle(this.sectionRationsSpread);
  26. this.sectionRationsSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, this.onRationSpreadCellDoubleClick);
  27. this.refreshSettingForHint();
  28. }
  29. },
  30. refreshSpread: function () {
  31. if (this.rationChapterSpread) {
  32. this.rationChapterSpread.refresh();
  33. }
  34. if (this.sectionRationsSpread) {
  35. this.sectionRationsSpread.refresh();
  36. }
  37. if(this.resultSpread){
  38. this.resultSpread.refresh();
  39. }
  40. },
  41. loadStdRationLibs: function () {
  42. let select = $('#stdRationLibSelect');
  43. select.empty();
  44. let ration_lib = projectInfoObj.projectInfo.engineeringInfo.ration_lib;
  45. let selectedRationLib = sessionStorage.getItem('stdRationLib');
  46. ration_lib.forEach(function (data) {
  47. let option = $('<option>').val(data.id).text(data.name);
  48. //select.append($('<option>').val(data.id).text(data.name));
  49. if(selectedRationLib){
  50. if(data.id == selectedRationLib){
  51. option.attr('selected', 'selected');
  52. }
  53. }else if(data.isDefault == true){
  54. option.attr('selected', 'selected');
  55. }
  56. select.append(option);
  57. });
  58. if (select[0].options.length !== 0) {
  59. rationLibObj.loadStdRation(select.val());
  60. }
  61. },
  62. loadStdRation: function (rationLibID) {
  63. $.bootstrapLoading.start();
  64. var that = this;
  65. var showRationChapterTree = function (datas) {
  66. var rationChapterTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: false});
  67. that.tree = rationChapterTree;
  68. var rationChapterTreeController = TREE_SHEET_CONTROLLER.createNew(rationChapterTree, that.rationChapterSpread.getActiveSheet(), that.rationChapterTreeSetting);
  69. rationChapterTree.loadDatas(datas);
  70. //读取展开收起状态
  71. let currentExpState = sessionStorage.getItem('stdRationLibExpState');
  72. if(currentExpState){
  73. that.tree.setExpandedByState(that.tree.items, currentExpState);
  74. }
  75. else {
  76. //展开至第二层
  77. for(let root of that.tree.roots){
  78. root.setExpanded(true);
  79. that.tree.setRootExpanded(root.children, false);
  80. }
  81. }
  82. rationChapterTreeController.showTreeData();
  83. rationChapterTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {
  84. rationLibObj.loadSectionRations(node && node.children.length === 0 ? node.getID() : null);
  85. });
  86. if (rationChapterTree.firstNode() && rationChapterTree.firstNode().length === 0) {
  87. rationLibObj.loadSectionRations(rationChapterTree.firstNode().getID());
  88. } else {
  89. rationLibObj.loadSectionRations();
  90. };
  91. };
  92. CommonAjax.post('/complementaryRation/api/getRationTree', {userId: userID, rationRepId: rationLibID}, function (datas) {
  93. showRationChapterTree(datas);
  94. if(that.doAfterGetRationTree){
  95. that.doAfterGetRationTree();
  96. }
  97. $.bootstrapLoading.end();
  98. }, function () {
  99. showRationChapterTree([]);
  100. $.bootstrapLoading.end();
  101. });
  102. },
  103. //双击隐藏显示
  104. onChapterSpreadCellDoubleClick: function (sender, args) {
  105. let me = rationLibObj;
  106. let node = me.tree.items[args.row];
  107. if (!node || node.children.length === 0)
  108. return;
  109. node.setExpanded(!node.expanded);
  110. sessionStorage.setItem('stdRationLibExpState', me.tree.getExpState(me.tree.items));
  111. TREE_SHEET_HELPER.massOperationSheet(args.sheet, function () {
  112. let iCount = node.posterityCount(), i, child;
  113. for (i = 0; i < iCount; i++) {
  114. child = me.tree.items[args.row + i + 1];
  115. args.sheet.setRowVisible(args.row + i + 1, child.visible, args.sheetArea);
  116. }
  117. args.sheet.invalidateLayout();
  118. });
  119. args.sheet.repaint();
  120. },
  121. setTagForHint: function (sheet, datas) {
  122. sheet.suspendPaint();
  123. sheet.suspendEvent();
  124. for(let i = 0, len = sheet.getRowCount(); i < len; i++){
  125. sheet.setTag(i, 0, '');
  126. }
  127. for(let i = 0, len = datas.length; i < len; i++){
  128. sheet.setTag(i, 0, datas[i].hint ? datas[i].hint : '');
  129. }
  130. sheet.resumePaint();
  131. sheet.resumeEvent();
  132. },
  133. loadSectionRations: function (sectionID) {
  134. let me = this;
  135. var showDatas = function (datas, setting) {
  136. let rationSheet = rationLibObj.sectionRationsSpread.getActiveSheet();
  137. TREE_SHEET_HELPER.massOperationSheet(rationSheet, function () {
  138. rationSheet.setColumnWidth(0, 25, GC.Spread.Sheets.SheetArea.rowHeader);
  139. });
  140. SheetDataHelper.loadSheetHeader(setting, rationLibObj.sectionRationsSpread.getActiveSheet());
  141. SheetDataHelper.loadSheetData(setting, rationLibObj.sectionRationsSpread.getActiveSheet(), datas);
  142. rationLibObj.setTagForHint(rationSheet, datas);
  143. };
  144. if (sectionID) {
  145. CommonAjax.post('/complementaryRation/api/getRationGljItemsBySection', {user_Id: userID, sectionId: sectionID}, function (datas) {
  146. showDatas(datas, rationLibObj.sectionRationsSetting);
  147. if(me.doAfterLoadGetRations){
  148. me.doAfterLoadGetRations(datas);
  149. me.doAfterLoadGetRations = null;
  150. }
  151. }, function () {
  152. showDatas([], rationLibObj.sectionRationsSetting);
  153. });
  154. } else {
  155. showDatas([], rationLibObj.sectionRationsSetting);
  156. }
  157. },
  158. onRationSpreadCellDoubleClick: function (sender, args) {
  159. var select = $('#stdRationLibSelect'), rationCode = args.sheet.getText(args.row, 0);
  160. if (rationCode !== '') {
  161. projectObj.project.Ration.addNewRation({userID: userID, rationRepId: select.val(), code: rationCode},rationType.ration, function () {
  162. projectObj.setActiveCell('quantity', true);
  163. });
  164. }
  165. },
  166. loadStdRationContextMenu: function () {
  167. let rationSpread = rationLibObj.sectionRationsSpread, rationSheet = rationSpread.getActiveSheet(), rationModel = projectObj.project.Ration;;
  168. $.contextMenu({
  169. selector: '#stdSectionRations',
  170. build: function ($trigger, e) {
  171. let target = SheetDataHelper.safeRightClickSelection($trigger, e, rationSpread);
  172. return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
  173. },
  174. items: {
  175. "insertStdRation": {
  176. name: "插入定额",
  177. icon: 'fa-sign-in',
  178. callback: function (key, opt) {
  179. let select = $('#stdRationLibSelect'), rationSelect = rationSheet.getSelections();
  180. let rationCode = rationSelect.length > 0 ? rationSheet.getText(rationSelect[0].row, 0) : '';
  181. if (rationCode !== '') {
  182. rationModel.addNewRation({userID: userID, rationRepId: select.val(), code: rationCode},rationType.ration, function () {
  183. });
  184. }
  185. }
  186. },
  187. "replaceStdRation": {
  188. name: "替换定额",
  189. icon: 'fa-sign-in',
  190. callback: function (key, opt) {
  191. let select = $('#stdRationLibSelect'), rationSelect = rationSheet.getSelections();
  192. let rationCode = rationSelect.length > 0 ? rationSheet.getText(rationSelect[0].row, 0) : '';
  193. let mainTreeSelected = projectObj.project.mainTree.selected;
  194. if (rationCode !== ''&&mainTreeSelected&&mainTreeSelected.sourceType == rationModel.getSourceType()) {
  195. rationModel.updateRationCodes([{'node':mainTreeSelected,value:rationCode}]);
  196. }
  197. }
  198. },
  199. }
  200. });
  201. },
  202. expandSearchNodes: function(nodes){
  203. let that = rationLibObj;
  204. TREE_SHEET_HELPER.massOperationSheet(that.rationChapterSpread.getActiveSheet(), function () {
  205. function expParentNode(node){
  206. if(node.parent){
  207. expParentNode(node.parent);
  208. if(!node.parent.expanded){
  209. node.parent.setExpanded(true);
  210. }
  211. }
  212. }
  213. for(let node of nodes){
  214. expParentNode(node);
  215. }
  216. TREE_SHEET_HELPER.refreshTreeNodeData(that.rationChapterTreeSetting, that.rationChapterSpread.getActiveSheet(), that.tree.roots, true);
  217. TREE_SHEET_HELPER.refreshNodesVisible(that.tree.roots, that.rationChapterSpread.getActiveSheet(), true);
  218. });
  219. },
  220. initSel: function (row) {
  221. let me = this;
  222. let sheet = me.rationChapterSpread.getActiveSheet();
  223. sheet.setActiveCell(row, 0);
  224. sheet.showRow(row, GC.Spread.Sheets.VerticalPosition.center);
  225. let sectionNode = me.tree.items[row] || null;
  226. me.loadSectionRations(sectionNode && sectionNode.children.length === 0 ? sectionNode.data.ID : null);
  227. },
  228. locateAtRation: function(libID, code){
  229. let me = rationLibObj;
  230. //查找定额,以确定定额所在章节节点
  231. let firstLibID = projectInfoObj.projectInfo.engineeringInfo.ration_lib.length > 0 ?
  232. projectInfoObj.projectInfo.engineeringInfo.ration_lib[0].id : null;
  233. let locateRow = 0,
  234. locateSubRow = 0;
  235. CommonAjax.post('/complementaryRation/api/getRationItem', {rationRepIds: [libID], code: code}, function (ration) {
  236. if(ration && ration.sectionId){
  237. let sectionNode = me.tree.findNode(ration.sectionId);
  238. if(sectionNode){
  239. me.expandSearchNodes([sectionNode]);
  240. sessionStorage.setItem('stdRationLibExpState', me.tree.getExpState(me.tree.items));
  241. }
  242. locateRow = sectionNode.serialNo();
  243. me.doAfterLoadGetRations = function (rationItems) {
  244. let rationSheet = me.sectionRationsSpread.getActiveSheet();
  245. locateSubRow = _.findIndex(rationItems, {ID: ration.ID});
  246. rationSheet.setActiveCell(locateSubRow, 0);
  247. rationSheet.showRow(locateSubRow, GC.Spread.Sheets.VerticalPosition.center);
  248. };
  249. me.initSel(locateRow);
  250. }
  251. else {
  252. me.initSel(locateRow);
  253. }
  254. }, function () {
  255. me.initSel(locateRow);
  256. });
  257. },
  258. rationChapterTreeSetting: {
  259. "emptyRowHeader": true,
  260. "rowHeaderWidth": 15,
  261. "emptyRows":0,
  262. "headRows":1,
  263. "headRowHeight":[30],
  264. "defaultRowHeight": 21,
  265. "treeCol": 0,
  266. "cols":[{
  267. "width":400,
  268. "readOnly": true,
  269. "head":{
  270. "titleNames":["名称"],
  271. "spanCols":[1],
  272. "spanRows":[1],
  273. "vAlign":[1],
  274. "hAlign":[1],
  275. "font":["Arial"]
  276. },
  277. "data":{
  278. "field":"name",
  279. "vAlign":1,
  280. "hAlign":0,
  281. "font":"Arial"
  282. }
  283. }]
  284. },
  285. sectionRationsSetting: {
  286. "emptyRows":3,
  287. "headRows":1,
  288. "headRowHeight":[20],
  289. "defaultRowHeight": 21,
  290. "cols":[{
  291. "width":60,
  292. "readOnly": true,
  293. "showHint": true,
  294. "head":{
  295. "titleNames":["编码"],
  296. "spanCols":[1],
  297. "spanRows":[1],
  298. "vAlign":[1],
  299. "hAlign":[1],
  300. "font":["Arial"]
  301. },
  302. "data":{
  303. "field":"code",
  304. "vAlign":1,
  305. "hAlign":0,
  306. "font":"Arial"
  307. }
  308. }, {
  309. "width":220,
  310. "readOnly": true,
  311. "head":{
  312. "titleNames":["名称"],
  313. "spanCols":[1],
  314. "spanRows":[1],
  315. "vAlign":[1],
  316. "hAlign":[1],
  317. "font":["Arial"]
  318. },
  319. "data":{
  320. "field":"name",
  321. "vAlign":1,
  322. "hAlign":0,
  323. "font":"Arial"
  324. }
  325. }, {
  326. "width":55,
  327. "readOnly":true,
  328. "head":{
  329. "titleNames":["单位"],
  330. "spanCols":[1],
  331. "spanRows":[1],
  332. "vAlign":[1],
  333. "hAlign":[1],
  334. "font":["Arial"]
  335. },
  336. "data":{
  337. "field":"unit",
  338. "vAlign":1,
  339. "hAlign":1,
  340. "font":"Arial"
  341. }
  342. }, {
  343. "width":60,
  344. "readOnly":true,
  345. "head":{
  346. "titleNames":["基价"],
  347. "spanCols":[1],
  348. "spanRows":[1],
  349. "vAlign":[1],
  350. "hAlign":[1],
  351. "font":["Arial"]
  352. },
  353. "data":{
  354. "field":"basePrice",
  355. "vAlign":1,
  356. "hAlign":2,
  357. "font":"Arial"
  358. }
  359. }]
  360. },
  361. getStdRationLibIDs: function () {
  362. let ids = [];
  363. if(projectInfoObj.projectInfo.engineeringInfo.ration_lib.length === 0){
  364. alert('当前项目无定额库,请添加定额库。');
  365. return null;
  366. }
  367. for(let rationLib of projectInfoObj.projectInfo.engineeringInfo.ration_lib){
  368. ids.push(rationLib.id);
  369. }
  370. return ids;
  371. },
  372. getCurrentStdRationLibID:function () {
  373. if(projectInfoObj.projectInfo.engineeringInfo.ration_lib.length === 0){
  374. alert('当前项目无定额库,请添加定额库。');
  375. return null;
  376. }
  377. if($('#stdRationLibSelect').val()){
  378. return parseInt($('#stdRationLibSelect').val());
  379. }else {
  380. return projectInfoObj.projectInfo.engineeringInfo.ration_lib[0].id;
  381. }
  382. },
  383. getFirstStdRationLibID: function () {
  384. if(projectInfoObj.projectInfo.engineeringInfo.ration_lib.length === 0){
  385. alert('当前项目无定额库,请添加定额库。');
  386. return null;
  387. }
  388. return parseInt(projectInfoObj.projectInfo.engineeringInfo.ration_lib[0].id);
  389. },
  390. getDefaultStdRationLibID:function(){
  391. let ration_lib = projectInfoObj.projectInfo.engineeringInfo.ration_lib;
  392. if(ration_lib.length === 0){
  393. alert('当前项目无定额库,请添加定额库。');
  394. return null;
  395. }
  396. let defaultLib = _.find(ration_lib,{'isDefault':true});
  397. let libID = defaultLib?defaultLib.id:ration_lib[0].id;
  398. return parseInt(libID);
  399. }
  400. };
  401. addEventOnResize(rationLibObj.refreshSettingForHint);
  402. //赋初始高度
  403. if($('#stdRationChapter').height() === 0 || $('#stdSectionRations').height() === 0){
  404. $('#stdRationChapter').height($(window).height()-$(".header").height()-$(".toolsbar").height()-$(".tools-bar-height-q").height()-312);
  405. $('#stdSectionRations').height(270);
  406. }
  407. $('#stdRationTab').bind('click', function () {
  408. if(!projectReadOnly){
  409. var select = $('#stdRationLibSelect');
  410. rationLibObj.checkSpread();
  411. if (select[0].options.length === 0) {
  412. rationLibObj.loadStdRationLibs();
  413. rationLibObj.loadStdRationContextMenu();
  414. };
  415. }
  416. });
  417. $('#stdRationLibSelect').change(function () {
  418. var select = $(this);
  419. if (this.children.length !== 0) {
  420. let rationLibId = select.val();
  421. sessionStorage.setItem('stdRationLib', rationLibId);
  422. sessionStorage.removeItem('stdRationLibExpState');
  423. rationLibObj.loadStdRation(rationLibId);
  424. }
  425. });
  426. //回车键搜索
  427. $('#rationSearchKeyword').bind('keypress', function (event) {
  428. if(event.keyCode === 13){
  429. $(this).blur();
  430. $('#rationSearch').click();
  431. }
  432. });
  433. $('#rationSearchKeyword').keyup(function () {
  434. let keyword = $('#rationSearchKeyword').val();
  435. if(keyword === ''){
  436. if($('#rationSearchResult').is(':visible')){
  437. $('#rationSearchResult').hide();
  438. $(".main-data-side-search", $('#rationSearchResult')).height(0);
  439. switchRationSearchMode(0);
  440. autoFlashHeight();
  441. rationLibObj.refreshSpread();
  442. }
  443. }
  444. });
  445. //变换搜索本定额、全部定额状态
  446. function switchRationSearchMode(mode) {
  447. //搜索本定额
  448. if(mode === 0){
  449. $('#curRationLib').removeClass('btn-light');
  450. $('#curRationLib').addClass('btn-secondary');
  451. $('#allRationLibs').removeClass('btn-secondary');
  452. $('#allRationLibs').addClass('btn-light');
  453. } else {//搜索全部定额
  454. $('#allRationLibs').removeClass('btn-light');
  455. $('#allRationLibs').addClass('btn-secondary');
  456. $('#curRationLib').removeClass('btn-secondary');
  457. $('#curRationLib').addClass('btn-light');
  458. }
  459. }
  460. //搜索本定额
  461. $('#curRationLib').click(function () {
  462. if($(this).hasClass('btn-secondary')){
  463. return;
  464. }
  465. switchRationSearchMode(0);
  466. $('#rationSearch').click();
  467. });
  468. //搜索全部定额
  469. $('#allRationLibs').click(function () {
  470. if($(this).hasClass('btn-secondary')){
  471. return;
  472. }
  473. switchRationSearchMode(1);
  474. $('#rationSearch').click();
  475. });
  476. //搜索
  477. $('#rationSearch').click(function () {
  478. var keyword = $('#rationSearchKeyword').val();
  479. if(keyword === ''){
  480. if($('#rationSearchResult').is(':visible')){
  481. $('#rationSearchResult').hide();
  482. $(".main-data-side-search", $('#rationSearchResult')).height(0);
  483. autoFlashHeight();
  484. rationLibObj.refreshSpread();
  485. }
  486. return;
  487. }
  488. //获取搜索定额的库:本库/所有库
  489. let rationLibIDs = [];
  490. if($('#curRationLib').hasClass('btn-secondary')){
  491. rationLibIDs.push($('#stdRationLibSelect').val());
  492. } else {
  493. for(let lib of projectInfoObj.projectInfo.engineeringInfo.ration_lib){
  494. rationLibIDs.push(lib.id);
  495. }
  496. }
  497. let bindContextmenuOpr = function (sheet) {
  498. $.contextMenu({
  499. selector: '#rationSearchResult',
  500. build: function($triggerElement, e){
  501. //控制允许右键菜单在哪个位置出现
  502. let offset = $('.main-data-side-search').offset(),
  503. x = e.pageX - offset.left,
  504. y = e.pageY - offset.top;
  505. let target = sheet.hitTest(x, y);
  506. if(target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){//在表格内
  507. sheet.setActiveCell(target.row, target.col);
  508. return {
  509. callback: function(){},
  510. items: {
  511. "locate": {
  512. name: "定位至章节",
  513. disabled: function () {
  514. return target.row >= rationLibObj.resultCache.length;
  515. },
  516. icon: "fa-arrow-left",
  517. callback: function (key, opt) {
  518. let data = rationLibObj.resultCache[target.row];
  519. $('#rationSearchResult').hide();
  520. $(".main-data-side-search", $('#rationSearchResult')).height(0);
  521. autoFlashHeight();
  522. rationLibObj.refreshSpread();
  523. switchRationSearchMode(0);
  524. if($('#stdRationLibSelect').select().val() != data.rationRepId){
  525. let libOpts = $('#stdRationLibSelect').find('option');
  526. for(let libOpt of libOpts){
  527. if($(libOpt).val() == data.rationRepId){
  528. $(libOpt).prop('selected', 'selected');
  529. break;
  530. }
  531. }
  532. $('#stdRationLibSelect').change();
  533. rationLibObj.doAfterGetRationTree = function () {
  534. this.locateAtRation(data.rationRepId, data.code);
  535. this.doAfterGetRationTree = null;
  536. };
  537. } else {
  538. rationLibObj.locateAtRation(data.rationRepId, data.code);
  539. }
  540. }}
  541. }
  542. };
  543. }
  544. else{
  545. return false;
  546. }
  547. }
  548. });
  549. };
  550. var showResult = function (result) {
  551. rationLibObj.resultCache = result;
  552. if(!rationLibObj.resultSpread){
  553. let resultSpread = SheetDataHelper.createNewSpread($('.main-data-side-search')[0]);
  554. rationLibObj.resultSpread = resultSpread;
  555. bindContextmenuOpr(resultSpread.getActiveSheet());
  556. SheetDataHelper.loadSheetHeader(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet());
  557. resultSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, rationLibObj.onRationSpreadCellDoubleClick);
  558. }else {
  559. rationLibObj.resultSpread.refresh();
  560. }
  561. SheetDataHelper.loadSheetData(rationLibObj.sectionRationsSetting, rationLibObj.resultSpread.getActiveSheet(), result);
  562. rationLibObj.setTagForHint(rationLibObj.resultSpread.getActiveSheet(), result);
  563. };
  564. $.bootstrapLoading.start();
  565. CommonAjax.post('/complementaryRation/api/findRation', {'user_id': userID, 'rationRepId': rationLibIDs, 'keyword': keyword}, function (result) {
  566. //sort
  567. result.sort(function (a, b) {
  568. let rst = 0;
  569. if(a.code > b.code) rst = 1;
  570. else if(a.code < b.code) rst = -1;
  571. return rst;
  572. });
  573. var resultObj = $('#rationSearchResult');
  574. $('#rationSearchCount').text(`搜索结果:${result.length.toString()}`);
  575. $('a', result).unbind('click');
  576. $('a', resultObj).bind('click', function () {
  577. switchRationSearchMode(0);
  578. resultObj.hide();
  579. $(".main-data-side-search", resultObj).height(0);
  580. autoFlashHeight();
  581. rationLibObj.refreshSpread();
  582. });
  583. resultObj.show();
  584. $(".main-data-side-search", resultObj).height($(window).height() - $(".header").height() - $(".toolsbar").height() - 64);
  585. showResult(result);
  586. $.bootstrapLoading.end();
  587. }, function () {
  588. $.bootstrapLoading.end();
  589. });
  590. });