billsGuidance.js 70 KB

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