mp_addChk.html 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973
  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>审核</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. height: 100vh;
  18. display: flex;
  19. flex-direction: column;
  20. overflow: hidden;
  21. box-sizing: border-box;
  22. }
  23. .frame-wrap {
  24. flex: 1;
  25. display: flex;
  26. flex-direction: column;
  27. overflow: hidden;
  28. }
  29. .top-iframe,
  30. .bottom-iframe {
  31. width: 100%;
  32. border: none;
  33. display: block;
  34. background: #fff;
  35. }
  36. .top-iframe {
  37. flex: none;
  38. height: 60%;
  39. }
  40. .bottom-iframe {
  41. flex: none;
  42. height: 40%;
  43. }
  44. .status-wrap {
  45. flex: 1;
  46. display: flex;
  47. align-items: center;
  48. justify-content: center;
  49. padding: 16px;
  50. box-sizing: border-box;
  51. }
  52. .status-card {
  53. width: 100%;
  54. max-width: 520px;
  55. background: #fff;
  56. border-radius: 8px;
  57. padding: 16px;
  58. box-sizing: border-box;
  59. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  60. }
  61. .status-title {
  62. font-size: 15px;
  63. font-weight: 600;
  64. color: #2d3748;
  65. }
  66. .status-text {
  67. margin-top: 8px;
  68. line-height: 1.6;
  69. color: #4a5568;
  70. font-size: 13px;
  71. word-break: break-all;
  72. }
  73. .status-retry {
  74. margin-top: 12px;
  75. height: 34px;
  76. padding: 0 14px;
  77. border: none;
  78. border-radius: 4px;
  79. background: #4a5568;
  80. color: #fff;
  81. font-size: 13px;
  82. }
  83. .url-log-fab {
  84. position: fixed;
  85. right: 12px;
  86. bottom: 72px;
  87. z-index: 1200;
  88. border: none;
  89. border-radius: 16px;
  90. background: rgba(36, 40, 53, 0.88);
  91. color: #fff;
  92. font-size: 12px;
  93. line-height: 1;
  94. padding: 8px 10px;
  95. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  96. }
  97. .url-log-panel {
  98. position: fixed;
  99. left: 12px;
  100. right: 12px;
  101. bottom: 116px;
  102. z-index: 1200;
  103. background: rgba(36, 40, 53, 0.96);
  104. color: #fff;
  105. border-radius: 8px;
  106. padding: 10px;
  107. max-height: 42vh;
  108. overflow: auto;
  109. box-sizing: border-box;
  110. }
  111. .url-log-panel__head {
  112. display: flex;
  113. align-items: center;
  114. justify-content: space-between;
  115. margin-bottom: 8px;
  116. font-size: 12px;
  117. }
  118. .url-log-panel__close {
  119. border: none;
  120. background: transparent;
  121. color: #fff;
  122. font-size: 14px;
  123. line-height: 1;
  124. }
  125. .url-log-panel__body {
  126. margin: 0;
  127. white-space: pre-wrap;
  128. word-break: break-all;
  129. font-size: 12px;
  130. line-height: 1.5;
  131. }
  132. </style>
  133. </head>
  134. <body>
  135. <div id="app" v-cloak>
  136. <div class="frame-wrap" v-if="initStatus === 'ready'">
  137. <iframe
  138. ref="topIframe"
  139. class="top-iframe"
  140. :src="topIframeSrc"
  141. frameborder="0"
  142. :style="topIframeHeight > 0 ? { height: `${topIframeHeight}px` } : null"
  143. ></iframe>
  144. <iframe
  145. ref="bottomIframe"
  146. class="bottom-iframe"
  147. :src="bottomIframeSrc"
  148. frameborder="0"
  149. :style="bottomIframeHeight > 0 ? { height: `${bottomIframeHeight}px` } : null"
  150. ></iframe>
  151. </div>
  152. <div class="status-wrap" v-else>
  153. <div class="status-card">
  154. <div class="status-title">{{ initStatusTitle }}</div>
  155. <div class="status-text">{{ initStatusMessage }}</div>
  156. <div class="status-text" v-if="missingParams.length > 0">
  157. 缺少参数:{{ missingParams.join('、') }}
  158. </div>
  159. <button class="status-retry" type="button" @click="callApi">
  160. 重新加载
  161. </button>
  162. </div>
  163. </div>
  164. <ss-bottom
  165. :buttons="bottomButtons"
  166. :show-shyj="true"
  167. @button-click="handleBottomAction"
  168. :disabled="submitting"
  169. v-if="initStatus === 'ready' && bottomButtons.length > 0"
  170. ></ss-bottom>
  171. <button class="url-log-fab" type="button" @click="showCurrentUrls">
  172. URL
  173. </button>
  174. <div class="url-log-panel" v-if="urlLogVisible">
  175. <div class="url-log-panel__head">
  176. <span>当前 URL</span>
  177. <button
  178. class="url-log-panel__close"
  179. type="button"
  180. @click="urlLogVisible = false"
  181. >
  182. ×
  183. </button>
  184. </div>
  185. <pre class="url-log-panel__body">{{ urlLogText }}</pre>
  186. </div>
  187. </div>
  188. <script>
  189. window.SS.ready(function () {
  190. window.SS.dom.initializeFormApp({
  191. el: "#app",
  192. data() {
  193. return {
  194. pageParams: {},
  195. loading: false,
  196. submitting: false,
  197. jdmc: "",
  198. sqid: "",
  199. shid: "",
  200. ssObjName: "",
  201. ssObjId: "",
  202. initStatus: "loading",
  203. initStatusTitle: "页面初始化中",
  204. initStatusMessage: "正在加载审核数据,请稍候...",
  205. missingParams: [],
  206. topIframeSrc: "",
  207. bottomIframeSrc: "",
  208. infoData: null,
  209. agrAddData: null,
  210. rejAddData: null,
  211. bottomButtons: [],
  212. layoutCalculated: false,
  213. headerSectionHeight: 0,
  214. availableHeight: 0,
  215. topIframeHeight: 0,
  216. bottomIframeHeight: 0,
  217. bottomIframeMinHeight: 0,
  218. isExpanded: false,
  219. isDragging: false,
  220. dragStartY: 0,
  221. dragStartBottomHeight: 0,
  222. bottomBarHeight: 0,
  223. layoutObserver: null,
  224. bottomResizeObserver: null,
  225. dragRafId: 0,
  226. pendingDeltaY: 0,
  227. lastDragEndAt: 0,
  228. urlLogVisible: false,
  229. urlLogText: "",
  230. };
  231. },
  232. mounted() {
  233. this.pageParams = this.getUrlParams();
  234. window.addEventListener("message", this.handleIframeMessage);
  235. this.callApi();
  236. },
  237. beforeDestroy() {
  238. window.removeEventListener("message", this.handleIframeMessage);
  239. this.unbindLayoutObserver();
  240. if (this.dragRafId) {
  241. cancelAnimationFrame(this.dragRafId);
  242. this.dragRafId = 0;
  243. }
  244. },
  245. methods: {
  246. normalizeError(error) {
  247. return {
  248. message: (error && error.message) || String(error),
  249. stack: (error && error.stack) || "",
  250. response: (error && error.response) || null,
  251. data: (error && error.data) || null,
  252. };
  253. },
  254. getUrlParams() {
  255. const params = {};
  256. const aliasMap = {
  257. ssobjname: "ssObjName",
  258. ssobjid: "ssObjId",
  259. sqid: "sqid",
  260. shid: "shid",
  261. };
  262. const urlSearchParams = new URLSearchParams(
  263. window.location.search
  264. );
  265. for (const [rawKey, rawValue] of urlSearchParams) {
  266. const decodedValue = this.safeDecode(rawValue);
  267. params[rawKey] = decodedValue;
  268. const normalizedKey = aliasMap[String(rawKey).toLowerCase()];
  269. if (normalizedKey) {
  270. params[normalizedKey] = decodedValue;
  271. }
  272. }
  273. return params;
  274. },
  275. setInitStatus(status, title, message) {
  276. this.initStatus = status;
  277. this.initStatusTitle = title || "";
  278. this.initStatusMessage = message || "";
  279. },
  280. safeDecode(text) {
  281. if (text === undefined || text === null || text === "") return "";
  282. try {
  283. return decodeURIComponent(String(text));
  284. } catch (_) {
  285. return String(text);
  286. }
  287. },
  288. pickFirstValue(sources, keys) {
  289. const srcArr = Array.isArray(sources) ? sources : [];
  290. const keyArr = Array.isArray(keys) ? keys : [];
  291. for (let i = 0; i < srcArr.length; i += 1) {
  292. const src = srcArr[i];
  293. if (!src || typeof src !== "object") continue;
  294. for (let j = 0; j < keyArr.length; j += 1) {
  295. const key = keyArr[j];
  296. const value = src[key];
  297. if (value !== undefined && value !== null && value !== "") {
  298. return value;
  299. }
  300. }
  301. }
  302. return "";
  303. },
  304. extractTokenData(apiResponse) {
  305. const wantedKeys = [
  306. "sqid",
  307. "shid",
  308. "ssObjName",
  309. "ssObjId",
  310. "jdmc",
  311. ];
  312. const candidates = [
  313. apiResponse && apiResponse.data && apiResponse.data.ssData,
  314. apiResponse && apiResponse.ssData,
  315. apiResponse && apiResponse.data,
  316. apiResponse,
  317. ];
  318. let best = {};
  319. let bestScore = -1;
  320. candidates.forEach((item) => {
  321. if (!item || typeof item !== "object") return;
  322. let score = 0;
  323. wantedKeys.forEach((key) => {
  324. if (
  325. item[key] !== undefined &&
  326. item[key] !== null &&
  327. item[key] !== ""
  328. ) {
  329. score += 1;
  330. }
  331. });
  332. if (score > bestScore) {
  333. best = item;
  334. bestScore = score;
  335. }
  336. });
  337. return best;
  338. },
  339. resolveBusinessContext(apiResponse) {
  340. const tokenData = this.extractTokenData(apiResponse);
  341. const sources = [tokenData, this.pageParams];
  342. const resolvedObjId = String(
  343. this.pickFirstValue(sources, ["ssObjId", "ssobjid"]) || ""
  344. );
  345. return {
  346. sqid: String(this.pickFirstValue(sources, ["sqid"]) || ""),
  347. shid: String(this.pickFirstValue(sources, ["shid"]) || ""),
  348. ssObjName: String(
  349. this.pickFirstValue(sources, ["ssObjName", "ssobjname"]) || ""
  350. ),
  351. ssObjId: resolvedObjId,
  352. jdmc: this.safeDecode(
  353. this.pickFirstValue(sources, ["jdmc"]) || ""
  354. ),
  355. };
  356. },
  357. parseInfoParm(rawParm) {
  358. if (!rawParm) return {};
  359. if (typeof rawParm === "object") return rawParm;
  360. const text = String(rawParm).trim();
  361. if (!text) return {};
  362. try {
  363. return JSON.parse(text);
  364. } catch (_) {}
  365. try {
  366. const normalized = text
  367. .replace(/([{,]\s*)([A-Za-z0-9_]+)\s*:/g, '$1"$2":')
  368. .replace(/'/g, '"');
  369. return JSON.parse(normalized);
  370. } catch (_) {
  371. return {};
  372. }
  373. },
  374. resolveInfoDestPath(destName) {
  375. const raw = String(destName || "").trim();
  376. if (!raw) return "";
  377. if (/^https?:\/\//i.test(raw)) return raw;
  378. if (raw.startsWith("/")) return raw;
  379. if (raw.endsWith(".html")) return `/page/${raw}`;
  380. if (raw.startsWith("mp_")) return `/page/${raw}.html`;
  381. return `/page/mp_${raw}.html`;
  382. },
  383. buildInfoIframeSrc(infoData, fallbackQuery) {
  384. const conf =
  385. infoData && typeof infoData === "object" ? infoData : {};
  386. const serviceName = conf.service || conf.servName || "";
  387. const destName = conf.dest || "";
  388. const parmObj = this.parseInfoParm(conf.parm);
  389. const mergedQuery = {
  390. ...(fallbackQuery || {}),
  391. ...(parmObj || {}),
  392. };
  393. if (!serviceName || !destName) {
  394. return this.buildIframeSrc(
  395. "/page/mp_objInfo.html",
  396. mergedQuery
  397. );
  398. }
  399. const pagePath = this.resolveInfoDestPath(destName);
  400. if (!pagePath) {
  401. return this.buildIframeSrc(
  402. "/page/mp_objInfo.html",
  403. mergedQuery
  404. );
  405. }
  406. const paramText =
  407. typeof conf.parm === "string"
  408. ? conf.parm
  409. : JSON.stringify(parmObj || {});
  410. const iframeQuery = {
  411. ...mergedQuery,
  412. ssServ: serviceName,
  413. ssDest: destName,
  414. service: serviceName,
  415. dest: destName,
  416. param: paramText,
  417. };
  418. return this.buildIframeSrc(pagePath, iframeQuery);
  419. },
  420. buildIframeSrc(path, queryObj) {
  421. const search = new URLSearchParams(queryObj);
  422. return `${path}?${search.toString()}`;
  423. },
  424. buildCommonQuery() {
  425. return {
  426. sqid: this.sqid,
  427. shid: this.shid,
  428. ssObjName: this.ssObjName,
  429. ssObjId: this.ssObjId,
  430. };
  431. },
  432. initializeLayout() {
  433. this.$nextTick(() => {
  434. const bottomIframe = this.$refs.bottomIframe;
  435. if (!bottomIframe || !bottomIframe.contentWindow) return;
  436. const waitForHeaderSection = () => {
  437. try {
  438. const iframeDoc = bottomIframe.contentWindow.document;
  439. const headerSection =
  440. iframeDoc.querySelector(".header-section");
  441. if (!headerSection) {
  442. setTimeout(waitForHeaderSection, 120);
  443. return;
  444. }
  445. const headerHeight = headerSection.offsetHeight || 0;
  446. this.headerSectionHeight = headerHeight;
  447. this.bottomIframeMinHeight = Math.max(44, headerHeight);
  448. this.recalculateLayoutMetrics();
  449. if (!this.layoutCalculated) {
  450. this.bottomIframeHeight = this.bottomIframeMinHeight;
  451. this.topIframeHeight = Math.max(
  452. 0,
  453. this.availableHeight - this.bottomIframeHeight
  454. );
  455. } else {
  456. const currentBottom =
  457. this.bottomIframeHeight || this.bottomIframeMinHeight;
  458. this.bottomIframeHeight = Math.max(
  459. this.bottomIframeMinHeight,
  460. Math.min(currentBottom, this.availableHeight)
  461. );
  462. this.topIframeHeight = Math.max(
  463. 0,
  464. this.availableHeight - this.bottomIframeHeight
  465. );
  466. }
  467. this.layoutCalculated = true;
  468. this.applyIframeHeights();
  469. this.bindLayoutObserver();
  470. } catch (error) {
  471. setTimeout(waitForHeaderSection, 180);
  472. }
  473. };
  474. setTimeout(waitForHeaderSection, 80);
  475. });
  476. },
  477. recalculateLayoutMetrics() {
  478. const viewportHeight = window.innerHeight || 0;
  479. const bottomBar = document.querySelector("#app .ss-bottom");
  480. this.bottomBarHeight = bottomBar ? bottomBar.offsetHeight : 0;
  481. this.availableHeight = Math.max(
  482. 0,
  483. viewportHeight - this.bottomBarHeight
  484. );
  485. },
  486. handleLayoutResize() {
  487. if (!this.layoutCalculated) return;
  488. this.recalculateLayoutMetrics();
  489. const bottomActualHeight = Math.max(
  490. this.bottomIframeMinHeight,
  491. Math.min(
  492. this.bottomIframeHeight || this.bottomIframeMinHeight,
  493. this.availableHeight
  494. )
  495. );
  496. this.bottomIframeHeight = bottomActualHeight;
  497. this.topIframeHeight = Math.max(
  498. 0,
  499. this.availableHeight - bottomActualHeight
  500. );
  501. this.applyIframeHeights();
  502. },
  503. bindLayoutObserver() {
  504. if (!this.layoutObserver) {
  505. this.layoutObserver = () => this.handleLayoutResize();
  506. window.addEventListener("resize", this.layoutObserver);
  507. }
  508. if (
  509. !this.bottomResizeObserver &&
  510. typeof window.ResizeObserver === "function"
  511. ) {
  512. const bottomBar = document.querySelector("#app .ss-bottom");
  513. if (bottomBar) {
  514. this.bottomResizeObserver = new ResizeObserver(() => {
  515. this.handleLayoutResize();
  516. });
  517. this.bottomResizeObserver.observe(bottomBar);
  518. }
  519. }
  520. },
  521. unbindLayoutObserver() {
  522. if (this.layoutObserver) {
  523. window.removeEventListener("resize", this.layoutObserver);
  524. this.layoutObserver = null;
  525. }
  526. if (this.bottomResizeObserver) {
  527. this.bottomResizeObserver.disconnect();
  528. this.bottomResizeObserver = null;
  529. }
  530. },
  531. applyIframeHeights() {
  532. const topIframe = this.$refs.topIframe;
  533. const bottomIframe = this.$refs.bottomIframe;
  534. if (!topIframe || !bottomIframe) return;
  535. topIframe.style.height = `${this.topIframeHeight}px`;
  536. bottomIframe.style.height = `${this.bottomIframeHeight}px`;
  537. },
  538. applyIframeHeightsFast() {
  539. const topIframe = this.$refs.topIframe;
  540. const bottomIframe = this.$refs.bottomIframe;
  541. if (!topIframe || !bottomIframe) return;
  542. topIframe.style.height = `${this.topIframeHeight}px`;
  543. bottomIframe.style.height = `${this.bottomIframeHeight}px`;
  544. },
  545. calculateHeights(bottomHeight) {
  546. const bottomActualHeight = Math.max(
  547. this.bottomIframeMinHeight,
  548. Math.min(bottomHeight, this.availableHeight)
  549. );
  550. this.bottomIframeHeight = bottomActualHeight;
  551. this.topIframeHeight = Math.max(
  552. 0,
  553. this.availableHeight - bottomActualHeight
  554. );
  555. this.applyIframeHeights();
  556. },
  557. toggleExpand() {
  558. if (!this.layoutCalculated || this.isDragging) return;
  559. if (Date.now() - this.lastDragEndAt < 180) return;
  560. this.isExpanded = !this.isExpanded;
  561. if (this.isExpanded) {
  562. this.calculateHeights(this.availableHeight);
  563. } else {
  564. this.calculateHeights(this.bottomIframeMinHeight);
  565. }
  566. },
  567. handleIframeMessage(event) {
  568. if (event.origin !== window.location.origin) return;
  569. const payload = event.data || {};
  570. const { type, data } = payload;
  571. if (type === "header-section-click") {
  572. this.toggleExpand();
  573. return;
  574. }
  575. if (type === "header-section-drag-start") {
  576. this.handleDragStart(data || {});
  577. return;
  578. }
  579. if (type === "header-section-drag-move") {
  580. this.handleDragMove((data && data.deltaY) || 0);
  581. return;
  582. }
  583. if (type === "header-section-drag-end") {
  584. this.handleDragEnd();
  585. }
  586. },
  587. handleDragStart(data) {
  588. if (!this.layoutCalculated) return;
  589. this.isDragging = true;
  590. this.dragStartY = Number(data && data.startY) || 0;
  591. this.dragStartBottomHeight = this.bottomIframeHeight;
  592. this.pendingDeltaY = 0;
  593. if (this.dragRafId) {
  594. cancelAnimationFrame(this.dragRafId);
  595. this.dragRafId = 0;
  596. }
  597. },
  598. handleDragMove(deltaY) {
  599. if (!this.isDragging || !this.layoutCalculated) return;
  600. this.pendingDeltaY = Number(deltaY || 0);
  601. if (this.dragRafId) return;
  602. this.dragRafId = requestAnimationFrame(() => {
  603. this.dragRafId = 0;
  604. const nextBottomHeight =
  605. this.dragStartBottomHeight - this.pendingDeltaY;
  606. const bottomActualHeight = Math.max(
  607. this.bottomIframeMinHeight,
  608. Math.min(nextBottomHeight, this.availableHeight)
  609. );
  610. this.bottomIframeHeight = bottomActualHeight;
  611. this.topIframeHeight = Math.max(
  612. 0,
  613. this.availableHeight - bottomActualHeight
  614. );
  615. this.applyIframeHeightsFast();
  616. });
  617. },
  618. handleDragEnd() {
  619. this.isDragging = false;
  620. this.dragStartY = 0;
  621. this.dragStartBottomHeight = 0;
  622. this.pendingDeltaY = 0;
  623. this.lastDragEndAt = Date.now();
  624. if (this.dragRafId) {
  625. cancelAnimationFrame(this.dragRafId);
  626. this.dragRafId = 0;
  627. }
  628. this.applyIframeHeights();
  629. },
  630. async callApi() {
  631. this.loading = true;
  632. this.infoData = null;
  633. this.agrAddData = null;
  634. this.rejAddData = null;
  635. this.bottomButtons = [];
  636. this.topIframeSrc = "";
  637. this.bottomIframeSrc = "";
  638. this.missingParams = [];
  639. this.setInitStatus(
  640. "loading",
  641. "页面初始化中",
  642. "正在加载审核数据,请稍候..."
  643. );
  644. let apiResponse = null;
  645. try {
  646. if (this.pageParams.ssToken) {
  647. const tokenUrl = `/service?ssToken=${this.pageParams.ssToken}`;
  648. apiResponse = await request.post(
  649. tokenUrl,
  650. {},
  651. { loading: false }
  652. );
  653. }
  654. const context = this.resolveBusinessContext(apiResponse);
  655. this.sqid = context.sqid;
  656. this.shid = context.shid;
  657. this.ssObjName = context.ssObjName;
  658. this.ssObjId = context.ssObjId;
  659. this.jdmc = context.jdmc || "";
  660. const requiredKeys = ["sqid", "shid", "ssObjId"];
  661. this.missingParams = requiredKeys.filter((key) => !this[key]);
  662. const query = this.buildCommonQuery();
  663. const infoUrl = `/service?ssServ=dataTag&ssDest=data&name=info&ssObjName=${encodeURIComponent(
  664. this.ssObjName
  665. )}&ssObjId=${encodeURIComponent(
  666. this.ssObjId
  667. )}&sqid=${encodeURIComponent(
  668. this.sqid
  669. )}&shid=${encodeURIComponent(this.shid)}`;
  670. const infoRes = await request.post(
  671. infoUrl,
  672. {},
  673. { loading: false, formData: true }
  674. );
  675. this.infoData =
  676. infoRes && infoRes.data ? infoRes.data.info : null;
  677. this.topIframeSrc = this.buildInfoIframeSrc(
  678. this.infoData,
  679. query
  680. );
  681. this.bottomIframeSrc = this.buildIframeSrc(
  682. "/page/mp_shList.html",
  683. query
  684. );
  685. this.setInitStatus("ready", "页面已就绪", "审核数据加载完成");
  686. this.$nextTick(() => {
  687. this.initializeLayout();
  688. });
  689. const agrUrl = `/service?ssServ=dataTag&ssDest=data&name=agrAdd&ssObjName=${encodeURIComponent(
  690. this.ssObjName
  691. )}&ssObjId=${encodeURIComponent(
  692. this.ssObjId
  693. )}&sqid=${encodeURIComponent(
  694. this.sqid
  695. )}&shid=${encodeURIComponent(this.shid)}`;
  696. const dataTagRes = await request.post(
  697. agrUrl,
  698. {},
  699. { loading: false, formData: true }
  700. );
  701. const rejUrl = `/service?ssServ=dataTag&ssDest=data&name=rejAdd&ssObjName=${encodeURIComponent(
  702. this.ssObjName
  703. )}&ssObjId=${encodeURIComponent(
  704. this.ssObjId
  705. )}&sqid=${encodeURIComponent(
  706. this.sqid
  707. )}&shid=${encodeURIComponent(this.shid)}`;
  708. const dataTagResRej = await request.post(
  709. rejUrl,
  710. {},
  711. { loading: false, formData: true }
  712. );
  713. this.agrAddData =
  714. dataTagRes && dataTagRes.data ? dataTagRes.data.agrAdd : null;
  715. this.rejAddData =
  716. dataTagResRej && dataTagResRej.data
  717. ? dataTagResRej.data.rejAdd
  718. : null;
  719. if (
  720. this.agrAddData &&
  721. !this.agrAddData.service &&
  722. this.agrAddData.servName
  723. ) {
  724. this.agrAddData.service = this.agrAddData.servName;
  725. }
  726. if (
  727. this.rejAddData &&
  728. !this.rejAddData.service &&
  729. this.rejAddData.servName
  730. ) {
  731. this.rejAddData.service = this.rejAddData.servName;
  732. }
  733. const btns = [];
  734. if (
  735. this.rejAddData &&
  736. this.rejAddData.service &&
  737. this.rejAddData.dest
  738. ) {
  739. btns.push({ text: "退回", action: "reject" });
  740. }
  741. if (
  742. this.agrAddData &&
  743. this.agrAddData.service &&
  744. this.agrAddData.dest
  745. ) {
  746. btns.push({ text: "同意", action: "agree" });
  747. }
  748. this.bottomButtons = btns;
  749. this.$nextTick(() => {
  750. this.initializeLayout();
  751. });
  752. } catch (error) {
  753. const normalized = this.normalizeError(error);
  754. this.setInitStatus(
  755. "error",
  756. "页面初始化失败",
  757. normalized.message || "页面初始化失败,请稍后重试"
  758. );
  759. console.error("[mp_addChk] 初始化失败", error);
  760. if (typeof showToastEffect === "function") {
  761. showToastEffect("页面初始化失败,请稍后重试", 2200, "error");
  762. }
  763. } finally {
  764. this.loading = false;
  765. }
  766. },
  767. buildSubmitPayload(actionPayload) {
  768. const submitPayload = {};
  769. if (this.shid) {
  770. submitPayload.shid = this.shid;
  771. }
  772. if (this.sqid) {
  773. submitPayload.sqid = this.sqid;
  774. }
  775. if (this.ssObjName) {
  776. submitPayload.ssObjName = this.ssObjName;
  777. }
  778. if (this.ssObjId) {
  779. submitPayload.ssObjId = this.ssObjId;
  780. }
  781. const payloadObj =
  782. actionPayload && typeof actionPayload === "object"
  783. ? actionPayload
  784. : {};
  785. const reviewValue = this.pickFirstValue(
  786. [payloadObj],
  787. [
  788. "shsm",
  789. "shyjValue",
  790. "shyj",
  791. "spyj",
  792. "opinion",
  793. "comment",
  794. "remark",
  795. "reason",
  796. "yj",
  797. ]
  798. );
  799. if (
  800. reviewValue !== undefined &&
  801. reviewValue !== null &&
  802. reviewValue !== ""
  803. ) {
  804. submitPayload.shsm = String(reviewValue);
  805. }
  806. return submitPayload;
  807. },
  808. navigateToMiniProgramHome() {
  809. const homePath = "/pages/main/index";
  810. const wxObj =
  811. typeof wx !== "undefined" ? wx : window.wx ? window.wx : null;
  812. const fallbackBack = () => {
  813. if (
  814. window.NavigationManager &&
  815. typeof window.NavigationManager.goBack === "function"
  816. ) {
  817. window.NavigationManager.goBack({ refreshParent: true });
  818. } else {
  819. window.history.back();
  820. }
  821. };
  822. if (!wxObj || !wxObj.miniProgram) {
  823. fallbackBack();
  824. return;
  825. }
  826. if (typeof wxObj.miniProgram.switchTab === "function") {
  827. wxObj.miniProgram.switchTab({
  828. url: homePath,
  829. fail: () => {
  830. if (typeof wxObj.miniProgram.reLaunch === "function") {
  831. wxObj.miniProgram.reLaunch({
  832. url: homePath,
  833. fail: fallbackBack,
  834. });
  835. return;
  836. }
  837. fallbackBack();
  838. },
  839. });
  840. return;
  841. }
  842. if (typeof wxObj.miniProgram.reLaunch === "function") {
  843. wxObj.miniProgram.reLaunch({
  844. url: homePath,
  845. fail: fallbackBack,
  846. });
  847. return;
  848. }
  849. fallbackBack();
  850. },
  851. async submitByConfig(conf, actionPayload) {
  852. const serviceName = conf && (conf.service || conf.servName);
  853. const destName = conf && conf.dest;
  854. if (!conf || !serviceName || !destName) {
  855. if (typeof showToastEffect === "function") {
  856. showToastEffect("缺少提交配置", 2200, "error");
  857. }
  858. return;
  859. }
  860. if (this.submitting) return;
  861. try {
  862. this.submitting = true;
  863. const submitUrl = `/service?ssServ=${encodeURIComponent(
  864. serviceName
  865. )}&ssDest=${encodeURIComponent(destName)}`;
  866. const submitPayload = this.buildSubmitPayload(actionPayload);
  867. await request.post(submitUrl, submitPayload, {
  868. loading: true,
  869. formData: true,
  870. });
  871. if (typeof showToastEffect === "function") {
  872. showToastEffect("提交成功", 1200, "success");
  873. }
  874. setTimeout(() => {
  875. this.navigateToMiniProgramHome();
  876. }, 300);
  877. } catch (error) {
  878. console.error("[mp_addChk] 提交失败", error);
  879. if (typeof showToastEffect === "function") {
  880. showToastEffect("提交失败,请稍后重试", 2200, "error");
  881. }
  882. } finally {
  883. this.submitting = false;
  884. }
  885. },
  886. showCurrentUrls() {
  887. const topIframe = this.$refs.topIframe;
  888. const bottomIframe = this.$refs.bottomIframe;
  889. const lines = [
  890. `page: ${window.location.href}`,
  891. `top: ${
  892. (topIframe && topIframe.src) || this.topIframeSrc || "(empty)"
  893. }`,
  894. `bottom: ${
  895. (bottomIframe && bottomIframe.src) ||
  896. this.bottomIframeSrc ||
  897. "(empty)"
  898. }`,
  899. ];
  900. this.urlLogText = lines.join("\n");
  901. this.urlLogVisible = true;
  902. },
  903. handleBottomAction(payload) {
  904. if (!payload || !payload.action) return;
  905. if (payload.action === "agree") {
  906. this.submitByConfig(this.agrAddData, payload);
  907. return;
  908. }
  909. if (payload.action === "reject") {
  910. this.submitByConfig(this.rejAddData, payload);
  911. }
  912. },
  913. },
  914. });
  915. });
  916. </script>
  917. </body>
  918. </html>