std_ration_lib.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  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. "showHint": true,
  312. "head":{
  313. "titleNames":["名称"],
  314. "spanCols":[1],
  315. "spanRows":[1],
  316. "vAlign":[1],
  317. "hAlign":[1],
  318. "font":["Arial"]
  319. },
  320. "data":{
  321. "field":"name",
  322. "vAlign":1,
  323. "hAlign":0,
  324. "font":"Arial"
  325. }
  326. }, {
  327. "width":55,
  328. "readOnly":true,
  329. "head":{
  330. "titleNames":["单位"],
  331. "spanCols":[1],
  332. "spanRows":[1],
  333. "vAlign":[1],
  334. "hAlign":[1],
  335. "font":["Arial"]
  336. },
  337. "data":{
  338. "field":"unit",
  339. "vAlign":1,
  340. "hAlign":1,
  341. "font":"Arial"
  342. }
  343. }, {
  344. "width":60,
  345. "readOnly":true,
  346. "head":{
  347. "titleNames":["基价"],
  348. "spanCols":[1],
  349. "spanRows":[1],
  350. "vAlign":[1],
  351. "hAlign":[1],
  352. "font":["Arial"]
  353. },
  354. "data":{
  355. "field":"basePrice",
  356. "vAlign":1,
  357. "hAlign":2,
  358. "font":"Arial"
  359. }
  360. }]
  361. },
  362. getStdRationLibIDs: function () {
  363. let ids = [];
  364. if(projectInfoObj.projectInfo.engineeringInfo.ration_lib.length === 0){
  365. alert('当前项目无定额库,请添加定额库。');
  366. return null;
  367. }
  368. for(let rationLib of projectInfoObj.projectInfo.engineeringInfo.ration_lib){
  369. ids.push(rationLib.id);
  370. }
  371. return ids;
  372. },
  373. getCurrentStdRationLibID:function () {
  374. if(projectInfoObj.projectInfo.engineeringInfo.ration_lib.length === 0){
  375. alert('当前项目无定额库,请添加定额库。');
  376. return null;
  377. }
  378. if($('#stdRationLibSelect').val()){
  379. return parseInt($('#stdRationLibSelect').val());
  380. }else {
  381. return projectInfoObj.projectInfo.engineeringInfo.ration_lib[0].id;
  382. }
  383. },
  384. getFirstStdRationLibID: function () {
  385. if(projectInfoObj.projectInfo.engineeringInfo.ration_lib.length === 0){
  386. alert('当前项目无定额库,请添加定额库。');
  387. return null;
  388. }
  389. return parseInt(projectInfoObj.projectInfo.engineeringInfo.ration_lib[0].id);
  390. },
  391. getDefaultStdRationLibID:function(){
  392. let ration_lib = projectInfoObj.projectInfo.engineeringInfo.ration_lib;
  393. if(ration_lib.length === 0){
  394. alert('当前项目无定额库,请添加定额库。');
  395. return null;
  396. }
  397. let defaultLib = _.find(ration_lib,{'isDefault':true});
  398. let libID = defaultLib?defaultLib.id:ration_lib[0].id;
  399. return parseInt(libID);
  400. }
  401. };
  402. addEventOnResize(rationLibObj.refreshSettingForHint);
  403. //赋初始高度
  404. if($('#stdRationChapter').height() === 0 || $('#stdSectionRations').height() === 0){
  405. $('#stdRationChapter').height($(window).height()-$(".header").height()-$(".toolsbar").height()-$(".tools-bar-height-q").height()-312);
  406. $('#stdSectionRations').height(270);
  407. }
  408. $('#stdRationTab').bind('click', function () {
  409. if(!projectReadOnly){
  410. var select = $('#stdRationLibSelect');
  411. rationLibObj.checkSpread();
  412. if (select[0].options.length === 0) {
  413. rationLibObj.loadStdRationLibs();
  414. rationLibObj.loadStdRationContextMenu();
  415. };
  416. }
  417. });
  418. $('#stdRationLibSelect').change(function () {
  419. var select = $(this);
  420. if (this.children.length !== 0) {
  421. let rationLibId = select.val();
  422. sessionStorage.setItem('stdRationLib', rationLibId);
  423. sessionStorage.removeItem('stdRationLibExpState');
  424. rationLibObj.loadStdRation(rationLibId);
  425. }
  426. });
  427. //回车键搜索
  428. $('#rationSearchKeyword').bind('keypress', function (event) {
  429. if(event.keyCode === 13){
  430. $(this).blur();
  431. $('#rationSearch').click();
  432. }
  433. });
  434. $('#rationSearchKeyword').keyup(function () {
  435. let keyword = $('#rationSearchKeyword').val();
  436. if(keyword === ''){
  437. if($('#rationSearchResult').is(':visible')){
  438. $('#rationSearchResult').hide();
  439. $(".main-data-side-search", $('#rationSearchResult')).height(0);
  440. switchRationSearchMode(0);
  441. autoFlashHeight();
  442. rationLibObj.refreshSpread();
  443. }
  444. }
  445. });
  446. //变换搜索本定额、全部定额状态
  447. function switchRationSearchMode(mode) {
  448. //搜索本定额
  449. if(mode === 0){
  450. $('#curRationLib').removeClass('btn-light');
  451. $('#curRationLib').addClass('btn-secondary');
  452. $('#allRationLibs').removeClass('btn-secondary');
  453. $('#allRationLibs').addClass('btn-light');
  454. } else {//搜索全部定额
  455. $('#allRationLibs').removeClass('btn-light');
  456. $('#allRationLibs').addClass('btn-secondary');
  457. $('#curRationLib').removeClass('btn-secondary');
  458. $('#curRationLib').addClass('btn-light');
  459. }
  460. }
  461. //搜索本定额
  462. $('#curRationLib').click(function () {
  463. if($(this).hasClass('btn-secondary')){
  464. return;
  465. }
  466. switchRationSearchMode(0);
  467. $('#rationSearch').click();
  468. });
  469. //搜索全部定额
  470. $('#allRationLibs').click(function () {
  471. if($(this).hasClass('btn-secondary')){
  472. return;
  473. }
  474. switchRationSearchMode(1);
  475. $('#rationSearch').click();
  476. });
  477. //搜索
  478. $('#rationSearch').click(function () {
  479. var keyword = $('#rationSearchKeyword').val();
  480. if(keyword === ''){
  481. if($('#rationSearchResult').is(':visible')){
  482. $('#rationSearchResult').hide();
  483. $(".main-data-side-search", $('#rationSearchResult')).height(0);
  484. autoFlashHeight();
  485. rationLibObj.refreshSpread();
  486. }
  487. return;
  488. }
  489. //获取搜索定额的库:本库/所有库
  490. let rationLibIDs = [];
  491. if($('#curRationLib').hasClass('btn-secondary')){
  492. rationLibIDs.push($('#stdRationLibSelect').val());
  493. } else {
  494. for(let lib of projectInfoObj.projectInfo.engineeringInfo.ration_lib){
  495. rationLibIDs.push(lib.id);
  496. }
  497. }
  498. let bindContextmenuOpr = function (sheet) {
  499. $.contextMenu({
  500. selector: '#rationSearchResult',
  501. build: function($triggerElement, e){
  502. //控制允许右键菜单在哪个位置出现
  503. let offset = $('.main-data-side-search').offset(),
  504. x = e.pageX - offset.left,
  505. y = e.pageY - offset.top;
  506. let target = sheet.hitTest(x, y);
  507. if(target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){//在表格内
  508. sheet.setActiveCell(target.row, target.col);
  509. return {
  510. callback: function(){},
  511. items: {
  512. "locate": {
  513. name: "定位至章节",
  514. disabled: function () {
  515. return target.row >= rationLibObj.resultCache.length;
  516. },
  517. icon: "fa-arrow-left",
  518. callback: function (key, opt) {
  519. let data = rationLibObj.resultCache[target.row];
  520. $('#rationSearchResult').hide();
  521. $(".main-data-side-search", $('#rationSearchResult')).height(0);
  522. autoFlashHeight();
  523. rationLibObj.refreshSpread();
  524. switchRationSearchMode(0);
  525. if($('#stdRationLibSelect').select().val() != data.rationRepId){
  526. let libOpts = $('#stdRationLibSelect').find('option');
  527. for(let libOpt of libOpts){
  528. if($(libOpt).val() == data.rationRepId){
  529. $(libOpt).prop('selected', 'selected');
  530. break;
  531. }
  532. }
  533. $('#stdRationLibSelect').change();
  534. rationLibObj.doAfterGetRationTree = function () {
  535. this.locateAtRation(data.rationRepId, data.code);
  536. this.doAfterGetRationTree = null;
  537. };
  538. } else {
  539. rationLibObj.locateAtRation(data.rationRepId, data.code);
  540. }
  541. }}
  542. }
  543. };
  544. }
  545. else{
  546. return false;
  547. }
  548. }
  549. });
  550. };
  551. var showResult = function (result) {
  552. rationLibObj.resultCache = result;
  553. if(!rationLibObj.resultSpread){
  554. let resultSpread = SheetDataHelper.createNewSpread($('.main-data-side-search')[0]);
  555. rationLibObj.resultSpread = resultSpread;
  556. bindContextmenuOpr(resultSpread.getActiveSheet());
  557. SheetDataHelper.loadSheetHeader(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet());
  558. resultSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, rationLibObj.onRationSpreadCellDoubleClick);
  559. }else {
  560. rationLibObj.resultSpread.refresh();
  561. }
  562. SheetDataHelper.loadSheetData(rationLibObj.sectionRationsSetting, rationLibObj.resultSpread.getActiveSheet(), result);
  563. rationLibObj.setTagForHint(rationLibObj.resultSpread.getActiveSheet(), result);
  564. };
  565. $.bootstrapLoading.start();
  566. CommonAjax.post('/complementaryRation/api/findRation', {'user_id': userID, 'rationRepId': rationLibIDs, 'keyword': keyword}, function (result) {
  567. //sort
  568. result.sort(function (a, b) {
  569. let rst = 0;
  570. if(a.code > b.code) rst = 1;
  571. else if(a.code < b.code) rst = -1;
  572. return rst;
  573. });
  574. var resultObj = $('#rationSearchResult');
  575. $('#rationSearchCount').text(`搜索结果:${result.length.toString()}`);
  576. $('a', result).unbind('click');
  577. $('a', resultObj).bind('click', function () {
  578. switchRationSearchMode(0);
  579. resultObj.hide();
  580. $(".main-data-side-search", resultObj).height(0);
  581. autoFlashHeight();
  582. rationLibObj.refreshSpread();
  583. });
  584. resultObj.show();
  585. $(".main-data-side-search", resultObj).height($(window).height() - $(".header").height() - $(".toolsbar").height() - 64);
  586. showResult(result);
  587. $.bootstrapLoading.end();
  588. }, function () {
  589. $.bootstrapLoading.end();
  590. });
  591. });