billsGuidance.js 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711
  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 = /[\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. // 插入选中定额
  1485. $('#insertRation').click(function () {
  1486. let checkedRows = getCheckedRationRows();
  1487. let insertDatas = getInsertRations(checkedRows);
  1488. if(insertDatas.length > 0){
  1489. insert(insertDatas, false, function () {
  1490. //清空选择
  1491. clearCheckedRation(checkedRows);
  1492. });
  1493. }
  1494. else {
  1495. clearCheckedRation(checkedRows);
  1496. }
  1497. });
  1498. // 插入全部定额
  1499. $('#insertAll').click(function () {
  1500. let isAll = true;
  1501. let checkedRows = getCheckedRationRows(isAll);
  1502. let insertDatas = getInsertRations(checkedRows);
  1503. if(insertDatas.length > 0){
  1504. insert(insertDatas, false);
  1505. }
  1506. });
  1507. //搜索定额
  1508. $('#searchBtn').click(function () {
  1509. let searchStr = $('#searchText').val();
  1510. if(!searchStr || searchStr === ''){
  1511. ration.cache = ration.datas;
  1512. }
  1513. else{
  1514. let reg = new RegExp(searchStr, 'i');
  1515. ration.cache = _.filter(ration.datas, function (data) {
  1516. return reg.test(data.code) || reg.test(data.name);
  1517. });
  1518. }
  1519. $('.top-content').hide();
  1520. $('#searchCount').text(`搜索结果: ${ration.cache.length}`);
  1521. $('#rationSearchResult').show();
  1522. autoFlashHeight();
  1523. ration.workBook.refresh();
  1524. let rationSheet = ration.workBook.getActiveSheet();
  1525. renderSheetFunc(rationSheet, function () {
  1526. clearCheckedRation(getCheckedRationRows());
  1527. showData(rationSheet, ration.headers, ration.cache);
  1528. })
  1529. });
  1530. //关闭搜索
  1531. $('#rationSearchResult a').click(function () {
  1532. $('.top-content').show();
  1533. $('#rationSearchResult').hide();
  1534. autoFlashHeight();
  1535. renderSheetFunc(ration.workBook.getActiveSheet(), function () {
  1536. clearCheckedRation(getCheckedRationRows());
  1537. });
  1538. section.workBook.refresh();
  1539. ration.workBook.refresh();
  1540. $('#searchText').val('');
  1541. //恢复章节树下的定额
  1542. sectionInitSel(section.workBook.getActiveSheet().getActiveRowIndex());
  1543. });
  1544. let keyupTime = 0,
  1545. delayTime = 500;
  1546. function delayKeyup(callback) {
  1547. let nowTime = Date.now();
  1548. keyupTime = nowTime;
  1549. setTimeout(function () {
  1550. if (nowTime - keyupTime == 0) {
  1551. callback();
  1552. }
  1553. }, delayTime);
  1554. }
  1555. //执行搜索
  1556. $('#searchText').keyup(function (e) {
  1557. delayKeyup(function () {
  1558. $('#searchBtn').click();
  1559. });
  1560. });
  1561. //编辑清单备注
  1562. $('.main-side-bottom').find('textarea').keyup(function () {
  1563. let me = this;
  1564. let node = bills.tree.selected;
  1565. let comment = $(me).val();
  1566. delayKeyup(function () {
  1567. if (node) {
  1568. let updateData = {lastOperator: userAccount, billsLibId: billsLibId, updateId: node.getID(), field: 'comment', data: comment};
  1569. updateBillsComment(updateData, function () {
  1570. node.data.comment = comment;
  1571. })
  1572. }
  1573. });
  1574. });
  1575. //编辑选项备注
  1576. $('.main-bottom-content').find('textarea').keyup(function () {
  1577. let me = this;
  1578. let node = bills.tree.selected.guidance.tree.selected;
  1579. let comment = $(me).val();
  1580. delayKeyup(function () {
  1581. if(node){
  1582. let updateDatas = [{updateType: updateType.update, findData: {ID: node.getID()}, updateData: {comment: comment}}];
  1583. updateGuideItems(updateDatas, function (rstData) {
  1584. node.data.comment = comment;
  1585. });
  1586. }
  1587. });
  1588. });
  1589. //定额高度拖动调整
  1590. let heightEleObj = {
  1591. module: moduleName,
  1592. resize: $('#deResize'),
  1593. top: $('#topContent'),
  1594. topSpread: $('#sectionSpread'),
  1595. bottom: $('#bottomContent'),
  1596. bottomSpread: $('#rationSpread')
  1597. },
  1598. heightLimit = {
  1599. min: 150,
  1600. max: `$(window).height()-$('.header').height()-$('.sidebar-tools-bar').height()-150-10`,
  1601. notTopSpread: 0,
  1602. notBottomSpread: 0,
  1603. };
  1604. SlideResize.verticalSlide(heightEleObj, heightLimit, function () {
  1605. if(section.workBook){
  1606. section.workBook.refresh();
  1607. }
  1608. if(ration.workBook){
  1609. ration.workBook.refresh();
  1610. }
  1611. });
  1612. /*slideResize(rationLibResizeEles, {min: 147, max: 680}, 'height', function() {
  1613. //autoFlashHeight();
  1614. if(section.workBook){
  1615. section.workBook.refresh();
  1616. }
  1617. if(ration.workBook){
  1618. ration.workBook.refresh();
  1619. }
  1620. });*/
  1621. //左右拖动
  1622. //清单表与项目指引表
  1623. let leftElesObj = {};
  1624. leftElesObj.module = moduleName;
  1625. leftElesObj.resize = $('#slideResizeLeft');
  1626. leftElesObj.parent = $('#dataRow');
  1627. leftElesObj.left = $('#leftContent');
  1628. leftElesObj.right = $('#midContent');
  1629. SlideResize.horizontalSlide(leftElesObj, {min: 200, max: `$('#dataRow').width() - $('#rightContent').width() - 200`}, function () {
  1630. refreshALlWorkBook();
  1631. });
  1632. //人材机表与人材机组成物表
  1633. let rightElesObj = {};
  1634. rightElesObj.module = moduleName;
  1635. rightElesObj.resize = $('#slideResizeRight');
  1636. rightElesObj.parent = $('#dataRow');
  1637. rightElesObj.left = $('#midContent');
  1638. rightElesObj.right = $('#rightContent');
  1639. SlideResize.horizontalSlide(rightElesObj, {min: 200, max: `$('#dataRow').width() - $('#leftContent').width() - 200`}, function () {
  1640. refreshALlWorkBook();
  1641. });
  1642. }
  1643. //刷新全部工作簿
  1644. //@return {void}
  1645. function refreshALlWorkBook() {
  1646. if (bills.workBook) {
  1647. bills.workBook.refresh();
  1648. }
  1649. if (guideItem.workBook) {
  1650. guideItem.workBook.refresh();
  1651. }
  1652. if (section.workBook) {
  1653. section.workBook.refresh();
  1654. }
  1655. if (ration.workBook) {
  1656. ration.workBook.refresh();
  1657. }
  1658. $('.main-side-bottom').find('textarea').height($('.main-side-bottom').height() - 20);
  1659. $('.main-side-bottom').find('textarea').width($('.main-side-bottom').width() - 25);
  1660. $('.main-bottom-content').find('textarea').height($('.main-bottom-content').height() - 20);
  1661. $('.main-bottom-content').find('textarea').width($('.main-bottom-content').width() - 25);
  1662. }
  1663. //读取拖动相关
  1664. //@return {void}
  1665. function initSlideSize() {
  1666. //定额表上下
  1667. let heightEleObj = {
  1668. module: moduleName,
  1669. top: $('#topContent'),
  1670. topSpread: $('#sectionSpread'),
  1671. bottom: $('#bottomContent'),
  1672. bottomSpread: $('#rationSpread')
  1673. };
  1674. SlideResize.loadVerticalHeight(heightEleObj.module, heightEleObj,
  1675. {totalHeight: `$(window).height()-$('.header').height()-$('.sidebar-tools-bar').height()-10`,
  1676. notTopSpread: 0, notBottomSpread: 0}, function () {
  1677. if(section.workBook){
  1678. section.workBook.refresh();
  1679. }
  1680. if(ration.workBook){
  1681. ration.workBook.refresh();
  1682. }
  1683. });
  1684. //水平
  1685. SlideResize.loadHorizonWidth(moduleName, [$('#slideResizeLeft'), $('#slideResizeRight')], [$('#leftContent'), $('#midContent'), $('#rightContent')], function () {
  1686. refreshALlWorkBook();
  1687. });
  1688. }
  1689. //初始化视图
  1690. //@param {void} @return {void}
  1691. function initViews(){
  1692. let modules = [bills, guideItem, section, ration];
  1693. initWorkBooks(modules);
  1694. lockUtil.lockTools($(document.body), locked);
  1695. getLibWithBills(libID);
  1696. initBtn();
  1697. initContextMenu();
  1698. initSlideSize();
  1699. }
  1700. return {initViews, initSlideSize};
  1701. })();
  1702. $(document).ready(function () {
  1703. billsGuidance.initViews();
  1704. });