mp_chgChgchk.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta
  6. name="viewport"
  7. content="width=device-width, initial-scale=1.0, user-scalable=no"
  8. />
  9. <title>变动情况 1</title>
  10. <script src="/js/mp_base/base.js"></script>
  11. <style>
  12. [v-cloak] {
  13. display: none !important;
  14. }
  15. #app {
  16. background: #f5f5f5;
  17. min-height: 100vh;
  18. }
  19. /* 新增变动情况页纯转圈加载态 by xu 2026-03-06 */
  20. .loading {
  21. min-height: 40vh;
  22. display: flex;
  23. align-items: center;
  24. justify-content: center;
  25. padding: 32px 16px;
  26. }
  27. .loading-spinner {
  28. width: 30px;
  29. height: 30px;
  30. border: 3px solid #e8f3ed;
  31. border-top-color: #40ac6d;
  32. border-radius: 50%;
  33. animation: page-spin 0.9s linear infinite;
  34. }
  35. @keyframes page-spin {
  36. from {
  37. transform: rotate(0deg);
  38. }
  39. to {
  40. transform: rotate(360deg);
  41. }
  42. }
  43. .status-wrap {
  44. padding: 16px;
  45. }
  46. .status-card {
  47. background: #fff;
  48. border-radius: 8px;
  49. padding: 16px;
  50. box-sizing: border-box;
  51. }
  52. .status-title {
  53. font-size: 15px;
  54. font-weight: 600;
  55. color: #2d3748;
  56. }
  57. .status-text {
  58. margin-top: 8px;
  59. line-height: 1.6;
  60. color: #4a5568;
  61. font-size: 13px;
  62. word-break: break-all;
  63. }
  64. .status-retry {
  65. margin-top: 12px;
  66. height: 34px;
  67. padding: 0 14px;
  68. border: none;
  69. border-radius: 4px;
  70. background: #4a5568;
  71. color: #fff;
  72. font-size: 13px;
  73. }
  74. .ss-sub-tab {
  75. min-height: 100vh;
  76. }
  77. .ss-sub-tab__content {
  78. background: #fff;
  79. }
  80. .ss-sub-tab__content iframe {
  81. width: 100%;
  82. min-height: calc(100vh - 56px);
  83. }
  84. /* 变动页签页补充 URL 调试浮层,便于打开和复制当前地址 by xu 2026-03-08 */
  85. .url-log-fab {
  86. position: fixed;
  87. right: 12px;
  88. bottom: 72px;
  89. z-index: 1200;
  90. border: none;
  91. border-radius: 16px;
  92. background: rgba(36, 40, 53, 0.88);
  93. color: #fff;
  94. font-size: 12px;
  95. line-height: 1;
  96. padding: 8px 10px;
  97. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  98. }
  99. .url-log-panel {
  100. position: fixed;
  101. left: 12px;
  102. right: 12px;
  103. bottom: 116px;
  104. z-index: 1200;
  105. background: rgba(36, 40, 53, 0.96);
  106. color: #fff;
  107. border-radius: 8px;
  108. padding: 10px;
  109. max-height: 42vh;
  110. overflow: auto;
  111. box-sizing: border-box;
  112. }
  113. .url-log-panel__head {
  114. display: flex;
  115. align-items: center;
  116. justify-content: space-between;
  117. margin-bottom: 8px;
  118. font-size: 12px;
  119. }
  120. .url-log-panel__close {
  121. border: none;
  122. background: transparent;
  123. color: #fff;
  124. font-size: 14px;
  125. line-height: 1;
  126. }
  127. .url-log-panel__actions {
  128. display: flex;
  129. flex-wrap: wrap;
  130. gap: 8px;
  131. margin-bottom: 8px;
  132. }
  133. .url-log-action {
  134. border: none;
  135. border-radius: 4px;
  136. padding: 5px 10px;
  137. font-size: 12px;
  138. color: #fff;
  139. background: rgba(255, 255, 255, 0.16);
  140. }
  141. .url-log-panel__body {
  142. margin: 0;
  143. white-space: pre-wrap;
  144. word-break: break-all;
  145. font-size: 12px;
  146. line-height: 1.5;
  147. }
  148. </style>
  149. </head>
  150. <body>
  151. <div id="app" v-cloak>
  152. <!-- 新增变动情况页纯转圈加载态 by xu 2026-03-06 -->
  153. <div v-if="loading" class="loading">
  154. <div class="loading-spinner"></div>
  155. </div>
  156. <div v-else-if="error" class="status-wrap">
  157. <div class="status-card">
  158. <div class="status-title">页面加载失败</div>
  159. <div class="status-text">{{ error }}</div>
  160. <button class="status-retry" type="button" @click="loadTabList">
  161. 重新加载
  162. </button>
  163. </div>
  164. </div>
  165. <div v-else-if="!tabList.length" class="status-wrap">
  166. <div class="status-card">
  167. <div class="status-title">暂无变动页签</div>
  168. <div class="status-text">当前接口未返回可展示的页签数据。</div>
  169. </div>
  170. </div>
  171. <!-- 新增变动情况子页 Tab 承接 by xu 2026-03-06 -->
  172. <ss-sub-tab
  173. v-else
  174. :tab-list="tabList"
  175. :base-params="baseParams"
  176. @tab-change="handleTabChange"
  177. />
  178. <!-- 变动页签页补充 URL 调试入口,便于打开和复制当前地址 by xu 2026-03-08 -->
  179. <button class="url-log-fab" type="button" @click="showCurrentUrls">
  180. URL
  181. </button>
  182. <div class="url-log-panel" v-if="urlLogVisible">
  183. <div class="url-log-panel__head">
  184. <span>当前 URL</span>
  185. <div>
  186. <button class="url-log-action" type="button" @click="showCurrentUrls">显示当前 URL</button>
  187. <button class="url-log-panel__close" type="button" @click="urlLogVisible = false">
  188. ×
  189. </button>
  190. </div>
  191. </div>
  192. <div class="url-log-panel__actions">
  193. <button class="url-log-action" type="button" @click="openCurrentUrl('page')">打开页面</button>
  194. <button class="url-log-action" type="button" @click="copyCurrentUrl('page')">复制页面</button>
  195. <button class="url-log-action" type="button" @click="openCurrentUrl('tab')">打开Tab</button>
  196. <button class="url-log-action" type="button" @click="copyCurrentUrl('tab')">复制Tab</button>
  197. </div>
  198. <pre class="url-log-panel__body">{{ urlLogText }}</pre>
  199. </div>
  200. </div>
  201. <script>
  202. window.SS.ready(function () {
  203. window.SS.dom.initializeFormApp({
  204. el: "#app",
  205. data() {
  206. return {
  207. pageParams: {},
  208. loading: false,
  209. error: "",
  210. tabList: [],
  211. baseParams: {},
  212. urlLogVisible: false,
  213. urlLogText: '',
  214. currentPageUrl: '',
  215. currentTabUrl: '',
  216. };
  217. },
  218. mounted() {
  219. this.pageParams = this.getUrlParams();
  220. this.loadTabList();
  221. },
  222. methods: {
  223. getUrlParams() {
  224. const params = {};
  225. const aliasMap = {
  226. ssobjname: "ssObjName",
  227. ssobjid: "ssObjId",
  228. datatype: "dataType",
  229. };
  230. const urlSearchParams = new URLSearchParams(
  231. window.location.search
  232. );
  233. for (const [rawKey, rawValue] of urlSearchParams) {
  234. const decodedValue = this.safeDecode(rawValue);
  235. params[rawKey] = decodedValue;
  236. const normalizedKey = aliasMap[String(rawKey).toLowerCase()];
  237. if (normalizedKey) {
  238. params[normalizedKey] = decodedValue;
  239. }
  240. }
  241. return params;
  242. },
  243. safeDecode(text) {
  244. if (text === undefined || text === null || text === "") return "";
  245. try {
  246. return decodeURIComponent(String(text));
  247. } catch (_) {
  248. return String(text);
  249. }
  250. },
  251. parseParamObject(paramStr) {
  252. if (!paramStr) return {};
  253. if (typeof paramStr === "object") return paramStr;
  254. try {
  255. return JSON.parse(paramStr);
  256. } catch (_) {
  257. try {
  258. const fixed = String(paramStr)
  259. .replace(/([{,]\s*)([A-Za-z0-9_]+)\s*:/g, '$1"$2":')
  260. .replace(/'/g, '"');
  261. return JSON.parse(fixed);
  262. } catch (error) {
  263. console.error("解析param失败:", error);
  264. return {};
  265. }
  266. }
  267. },
  268. buildBaseParams(serviceName, destName, paramText) {
  269. return {
  270. sqid: this.pageParams.sqid || "",
  271. shid: this.pageParams.shid || "",
  272. shyjm: this.pageParams.shyjm || "",
  273. bdlbm: this.pageParams.bdlbm || "",
  274. dataType: this.pageParams.dataType || this.pageParams.datatype || "bdplay",
  275. encode_shid: this.pageParams.encode_shid || "",
  276. ssObjName: this.pageParams.ssObjName || this.pageParams.ssobjname || "",
  277. ssObjId: this.pageParams.ssObjId || this.pageParams.ssobjid || "",
  278. jdmc: this.pageParams.jdmc || "",
  279. service: serviceName,
  280. dest: destName,
  281. ssServ: serviceName,
  282. ssDest: destName,
  283. param: paramText,
  284. };
  285. },
  286. pickTabList(data) {
  287. if (!data) return [];
  288. if (Array.isArray(data.tabList)) return data.tabList;
  289. if (data.data && Array.isArray(data.data.tabList)) return data.data.tabList;
  290. if (data.chgList && Array.isArray(data.chgList.tabList)) return data.chgList.tabList;
  291. if (Array.isArray(data.tabs)) return data.tabs;
  292. return [];
  293. },
  294. async loadTabList() {
  295. // 按 chgChkTab 规则加载变动子页签数据 by xu 2026-03-06
  296. this.loading = true;
  297. this.error = "";
  298. this.tabList = [];
  299. try {
  300. const serviceName = String(
  301. this.pageParams.service || this.pageParams.ssServ || "selChgInfo"
  302. ).trim();
  303. const destName = String(
  304. this.pageParams.dest || this.pageParams.ssDest || "chgList"
  305. ).trim();
  306. const paramObj = this.parseParamObject(this.pageParams.param);
  307. const requestData = {
  308. ...paramObj,
  309. };
  310. const appendIfMissing = (targetKey, sourceKeys) => {
  311. if (
  312. requestData[targetKey] !== undefined &&
  313. requestData[targetKey] !== null &&
  314. requestData[targetKey] !== ""
  315. ) {
  316. return;
  317. }
  318. for (let i = 0; i < sourceKeys.length; i += 1) {
  319. const value = this.pageParams[sourceKeys[i]];
  320. if (value !== undefined && value !== null && value !== "") {
  321. requestData[targetKey] = value;
  322. return;
  323. }
  324. }
  325. };
  326. appendIfMissing("sqid", ["sqid"]);
  327. appendIfMissing("shid", ["shid"]);
  328. appendIfMissing("ssObjName", ["ssObjName", "ssobjname"]);
  329. appendIfMissing("ssObjId", ["ssObjId", "ssobjid"]);
  330. appendIfMissing("bdlbm", ["bdlbm"]);
  331. appendIfMissing("dataType", ["dataType", "datatype"]);
  332. appendIfMissing("encode_shid", ["encode_shid"]);
  333. appendIfMissing("jdmc", ["jdmc"]);
  334. appendIfMissing("ssToken", ["ssToken"]);
  335. const response = await request.post(
  336. `/service?ssServ=${encodeURIComponent(
  337. serviceName
  338. )}&ssDest=${encodeURIComponent(destName)}`,
  339. requestData,
  340. { loading: false, formData: true }
  341. );
  342. const responseData = response && response.data ? response.data : response;
  343. this.tabList = this.pickTabList(responseData);
  344. this.baseParams = this.buildBaseParams(
  345. serviceName,
  346. destName,
  347. typeof this.pageParams.param === "string"
  348. ? this.pageParams.param
  349. : JSON.stringify(requestData || {})
  350. );
  351. // 新增变动页签单页兜底 by xu 2026-03-06
  352. if (!this.tabList.length && destName) {
  353. this.tabList = [
  354. {
  355. desc: '变动详情',
  356. title: '变动详情',
  357. service: serviceName,
  358. dest: destName,
  359. param: typeof this.pageParams.param === "string"
  360. ? this.pageParams.param
  361. : JSON.stringify(requestData || {}),
  362. },
  363. ];
  364. }
  365. if (!this.tabList.length) {
  366. console.warn("[mp_chgChgchk] 未获取到tabList:", responseData);
  367. }
  368. } catch (error) {
  369. console.error("加载变动情况页签失败:", error);
  370. this.error = (error && error.message) || "加载失败,请稍后重试";
  371. } finally {
  372. this.loading = false;
  373. }
  374. },
  375. getCurrentTabIframeSrc() {
  376. const frame = document.querySelector('.ss-sub-tab__content iframe');
  377. return (frame && frame.src) || '';
  378. },
  379. getCurrentUrlMap() {
  380. return {
  381. page: window.location.href,
  382. tab: this.getCurrentTabIframeSrc(),
  383. };
  384. },
  385. // 功能说明:变动页签页补充“显示当前 URL”按钮,并直接展示 page/tab 文本 by xu 2026-03-08
  386. showCurrentUrls() {
  387. const currentUrls = this.getCurrentUrlMap();
  388. this.currentPageUrl = currentUrls.page || '';
  389. this.currentTabUrl = currentUrls.tab || '';
  390. this.urlLogText = [
  391. `page: ${this.currentPageUrl || '(empty)'}`,
  392. `tab: ${this.currentTabUrl || '(empty)'}`,
  393. ].join('\n');
  394. this.urlLogVisible = true;
  395. },
  396. getUrlByType(type) {
  397. const currentUrls = this.getCurrentUrlMap();
  398. return String(currentUrls[type] || '').trim();
  399. },
  400. async copyText(text) {
  401. const value = String(text || '').trim();
  402. if (!value) throw new Error('empty');
  403. if (navigator.clipboard && navigator.clipboard.writeText) {
  404. await navigator.clipboard.writeText(value);
  405. return;
  406. }
  407. const textarea = document.createElement('textarea');
  408. textarea.value = value;
  409. textarea.style.position = 'fixed';
  410. textarea.style.opacity = '0';
  411. document.body.appendChild(textarea);
  412. textarea.focus();
  413. textarea.select();
  414. document.execCommand('copy');
  415. document.body.removeChild(textarea);
  416. },
  417. async copyCurrentUrl(type) {
  418. try {
  419. await this.copyText(this.getUrlByType(type));
  420. if (typeof showToastEffect === 'function') showToastEffect('URL 已复制', 1400, 'success');
  421. } catch (_) {
  422. if (typeof showToastEffect === 'function') showToastEffect('复制失败', 1800, 'error');
  423. }
  424. },
  425. openCurrentUrl(type) {
  426. const url = this.getUrlByType(type);
  427. if (!url) {
  428. if (typeof showToastEffect === 'function') showToastEffect('当前没有可打开的 URL', 1800, 'warning');
  429. return;
  430. }
  431. const newWindow = window.open(url, '_blank');
  432. if (!newWindow) {
  433. window.location.href = url;
  434. }
  435. },
  436. handleTabChange({ index, tab }) {
  437. console.log("[mp_chgChgchk] 切换页签:", index, tab);
  438. if (this.urlLogVisible) {
  439. setTimeout(() => this.showCurrentUrls(), 80);
  440. }
  441. },
  442. },
  443. });
  444. });
  445. </script>
  446. </body>
  447. </html>