std_billsGuidance_lib.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Zhong
  6. * @date 2018/6/11
  7. * @version
  8. */
  9. const billsGuidance = (function () {
  10. const libSel = $('#stdBillsGuidanceLibSelect');
  11. //工作内容
  12. let stdBillsJobData = [];
  13. //项目特征
  14. let stdBillsFeatureData = [];
  15. const bills = {
  16. dom: $('#billsGuidance_bills'),
  17. workBook: null,
  18. cache: [],
  19. tree: null,
  20. controller: null,
  21. treeSetting: {
  22. treeCol: 0,
  23. emptyRows: 0,
  24. headRows: 1,
  25. headRowHeight: [40],
  26. defaultRowHeight: 21,
  27. cols: [{
  28. width: 160,
  29. readOnly: true,
  30. head: {
  31. titleNames: ["项目编码"],
  32. spanCols: [1],
  33. spanRows: [1],
  34. vAlign: [1],
  35. hAlign: [1],
  36. font: ["Arial"]
  37. },
  38. data: {
  39. field: "code",
  40. vAlign: 1,
  41. hAlign: 0,
  42. font: "Arial"
  43. }
  44. }, {
  45. width: 220,
  46. readOnly: true,
  47. head: {
  48. titleNames: ["项目名称"],
  49. spanCols: [1],
  50. spanRows: [1],
  51. vAlign: [1],
  52. hAlign: [1],
  53. font: ["Arial"]
  54. },
  55. data: {
  56. field: "name",
  57. vAlign: 1,
  58. hAlign: 0,
  59. font: "Arial"
  60. }
  61. },
  62. {
  63. width: 45,
  64. readOnly: true,
  65. head: {
  66. titleNames: ["计量单位"],
  67. spanCols: [1],
  68. spanRows: [1],
  69. vAlign: [1],
  70. hAlign: [1],
  71. font: ["Arial"]
  72. },
  73. data: {
  74. field: "unit",
  75. vAlign: 1,
  76. hAlign: 1,
  77. font: "Arial"
  78. }
  79. }
  80. ]
  81. },
  82. headers: [
  83. {name: '项目编码', dataCode: 'code', width: 160, vAlign: 'center', hAlign: 'left', formatter: '@'},
  84. {name: '项目名称', dataCode: 'name', width: 220, vAlign: 'center', hAlign: 'left', formatter: '@'},
  85. {name: '单位', dataCode: 'unit', width: 45, vAlign: 'center', hAlign: 'center', formatter: '@'},
  86. ],
  87. events: {
  88. SelectionChanging: function (sender, info) {
  89. billsInitSel(info.newSelections[0].row);
  90. },
  91. CellDoubleClick: function (sender, args) {
  92. if(!bills.tree){
  93. return;
  94. }
  95. let node = bills.tree.items[args.row];
  96. if(!node){
  97. return;
  98. }
  99. if(node.children.length === 0){
  100. //插入清单
  101. let insert = billsLibObj.insertBills(stdBillsJobData, stdBillsFeatureData, node);
  102. if(insert){
  103. //插入选中的定额
  104. let addRationDatas = getInsertRationData(getCheckedRows());
  105. insertRations(addRationDatas);
  106. }
  107. }
  108. else {
  109. node.setExpanded(!node.expanded);
  110. //设置展开收起状态
  111. sessionStorage.setItem('stdBillsGuidanceExpState', bills.tree.getExpState(bills.tree.items));
  112. renderSheetFunc(args.sheet, function () {
  113. let iCount = node.posterityCount(), i, child;
  114. for (i = 0; i < iCount; i++) {
  115. child = bills.tree.items[args.row + i + 1];
  116. args.sheet.setRowVisible(args.row + i + 1, child.visible, args.sheetArea);
  117. }
  118. args.sheet.invalidateLayout();
  119. });
  120. args.sheet.repaint();
  121. }
  122. }
  123. }
  124. };
  125. //项目指引类型
  126. const itemType = {
  127. job: 0,
  128. ration: 1
  129. };
  130. const guideItem = {
  131. dom: $('#billsGuidance_items'),
  132. workBook: null,
  133. tree: null,
  134. controller: null,
  135. treeSetting: {
  136. treeCol: 0,
  137. emptyRows: 0,
  138. headRows: 1,
  139. headRowHeight: [40],
  140. defaultRowHeight: 21,
  141. cols: [{
  142. width: 420,
  143. readOnly: false,
  144. head: {
  145. titleNames: ["项目指引"],
  146. spanCols: [1],
  147. spanRows: [1],
  148. vAlign: [1],
  149. hAlign: [1],
  150. font: ["Arial"]
  151. },
  152. data: {
  153. field: "name",
  154. vAlign: 1,
  155. hAlign: 0,
  156. font: "Arial"
  157. }
  158. },
  159. {
  160. width: 35,
  161. readOnly: false,
  162. head: {
  163. titleNames: ["选择"],
  164. spanCols: [1],
  165. spanRows: [1],
  166. vAlign: [1],
  167. hAlign: [1],
  168. font: ["Arial"]
  169. },
  170. data: {
  171. field: "select",
  172. vAlign: 1,
  173. hAlign: 1,
  174. font: "Arial"
  175. }
  176. }
  177. ]
  178. },
  179. headers: [
  180. {name: '项目指引', dataCode: 'name', width: 300, vAlign: 'center', hAlign: 'left', formatter: '@'},
  181. {name: '选择', dataCode: 'select', width: 35, vAlign: 'center', hAlign: 'center', formatter: '@'},
  182. ],
  183. events: {
  184. EditStarting: function (sender, args) {
  185. if(!bills.tree || guideItem.headers[args.col]['dataCode'] === 'name'){
  186. args.cancel = true;
  187. }
  188. },
  189. ButtonClicked: function (sender, args) {
  190. if(args.sheet.isEditing()){
  191. args.sheet.endEdit(true);
  192. }
  193. },
  194. CellDoubleClick: function (sender, args) {
  195. if(!bills.tree || !bills.tree.selected){
  196. return;
  197. }
  198. let node = bills.tree.selected.guidance.tree.selected;
  199. if(!node){
  200. return;
  201. }
  202. if(node.children.length === 0){
  203. if(guideItem.headers[args.col]['dataCode'] === 'name'){
  204. insertRations(getInsertRationData([args.row]));
  205. }
  206. }
  207. else {
  208. node.setExpanded(!node.expanded);
  209. renderSheetFunc(args.sheet, function () {
  210. let iCount = node.posterityCount(), i, child;
  211. for (i = 0; i < iCount; i++) {
  212. child = bills.tree.selected.guidance.tree.items[args.row + i + 1];
  213. args.sheet.setRowVisible(args.row + i + 1, child.visible, args.sheetArea);
  214. }
  215. args.sheet.invalidateLayout();
  216. });
  217. args.sheet.repaint();
  218. }
  219. }
  220. }
  221. };
  222. const options = {
  223. workBook: {
  224. tabStripVisible: false,
  225. allowContextMenu: false,
  226. allowCopyPasteExcelStyle : false,
  227. allowExtendPasteRange: false,
  228. allowUserDragDrop : false,
  229. allowUserDragFill: false,
  230. scrollbarMaxAlign : true
  231. },
  232. sheet: {
  233. protectionOptions: {allowResizeRows: true, allowResizeColumns: true},
  234. clipBoardOptions: GC.Spread.Sheets.ClipboardPasteOptions.values
  235. }
  236. };
  237. //渲染时方法,停止渲染
  238. //@param {Object}sheet {Function}func @return {void}
  239. function renderSheetFunc(sheet, func){
  240. sheet.suspendEvent();
  241. sheet.suspendPaint();
  242. if(func){
  243. func();
  244. }
  245. sheet.resumeEvent();
  246. sheet.resumePaint();
  247. }
  248. //设置表选项
  249. //@param {Object}workBook {Object}opts @return {void}
  250. function setOptions (workBook, opts) {
  251. for(let opt in opts.workBook){
  252. workBook.options[opt] = opts.workBook[opt];
  253. }
  254. for(let opt in opts.sheet){
  255. workBook.getActiveSheet().options[opt] = opts.sheet[opt];
  256. }
  257. }
  258. //建表头
  259. //@param {Object}sheet {Array}headers @return {void}
  260. function buildHeader(sheet, headers) {
  261. let fuc = function () {
  262. sheet.setColumnCount(headers.length);
  263. sheet.setRowHeight(0, 40, GC.Spread.Sheets.SheetArea.colHeader);
  264. for(let i = 0, len = headers.length; i < len; i++){
  265. sheet.setValue(0, i, headers[i].name, GC.Spread.Sheets.SheetArea.colHeader);
  266. sheet.setColumnWidth(i, headers[i].width, GC.Spread.Sheets.SheetArea.colHeader);
  267. if(headers[i].formatter){
  268. sheet.setFormatter(-1, i, headers[i].formatter);
  269. }
  270. sheet.getRange(-1, i, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[headers[i]['hAlign']]);
  271. sheet.getRange(-1, i, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[headers[i]['vAlign']]);
  272. }
  273. };
  274. renderSheetFunc(sheet, fuc);
  275. }
  276. //表监听事件
  277. //@param {Object}workBook @return {void}
  278. function bindEvent(workBook, events) {
  279. if(Object.keys(events).length === 0){
  280. return;
  281. }
  282. const Events = GC.Spread.Sheets.Events;
  283. for(let event in events){
  284. workBook.bind(Events[event], events[event]);
  285. }
  286. }
  287. //建表
  288. //@param {Object}module @return {void}
  289. function buildSheet(module) {
  290. if(!module.workBook){
  291. module.workBook = new GC.Spread.Sheets.Workbook(module.dom[0], {sheetCount: 1});
  292. let sheet = module.workBook.getActiveSheet();
  293. if(module === bills){
  294. //默认初始可控制焦点在清单表中
  295. module.workBook.focus();
  296. sheet.options.isProtected = true;
  297. sheet.name('stdBillsGuidance_bills');
  298. }
  299. if(module === guideItem){
  300. sheet.options.isProtected = true;
  301. sheet.getRange(-1, 1, -1, 1).locked(false);
  302. sheet.getRange(-1, 0, -1, 1).locked(true);
  303. }
  304. setOptions(module.workBook, options);
  305. buildHeader(module.workBook.getActiveSheet(), module.headers);
  306. bindEvent(module.workBook, module.events);
  307. }
  308. }
  309. //清空表数据
  310. //@param {Object}sheet {Array}headers {Number}rowCount @return {void}
  311. function cleanData(sheet, headers, rowCount){
  312. renderSheetFunc(sheet, function () {
  313. sheet.clear(-1, 0, -1, headers.length, GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
  314. if (rowCount > 0) {
  315. sheet.setRowCount(rowCount);
  316. }
  317. });
  318. }
  319. //初始化各工作表
  320. //@param {Array}modules @return {void}
  321. function initWorkBooks(modules){
  322. for(let module of modules){
  323. buildSheet(module);
  324. }
  325. }
  326. //初始化并输出树
  327. //@param {Object}module {Object}sheet {Object}treeSetting {Array}datas
  328. function initTree(module, sheet, treeSetting, datas){
  329. module.tree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: true});
  330. module.controller = TREE_SHEET_CONTROLLER.createNew(module.tree, sheet, treeSetting);
  331. module.tree.loadDatas(datas);
  332. if(module === bills){
  333. initExpandStat();
  334. }
  335. module.controller.showTreeData();
  336. }
  337. //项目指引表焦点控制
  338. //@param {Number}row @return {void}
  339. function guideItemInitSel(row){
  340. let billsNode = bills.tree.selected;
  341. let node = null;
  342. if(billsNode && billsNode.guidance.tree){
  343. node = billsNode.guidance.tree.items[row];
  344. if(node){
  345. billsNode.guidance.tree.selected = node;
  346. }
  347. }
  348. }
  349. //根据项目指引的类型设置单元格类型,定额类型的项目指引为复选框
  350. //@param {Array}nodes @return {void}
  351. function setItemCellType(nodes){
  352. //设置单元格类型
  353. const base = new GC.Spread.Sheets.CellTypes.Base();
  354. const checkBox = new GC.Spread.Sheets.CellTypes.CheckBox();
  355. const sheet = guideItem.workBook.getActiveSheet();
  356. renderSheetFunc(sheet, function(){
  357. for(let node of nodes){
  358. sheet.setCellType(node.serialNo(), 1, node.data.type === itemType.ration ? checkBox : base);
  359. }
  360. });
  361. }
  362. //清单表焦点控制
  363. //@param {Number}row @return {void}
  364. function billsInitSel(row){
  365. if(!bills.tree){
  366. return;
  367. }
  368. let guideSheet = guideItem.workBook.getActiveSheet();
  369. cleanData(guideSheet, guideItem.headers, -1);
  370. let node = bills.tree.items[row];
  371. if(!node){
  372. return;
  373. }
  374. bills.tree.selected = node;
  375. if(!node.guidance.tree){
  376. CommonAjax.post('/billsGuidance/api/getItemsByBills', {guidanceLibID: libSel.val(), billsID: node.getID()}, function (rstData) {
  377. initTree(node.guidance, guideSheet, guideItem.treeSetting, rstData);
  378. setItemCellType(node.guidance.tree.items);
  379. //项目指引初始焦点
  380. guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
  381. });
  382. }
  383. else{
  384. node.guidance.controller.showTreeData();
  385. setItemCellType(node.guidance.tree.items);
  386. //项目指引初始焦点
  387. guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
  388. }
  389. }
  390. //初始化清单的工作内容和项目特征
  391. //@param {Number}billsLibId @return {void}
  392. function initJobAndCharacter(billsLibId){
  393. CommonAjax.post('/stdBillsEditor/getJobContent', {userId: userID, billsLibId: billsLibId}, function (datas) {
  394. stdBillsJobData = datas;
  395. });
  396. CommonAjax.post('/stdBillsEditor/getItemCharacter', {userId: userID, billsLibId: billsLibId}, function (datas) {
  397. stdBillsFeatureData = datas;
  398. });
  399. }
  400. //初始化清单展开收起状态
  401. //@return {void}
  402. function initExpandStat(){
  403. //读取展开收起状态
  404. let currentExpState = sessionStorage.getItem('stdBillsGuidanceExpState');
  405. if(currentExpState){
  406. bills.tree.setExpandedByState(bills.tree.items, currentExpState);
  407. }
  408. //非叶子节点默认收起
  409. else{
  410. bills.tree.setRootExpanded(bills.tree.roots, false);
  411. }
  412. }
  413. //初始选择清单指引库
  414. //@param {Number}libID @return {void}
  415. function libInitSel(libID){
  416. //获取清单
  417. CommonAjax.post('/billsGuidance/api/getLibWithBills', {libID: libID}, function(rstData){
  418. //获取清单库中的工作内容和项目特征
  419. initJobAndCharacter(rstData.guidanceLib.billsLibId);
  420. initTree(bills, bills.workBook.getActiveSheet(), bills.treeSetting, rstData.bills);
  421. //每一棵项目指引树挂在清单节点上
  422. for(let node of bills.tree.items){
  423. node.guidance = {tree: null, controller: null};
  424. }
  425. //默认初始节点
  426. billsInitSel(0);
  427. });
  428. }
  429. //初始化清单指引库
  430. //@param {Array}libDats @return {void}
  431. function initLibs(libDatas){
  432. libSel.empty();
  433. if(!libDatas){
  434. return;
  435. }
  436. let selectedLib = sessionStorage.getItem('stdBillsGuidance');
  437. for(let libData of libDatas){
  438. let opt = $('<option>').val(libData.id).text(libData.name);
  439. if(selectedLib && libData.id == selectedLib){
  440. opt.attr('selected', 'selected');
  441. }
  442. libSel.append(opt);
  443. }
  444. //初始默认选择
  445. libInitSel(libSel.select().val());
  446. }
  447. //初始化视图
  448. //@param {void} @return {void}
  449. function initViews(){
  450. //赋初始高度
  451. if($('#billsGuidance_bills').height() === 0 || $('#billsGuidance_items').height() === 0){
  452. let height = $(window).height()-$(".header").height()-$(".toolsbar").height()-$(".tools-bar-height-z").height();
  453. $('#billsGuidance_bills').height(height / 2);
  454. $('#billsGuidance_items').height(height / 2);
  455. }
  456. let modules = [bills, guideItem];
  457. initWorkBooks(modules);
  458. }
  459. //获取选中的行
  460. //@return {Array}
  461. function getCheckedRows(){
  462. let rst = [];
  463. let itemSheet = guideItem.workBook.getActiveSheet();
  464. for(let row = 0; row < itemSheet.getRowCount(); row++){
  465. let rowV = itemSheet.getValue(row, 1);
  466. if(rowV){
  467. rst.push(row);
  468. }
  469. }
  470. return rst;
  471. }
  472. //获取选中的定额数据
  473. //@param {Array}rows @return {Array}
  474. function getInsertRationData(rows){
  475. let rst = [];
  476. for(let row of rows){
  477. let node = bills.tree.selected.guidance.tree.items[row];
  478. if(node && node.data.type === itemType.ration){
  479. rst.push({itemQuery: {userID: userID, ID: node.data.rationID}, rationType: rationType.ration});
  480. }
  481. }
  482. return rst;
  483. }
  484. //插入定额
  485. //@return {void}
  486. function insertRations(addRationDatas){
  487. if(addRationDatas.length > 0){
  488. projectObj.project.Ration.addMultiRation(addRationDatas, function () {
  489. //恢复
  490. let sheet = guideItem.workBook.getActiveSheet();
  491. renderSheetFunc(sheet, function () {
  492. for(let row = 0; row < sheet.getRowCount(); row++){
  493. if(sheet.getValue(row, 1)){
  494. sheet.setValue(row, 1, false);
  495. }
  496. }
  497. });
  498. });
  499. }
  500. }
  501. //展开至搜索出来点的节点
  502. //@param {Array}nodes @return {void}
  503. function expandSearchNodes(nodes){
  504. let that = this;
  505. let billsSheet = bills.workBook.getActiveSheet();
  506. renderSheetFunc(billsSheet, function () {
  507. function expParentNode(node){
  508. if(node.parent && !node.parent.expanded){
  509. node.parent.setExpanded(true);
  510. expParentNode(node.parent);
  511. }
  512. }
  513. for(let node of nodes){
  514. expParentNode(node);
  515. }
  516. TREE_SHEET_HELPER.refreshTreeNodeData(bills.treeSetting, billsSheet, bills.tree.roots, true);
  517. TREE_SHEET_HELPER.refreshNodesVisible(bills.tree.roots, billsSheet, true);
  518. });
  519. }
  520. //各按钮监听事件
  521. //@return {void}
  522. function bindBtn(){
  523. //打开清单指引库
  524. $('#stdBillsGuidanceTab').click(function () {
  525. if(libSel.children().length === 0){
  526. initLibs(projectInfoObj.projectInfo.engineeringInfo.billsGuidance_lib);
  527. }
  528. });
  529. //更改清单指引库
  530. $('#stdBillsGuidanceLibSelect').change(function () {
  531. //关闭搜索窗口
  532. $('#billsGuidanceSearchResult').hide();
  533. billsLibObj.clearHighLight(bills.workBook);
  534. libInitSel($(this).select().val());
  535. //记住选项
  536. sessionStorage.setItem('stdBillsGuidance', $(this).select().val());
  537. //清除展开收起状态sessionStorage
  538. sessionStorage.removeItem('stdBillsGuidanceExpState');
  539. });
  540. //插入定额
  541. $('#guidanceInsertRation').click(function () {
  542. let addRationDatas = getInsertRationData(getCheckedRows());
  543. insertRations(addRationDatas);
  544. });
  545. //插入清单
  546. $('#guidanceInsertBills').click(function () {
  547. //插入清单
  548. if(!bills.tree || !bills.tree.selected){
  549. return;
  550. }
  551. if(bills.tree.selected.children.length === 0){
  552. let insert = billsLibObj.insertBills(stdBillsJobData, stdBillsFeatureData, bills.tree.selected);
  553. if(insert){
  554. //插入选中的定额
  555. let addRationDatas = getInsertRationData(getCheckedRows());
  556. insertRations(addRationDatas);
  557. }
  558. }
  559. });
  560. //搜索
  561. $('#stdBillsGuidanceSearch>span>button').click(function () {
  562. if(!bills.tree){
  563. return;
  564. }
  565. let billsSheet = bills.workBook.getActiveSheet();
  566. billsLibObj.clearHighLight(bills.workBook);
  567. let keyword = $('#stdBillsGuidanceSearch>input').val();
  568. if (!keyword || keyword === '') {
  569. $('#billsGuidanceSearchResult').hide();
  570. return;
  571. }
  572. let result = bills.tree.items.filter(function (item) {
  573. let codeIs = item.data.code ? item.data.code.indexOf(keyword) !== -1 : false;
  574. let nameIs = item.data.name ? item.data.name.indexOf(keyword) !== -1 : false;
  575. return codeIs || nameIs;
  576. });
  577. result.sort(function (x, y) {
  578. return x.serialNo() - y.serialNo();
  579. });
  580. if (result.length !== 0) {
  581. //展开搜索出来的节点
  582. expandSearchNodes(result);
  583. //设置记住展开
  584. sessionStorage.setItem('stdBillsGuidanceExpState', bills.tree.getExpState(bills.tree.items));
  585. let sel = billsSheet.getSelections();
  586. bills.controller.setTreeSelected(result[0]);
  587. billsSheet.setSelection(result[0].serialNo(), sel[0].col, 1, 1);
  588. billsInitSel(result[0].serialNo());
  589. for (let node of result) {
  590. billsSheet.getRange(node.serialNo(), -1, 1, -1).backColor('lemonChiffon');
  591. }
  592. $('#nextBillsGuidance').show();
  593. $('#nextBillsGuidance').unbind('click');
  594. $('#nextBillsGuidance').bind('click', function () {
  595. let cur = bills.tree.selected, resultIndex = result.indexOf(cur), sel = billsSheet.getSelections();
  596. if (resultIndex === result.length - 1) {
  597. bills.controller.setTreeSelected(result[0]);
  598. billsSheet.setSelection(result[0].serialNo(), sel[0].col, 1, 1);
  599. billsInitSel(result[0].serialNo());
  600. billsSheet.showRow(result[0].serialNo(), GC.Spread.Sheets.VerticalPosition.bottom);
  601. } else {
  602. bills.controller.setTreeSelected(result[resultIndex + 1]);
  603. billsSheet.setSelection(result[resultIndex + 1].serialNo(), sel[0].col, 1, 1);
  604. billsInitSel(result[resultIndex + 1].serialNo());
  605. billsSheet.showRow(result[resultIndex + 1].serialNo(), GC.Spread.Sheets.VerticalPosition.bottom);
  606. }
  607. });
  608. } else {
  609. billsLibObj.clearHighLight(bills.workBook);
  610. $('#nextBillsGuidance').hide();
  611. }
  612. $('#billsGuidanceSearchResultCount').text('搜索结果:' + result.length);
  613. $('#billsGuidanceSearchResult').show();
  614. });
  615. //搜索框回车
  616. $('#stdBillsGuidanceSearch>input').bind('keypress', function (event) {
  617. if(event.keyCode === 13){
  618. $(this).blur();
  619. $('#stdBillsGuidanceSearch>span>button').click();
  620. }
  621. });
  622. // 关闭搜索结果
  623. $('#closeSearchBillsGuidance').click(function () {
  624. $('#billsGuidanceSearchResult').hide();
  625. billsLibObj.clearHighLight(bills.workBook);
  626. refreshWorkBook();
  627. });
  628. }
  629. //刷新表
  630. //@return {void}
  631. function refreshWorkBook(){
  632. if(bills.workBook){
  633. bills.workBook.refresh();
  634. }
  635. if(guideItem.workBook){
  636. guideItem.workBook.refresh();
  637. }
  638. }
  639. return {initViews, bindBtn, refreshWorkBook, bills};
  640. })();
  641. $(document).ready(function(){
  642. billsGuidance.initViews();
  643. billsGuidance.bindBtn();
  644. });