billsGuidance.js 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Zhong
  6. * @date 2018/6/1
  7. * @version
  8. */
  9. const billsGuidance = (function () {
  10. function _isDef(v) {
  11. return typeof v !== 'undefined' && v !== null;
  12. }
  13. let moduleName = 'stdBillsGuidance';
  14. //上下拖动的拖动条高度
  15. const verticalResize = 10;
  16. //自执行函数全局变量定义
  17. const libID = getQueryString('libID');
  18. //总工作内容数据
  19. let stdBillsJobData = [];
  20. //总项目特征数据
  21. let stdBillsFeatureData = [];
  22. const bills = {
  23. dom: $('#billsSpread'),
  24. workBook: null,
  25. cache: [],
  26. tree: null,
  27. controller: null,
  28. treeSetting: {
  29. treeCol: 0,
  30. emptyRows: 0,
  31. headRows: 1,
  32. headRowHeight: [40],
  33. defaultRowHeight: 21,
  34. cols: [{
  35. width: 200,
  36. readOnly: true,
  37. showHint: true,
  38. head: {
  39. titleNames: ["项目编码"],
  40. spanCols: [1],
  41. spanRows: [1],
  42. vAlign: [1],
  43. hAlign: [1],
  44. font: ["Arial"]
  45. },
  46. data: {
  47. field: "code",
  48. vAlign: 1,
  49. hAlign: 0,
  50. font: "Arial"
  51. }
  52. }, {
  53. width: 200,
  54. readOnly: true,
  55. head: {
  56. titleNames: ["项目名称"],
  57. spanCols: [1],
  58. spanRows: [1],
  59. vAlign: [1],
  60. hAlign: [1],
  61. font: ["Arial"]
  62. },
  63. data: {
  64. field: "name",
  65. vAlign: 1,
  66. hAlign: 0,
  67. font: "Arial"
  68. }
  69. }]
  70. },
  71. headers: [
  72. {name: '项目编码', dataCode: 'code', width: 200, vAlign: 'center', hAlign: 'left', formatter: '@'},
  73. {name: '项目名称', dataCode: 'name', width: 200, vAlign: 'center', hAlign: 'left', formatter: '@'}
  74. ],
  75. events: {
  76. SelectionChanged: function (sender, info) {
  77. billsInitSel(info.newSelections[0].row);
  78. }
  79. }
  80. };
  81. //项目指引类型
  82. const itemType = {
  83. job: 0,
  84. ration: 1
  85. };
  86. //项目指引复制整块localStorage key
  87. const itemCopyBlockKey = 'guideItemCopyBlock';
  88. const updateType = {
  89. create: 'create',
  90. update: 'update',
  91. del: 'delete'
  92. };
  93. //项目指引节点状态:展开全部、收起定额
  94. const itemExpandState = {
  95. expand: 1,
  96. contract: 0
  97. };
  98. //项目指引当前节点展开收缩状态,默认展开全部
  99. let curExpandState = 1;
  100. const guideItem = {
  101. dom: $('#guideItemSpread'),
  102. workBook: null,
  103. tree: null,
  104. controller: null,
  105. treeSetting: {
  106. treeCol: 0,
  107. emptyRows: 0,
  108. headRows: 1,
  109. headRowHeight: [40],
  110. defaultRowHeight: 21,
  111. cols: [{
  112. width: 400,
  113. readOnly: false,
  114. head: {
  115. titleNames: ["项目指引"],
  116. spanCols: [1],
  117. spanRows: [1],
  118. vAlign: [1],
  119. hAlign: [1],
  120. font: ["Arial"]
  121. },
  122. data: {
  123. field: "name",
  124. vAlign: 1,
  125. hAlign: 0,
  126. font: "Arial"
  127. }
  128. }]
  129. },
  130. headers: [
  131. {name: '项目指引', dataCode: 'name', width: 400, vAlign: 'center', hAlign: 'left', formatter: '@'},
  132. ],
  133. events: {
  134. SelectionChanged: function (sender, info) {
  135. guideItemInitSel(info.newSelections[0].row)
  136. },
  137. EditEnded: function (sender, args) {
  138. edit(args.sheet, [{row: args.row, col: args.col}]);
  139. },
  140. RangeChanged: function (sender, args) {
  141. edit(args.sheet, args.changedCells);
  142. }
  143. }
  144. };
  145. //定额章节树
  146. const section = {
  147. dom: $('#sectionSpread'),
  148. workBook: null,
  149. cache: [],
  150. tree: null,
  151. controller: null,
  152. treeSetting: {
  153. treeCol: 0,
  154. emptyRows: 0,
  155. headRows: 1,
  156. headRowHeight: [40],
  157. defaultRowHeight: 21,
  158. cols: [{
  159. width: 400,
  160. readOnly: true,
  161. head: {
  162. titleNames: ["名称"],
  163. spanCols: [1],
  164. spanRows: [1],
  165. vAlign: [1],
  166. hAlign: [1],
  167. font: ["Arial"]
  168. },
  169. data: {
  170. field: "name",
  171. vAlign: 1,
  172. hAlign: 0,
  173. font: "Arial"
  174. }
  175. }]
  176. },
  177. headers: [
  178. {name: '名称', dataCode: 'name', width: 400, vAlign: 'center', hAlign: 'left', formatter: '@'},
  179. ],
  180. events: {
  181. SelectionChanged: function (sender, info) {
  182. sectionInitSel(info.newSelections[0].row)
  183. }
  184. }
  185. };
  186. const ration = {
  187. dom: $('#rationSpread'),
  188. workBook: null,
  189. datas: [],//所有的数据,搜索定额时,从所有数据中筛选
  190. cache: [],//显示在表格上的数据,添加定额可以有效根据行识别定额
  191. headers: [
  192. {name: '选择', dataCode: 'select', width: 50, vAlign: 'center', hAlign: 'center'},
  193. {name: '编码', dataCode: 'code', width: 110, vAlign: 'center', hAlign: 'left', formatter: '@'},
  194. {name: '名称', dataCode: 'name', width: 250, vAlign: 'center', hAlign: 'left', formatter: '@'},
  195. {name: '单位', dataCode: 'unit', width: 100, vAlign: 'center', hAlign: 'left', formatter: '@'}
  196. ],
  197. events: {
  198. ButtonClicked: function (sender, args) {
  199. if(args.sheet.isEditing()){
  200. args.sheet.endEdit(true);
  201. }
  202. },
  203. CellDoubleClick: function (sender, args) {
  204. if(ration.headers[args.col].dataCode === 'name'){
  205. let insertDatas = getInsertRations([args.row]);
  206. if(insertDatas.length > 0){
  207. insert(insertDatas, false);
  208. }
  209. }
  210. }
  211. }
  212. };
  213. const options = {
  214. workBook: {
  215. tabStripVisible: false,
  216. allowContextMenu: false,
  217. allowCopyPasteExcelStyle : false,
  218. allowExtendPasteRange: false,
  219. allowUserDragDrop : false,
  220. allowUserDragFill: false,
  221. scrollbarMaxAlign : true
  222. },
  223. sheet: {
  224. protectionOptions: {allowResizeRows: true, allowResizeColumns: true},
  225. clipBoardOptions: GC.Spread.Sheets.ClipboardPasteOptions.values
  226. }
  227. };
  228. //渲染时方法,停止渲染
  229. //@param {Object}sheet {Function}func @return {void}
  230. function renderSheetFunc(sheet, func){
  231. sheet.suspendEvent();
  232. sheet.suspendPaint();
  233. if(func){
  234. func();
  235. }
  236. sheet.resumeEvent();
  237. sheet.resumePaint();
  238. }
  239. //设置表选项
  240. //@param {Object}workBook {Object}opts @return {void}
  241. function setOptions (workBook, opts) {
  242. for(let opt in opts.workBook){
  243. workBook.options[opt] = opts.workBook[opt];
  244. }
  245. for(let opt in opts.sheet){
  246. workBook.getActiveSheet().options[opt] = opts.sheet[opt];
  247. }
  248. }
  249. //建表头
  250. //@param {Object}sheet {Array}headers @return {void}
  251. function buildHeader(sheet, headers) {
  252. let fuc = function () {
  253. sheet.setColumnCount(headers.length);
  254. sheet.setRowHeight(0, 40, GC.Spread.Sheets.SheetArea.colHeader);
  255. for(let i = 0, len = headers.length; i < len; i++){
  256. sheet.setValue(0, i, headers[i].name, GC.Spread.Sheets.SheetArea.colHeader);
  257. sheet.setColumnWidth(i, headers[i].width, GC.Spread.Sheets.SheetArea.colHeader);
  258. if(headers[i].formatter){
  259. sheet.setFormatter(-1, i, headers[i].formatter);
  260. }
  261. sheet.getRange(-1, i, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[headers[i]['hAlign']]);
  262. sheet.getRange(-1, i, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[headers[i]['vAlign']]);
  263. }
  264. };
  265. renderSheetFunc(sheet, fuc);
  266. }
  267. //表监听事件
  268. //@param {Object}workBook @return {void}
  269. function bindEvent(workBook, events) {
  270. if(Object.keys(events).length === 0){
  271. return;
  272. }
  273. const Events = GC.Spread.Sheets.Events;
  274. let sheet = workBook.getActiveSheet();
  275. for(let event in events){
  276. workBook.bind(Events[event], events[event]);
  277. }
  278. }
  279. //建表
  280. //@param {Object}module @return {void}
  281. function buildSheet(module) {
  282. if(!module.workBook){
  283. module.workBook = new GC.Spread.Sheets.Workbook(module.dom[0], {sheetCount: 1});
  284. let sheet = module.workBook.getActiveSheet();
  285. if(module === bills){
  286. sheet.name('stdBillsGuidance_bills');
  287. //默认初始可控制焦点在清单表中
  288. module.workBook.focus();
  289. sheet.options.isProtected = true;
  290. }
  291. else if(module === ration){
  292. sheet.options.isProtected = true;
  293. sheet.getRange(-1, 0, -1, 1).locked(false);
  294. sheet.getRange(-1, 1, -1, -1).locked(true);
  295. }
  296. else if(module === guideItem){
  297. sheetCommonObj.bindEscKey(module.workBook, [{sheet: sheet, editStarting: null, editEnded: module.events.EditEnded}]);
  298. }
  299. setOptions(module.workBook, options);
  300. buildHeader(module.workBook.getActiveSheet(), module.headers);
  301. bindEvent(module.workBook, module.events);
  302. }
  303. }
  304. //清空表数据
  305. //@param {Object}sheet {Array}headers {Number}rowCount @return {void}
  306. function cleanData(sheet, headers, rowCount){
  307. renderSheetFunc(sheet, function () {
  308. sheet.clear(-1, 0, -1, headers.length, GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
  309. if (rowCount >= 0) {
  310. sheet.setRowCount(rowCount);
  311. }
  312. });
  313. }
  314. //根据清单获取项目指引
  315. //@param {String}guidanceLibID {Number}billsID {Function}callback @return {void}
  316. function getItemsByBills(guidanceLibID, billsID, callback){
  317. CommonAjax.post('/billsGuidance/api/getItemsByBills', {guidanceLibID: guidanceLibID, billsID: billsID}, function (rstData) {
  318. if(callback){
  319. callback(rstData);
  320. }
  321. });
  322. }
  323. //清单表焦点控制
  324. //@param {Number}row @return {void}
  325. function billsInitSel(row){
  326. let guideSheet = guideItem.workBook.getActiveSheet();
  327. cleanData(guideSheet, guideItem.headers, -1);
  328. let node = bills.tree.items[row];
  329. if(!node){
  330. return;
  331. }
  332. bills.tree.selected = node;
  333. //显示备注
  334. $('.main-side-bottom').find('textarea').val(node.data.comment ? node.data.comment : '');
  335. if(!node.guidance.tree){
  336. getItemsByBills(libID, node.data.ID, function (rstData) {
  337. initTree(node.guidance, guideSheet, guideItem.treeSetting, rstData);
  338. setNodesExpandState(node.guidance.tree.items, curExpandState);
  339. renderSheetFunc(guideSheet, function () {
  340. TREE_SHEET_HELPER.refreshNodesVisible(node.guidance.tree.roots, guideSheet, true);
  341. });
  342. //设置底色
  343. setNodesColor(guideSheet, node.guidance.tree.items);
  344. //项目指引初始焦点
  345. guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
  346. });
  347. } else{
  348. setNodesExpandState(node.guidance.tree.items, curExpandState);
  349. node.guidance.controller.showTreeData();
  350. //设置底色
  351. setNodesColor(guideSheet, node.guidance.tree.items);
  352. //项目指引初始焦点
  353. guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
  354. }
  355. }
  356. //设置项目节点展开收起状态:展开全部、收起定额
  357. //@param {Array}nodes(当前清单下的所有项目指引节点) {Number}expandState(展开全部1或收起定额0).
  358. function setNodesExpandState(nodes, expandState) {
  359. if(expandState === itemExpandState.contract) {
  360. //找出所有定额的父节点
  361. let rations = _.filter(nodes, function (node) {
  362. return node.data.type === itemType.ration;
  363. });
  364. let rationParentIDs = [];
  365. for(let ration of rations){
  366. if(ration.data.ParentID != -1){
  367. rationParentIDs.push(ration.data.ParentID);
  368. }
  369. }
  370. rationParentIDs = Array.from(new Set(rationParentIDs));
  371. let rationParentNodes = _.filter(nodes, function (node) {
  372. return rationParentIDs.includes(node.data.ID);
  373. });
  374. //收起定额
  375. for(let node of rationParentNodes){
  376. node.setExpanded(false);
  377. }
  378. } else {
  379. for(let node of nodes){
  380. node.setExpanded(true);
  381. }
  382. }
  383. }
  384. //根据奇偶层级设置节点底色,奇数层为蓝色(树节点深度为偶数)
  385. //@param {Object}sheet {Array}nodes @return {void}
  386. function setNodesColor(sheet, nodes) {
  387. const color = '#DFE8F9';
  388. renderSheetFunc(sheet, function () {
  389. for(let node of nodes){
  390. let style = new GC.Spread.Sheets.Style();
  391. style.borderLeft = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  392. style.borderTop = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  393. style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  394. style.borderBottom = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  395. let nDepth = node.depth();
  396. style.backColor = nDepth % 2 == 0 && _isDef(node.data.type) && node.data.type === itemType.job ? color : 'White';
  397. sheet.setStyle(node.serialNo(), -1, style);
  398. }
  399. });
  400. }
  401. //选中的节点是否全是同层节点
  402. //@param {Object}sheet {Array}items @return {Boolean}
  403. function itemsSameDepth(sheet, items) {
  404. let sels = sheet.getSelections();
  405. if(sels.length === 0 || items.length === 0){
  406. return false;
  407. }
  408. let depths = [];
  409. for(let i = 0; i < sels[0].rowCount; i++){
  410. let row = sels[0].row + i;
  411. let node = items[row];
  412. if(node){
  413. depths.push(node.depth());
  414. }
  415. }
  416. }
  417. //节点子项是否全是工作内容
  418. //@param {Object}node @return {Boolean}
  419. function allJobChildren(node){
  420. for(let c of node.children){
  421. if(c.data.type === itemType.ration){
  422. return false;
  423. }
  424. }
  425. return true;
  426. }
  427. //节点子项是否全是定额
  428. //@param {Object}node @return {Boolean}
  429. function allRationChildren(node){
  430. for(let c of node.children){
  431. if(c.data.type === itemType.job){
  432. return false;
  433. }
  434. }
  435. return true;
  436. }
  437. //刷新按钮有效性
  438. //@param {Object}node @return {void}
  439. function refreshBtn(node){
  440. //全部设为无效
  441. $('.tools-btn').children().addClass('disabled');
  442. $('#insertRation').addClass('disabled');
  443. $('#insertAll').addClass('disabled');
  444. $('.main-bottom-content').find('textarea').attr('readonly', true);
  445. //插入
  446. if(bills.tree.selected && bills.tree.selected.guidance.tree){
  447. $('#insert').removeClass('disabled');
  448. if(node && node.data.type === itemType.ration){
  449. $('#insert').addClass('disabled');
  450. }
  451. }
  452. //删除
  453. if(node){
  454. $('#del').removeClass('disabled');
  455. }
  456. if(node && node.data.type === itemType.job){
  457. //升级
  458. if(node.parent){
  459. $('#upLevel').removeClass('disabled');
  460. if(node.nextSibling && node.children.length > 0 && !allJobChildren(node)){
  461. $('#upLevel').addClass('disabled');
  462. }
  463. }
  464. //降级
  465. if(node.preSibling){
  466. $('#downLevel').removeClass('disabled');
  467. if(node.preSibling.children.length > 0 && !allJobChildren(node.preSibling)){
  468. $('#downLevel').addClass('disabled');
  469. }
  470. }
  471. }
  472. //上移
  473. if(node && node.preSibling){
  474. $('#upMove').removeClass('disabled')
  475. }
  476. //下移
  477. if(node && node.nextSibling){
  478. $('#downMove').removeClass('disabled');
  479. }
  480. //收起定额、展开全部
  481. $('#expandContract').removeClass('disabled');
  482. //插入定额
  483. if(node && (node.children.length === 0 || allRationChildren(node))){
  484. $('#insertRation').removeClass('disabled');
  485. $('#insertAll').removeClass('disabled');
  486. }
  487. //备注,奇数节点可用
  488. if(node && (node.depth() + 1) % 2 === 1 && node.data.type !== itemType.ration){
  489. $('.main-bottom-content').find('textarea').attr('readonly', false);
  490. }
  491. }
  492. //项目指引表焦点控制
  493. //@param {Number}row @return {void}
  494. function guideItemInitSel(row){
  495. let billsNode = bills.tree.selected;
  496. let node = null;
  497. if(billsNode && billsNode.guidance.tree){
  498. node = billsNode.guidance.tree.items[row];
  499. if(node){
  500. billsNode.guidance.tree.selected = node;
  501. //显示备注
  502. $('.main-bottom-content').find('textarea').val(node.data.comment ? node.data.comment : '');
  503. }
  504. }
  505. refreshBtn(node);
  506. }
  507. //初始化当前库名
  508. //@param {String} @return {void}
  509. function initLibName(libName) {
  510. $('#libName')[0].outerHTML = $('#libName')[0].outerHTML.replace("XXX清单指引", libName);
  511. }
  512. //初始化各工作表
  513. //@param {Array}modules @return {void}
  514. function initWorkBooks(modules){
  515. for(let module of modules){
  516. buildSheet(module);
  517. }
  518. }
  519. function tipDivCheck(){
  520. setTimeout(function () {
  521. let tips = $('#autoTip');
  522. if(ration.tipDiv == 'show'){
  523. return;
  524. } else if(ration.tipDiv == 'hide'&&tips){
  525. tips.hide();
  526. ration._toolTipElement = null;
  527. }
  528. },600)
  529. }
  530. //获取悬浮提示单元格
  531. //@param {Object}sheet @return {Object}
  532. function getTipCellType(sheet) {
  533. let setting = {};
  534. let TipCellType = function () {};
  535. TipCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
  536. TipCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
  537. return {
  538. x: x,
  539. y: y,
  540. row: context.row,
  541. col: context.col,
  542. cellStyle: cellStyle,
  543. cellRect: cellRect,
  544. sheet: context.sheet,
  545. sheetArea: context.sheetArea
  546. };
  547. };
  548. TipCellType.prototype.processMouseEnter = function (hitinfo) {
  549. let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
  550. let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
  551. if(tag !== undefined && tag){
  552. text = tag;
  553. }
  554. if(sheet && sheet.getParent().qo){
  555. setting.pos = SheetDataHelper.getObjPos(sheet.getParent().qo);
  556. }
  557. let delayTimes = 500; //延时时间
  558. let now_timeStamp = +new Date();
  559. this.tipTimeStamp = now_timeStamp;
  560. let me = this;
  561. setTimeout(function () {
  562. if(now_timeStamp - me.tipTimeStamp == 0){//鼠标停下的时候才显示
  563. if (setting.pos && text && text !== '') {
  564. //固定不显示的div,存储文本获取固定div宽度,toolTipElement由于显示和隐藏,获取宽度不正确
  565. if(!me._fixedTipElement){
  566. let div = $('#fixedTip1')[0];
  567. if (!div) {
  568. div = document.createElement("div");
  569. $(div).css("padding", 5)
  570. .attr("id", 'fixedTip');
  571. $(div).hide();
  572. document.body.insertBefore(div, null);
  573. }
  574. me._fixedTipElement = div;
  575. }
  576. $(me._fixedTipElement).width('');
  577. $(me._fixedTipElement).html(text);
  578. if (!me._toolTipElement) {
  579. let div = $('#autoTip1')[0];
  580. if (!div) {
  581. div = document.createElement("div");
  582. $(div).css("position", "absolute")
  583. .css("border", "1px #C0C0C0 solid")
  584. .css("box-shadow", "1px 2px 5px rgba(0,0,0,0.4)")
  585. .css("font", "0.9rem Calibri")
  586. .css("background", "white")
  587. .css("padding", 5)
  588. .attr("id", 'autoTip1');
  589. $(div).hide();
  590. document.body.insertBefore(div, null);
  591. }
  592. me._toolTipElement = div;
  593. $(me._toolTipElement).width('');
  594. //实时读取位置信息
  595. if(hitinfo.sheet && hitinfo.sheet.getParent().qo){
  596. setting.pos = SheetDataHelper.getObjPos(hitinfo.sheet.getParent().qo);
  597. }
  598. $(me._toolTipElement).html(text);
  599. //定额库定额特殊处理
  600. if($(hitinfo.sheet.getParent().qo).attr('id') === 'rationSpread'){
  601. let divWidth = $(me._fixedTipElement).width(),
  602. divHeight = $(me._fixedTipElement).height();
  603. if(divWidth > 600){
  604. divWidth = 590;
  605. $(me._toolTipElement).width(divWidth);
  606. }
  607. let top = setting.pos.y + hitinfo.y - divHeight < 0 ? 0 : setting.pos.y + hitinfo.cellRect.y - divHeight;
  608. $(me._toolTipElement).css("top", top).css("left", setting.pos.x - divWidth);
  609. }
  610. else{
  611. $(me._toolTipElement).css("top", setting.pos.y + hitinfo.y +15).css("left", setting.pos.x + hitinfo.x + 15);
  612. }
  613. //名称
  614. if(hitinfo.col === 2){
  615. let acStyle = hitinfo.sheet.getActualStyle(hitinfo.row, hitinfo.col),
  616. zoom = hitinfo.sheet.zoom();
  617. let value = hitinfo.sheet.getValue(hitinfo.row, hitinfo.col);
  618. let textLength = me.getAutoFitWidth(value, text, acStyle, zoom, {sheet: hitinfo.sheet, row: hitinfo.row, col: hitinfo.col, sheetArea: GC.Spread.Sheets.SheetArea.viewport});
  619. let cellWidth = hitinfo.sheet.getCell(-1, hitinfo.col).width();
  620. if(textLength > cellWidth){
  621. $(me._toolTipElement).css("top", setting.pos.y + hitinfo.y +15).css("left", setting.pos.x + hitinfo.x + 15);
  622. $(me._toolTipElement).show("fast");
  623. ration.tipDiv = 'show';//做个标记
  624. }
  625. }
  626. else {
  627. $(me._toolTipElement).show("fast");
  628. ration.tipDiv = 'show';//做个标记
  629. }
  630. }
  631. }
  632. }
  633. },delayTimes);
  634. };
  635. TipCellType.prototype.processMouseLeave = function (hininfo) {
  636. this.tipTimeStamp = +new Date();
  637. ration.tipDiv = 'hide';
  638. if (this._toolTipElement) {
  639. $(this._toolTipElement).hide();
  640. this._toolTipElement = null;
  641. }
  642. tipDivCheck();//延时检查:当tips正在show的时候,就调用了hide方法,会导致tips一直存在,所以设置一个超时处理
  643. }
  644. return new TipCellType();
  645. }
  646. //输出表数据(定额表)
  647. //@param {Object}sheet {Array}headers {Array}datas @return {void}
  648. function showData(sheet, headers, datas){
  649. let fuc = function () {
  650. sheet.setRowCount(datas.length);
  651. //复选框
  652. let checkBoxType = new GC.Spread.Sheets.CellTypes.CheckBox();
  653. let tipCellType = getTipCellType(sheet);
  654. sheet.setCellType(-1, 0, checkBoxType);
  655. for(let col = 0, cLen = headers.length; col < cLen; col++){
  656. for(let row = 0, rLen = datas.length; row < rLen; row++){
  657. sheet.setValue(row, col, datas[row][headers[col]['dataCode']]);
  658. if(col === 1){
  659. sheet.setTag(row, col, datas[row]['hint']);
  660. }
  661. }
  662. }
  663. sheet.setCellType(-1, 1, tipCellType);
  664. sheet.setCellType(-1, 2, tipCellType);
  665. };
  666. renderSheetFunc(sheet, fuc);
  667. }
  668. //根据定额章节树ID获取定额(从数据缓存中获取,定额数据一开始一次性拉取)
  669. //@param {Number}sectionId {Array}rations @return {Array}
  670. function getRationsBySectionId(sectionId, rations) {
  671. if(!sectionId || !rations){
  672. return [];
  673. }
  674. return _.filter(rations, {sectionId});
  675. }
  676. //定额章节树焦点控制
  677. //@param {Number}row @return {void}
  678. function sectionInitSel(row) {
  679. let rationSheet = ration.workBook.getActiveSheet();
  680. let sectionNode = section.tree ? section.tree.items[row] : null;
  681. if(sectionNode && sectionNode.children.length === 0){
  682. let sectionRations = getRationsBySectionId(sectionNode.data.ID, ration.datas);
  683. ration.cache = sectionRations;
  684. showData(rationSheet, ration.headers, sectionRations);
  685. }
  686. else {
  687. cleanData(rationSheet, ration.headers, 0);
  688. }
  689. }
  690. //初始化定额条目
  691. //@param {Number}rationLibId @return {void}
  692. function initRationItems(rationLibId){
  693. $.bootstrapLoading.start();
  694. //获取定额章节树
  695. let sectionSheet = section.workBook.getActiveSheet();
  696. CommonAjax.post('/rationRepository/api/getRationTree', {rationLibId: rationLibId}, function (sectionDatas) {
  697. //获取所有定额数据
  698. let reqEntity = {rationLibId: rationLibId, showHint: true, returnFields: '-_id code ID sectionId name unit basePrice rationGljList jobContent annotation'};
  699. CommonAjax.post('/rationRepository/api/getRationItemsByLib', reqEntity, function (rstData) {
  700. section.cache = sectionDatas;
  701. initTree(section, section.workBook.getActiveSheet(), section.treeSetting, sectionDatas);
  702. //初始焦点在第一行(切换库)
  703. sectionSheet.setActiveCell(0, 0);
  704. rstData.sort(function (a, b) {
  705. let rst = 0;
  706. if(a.code > b.code){
  707. rst = 1;
  708. }
  709. else if(a.code < b.code){
  710. rst = -1;
  711. }
  712. return rst;
  713. });
  714. ration.datas = rstData;
  715. sectionInitSel(0);
  716. $.bootstrapLoading.end();
  717. }, function () {
  718. $.bootstrapLoading.end();
  719. });
  720. }, function () {
  721. $.bootstrapLoading.end();
  722. });
  723. }
  724. //初始化定额库选择
  725. //@param {String}compilationId @return {void}
  726. function initRationLibs(compilationId){
  727. CommonAjax.post('/rationRepository/api/getRationLibsByCompilation', {compilationId: compilationId}, function (rstData) {
  728. $('#rationLibSel').empty();
  729. for(let rationLib of rstData){
  730. let opt = `<option value="${rationLib.ID}">${rationLib.dispName}</option>`;
  731. $('#rationLibSel').append(opt);
  732. }
  733. //初始选择
  734. initRationItems(parseInt($('#rationLibSel').select().val()));
  735. $('#rationLibSel').change(function () {
  736. let rationLibId = parseInt($(this).select().val());
  737. initRationItems(rationLibId);
  738. })
  739. });
  740. }
  741. //清单设置悬浮提示信息
  742. //@param {Array}billsNodes(清单节点) {Array}jobs(总的工作内容数据) {Array}items(总的项目特征数据)
  743. function setBillsHint(billsNodes, jobs, items) {
  744. let jobsMapping = {},
  745. itemsMapping = {};
  746. for(let job of jobs){
  747. jobsMapping[job.id] = job;
  748. }
  749. for(let item of items){
  750. itemsMapping[item.id] = item;
  751. }
  752. let tagInfo = [];
  753. for(let billsNode of billsNodes){
  754. let hintArr = [];
  755. let billsItems = billsNode.data.items;
  756. if(billsItems.length > 0){
  757. //项目特征
  758. hintArr.push('项目特征:');
  759. }
  760. let itemCount = 1,
  761. jobCount = 1;
  762. for(let billsItem of billsItems){
  763. let itemData = itemsMapping[billsItem.id];
  764. if(itemData){
  765. //特征值
  766. let eigens = [];
  767. for(let eigen of itemData.itemValue){
  768. eigens.push(eigen.value);
  769. }
  770. eigens = eigens.join(';');
  771. hintArr.push(`${itemCount}.${itemData.content}${eigens === '' ? '' : ': ' + eigens}`);
  772. itemCount ++;
  773. }
  774. }
  775. //工作内容
  776. let billsJobs = billsNode.data.jobs;
  777. if(billsJobs.length > 0){
  778. hintArr.push('工作内容:');
  779. }
  780. for(let billsJob of billsJobs){
  781. let jobData = jobsMapping[billsJob.id];
  782. if(jobData){
  783. hintArr.push(`${jobCount}.${jobData.content}`);
  784. jobCount ++;
  785. }
  786. }
  787. /*if(billsNode.data.ruleText && billsNode.data.ruleText !== ''){
  788. hintArr.push('工程量计算规则:');
  789. hintArr.push(billsNode.data.ruleText);
  790. }
  791. if(billsNode.data.recharge && billsNode.data.recharge !== ''){
  792. hintArr.push('补注:');
  793. hintArr.push(billsNode.data.recharge);
  794. }*/
  795. if(hintArr.length > 0){
  796. tagInfo.push({row: billsNode.serialNo(), value: hintArr.join('\n')});
  797. }
  798. }
  799. let sheet = bills.workBook.getActiveSheet();
  800. renderSheetFunc(sheet, function () {
  801. for(let tagI of tagInfo){
  802. sheet.setTag(tagI.row, 0, tagI.value);
  803. }
  804. });
  805. }
  806. //初始化清单的工作内容和项目特征
  807. //@param {Number}billsLibId {Function}callback @return {void}
  808. function initJobAndCharacter(billsLibId, callback){
  809. CommonAjax.post('/stdBillsEditor/getJobContent', {billsLibId: billsLibId}, function (datas) {
  810. stdBillsJobData = datas;
  811. CommonAjax.post('/stdBillsEditor/getItemCharacter', {billsLibId: billsLibId}, function (datas) {
  812. stdBillsFeatureData = datas;
  813. if(callback){
  814. callback();
  815. }
  816. });
  817. });
  818. }
  819. let billsLibId = 0;
  820. //获取指引库信息及关联的清单
  821. //@param {Number}libID {Function}callback @return {Object}
  822. function getLibWithBills(libID, callback){
  823. CommonAjax.post('/billsGuidance/api/getLibWithBills', {libID: libID}, function (rstData) {
  824. billsLibId = rstData.guidanceLib.billsLibId;
  825. initRationLibs(rstData.guidanceLib.compilationId);
  826. bills.cache = rstData.bills;
  827. initLibName(rstData.guidanceLib.name);
  828. /*initTree(bills, bills.workBook.getActiveSheet(), bills.treeSetting, bills.cache);
  829. //每一棵项目指引树挂在清单节点上
  830. for(let node of bills.tree.items){
  831. node.guidance = {tree: null, controller: null};
  832. }
  833. //默认初始节点
  834. billsInitSel(0);
  835. if(callback){
  836. callback(rstData);
  837. }*/
  838. let initDataCallback = function () {
  839. initTree(bills, bills.workBook.getActiveSheet(), bills.treeSetting, bills.cache);
  840. //每一棵项目指引树挂在清单节点上
  841. for(let node of bills.tree.items){
  842. node.guidance = {tree: null, controller: null};
  843. }
  844. //默认初始节点
  845. billsInitSel(0);
  846. if(callback){
  847. callback(rstData);
  848. }
  849. };
  850. initJobAndCharacter(rstData.guidanceLib.billsLibId, initDataCallback);
  851. }, function (msg) {
  852. window.location.href = '/billsGuidance/main';
  853. });
  854. }
  855. //初始化并输出树
  856. //@param {Object}module {Object}sheet {Object}treeSetting {Array}datas
  857. function initTree(module, sheet, treeSetting, datas){
  858. module.tree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: true});
  859. module.controller = TREE_SHEET_CONTROLLER.createNew(module.tree, sheet, treeSetting);
  860. module.tree.loadDatas(datas);
  861. module.controller.showTreeData();
  862. if(module === bills){
  863. setBillsHint(bills.tree.items, stdBillsJobData, stdBillsFeatureData);
  864. }
  865. }
  866. //更新清单备注
  867. function updateBillsComment(updateData, callback) {
  868. CommonAjax.post('/stdBillsEditor/updateBills', updateData, function () {
  869. if (callback) {
  870. callback();
  871. }
  872. });
  873. }
  874. //更新项目指引
  875. //@param {Array}updateDatas {Function}callback @return {void}
  876. function updateGuideItems(updateDatas, callback){
  877. CommonAjax.post('/billsGuidance/api/updateItems', {updateDatas: updateDatas}, function (rstData) {
  878. if(callback){
  879. callback(rstData);
  880. }
  881. });
  882. }
  883. //编辑后自动去除换行符回车符
  884. const deESC = /[\r, \n]/g;
  885. //项目指引编辑
  886. //@param {Object}sheet {Array}cells
  887. function edit(sheet, cells){
  888. let updateDatas = [];
  889. //同步节点数据
  890. let syncDatas = [];
  891. for(let cell of cells){
  892. let text = sheet.getValue(cell.row, cell.col);
  893. text = text ? text.toString() : '';
  894. text = text.replace(deESC, '');
  895. sheet.setValue(cell.row, cell.col, text);
  896. let node = bills.tree.selected.guidance.tree.items[cell.row];
  897. if(node.data.name != text){
  898. syncDatas.push({node: node, text: text});
  899. updateDatas.push({updateType: updateType.update, findData: {ID: node.getID()}, updateData: {name: text}});
  900. }
  901. }
  902. if(updateDatas.length > 0){
  903. updateGuideItems(updateDatas, function () {
  904. for(let syncData of syncDatas){
  905. syncData.node.data.name = syncData.text;
  906. }
  907. }, function () {
  908. //失败恢复
  909. renderSheetFunc(sheet, function () {
  910. for(let syncData of syncDatas){
  911. sheet.setValue(syncData.node.serialNo(), 0, syncData.node.data.name ? syncData.node.data.name : '');
  912. }
  913. });
  914. });
  915. }
  916. }
  917. //项目指引插入,支持一次插入多条数据
  918. //@param {Array}datas {Boolean}tobeChild(插入成为子项) {Function}callback @return {void}
  919. function insert(datas, tobeChild, callback = null){
  920. $.bootstrapLoading.start();
  921. let sheet = guideItem.workBook.getActiveSheet();
  922. let controller = bills.tree.selected.guidance.controller;
  923. let selected = bills.tree.selected.guidance.tree.selected;
  924. let updateDatas = [];
  925. //建立数组下标索引
  926. let newDataIndex = {};
  927. for(let i = 0; i < datas.length; i++){
  928. let newNodeData = {
  929. libID: libID, ID: uuid.v1(), ParentID: selected ? selected.getParentID() : -1, NextSiblingID: selected ? selected.getNextSiblingID() : -1,
  930. billsID: bills.tree.selected.getID()
  931. };
  932. //定额类型插入当前工作内容焦点行,
  933. if(selected && ((selected.data.type === itemType.job && datas[i].type === itemType.ration) || tobeChild)){
  934. newNodeData.ParentID = selected.getID();
  935. newNodeData.NextSiblingID = -1;
  936. }
  937. Object.assign(newNodeData, datas[i]);
  938. newDataIndex[i] = newNodeData;
  939. }
  940. for(let i = 0; i < datas.length; i++){
  941. //第一个节点
  942. if(i === 0){
  943. //非插入成子节点,更新选中节点NestSiblingID
  944. if(selected && !((selected.data.type === itemType.job && datas[i].type === itemType.ration) || tobeChild)){
  945. updateDatas.push({updateType: updateType.update, findData: {ID: selected.getID()}, updateData: {NextSiblingID: newDataIndex[i].ID}});
  946. }
  947. }
  948. //非最后一个节点
  949. if(i !== datas.length - 1){
  950. newDataIndex[i].NextSiblingID = newDataIndex[i + 1].ID;
  951. }
  952. updateDatas.push({updateType: updateType.create, updateData: newDataIndex[i]});
  953. }
  954. updateGuideItems(updateDatas, function () {
  955. for(let updateData of updateDatas){
  956. if(updateData.updateType === updateType.create){
  957. let newNode = controller.insertByIDS(updateData.updateData.ID, updateData.updateData.ParentID, updateData.updateData.NextSiblingID);
  958. //同步data
  959. Object.assign(newNode.data, updateData.updateData);
  960. sheet.setValue(newNode.serialNo(), 0, newNode.data.name);
  961. refreshBtn(newNode);
  962. }
  963. }
  964. if(callback){
  965. callback();
  966. }
  967. setNodesColor(sheet, bills.tree.selected.guidance.tree.items);
  968. guideItem.workBook.focus(true);
  969. $.bootstrapLoading.end();
  970. });
  971. }
  972. //项目指引删除操作
  973. //@return {void}
  974. function del(){
  975. $.bootstrapLoading.start();
  976. let controller = bills.tree.selected.guidance.controller;
  977. let selNodes = [];
  978. let sheet = guideItem.workBook.getSheet(0);
  979. let sel = sheet.getSelections()[0];
  980. if(sel){
  981. sel.row = sel.row === -1 ? 0 : sel.row;
  982. for(let i = 0; i < sel.rowCount; i++){
  983. if(bills.tree.selected.guidance.tree.items[sel.row + i]){
  984. selNodes.push(bills.tree.selected.guidance.tree.items[sel.row + i]);
  985. }
  986. }
  987. }
  988. //选中的块节点
  989. let blockNodes = getBlockNodes(selNodes);
  990. let updateDatas = [];
  991. function getDelDatas(nodes){
  992. for (let node of nodes) {
  993. updateDatas.push({updateType: updateType.del, findData: {ID: node.getID()}});
  994. if (node.children.length > 0) {
  995. getDelDatas(node.children);
  996. }
  997. }
  998. }
  999. getDelDatas(blockNodes);
  1000. //更新相关的前节点
  1001. for (let node of blockNodes) {
  1002. if (node.preSibling && !blockNodes.includes(node.preSibling)) {
  1003. let next = node;
  1004. while (next.nextSibling && blockNodes.includes(next.nextSibling)) {
  1005. next = next.nextSibling;
  1006. }
  1007. updateDatas.push({updateType: updateType.update, findData: {ID: node.preSibling.getID()}, updateData: {NextSiblingID: next.getNextSiblingID()}});
  1008. }
  1009. }
  1010. updateGuideItems(updateDatas, function () {
  1011. controller.m_delete(blockNodes);
  1012. guideItemInitSel(sheet.getActiveRowIndex());
  1013. refreshBtn(bills.tree.selected.guidance.tree.selected);
  1014. setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
  1015. $.bootstrapLoading.end();
  1016. guideItem.workBook.focus(true)
  1017. });
  1018. }
  1019. //项目指引升级
  1020. //@return {void}
  1021. function upLevel(){
  1022. $.bootstrapLoading.start();
  1023. let controller = bills.tree.selected.guidance.controller;
  1024. let selected = bills.tree.selected.guidance.tree.selected;
  1025. let updateDatas = [];
  1026. //更新父节点
  1027. updateDatas.push({updateType: updateType.update, findData: {ID: selected.getParentID()}, updateData: {NextSiblingID: selected.getID()}});
  1028. //更新选中节点
  1029. updateDatas.push({updateType: updateType.update, findData: {ID: selected.getID()},
  1030. updateData: {ParentID: selected.parent.getParentID(), NextSiblingID: selected.parent.getNextSiblingID()}});
  1031. if(selected.nextSibling && selected.children.length > 0){
  1032. //更新选中节点最末子节点
  1033. let lastChild = selected.children[selected.children.length - 1];
  1034. updateDatas.push({updateType: updateType.update, findData: {ID: lastChild.getID()}, updateData: {NextSiblingID: -1}});
  1035. }
  1036. //选中节点的所有后兄弟节点成为选中节点的子项
  1037. let selectedNextIDs = [];
  1038. let sNext = selected.nextSibling;
  1039. while(sNext){
  1040. selectedNextIDs.push(sNext.getID());
  1041. sNext = sNext.nextSibling;
  1042. }
  1043. for(let sID of selectedNextIDs){
  1044. updateDatas.push({updateType: updateType.update, findData: {ID: sID}, updateData: {ParentID: selected.getID()}});
  1045. }
  1046. updateGuideItems(updateDatas, function () {
  1047. controller.upLevel();
  1048. refreshBtn(bills.tree.selected.guidance.tree.selected);
  1049. setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
  1050. $.bootstrapLoading.end();
  1051. guideItem.workBook.focus(true)//31574
  1052. });
  1053. }
  1054. //项目指引降级
  1055. //@return {void}
  1056. function downLevel(){
  1057. $.bootstrapLoading.start();
  1058. let controller = bills.tree.selected.guidance.controller;
  1059. let selected = bills.tree.selected.guidance.tree.selected;
  1060. let updateDatas = [];
  1061. //更新前兄弟节点
  1062. updateDatas.push({updateType: updateType.update, findData: {ID: selected.preSibling.getID()}, updateData: {NextSiblingID: selected.getNextSiblingID()}});
  1063. //更新前兄弟节点最末子节点
  1064. if(selected.preSibling.children.length > 0){
  1065. let lastChild = selected.preSibling.children[selected.preSibling.children.length - 1];
  1066. updateDatas.push({updateType: updateType.update, findData: {ID: lastChild.getID()}, updateData: {NextSiblingID: selected.getID()}});
  1067. }
  1068. //更新选中节点
  1069. updateDatas.push({updateType: updateType.update, findData: {ID: selected.getID()}, updateData: {ParentID: selected.preSibling.getID(), NextSiblingID: -1}});
  1070. updateGuideItems(updateDatas, function () {
  1071. controller.downLevel();
  1072. refreshBtn(bills.tree.selected.guidance.tree.selected);
  1073. setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
  1074. $.bootstrapLoading.end();
  1075. guideItem.workBook.focus(true)
  1076. });
  1077. }
  1078. //项目指引上移
  1079. //@return {void}
  1080. function upMove(){
  1081. $.bootstrapLoading.start();
  1082. let controller = bills.tree.selected.guidance.controller;
  1083. let selected = bills.tree.selected.guidance.tree.selected;
  1084. let updateDatas = [];
  1085. //更新前节点
  1086. updateDatas.push({updateType: updateType.update, findData: {ID: selected.preSibling.getID()}, updateData: {NextSiblingID: selected.getNextSiblingID()}});
  1087. //更新前前节点
  1088. if(selected.preSibling.preSibling){
  1089. updateDatas.push({updateType: updateType.update, findData: {ID: selected.preSibling.preSibling.getID()}, updateData: {NextSiblingID: selected.getID()}});
  1090. }
  1091. //更新选中节点
  1092. updateDatas.push({updateType: updateType.update, findData: {ID: selected.getID()}, updateData: {NextSiblingID: selected.preSibling.getID()}});
  1093. updateGuideItems(updateDatas, function () {
  1094. controller.upMove();
  1095. refreshBtn(bills.tree.selected.guidance.tree.selected);
  1096. setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
  1097. $.bootstrapLoading.end();
  1098. guideItem.workBook.focus(true)
  1099. });
  1100. }
  1101. //项目指引下移
  1102. //@return {void}
  1103. function downMove(){
  1104. $.bootstrapLoading.start();
  1105. let controller = bills.tree.selected.guidance.controller;
  1106. let selected = bills.tree.selected.guidance.tree.selected;
  1107. let updateDatas = [];
  1108. //更新下节点
  1109. updateDatas.push({updateType: updateType.update, findData: {ID: selected.getNextSiblingID()}, updateData: {NextSiblingID: selected.getID()}});
  1110. //更新前节点
  1111. if(selected.preSibling){
  1112. updateDatas.push({updateType: updateType.update, findData: {ID: selected.preSibling.getID()}, updateData: {NextSiblingID: selected.getNextSiblingID()}});
  1113. }
  1114. //更新选中节点
  1115. updateDatas.push({updateType: updateType.update, findData: {ID: selected.getID()}, updateData: {NextSiblingID: selected.nextSibling.getNextSiblingID()}});
  1116. updateGuideItems(updateDatas, function () {
  1117. controller.downMove();
  1118. refreshBtn(bills.tree.selected.guidance.tree.selected);
  1119. setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
  1120. $.bootstrapLoading.end();
  1121. guideItem.workBook.focus(true)
  1122. });
  1123. }
  1124. //获取定额类型的项目指引名称,通过定额转换
  1125. //@param {Object}ration @return {String}
  1126. function getRationItemName(ration){
  1127. let arr = [];
  1128. arr.push(ration.code ? ration.code : '');
  1129. arr.push(ration.name ? ration.name : '');
  1130. arr.push(ration.basePrice ? ration.basePrice : '');
  1131. let rst = arr.join(' ');
  1132. rst += `/${ration.unit ? ration.unit : ''}`;
  1133. return rst;
  1134. }
  1135. //获取选中的定额表行
  1136. //@return {Array}
  1137. function getCheckedRationRows(all){
  1138. let rst = [];
  1139. let sheet = ration.workBook.getActiveSheet();
  1140. for(let i = 0; i < sheet.getRowCount(); i++){
  1141. // 全选
  1142. if (all) {
  1143. rst.push(i);
  1144. continue;
  1145. }
  1146. let checked = sheet.getValue(i, 0);
  1147. if(checked){
  1148. rst.push(i);
  1149. }
  1150. }
  1151. return rst;
  1152. }
  1153. //清空选中定额表行
  1154. //@param {Array}rows @return {void}
  1155. function clearCheckedRation(rows) {
  1156. let sheet = ration.workBook.getActiveSheet();
  1157. renderSheetFunc(sheet, function () {
  1158. for(let row of rows){
  1159. sheet.setValue(row, 0, 0);
  1160. }
  1161. });
  1162. }
  1163. //获取要插入的定额数据
  1164. //@param {Array}rows @return {Array}
  1165. function getInsertRations(rows){
  1166. let rst = [];
  1167. //当前已存在定额
  1168. let curRationIems = [];
  1169. let selected = bills.tree.selected.guidance.tree.selected;
  1170. if(selected){
  1171. if(selected.data.type === itemType.job){
  1172. curRationIems = selected.children;
  1173. }
  1174. else {
  1175. curRationIems = selected.parent ? selected.parent.children : selected.tree.roots;
  1176. }
  1177. }
  1178. for(let row of rows){
  1179. let selRation = ration.cache[row];
  1180. if(selRation){
  1181. //添加的定额是否已存在,不重复添加
  1182. let isExist = false;
  1183. for(let curRation of curRationIems){
  1184. if(curRation.data.rationID == selRation.ID){
  1185. isExist = true;
  1186. break;
  1187. }
  1188. }
  1189. if(!isExist){
  1190. rst.push({type: itemType.ration, name: getRationItemName(selRation), rationID: selRation.ID});
  1191. }
  1192. }
  1193. }
  1194. return rst;
  1195. }
  1196. //获取块节点父项不存在于选中节点中的节点
  1197. //@param {Array}nodes(选中的节点) @return {Array}
  1198. function getBlockNodes(nodes) {
  1199. let nodeMapping = {};
  1200. for(let node of nodes){
  1201. nodeMapping[node.data.ID] = node;
  1202. }
  1203. //块节点,父项不存在于选中节点中的节点
  1204. let blockNodes = [];
  1205. for(let node of nodes){
  1206. if(!nodeMapping[node.data.ParentID]){
  1207. blockNodes.push(node);
  1208. }
  1209. }
  1210. return blockNodes;
  1211. }
  1212. //允许复制整块,如果有多个块节点,且块节点的父项不同,则不可复制
  1213. //@param {Array}nodes(块节点) @return {Boolean}
  1214. function canCopyBlock(nodes) {
  1215. if(!nodes || nodes.length === 0){
  1216. return false;
  1217. }
  1218. let pID = nodes[0].data.ParentID;
  1219. for(let node of nodes){
  1220. if(node.data.ParentID !== pID){
  1221. return false;
  1222. }
  1223. }
  1224. return true;
  1225. }
  1226. //允许粘贴整块 有粘贴数据,节点存在,如果粘贴到的节点为定额数据,粘贴数据为全定额数据
  1227. //@param {Object}node(粘贴到的节点)
  1228. function canPasteBlock(node) {
  1229. let pasteDatas = JSON.parse(getLocalCache(itemCopyBlockKey));
  1230. if(!pasteDatas || pasteDatas.length === 0){
  1231. return false;
  1232. }
  1233. if(!node){
  1234. return false;
  1235. }
  1236. //若粘贴到定额节点,则数据须全为定额
  1237. if(node.data.type === itemType.ration){
  1238. for(let data of pasteDatas){
  1239. if(data.type !== itemType.ration){
  1240. return false;
  1241. }
  1242. }
  1243. }
  1244. //若粘贴到非定额节点,则粘贴的顶层数据须全为非定额
  1245. else {
  1246. let topDatas = _.filter(pasteDatas, {ParentID: -1});
  1247. for(let topData of topDatas){
  1248. if(topData.type === itemType.ration){
  1249. return false;
  1250. }
  1251. }
  1252. }
  1253. return true;
  1254. }
  1255. //复制整块,将块节点下所有节点数据复制一份,并且重新生成ID、ParentID、NextSiblingID,使用localStorage存储
  1256. //@param {Array}nodes(块节点) @return {void}
  1257. function copyBlocks(nodes) {
  1258. nodes = _.cloneDeep(nodes);
  1259. //将块节点的ParentID暂时设置为-1
  1260. for(let topNode of nodes){
  1261. topNode.data.ParentID = -1;
  1262. }
  1263. let copyDatas = [];
  1264. let copyNodes = [];
  1265. //获取块节点包含的所有节点(包括自己)
  1266. function containNodes(nodes) {
  1267. for(let node of nodes){
  1268. copyNodes.push(node);
  1269. if(node.children.length > 0){
  1270. containNodes(node.children);
  1271. }
  1272. }
  1273. }
  1274. containNodes(nodes);
  1275. for(let node of copyNodes){
  1276. copyDatas.push(node.data);
  1277. }
  1278. console.log(`copyDatas`);
  1279. console.log(copyDatas);
  1280. setLocalCache(itemCopyBlockKey, JSON.stringify(copyDatas));
  1281. }
  1282. //粘贴整块,整块数据粘贴到相关节点,并成为其后项
  1283. //@param {Object}node(粘贴到的节点) @return {void}
  1284. function pasteBlock(node) {
  1285. let itemObj = bills.tree.selected.guidance;
  1286. let pasteDatas = JSON.parse(getLocalCache(itemCopyBlockKey));
  1287. //整理ID
  1288. let IDMapping = {};
  1289. for(let data of pasteDatas){
  1290. data.newID = uuid.v1();
  1291. IDMapping[data.ID] = data;
  1292. }
  1293. for(let data of pasteDatas){
  1294. let nextData = IDMapping[data.NextSiblingID];
  1295. data.NextSiblingID = nextData ? nextData.newID : -1;
  1296. let parentData = IDMapping[data.ParentID];
  1297. data.ParentID = parentData ? parentData.newID : -1;
  1298. }
  1299. for(let data of pasteDatas){
  1300. data.ID = data.newID;
  1301. delete data.newID;
  1302. }
  1303. let updateDatas = [];
  1304. //将最顶层的块数据的ParentID设置成粘贴到节点的ParentID,并设置新的billsID
  1305. let topDatas = _.filter(pasteDatas, {ParentID: -1});
  1306. for(let topData of topDatas){
  1307. topData.ParentID = node.getParentID();
  1308. }
  1309. //更新数据
  1310. //更新插入的最末顶层数据NextSiblingID
  1311. if(node.nextSibling){
  1312. topDatas[topDatas.length - 1].NextSiblingID = node.getNextSiblingID();
  1313. }
  1314. //新建节点
  1315. for(let data of pasteDatas){
  1316. data.libID = libID;
  1317. data.billsID = node.data.billsID;
  1318. delete data._id;
  1319. updateDatas.push({updateType: updateType.create, updateData: data});
  1320. }
  1321. console.log(`pasteDatas`);
  1322. console.log(pasteDatas);
  1323. //更新粘贴到的节点的NextSiblingID
  1324. updateDatas.push({updateType: updateType.update, findData: {ID: node.data.ID}, updateData: {NextSiblingID: topDatas[0].ID}})
  1325. $.bootstrapLoading.start();
  1326. updateGuideItems(updateDatas, function (rstData) {
  1327. $.bootstrapLoading.end();
  1328. node.data.NextSiblingID = topDatas[0].ID;
  1329. let newNodes = itemObj.tree.insertDatasTo(node.data, pasteDatas);
  1330. cleanData(guideItem.workBook.getActiveSheet(), guideItem.headers, -1);
  1331. itemObj.controller.showTreeData();
  1332. setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
  1333. }, function () {
  1334. $.bootstrapLoading.end();
  1335. });
  1336. }
  1337. //初始化右键菜单
  1338. //@return {void}
  1339. function initContextMenu() {
  1340. $.contextMenu({
  1341. selector: '#guideItemSpread',
  1342. build: function($triggerElement, e){
  1343. //控制允许右键菜单在哪个位置出现
  1344. let sheet = guideItem.workBook.getSheet(0);
  1345. let offset = $("#guideItemSpread").offset(),
  1346. x = e.pageX - offset.left,
  1347. y = e.pageY - offset.top;
  1348. let target = sheet.hitTest(x, y);
  1349. if(target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){//在表格内
  1350. let sel = sheet.getSelections()[0];
  1351. if(sel && sel.rowCount === 1){
  1352. sheet.setActiveCell(target.row, target.col);
  1353. }
  1354. sel = sheet.getSelections()[0];
  1355. let selNodes = [];
  1356. if(sel){
  1357. sel.row = sel.row === -1 ? 0 : sel.row;
  1358. for(let i = 0; i < sel.rowCount; i++){
  1359. if(bills.tree.selected.guidance.tree.items[sel.row + i]){
  1360. selNodes.push(bills.tree.selected.guidance.tree.items[sel.row + i]);
  1361. }
  1362. }
  1363. }
  1364. //块节点
  1365. let blockNodes = getBlockNodes(selNodes);
  1366. //右键在多选内则不重设焦点
  1367. if(!sel || sel.rowCount === 1 || !(target.row >= sel.row && target.row <= sel.row + sel.rowCount - 1)){
  1368. sheet.setActiveCell(target.row, target.col);
  1369. }
  1370. guideItemInitSel(target.row);
  1371. return {
  1372. callback: function(){},
  1373. items: {
  1374. "copy": {
  1375. name: "复制整块",
  1376. disabled: function () {
  1377. return !canCopyBlock(blockNodes);
  1378. },
  1379. icon: "fa-copy",
  1380. callback: function (key, opt) {
  1381. copyBlocks(blockNodes);
  1382. }},
  1383. "paste": {
  1384. name: "粘贴整块",
  1385. disabled: function () {
  1386. let pasteNode = bills.tree.selected.guidance.tree.items[target.row];
  1387. return !canPasteBlock(pasteNode);
  1388. },
  1389. icon: "fa-paste",
  1390. callback: function (key, opt) {
  1391. let pasteNode = bills.tree.selected.guidance.tree.items[target.row];
  1392. pasteBlock(pasteNode);
  1393. }},
  1394. "del": {
  1395. name: '删除',
  1396. disabled: function () {
  1397. let node = bills.tree.selected.guidance.tree.items[target.row];
  1398. return !node
  1399. },
  1400. icon: "fa-arrow-left",
  1401. callback: function (key, opt) {
  1402. $('#delAlert').modal('show');
  1403. }
  1404. },
  1405. "insertSibling": {
  1406. name: '插入行',
  1407. disabled: function () {
  1408. let node = bills.tree.selected.guidance.tree.items[target.row];
  1409. return !node || node.data.type !== itemType.job;
  1410. },
  1411. icon: "fa-arrow-left",
  1412. callback: function (key, opt) {
  1413. insert([{type: itemType.job, name: ''}], false);
  1414. }
  1415. },
  1416. "insertChild": {
  1417. name: '插入子项',
  1418. disabled: function () {
  1419. let node = bills.tree.selected.guidance.tree.items[target.row];
  1420. return !node || node.data.type !== itemType.job || !allJobChildren(node);
  1421. },
  1422. icon: 'fa-arrow-left',
  1423. callback: function (key, opt) {
  1424. insert([{type: itemType.job, name: ''}], true);
  1425. }
  1426. }
  1427. }
  1428. };
  1429. }
  1430. else{
  1431. return false;
  1432. }
  1433. }
  1434. });
  1435. }
  1436. //初始化个按钮点击
  1437. //@return {void}
  1438. function initBtn(){
  1439. $('#insert').click(function () {
  1440. insert([{type: itemType.job, name: ''}], false);
  1441. });
  1442. $('#delConfirm').click(function () {
  1443. del();
  1444. $('#delAlert').modal('hide');
  1445. });
  1446. $('#del').click(function () {
  1447. $('#delAlert').modal('show');
  1448. });
  1449. $('#upLevel').click(function () {
  1450. upLevel();
  1451. });
  1452. $('#downLevel').click(function () {
  1453. downLevel();
  1454. });
  1455. $('#upMove').click(function () {
  1456. upMove();
  1457. });
  1458. $('#downMove').click(function () {
  1459. downMove();
  1460. });
  1461. //收起定额、展开全部
  1462. $('#expandContract').click(function () {
  1463. //目前状态时展开全部节点状态,点击则收起定额
  1464. let tree = bills.tree.selected.guidance.tree,
  1465. itemSheet = guideItem.workBook.getActiveSheet();
  1466. if(curExpandState === itemExpandState.expand){
  1467. curExpandState = itemExpandState.contract;
  1468. $(this).html('<i class="fa fa-plus-square-o" aria-hidden="true"></i> 展开全部');
  1469. setNodesExpandState(tree.items, itemExpandState.contract);
  1470. } else {
  1471. curExpandState = itemExpandState.expand;
  1472. $(this).html('<i class="fa fa-minus-square-o" aria-hidden="true"></i> 收起定额');
  1473. setNodesExpandState(tree.items, itemExpandState.expand);
  1474. }
  1475. renderSheetFunc(itemSheet, function () {
  1476. TREE_SHEET_HELPER.refreshNodesVisible(tree.roots, itemSheet, true);
  1477. });
  1478. });
  1479. $('#insertRation').click(function () {
  1480. let checkedRows = getCheckedRationRows();
  1481. let insertDatas = getInsertRations(checkedRows);
  1482. if(insertDatas.length > 0){
  1483. insert(insertDatas, false, function () {
  1484. //清空选择
  1485. clearCheckedRation(checkedRows);
  1486. });
  1487. }
  1488. else {
  1489. clearCheckedRation(checkedRows);
  1490. }
  1491. });
  1492. // 插入全部定额
  1493. $('#insertAll').click(function () {
  1494. let isAll = true;
  1495. let checkedRows = getCheckedRationRows(isAll);
  1496. let insertDatas = getInsertRations(checkedRows);
  1497. if(insertDatas.length > 0){
  1498. insert(insertDatas, false);
  1499. }
  1500. });
  1501. //搜索定额
  1502. $('#searchBtn').click(function () {
  1503. let searchStr = $('#searchText').val();
  1504. if(!searchStr || searchStr === ''){
  1505. ration.cache = ration.datas;
  1506. }
  1507. else{
  1508. let reg = new RegExp(searchStr, 'i');
  1509. ration.cache = _.filter(ration.datas, function (data) {
  1510. return reg.test(data.code) || reg.test(data.name);
  1511. });
  1512. }
  1513. $('.top-content').hide();
  1514. $('#searchCount').text(`搜索结果: ${ration.cache.length}`);
  1515. $('#rationSearchResult').show();
  1516. autoFlashHeight();
  1517. ration.workBook.refresh();
  1518. let rationSheet = ration.workBook.getActiveSheet();
  1519. renderSheetFunc(rationSheet, function () {
  1520. clearCheckedRation(getCheckedRationRows());
  1521. showData(rationSheet, ration.headers, ration.cache);
  1522. })
  1523. });
  1524. //关闭搜索
  1525. $('#rationSearchResult a').click(function () {
  1526. $('.top-content').show();
  1527. $('#rationSearchResult').hide();
  1528. autoFlashHeight();
  1529. renderSheetFunc(ration.workBook.getActiveSheet(), function () {
  1530. clearCheckedRation(getCheckedRationRows());
  1531. });
  1532. section.workBook.refresh();
  1533. ration.workBook.refresh();
  1534. $('#searchText').val('');
  1535. //恢复章节树下的定额
  1536. sectionInitSel(section.workBook.getActiveSheet().getActiveRowIndex());
  1537. });
  1538. let keyupTime = 0,
  1539. delayTime = 500;
  1540. function delayKeyup(callback) {
  1541. let nowTime = Date.now();
  1542. keyupTime = nowTime;
  1543. setTimeout(function () {
  1544. if (nowTime - keyupTime == 0) {
  1545. callback();
  1546. }
  1547. }, delayTime);
  1548. }
  1549. //执行搜索
  1550. $('#searchText').keyup(function (e) {
  1551. delayKeyup(function () {
  1552. $('#searchBtn').click();
  1553. });
  1554. });
  1555. //编辑清单备注
  1556. $('.main-side-bottom').find('textarea').keyup(function () {
  1557. let me = this;
  1558. let node = bills.tree.selected;
  1559. let comment = $(me).val();
  1560. delayKeyup(function () {
  1561. if (node) {
  1562. let updateData = {lastOperator: userAccount, billsLibId: billsLibId, updateId: node.getID(), field: 'comment', data: comment};
  1563. updateBillsComment(updateData, function () {
  1564. node.data.comment = comment;
  1565. })
  1566. }
  1567. });
  1568. });
  1569. //编辑选项备注
  1570. $('.main-bottom-content').find('textarea').keyup(function () {
  1571. let me = this;
  1572. let node = bills.tree.selected.guidance.tree.selected;
  1573. let comment = $(me).val();
  1574. delayKeyup(function () {
  1575. if(node){
  1576. let updateDatas = [{updateType: updateType.update, findData: {ID: node.getID()}, updateData: {comment: comment}}];
  1577. updateGuideItems(updateDatas, function (rstData) {
  1578. node.data.comment = comment;
  1579. });
  1580. }
  1581. });
  1582. });
  1583. //定额高度拖动调整
  1584. let heightEleObj = {
  1585. module: moduleName,
  1586. resize: $('#deResize'),
  1587. top: $('#topContent'),
  1588. topSpread: $('#sectionSpread'),
  1589. bottom: $('#bottomContent'),
  1590. bottomSpread: $('#rationSpread')
  1591. },
  1592. heightLimit = {
  1593. min: 150,
  1594. max: `$(window).height()-$('.header').height()-$('.sidebar-tools-bar').height()-150-10`,
  1595. notTopSpread: 0,
  1596. notBottomSpread: 0,
  1597. };
  1598. SlideResize.verticalSlide(heightEleObj, heightLimit, function () {
  1599. if(section.workBook){
  1600. section.workBook.refresh();
  1601. }
  1602. if(ration.workBook){
  1603. ration.workBook.refresh();
  1604. }
  1605. });
  1606. /*slideResize(rationLibResizeEles, {min: 147, max: 680}, 'height', function() {
  1607. //autoFlashHeight();
  1608. if(section.workBook){
  1609. section.workBook.refresh();
  1610. }
  1611. if(ration.workBook){
  1612. ration.workBook.refresh();
  1613. }
  1614. });*/
  1615. //左右拖动
  1616. //清单表与项目指引表
  1617. let leftElesObj = {};
  1618. leftElesObj.module = moduleName;
  1619. leftElesObj.resize = $('#slideResizeLeft');
  1620. leftElesObj.parent = $('#dataRow');
  1621. leftElesObj.left = $('#leftContent');
  1622. leftElesObj.right = $('#midContent');
  1623. SlideResize.horizontalSlide(leftElesObj, {min: 200, max: `$('#dataRow').width() - $('#rightContent').width() - 200`}, function () {
  1624. refreshALlWorkBook();
  1625. });
  1626. //人材机表与人材机组成物表
  1627. let rightElesObj = {};
  1628. rightElesObj.module = moduleName;
  1629. rightElesObj.resize = $('#slideResizeRight');
  1630. rightElesObj.parent = $('#dataRow');
  1631. rightElesObj.left = $('#midContent');
  1632. rightElesObj.right = $('#rightContent');
  1633. SlideResize.horizontalSlide(rightElesObj, {min: 200, max: `$('#dataRow').width() - $('#leftContent').width() - 200`}, function () {
  1634. refreshALlWorkBook();
  1635. });
  1636. }
  1637. //刷新全部工作簿
  1638. //@return {void}
  1639. function refreshALlWorkBook() {
  1640. if (bills.workBook) {
  1641. bills.workBook.refresh();
  1642. }
  1643. if (guideItem.workBook) {
  1644. guideItem.workBook.refresh();
  1645. }
  1646. if (section.workBook) {
  1647. section.workBook.refresh();
  1648. }
  1649. if (ration.workBook) {
  1650. ration.workBook.refresh();
  1651. }
  1652. $('.main-side-bottom').find('textarea').height($('.main-side-bottom').height() - 20);
  1653. $('.main-side-bottom').find('textarea').width($('.main-side-bottom').width() - 25);
  1654. $('.main-bottom-content').find('textarea').height($('.main-bottom-content').height() - 20);
  1655. $('.main-bottom-content').find('textarea').width($('.main-bottom-content').width() - 25);
  1656. }
  1657. //读取拖动相关
  1658. //@return {void}
  1659. function initSlideSize() {
  1660. //定额表上下
  1661. let heightEleObj = {
  1662. module: moduleName,
  1663. top: $('#topContent'),
  1664. topSpread: $('#sectionSpread'),
  1665. bottom: $('#bottomContent'),
  1666. bottomSpread: $('#rationSpread')
  1667. };
  1668. SlideResize.loadVerticalHeight(heightEleObj.module, heightEleObj,
  1669. {totalHeight: `$(window).height()-$('.header').height()-$('.sidebar-tools-bar').height()-10`,
  1670. notTopSpread: 0, notBottomSpread: 0}, function () {
  1671. if(section.workBook){
  1672. section.workBook.refresh();
  1673. }
  1674. if(ration.workBook){
  1675. ration.workBook.refresh();
  1676. }
  1677. });
  1678. //水平
  1679. SlideResize.loadHorizonWidth(moduleName, [$('#slideResizeLeft'), $('#slideResizeRight')], [$('#leftContent'), $('#midContent'), $('#rightContent')], function () {
  1680. refreshALlWorkBook();
  1681. });
  1682. }
  1683. //初始化视图
  1684. //@param {void} @return {void}
  1685. function initViews(){
  1686. let modules = [bills, guideItem, section, ration];
  1687. initWorkBooks(modules);
  1688. getLibWithBills(libID);
  1689. initBtn();
  1690. initContextMenu();
  1691. initSlideSize();
  1692. }
  1693. return {initViews, initSlideSize};
  1694. })();
  1695. $(document).ready(function () {
  1696. billsGuidance.initViews();
  1697. });