side_tools.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. // 块模板库上下拖动(上中)
  120. /* let blockLibTopMid = {};
  121. blockLibTopMid.eleObj = {
  122. module: 'kmbk',
  123. resize: $('#kmbkResizeA'),
  124. top: $('#kmbkTopDiv'),
  125. topSpread: $('#div_block_tree'),
  126. bottom: $('#kmbkMidDiv'),
  127. bottomSpread: $('#div_block_bill')
  128. };
  129. blockLibTopMid.limit = {
  130. min: 100,
  131. max: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-$('#kmbkBottomDiv').height()-100-5*2`,
  132. notTopSpread: 0,
  133. notBottomSpread: 0,
  134. totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-$('#kmbkBottomDiv').height()-5*2` //5: resize.height()
  135. };
  136. SlideResize.verticalSlide(blockLibTopMid.eleObj, blockLibTopMid.limit, function () {
  137. blockLibObj.refreshSpread();
  138. });
  139. // 块模板库上下拖动(中下)
  140. let blockLibMidBottom = {};
  141. blockLibMidBottom.eleObj = {
  142. module: 'kmbk',
  143. resize: $('#kmbkResizeB'),
  144. top: $('#kmbkMidDiv'),
  145. topSpread: $('#div_block_bill'),
  146. bottom: $('#kmbkBottomDiv'),
  147. bottomSpread: $('#div_block_ration')
  148. };
  149. blockLibMidBottom.limit = {
  150. min: 100,
  151. max: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-$('#kmbkTopDiv').height()-100-5*2`,
  152. notTopSpread: 0,
  153. notBottomSpread: 0,
  154. totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-$('#kmbkTopDiv').height()-5*2` //5: resize.height()
  155. };
  156. SlideResize.verticalSlide(blockLibMidBottom.eleObj, blockLibMidBottom.limit, function () {
  157. blockLibObj.refreshSpread();
  158. });
  159. //加载块模板库多个结构的变量对象
  160. let blockLibMulti = {
  161. module: 'kmbk',
  162. eles: [
  163. {container: $('#kmbkTopDiv'), spread: $('#div_block_tree'), notSpread: 0, defaultProportion: 0.6},
  164. {container: $('#kmbkMidDiv'), spread: $('#div_block_bill'), notSpread: 0, defaultProportion: 0.15},
  165. {container: $('#kmbkBottomDiv'), spread: $('#div_block_ration'), notSpread: 0, defaultProportion: 0.25},
  166. ],
  167. totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-5*2`
  168. }; */
  169. // 组价模板(新的块模板库,上下结构)
  170. function getBlockResize() {
  171. let resizeObj = {};
  172. resizeObj.eleObj = {
  173. module: 'zjmb',
  174. resize: $('#kmbkResizeB'),
  175. top: $('#kmbkTopDiv'),
  176. topSpread: $('#div_block_tree'),
  177. bottom: $('#kmbkBottomDiv'),
  178. bottomSpread: $('#div_block_ration')
  179. };
  180. resizeObj.limit = {
  181. min: 100,
  182. max: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-100-5`,
  183. notTopSpread: 0,
  184. notBottomSpread: 0,
  185. totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-5`
  186. };
  187. return resizeObj;
  188. }
  189. let blockLibResize = getBlockResize();
  190. SlideResize.verticalSlide(blockLibResize.eleObj, blockLibResize.limit, function () {
  191. blockLibObj.refreshSpread();
  192. });
  193. //加载各库内部上下高度(有的库需要上下拖动)
  194. function loadSideToolsHeight() {
  195. //定额库
  196. if ($('#de').is(':visible')) {
  197. SlideResize.loadVerticalHeight(rationLibResizeEles.eleObj.module, rationLibResizeEles.eleObj, rationLibResizeEles.limit, function () {
  198. rationLibObj.refreshSpread();
  199. });
  200. } else if ($('#locate').is(':visible')) {
  201. //查找定位
  202. let options = $("input[name='content_type']:checked").val();
  203. locateObject.refreshView(options, true);
  204. } else if ($('#kmbk').is(':visible')) {
  205. SlideResize.loadVerticalHeight(blockLibResize.eleObj.module, blockLibResize.eleObj, blockLibResize.limit, function () {
  206. blockLibObj.refreshSpread();
  207. });
  208. /* SlideResize.loadMultiVerticalHeight(blockLibMulti.module, blockLibMulti.eles, blockLibMulti.totalHeight, function () {
  209. blockLibObj.refreshSpread();
  210. }); */
  211. }else if($('#divide_de').is(':visible')){
  212. SlideResize.loadVerticalHeight(dividRationLibResizeEles.eleObj.module, dividRationLibResizeEles.eleObj, dividRationLibResizeEles.limit, function () {
  213. //rationLibObj.refreshSpread();
  214. });
  215. }
  216. }
  217. var sideToolsObj = {
  218. showSideTools: function (tabPanel, show, id) {
  219. sideResizeEles.eleObj.module = id;
  220. if (show) {
  221. //刚打开各库时的默认比例
  222. sideResizeEles.eleObj.left.css('width', '66.666667%');
  223. sideResizeEles.eleObj.right.css('width', '33.333333%');
  224. SlideResize.setResizeWidth(sideResizeEles.eleObj.resize);
  225. $('.main-side .tab-pane').hide();
  226. id === 'locateTab'?tabPanel.show(locateObject.onshow):tabPanel.show();//locateTab要等div显示后才执行刷新操作
  227. //加载打开的库与主界面的宽度比
  228. SlideResize.loadHorizonWidth(id, [sideResizeEles.eleObj.resize], [sideResizeEles.eleObj.left, sideResizeEles.eleObj.right], function(){
  229. if (id === 'stdRationTab') {//加载定额库内部上下高度
  230. SlideResize.loadVerticalHeight(rationLibResizeEles.eleObj.module, rationLibResizeEles.eleObj, rationLibResizeEles.limit, function () {
  231. sheetCommonObj.setColumnWidthByRate($('#stdRationChapter').width() - 30, rationLibObj.rationChapterSpread, rationLibObj.rationChapterTreeSetting.cols);
  232. });
  233. } else if (id === 'blockLibTab') {//块模板库
  234. /* SlideResize.loadMultiVerticalHeight(blockLibMulti.module, blockLibMulti.eles, blockLibMulti.totalHeight, function () {
  235. blockLibObj.refreshSpread();
  236. }); */
  237. SlideResize.loadVerticalHeight(blockLibResize.eleObj.module, blockLibResize.eleObj, blockLibResize.limit, function () {
  238. blockLibObj.refreshSpread();
  239. });
  240. }
  241. });
  242. } else {
  243. sideResizeEles.eleObj.left.css('width', '100%');
  244. sideResizeEles.eleObj.right.css('width', '0%');
  245. tabPanel.hide();
  246. }
  247. autoFlashHeight();
  248. subObj.initGljSubTab();
  249. billsGuidance.refreshWorkBook();
  250. billsLibObj.refreshBillsSpread();
  251. refreshSubSpread();
  252. billsLibObj.refreshBillsRelaSpread();
  253. rationLibObj.refreshSpread();//subSpread、jobSpread、itemSpread显示问题
  254. zmhs_obj.refresh();
  255. }
  256. };
  257. $('.right-nav-link').bind('click', function () {//$('.side-tabs ul li a').bind 2018-11-23 使用更多标签,所以不能这样绑定事件了
  258. var tab = $(this), tabPanel = $(tab.attr('relaPanel'));
  259. if(tab.hasClass('disabled')){
  260. return;
  261. }
  262. let setActiveTab = tab.hasClass("dropdown-item")?tab.parent().prev('.nav-link'):tab;//如果是点击了更多下拉菜单的子项,则需设置成active 的tab是“更多”
  263. if (!(setActiveTab.hasClass('active')&&tabPanel.is(":visible"))) {
  264. $('.side-tabs ul li a').removeClass('active');
  265. setActiveTab.addClass('active');
  266. sideToolsObj.showSideTools(tabPanel, true, tab.attr('id'));
  267. } else {
  268. setActiveTab.removeClass('active');
  269. sideToolsObj.showSideTools(tabPanel, false, tab.attr('id'));
  270. }
  271. projectObj.refreshMainSpread();
  272. });