side_tools.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /**
  2. * Created by Mai on 2017/6/16.
  3. */
  4. $(window).resize(function() {
  5. autoFlashHeight();
  6. if ($('#stdRationChapter').width() > 0) {
  7. sheetCommonObj.setColumnWidthByRate($('#stdRationChapter').width() - 30, rationLibObj.rationChapterSpread, rationLibObj.rationChapterTreeSetting.cols);
  8. }
  9. billsGuidance.setColumnWidthByRate(billsGuidance.elfItem.workBook, $('#zy').width(), billsGuidance.elfItem.headers);
  10. billsGuidance.refreshWorkBook();
  11. rationLibObj.refreshSpread();
  12. loadDivideHeight();
  13. //BillsElf.setColumnWidthByRate();
  14. loadSideToolsHeight();
  15. //刷新主界面与各库中间的拖动条宽度:始终保持为一个宽度(在小窗口打开一个库,再放大窗口后,该拖动条宽度会变大)
  16. SlideResize.setResizeWidth($('#sideResize'));
  17. subObj.initGljSubTab();
  18. refreshSubSpread();
  19. });
  20. //造价书与各库左右拖动
  21. let sideResizeEles = {};
  22. sideResizeEles.eleObj = {
  23. module: 'stdBillsGuidanceTab',
  24. resize: $('#sideResize'),
  25. parent: $('#mainRow'),
  26. left: $('#main'),
  27. right: $('#mainSide')
  28. };
  29. sideResizeEles.limit = {
  30. min: 150,
  31. max: `$('#mainRow').width()-150`
  32. };
  33. SlideResize.horizontalSlide(sideResizeEles.eleObj, sideResizeEles.limit, function(){
  34. // MaterialController.showReplaceDiv();
  35. subObj.initGljSubTab();
  36. //BillsElf.setColumnWidthByRate();
  37. projectObj.refreshMainSpread();
  38. refreshSubSpread();
  39. if (sideResizeEles.eleObj.module === 'stdBillsGuidanceTab') {//清单精灵(规则)
  40. billsGuidance.setColumnWidthByRate(billsGuidance.elfItem.workBook, $('#zy').width(), billsGuidance.elfItem.headers);
  41. billsGuidance.refreshWorkBook();
  42. } else if (sideResizeEles.eleObj.module === 'stdRationTab') {//定额库
  43. sheetCommonObj.setColumnWidthByRate($('#stdRationChapter').width() - 40, rationLibObj.rationChapterSpread, rationLibObj.rationChapterTreeSetting.cols);
  44. rationLibObj.refreshSpread();
  45. } else if (sideResizeEles.eleObj.module === 'blockLibTab') {//块模板库
  46. blockLibObj.refreshSpread();
  47. } else if (sideResizeEles.eleObj.module === 'locateTab'){//查找定位
  48. locateObject.refreshWorkBook();
  49. }
  50. });
  51. //定额库上下拖动
  52. let rationLibResizeEles = {};
  53. rationLibResizeEles.eleObj = {
  54. module: 'de',
  55. resize: $('#deResize'),
  56. top: $('#deTopDiv'),
  57. topSpread: $('#stdRationChapter'),
  58. bottom: $('#deBottomDiv'),
  59. bottomSpread: $('#stdSectionRations')
  60. };
  61. rationLibResizeEles.limit = {
  62. min: 150,
  63. max: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#deToolsBar').height()-150-5`,//5: resize.height()
  64. notTopSpread: 0,
  65. notBottomSpread: 0,
  66. totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#deToolsBar').height()-5`
  67. };
  68. SlideResize.verticalSlide(rationLibResizeEles.eleObj, rationLibResizeEles.limit, function () {
  69. rationLibObj.refreshSpread();
  70. });
  71. //查找定位上下拖动
  72. function getLocateLibResize(){
  73. let resizeObj = {};
  74. resizeObj.eleObj = {
  75. module: 'locate',
  76. resize: $('#locate_resize'),
  77. top: $('#locateTopDiv'),
  78. topSpread: $('#locate_result'),
  79. bottom: $('#locateBottomDiv'),
  80. bottomSpread: $('#locate_sub')
  81. };
  82. resizeObj.limit = {
  83. min: 150,
  84. max: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#searchPanel').height()-150-5`,//5: resize.height()
  85. notTopSpread: 0,
  86. notBottomSpread: 0,
  87. totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#searchPanel').height()-5`
  88. };
  89. return resizeObj;
  90. }
  91. let locateLibResize = getLocateLibResize();
  92. SlideResize.verticalSlide(locateLibResize.eleObj, locateLibResize.limit, function () {
  93. locateObject.refreshWorkBook();
  94. });
  95. function getBookmarkResize() {
  96. let resizeObj = {};
  97. resizeObj.eleObj = {
  98. module: 'bookmark',
  99. resize: $('#bookmark_resize'),
  100. top: $('#bookmarkTopDiv'),
  101. topSpread: $('#bookmarkSpread'),
  102. bottom: $('#annotationDiv'),
  103. bottomSpread: $('#annotationTextarea')
  104. };
  105. resizeObj.limit = {
  106. min: 150,
  107. max: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#searchPanel').height()-100-5`,//5: resize.height()
  108. notTopSpread: 35,
  109. notBottomSpread: 15,
  110. totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#searchPanel').height()-5`//5: resize.height()
  111. };
  112. return resizeObj;
  113. }
  114. let bookMarkLibResize = getBookmarkResize();
  115. SlideResize.verticalSlide(bookMarkLibResize.eleObj, bookMarkLibResize.limit, function () {
  116. locateObject.refreshWorkBook();
  117. });
  118. // 块模板库上下拖动(上中)
  119. let blockLibTopMid = {};
  120. blockLibTopMid.eleObj = {
  121. module: 'kmbk',
  122. resize: $('#kmbkResizeA'),
  123. top: $('#kmbkTopDiv'),
  124. topSpread: $('#div_block_tree'),
  125. bottom: $('#kmbkMidDiv'),
  126. bottomSpread: $('#div_block_bill')
  127. };
  128. blockLibTopMid.limit = {
  129. min: 100,
  130. max: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-$('#kmbkBottomDiv').height()-100-5*2`,
  131. notTopSpread: 0,
  132. notBottomSpread: 0,
  133. totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-$('#kmbkBottomDiv').height()-5*2` //5: resize.height()
  134. };
  135. SlideResize.verticalSlide(blockLibTopMid.eleObj, blockLibTopMid.limit, function () {
  136. blockLibObj.refreshSpread();
  137. });
  138. // 块模板库上下拖动(中下)
  139. let blockLibMidBottom = {};
  140. blockLibMidBottom.eleObj = {
  141. module: 'kmbk',
  142. resize: $('#kmbkResizeB'),
  143. top: $('#kmbkMidDiv'),
  144. topSpread: $('#div_block_bill'),
  145. bottom: $('#kmbkBottomDiv'),
  146. bottomSpread: $('#div_block_ration')
  147. };
  148. blockLibMidBottom.limit = {
  149. min: 100,
  150. max: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-$('#kmbkTopDiv').height()-100-5*2`,
  151. notTopSpread: 0,
  152. notBottomSpread: 0,
  153. totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-$('#kmbkTopDiv').height()-5*2` //5: resize.height()
  154. };
  155. SlideResize.verticalSlide(blockLibMidBottom.eleObj, blockLibMidBottom.limit, function () {
  156. blockLibObj.refreshSpread();
  157. });
  158. //加载块模板库多个结构的变量对象
  159. let blockLibMulti = {
  160. module: 'kmbk',
  161. eles: [
  162. {container: $('#kmbkTopDiv'), spread: $('#div_block_tree'), notSpread: 0, defaultProportion: 0.6},
  163. {container: $('#kmbkMidDiv'), spread: $('#div_block_bill'), notSpread: 0, defaultProportion: 0.15},
  164. {container: $('#kmbkBottomDiv'), spread: $('#div_block_ration'), notSpread: 0, defaultProportion: 0.25},
  165. ],
  166. totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-5*2`
  167. };
  168. //加载各库内部上下高度(有的库需要上下拖动)
  169. function loadSideToolsHeight() {
  170. //定额库
  171. if ($('#de').is(':visible')) {
  172. SlideResize.loadVerticalHeight(rationLibResizeEles.eleObj.module, rationLibResizeEles.eleObj, rationLibResizeEles.limit, function () {
  173. rationLibObj.refreshSpread();
  174. });
  175. } else if ($('#locate').is(':visible')) {
  176. //查找定位
  177. let options = $("input[name='content_type']:checked").val();
  178. locateObject.refreshView(options, true);
  179. } else if ($('#kmbk').is(':visible')) {
  180. SlideResize.loadMultiVerticalHeight(blockLibMulti.module, blockLibMulti.eles, blockLibMulti.totalHeight, function () {
  181. blockLibObj.refreshSpread();
  182. });
  183. }else if($('#divide_de').is(':visible')){
  184. SlideResize.loadVerticalHeight(dividRationLibResizeEles.eleObj.module, dividRationLibResizeEles.eleObj, dividRationLibResizeEles.limit, function () {
  185. //rationLibObj.refreshSpread();
  186. });
  187. }
  188. }
  189. var sideToolsObj = {
  190. showSideTools: function (tabPanel, show, id) {
  191. sideResizeEles.eleObj.module = id;
  192. if (show) {
  193. //刚打开各库时的默认比例
  194. sideResizeEles.eleObj.left.css('width', '66.666667%');
  195. sideResizeEles.eleObj.right.css('width', '33.333333%');
  196. SlideResize.setResizeWidth(sideResizeEles.eleObj.resize);
  197. $('.main-side .tab-pane').hide();
  198. id === 'locateTab'?tabPanel.show(locateObject.onshow):tabPanel.show();//locateTab要等div显示后才执行刷新操作
  199. //加载打开的库与主界面的宽度比
  200. SlideResize.loadHorizonWidth(id, [sideResizeEles.eleObj.resize], [sideResizeEles.eleObj.left, sideResizeEles.eleObj.right], function(){
  201. if (id === 'stdRationTab') {//加载定额库内部上下高度
  202. SlideResize.loadVerticalHeight(rationLibResizeEles.eleObj.module, rationLibResizeEles.eleObj, rationLibResizeEles.limit, function () {
  203. sheetCommonObj.setColumnWidthByRate($('#stdRationChapter').width() - 30, rationLibObj.rationChapterSpread, rationLibObj.rationChapterTreeSetting.cols);
  204. });
  205. } else if (id === 'blockLibTab') {//块模板库
  206. SlideResize.loadMultiVerticalHeight(blockLibMulti.module, blockLibMulti.eles, blockLibMulti.totalHeight, function () {
  207. blockLibObj.refreshSpread();
  208. });
  209. }
  210. });
  211. } else {
  212. sideResizeEles.eleObj.left.css('width', '100%');
  213. sideResizeEles.eleObj.right.css('width', '0%');
  214. tabPanel.hide();
  215. }
  216. autoFlashHeight();
  217. subObj.initGljSubTab();
  218. billsGuidance.refreshWorkBook();
  219. billsLibObj.refreshBillsSpread();
  220. refreshSubSpread();
  221. billsLibObj.refreshBillsRelaSpread();
  222. rationLibObj.refreshSpread();//subSpread、jobSpread、itemSpread显示问题
  223. zmhs_obj.refresh();
  224. }
  225. };
  226. $('.right-nav-link').bind('click', function () {//$('.side-tabs ul li a').bind 2018-11-23 使用更多标签,所以不能这样绑定事件了
  227. var tab = $(this), tabPanel = $(tab.attr('relaPanel'));
  228. if(tab.hasClass('disabled')){
  229. return;
  230. }
  231. let setActiveTab = tab.hasClass("dropdown-item")?tab.parent().prev('.nav-link'):tab;//如果是点击了更多下拉菜单的子项,则需设置成active 的tab是“更多”
  232. if (!(setActiveTab.hasClass('active')&&tabPanel.is(":visible"))) {
  233. $('.side-tabs ul li a').removeClass('active');
  234. setActiveTab.addClass('active');
  235. sideToolsObj.showSideTools(tabPanel, true, tab.attr('id'));
  236. } else {
  237. setActiveTab.removeClass('active');
  238. sideToolsObj.showSideTools(tabPanel, false, tab.attr('id'));
  239. }
  240. projectObj.refreshMainSpread();
  241. });