objInfo.ss.jsp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <html>
  2. <head>
  3. <style>
  4. html,
  5. body,
  6. #objInfoApp {
  7. height: 100%;
  8. }
  9. #objInfoApp {
  10. overflow: hidden;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15. <%-- 查看页统一使用新UI选项卡。Lin --%>
  16. <tab.ss name="baseInfo,child"/>
  17. <jsp.ss file="/ss/tabState.jsp"/>
  18. <%-- 页脚 initVue.js 会统一挂载 #app;查看页组件必须使用独立根节点,避免重复挂载后丢失页签事件。 --%>
  19. <div id="app" style="display:none"></div>
  20. <div id="objInfoApp">
  21. <div class="project-edit-container">
  22. <ss-sub-tab
  23. :menu-list="tabConfig"
  24. :active-menu="initialActiveMenu"
  25. @menu-change="handleMenuChange"
  26. :left-display="leftDisplay"
  27. :footer-buttons="footerButtons"
  28. />
  29. </div>
  30. </div>
  31. <script type="text/javascript">
  32. window.objInfoTabItems = [];
  33. <rpt.ss name="${tabList}" id="item">
  34. window.objInfoTabItems.push({
  35. url: "<varServ.ss name='${item.servName}' dest='${item.dest}' parm='${item.parm}'/>",
  36. title: "${item.desc}",
  37. name: "${item.name}",
  38. width: "${item.width}",
  39. height: "${item.height}",
  40. minHeight: "${item.minHeight}",
  41. maxHeight: "${item.maxHeight}",
  42. iconName: "${item.iconName}",
  43. pobj: "${item.pobj}",
  44. cobj: "${item.cobj}"
  45. });
  46. </rpt.ss>
  47. window.objInfoNextTabIndex = Number("<txt.ss val='${ssNextTabNo}'/>");
  48. window.objInfoTabHeight = <txt.ss val="${tabHeight}"/> || {};
  49. function objInfoFitDialogToViewport() {
  50. if (!wd || !wd.display || typeof wd.display.getwdDialogWindows !== "function")
  51. return;
  52. const dialog = wd.display.getwdDialogWindows();
  53. if (!dialog || typeof dialog.getDimension !== "function")
  54. return;
  55. const dimension = dialog.getDimension();
  56. const maxWidth = Math.max(320, wd.topWindow.innerWidth - 20);
  57. const maxHeight = Math.max(320, wd.topWindow.innerHeight - 20);
  58. const width = Math.min(dimension[0], maxWidth);
  59. const height = Math.min(dimension[1], maxHeight);
  60. if (width === dimension[0] && height === dimension[1])
  61. return;
  62. dialog.setDimension(width, height);
  63. dialog.keepInViewport(true);
  64. dialog.center();
  65. }
  66. function objInfoFitHeight() {
  67. const iframe = document.querySelector("#sub-tab-iframe");
  68. const param = window.objInfoTabHeight || {};
  69. let fit = "";
  70. if (param.minHeight)
  71. fit += "min:" + param.minHeight + ",";
  72. if (param.maxHeight)
  73. fit += "max:" + param.maxHeight + ",";
  74. if (iframe && fit)
  75. iframe.setAttribute("ssFith", fit.slice(0, -1));
  76. if (typeof window.initWdFitHeight === "function")
  77. window.initWdFitHeight(33);
  78. }
  79. </script>
  80. <script type="text/javascript">var wdRecordValue='${wdRecordValue}';</script>
  81. <script type="text/javascript" src="/ss/js/wdRecord.js"></script>
  82. <script type="text/javascript">(function(){wdRecord("objInfo");})();</script>
  83. <script type="text/javascript" src="/ss/js/wdFitHeight.js"></script>
  84. <script type="text/javascript">initWdFitHeight(33)</script>
  85. <script type="text/javascript">initWdFitHeightFunction=function(){initWdFitHeight(33);};</script>
  86. <script type="text/javascript">
  87. tokenCleanser("<varServ.ss name='clearPageToken'/>", {
  88. tokenList: "<%= pageContext.getAttribute(ss.page.PageC.PAGE_tokenList)%>"
  89. });
  90. </script>
  91. <script type="module">
  92. const tabConfig = window.objInfoTabItems.map(tab => ({
  93. ...tab,
  94. cgxList: false
  95. }));
  96. const requestedIndex = Number(window.objInfoNextTabIndex);
  97. const initialActiveMenu = Number.isInteger(requestedIndex) && requestedIndex > 0
  98. ? (tabConfig[requestedIndex - 1] || {}).title || ""
  99. : "";
  100. const data = {
  101. tabConfig,
  102. initialActiveMenu,
  103. leftDisplay: true,
  104. footerButtons: [
  105. {
  106. iconName: "icon-close",
  107. text: "关闭",
  108. onclick: function () {
  109. wd.display.closeDialog();
  110. }
  111. }
  112. ]
  113. };
  114. SS.ready(function () {
  115. const app = window.SS.dom.initializeFormApp({
  116. el: "#objInfoApp",
  117. data() {
  118. return data;
  119. },
  120. methods: {
  121. handleMenuChange(menu) {
  122. setTimeout(objInfoFitHeight, 0);
  123. },
  124. async showTagState(url) {
  125. const tokenList = this.tabConfig.map(tab => {
  126. const match = /(?:[?&])ssToken=([^&]+)/.exec(tab.url);
  127. return match ? match[1] : null;
  128. });
  129. try {
  130. const response = await $.post(url, {
  131. tokenList: JSON.stringify(tokenList)
  132. });
  133. const result = typeof response === "string"
  134. ? JSON.parse(response)
  135. : response;
  136. this.tabConfig = this.tabConfig.map((tab, index) => {
  137. if (!result || !result[index])
  138. return tab;
  139. return {
  140. ...tab,
  141. cgxList: result[index].cgxList === true
  142. };
  143. });
  144. } catch (error) {
  145. console.error("获取标签状态失败", error);
  146. }
  147. }
  148. },
  149. mounted() {
  150. setTimeout(objInfoFitDialogToViewport, 0);
  151. setTimeout(objInfoFitHeight, 0);
  152. this.showTagState("<varServ.ss name='wrTabState' parm='{ssObjName:\"${ssObjName}\",ssObjId:\"${ssObjId}\",\"${ssObjIdName}\":\"${ssObjId}\",dataType:\"${dataType}\"}'/>");
  153. }
  154. });
  155. window.SS.dom.currentApp = app;
  156. (function enableObjInfoMenuModeButton() {
  157. try {
  158. if (wd && wd.display && wd.display.enableSsSubTabMenuModeButton
  159. && wd.display.enableSsSubTabMenuModeButton()) {
  160. return;
  161. }
  162. } catch (error) {
  163. console.log(error);
  164. }
  165. setTimeout(enableObjInfoMenuModeButton, 200);
  166. })();
  167. setTimeout(objInfoFitHeight, 200);
  168. setTimeout(objInfoFitHeight, 800);
  169. setTimeout(objInfoFitDialogToViewport, 200);
  170. setTimeout(objInfoFitDialogToViewport, 800);
  171. });
  172. </script>
  173. </body>
  174. </html>