side_tools.js 10 KB

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