std_billsGuidance_lib.js 25 KB

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