| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8" />
- <meta
- name="viewport"
- content="width=device-width, initial-scale=1.0, user-scalable=no"
- />
- <title>审核</title>
- <script src="/js/mp_base/base.js"></script>
- <style>
- [v-cloak] {
- display: none !important;
- }
- #app {
- background: #f5f5f5;
- height: 100vh;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- box-sizing: border-box;
- }
- .frame-wrap {
- flex: 1;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- }
- .top-iframe,
- .bottom-iframe {
- width: 100%;
- border: none;
- display: block;
- background: #fff;
- }
- .top-iframe {
- flex: none;
- height: 60%;
- }
- .bottom-iframe {
- flex: none;
- height: 40%;
- }
- .status-wrap {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 16px;
- box-sizing: border-box;
- }
- .status-card {
- width: 100%;
- max-width: 520px;
- background: #fff;
- border-radius: 8px;
- padding: 16px;
- box-sizing: border-box;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
- }
- .status-title {
- font-size: 15px;
- font-weight: 600;
- color: #2d3748;
- }
- .status-text {
- margin-top: 8px;
- line-height: 1.6;
- color: #4a5568;
- font-size: 13px;
- word-break: break-all;
- }
- .status-retry {
- margin-top: 12px;
- height: 34px;
- padding: 0 14px;
- border: none;
- border-radius: 4px;
- background: #4a5568;
- color: #fff;
- font-size: 13px;
- }
- .url-log-fab {
- position: fixed;
- right: 12px;
- bottom: 72px;
- z-index: 1200;
- border: none;
- border-radius: 16px;
- background: rgba(36, 40, 53, 0.88);
- color: #fff;
- font-size: 12px;
- line-height: 1;
- padding: 8px 10px;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
- }
- .url-log-panel {
- position: fixed;
- left: 12px;
- right: 12px;
- bottom: 116px;
- z-index: 1200;
- background: rgba(36, 40, 53, 0.96);
- color: #fff;
- border-radius: 8px;
- padding: 10px;
- max-height: 42vh;
- overflow: auto;
- box-sizing: border-box;
- }
- .url-log-panel__head {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 8px;
- font-size: 12px;
- }
- .url-log-panel__close {
- border: none;
- background: transparent;
- color: #fff;
- font-size: 14px;
- line-height: 1;
- }
- .url-log-panel__body {
- margin: 0;
- white-space: pre-wrap;
- word-break: break-all;
- font-size: 12px;
- line-height: 1.5;
- }
- </style>
- </head>
- <body>
- <div id="app" v-cloak>
- <div class="frame-wrap" v-if="initStatus === 'ready'">
- <iframe
- ref="topIframe"
- class="top-iframe"
- :src="topIframeSrc"
- frameborder="0"
- :style="topIframeHeight > 0 ? { height: `${topIframeHeight}px` } : null"
- ></iframe>
- <iframe
- ref="bottomIframe"
- class="bottom-iframe"
- :src="bottomIframeSrc"
- frameborder="0"
- :style="bottomIframeHeight > 0 ? { height: `${bottomIframeHeight}px` } : null"
- ></iframe>
- </div>
- <div class="status-wrap" v-else>
- <div class="status-card">
- <div class="status-title">{{ initStatusTitle }}</div>
- <div class="status-text">{{ initStatusMessage }}</div>
- <div class="status-text" v-if="missingParams.length > 0">
- 缺少参数:{{ missingParams.join('、') }}
- </div>
- <button class="status-retry" type="button" @click="callApi">
- 重新加载
- </button>
- </div>
- </div>
- <ss-bottom
- :buttons="bottomButtons"
- :show-shyj="true"
- @button-click="handleBottomAction"
- :disabled="submitting"
- v-if="initStatus === 'ready' && bottomButtons.length > 0"
- ></ss-bottom>
- <button class="url-log-fab" type="button" @click="showCurrentUrls">
- URL
- </button>
- <div class="url-log-panel" v-if="urlLogVisible">
- <div class="url-log-panel__head">
- <span>当前 URL</span>
- <button
- class="url-log-panel__close"
- type="button"
- @click="urlLogVisible = false"
- >
- ×
- </button>
- </div>
- <pre class="url-log-panel__body">{{ urlLogText }}</pre>
- </div>
- </div>
- <script>
- window.SS.ready(function () {
- window.SS.dom.initializeFormApp({
- el: "#app",
- data() {
- return {
- pageParams: {},
- loading: false,
- submitting: false,
- jdmc: "",
- sqid: "",
- shid: "",
- ssObjName: "",
- ssObjId: "",
- initStatus: "loading",
- initStatusTitle: "页面初始化中",
- initStatusMessage: "正在加载审核数据,请稍候...",
- missingParams: [],
- topIframeSrc: "",
- bottomIframeSrc: "",
- infoData: null,
- agrAddData: null,
- rejAddData: null,
- bottomButtons: [],
- layoutCalculated: false,
- headerSectionHeight: 0,
- availableHeight: 0,
- topIframeHeight: 0,
- bottomIframeHeight: 0,
- bottomIframeMinHeight: 0,
- isExpanded: false,
- isDragging: false,
- dragStartY: 0,
- dragStartBottomHeight: 0,
- bottomBarHeight: 0,
- layoutObserver: null,
- bottomResizeObserver: null,
- dragRafId: 0,
- pendingDeltaY: 0,
- lastDragEndAt: 0,
- urlLogVisible: false,
- urlLogText: "",
- };
- },
- mounted() {
- this.pageParams = this.getUrlParams();
- window.addEventListener("message", this.handleIframeMessage);
- this.callApi();
- },
- beforeDestroy() {
- window.removeEventListener("message", this.handleIframeMessage);
- this.unbindLayoutObserver();
- if (this.dragRafId) {
- cancelAnimationFrame(this.dragRafId);
- this.dragRafId = 0;
- }
- },
- methods: {
- normalizeError(error) {
- return {
- message: (error && error.message) || String(error),
- stack: (error && error.stack) || "",
- response: (error && error.response) || null,
- data: (error && error.data) || null,
- };
- },
- getUrlParams() {
- const params = {};
- const aliasMap = {
- ssobjname: "ssObjName",
- ssobjid: "ssObjId",
- sqid: "sqid",
- shid: "shid",
- };
- const urlSearchParams = new URLSearchParams(
- window.location.search
- );
- for (const [rawKey, rawValue] of urlSearchParams) {
- const decodedValue = this.safeDecode(rawValue);
- params[rawKey] = decodedValue;
- const normalizedKey = aliasMap[String(rawKey).toLowerCase()];
- if (normalizedKey) {
- params[normalizedKey] = decodedValue;
- }
- }
- return params;
- },
- setInitStatus(status, title, message) {
- this.initStatus = status;
- this.initStatusTitle = title || "";
- this.initStatusMessage = message || "";
- },
- safeDecode(text) {
- if (text === undefined || text === null || text === "") return "";
- try {
- return decodeURIComponent(String(text));
- } catch (_) {
- return String(text);
- }
- },
- pickFirstValue(sources, keys) {
- const srcArr = Array.isArray(sources) ? sources : [];
- const keyArr = Array.isArray(keys) ? keys : [];
- for (let i = 0; i < srcArr.length; i += 1) {
- const src = srcArr[i];
- if (!src || typeof src !== "object") continue;
- for (let j = 0; j < keyArr.length; j += 1) {
- const key = keyArr[j];
- const value = src[key];
- if (value !== undefined && value !== null && value !== "") {
- return value;
- }
- }
- }
- return "";
- },
- extractTokenData(apiResponse) {
- const wantedKeys = [
- "sqid",
- "shid",
- "ssObjName",
- "ssObjId",
- "jdmc",
- ];
- const candidates = [
- apiResponse && apiResponse.data && apiResponse.data.ssData,
- apiResponse && apiResponse.ssData,
- apiResponse && apiResponse.data,
- apiResponse,
- ];
- let best = {};
- let bestScore = -1;
- candidates.forEach((item) => {
- if (!item || typeof item !== "object") return;
- let score = 0;
- wantedKeys.forEach((key) => {
- if (
- item[key] !== undefined &&
- item[key] !== null &&
- item[key] !== ""
- ) {
- score += 1;
- }
- });
- if (score > bestScore) {
- best = item;
- bestScore = score;
- }
- });
- return best;
- },
- resolveBusinessContext(apiResponse) {
- const tokenData = this.extractTokenData(apiResponse);
- const sources = [tokenData, this.pageParams];
- const resolvedObjId = String(
- this.pickFirstValue(sources, ["ssObjId", "ssobjid"]) || ""
- );
- return {
- sqid: String(this.pickFirstValue(sources, ["sqid"]) || ""),
- shid: String(this.pickFirstValue(sources, ["shid"]) || ""),
- ssObjName: String(
- this.pickFirstValue(sources, ["ssObjName", "ssobjname"]) || ""
- ),
- ssObjId: resolvedObjId,
- jdmc: this.safeDecode(
- this.pickFirstValue(sources, ["jdmc"]) || ""
- ),
- };
- },
- parseInfoParm(rawParm) {
- if (!rawParm) return {};
- if (typeof rawParm === "object") return rawParm;
- const text = String(rawParm).trim();
- if (!text) return {};
- try {
- return JSON.parse(text);
- } catch (_) {}
- try {
- const normalized = text
- .replace(/([{,]\s*)([A-Za-z0-9_]+)\s*:/g, '$1"$2":')
- .replace(/'/g, '"');
- return JSON.parse(normalized);
- } catch (_) {
- return {};
- }
- },
- resolveInfoDestPath(destName) {
- const raw = String(destName || "").trim();
- if (!raw) return "";
- if (/^https?:\/\//i.test(raw)) return raw;
- if (raw.startsWith("/")) return raw;
- if (raw.endsWith(".html")) return `/page/${raw}`;
- if (raw.startsWith("mp_")) return `/page/${raw}.html`;
- return `/page/mp_${raw}.html`;
- },
- buildInfoIframeSrc(infoData, fallbackQuery) {
- const conf =
- infoData && typeof infoData === "object" ? infoData : {};
- const serviceName = conf.service || conf.servName || "";
- const destName = conf.dest || "";
- const parmObj = this.parseInfoParm(conf.parm);
- const mergedQuery = {
- ...(fallbackQuery || {}),
- ...(parmObj || {}),
- };
- if (!serviceName || !destName) {
- return this.buildIframeSrc(
- "/page/mp_objInfo.html",
- mergedQuery
- );
- }
- const pagePath = this.resolveInfoDestPath(destName);
- if (!pagePath) {
- return this.buildIframeSrc(
- "/page/mp_objInfo.html",
- mergedQuery
- );
- }
- const paramText =
- typeof conf.parm === "string"
- ? conf.parm
- : JSON.stringify(parmObj || {});
- const iframeQuery = {
- ...mergedQuery,
- ssServ: serviceName,
- ssDest: destName,
- service: serviceName,
- dest: destName,
- param: paramText,
- };
- return this.buildIframeSrc(pagePath, iframeQuery);
- },
- buildIframeSrc(path, queryObj) {
- const search = new URLSearchParams(queryObj);
- return `${path}?${search.toString()}`;
- },
- buildCommonQuery() {
- return {
- sqid: this.sqid,
- shid: this.shid,
- ssObjName: this.ssObjName,
- ssObjId: this.ssObjId,
- };
- },
- initializeLayout() {
- this.$nextTick(() => {
- const bottomIframe = this.$refs.bottomIframe;
- if (!bottomIframe || !bottomIframe.contentWindow) return;
- const waitForHeaderSection = () => {
- try {
- const iframeDoc = bottomIframe.contentWindow.document;
- const headerSection =
- iframeDoc.querySelector(".header-section");
- if (!headerSection) {
- setTimeout(waitForHeaderSection, 120);
- return;
- }
- const headerHeight = headerSection.offsetHeight || 0;
- this.headerSectionHeight = headerHeight;
- this.bottomIframeMinHeight = Math.max(44, headerHeight);
- this.recalculateLayoutMetrics();
- if (!this.layoutCalculated) {
- this.bottomIframeHeight = this.bottomIframeMinHeight;
- this.topIframeHeight = Math.max(
- 0,
- this.availableHeight - this.bottomIframeHeight
- );
- } else {
- const currentBottom =
- this.bottomIframeHeight || this.bottomIframeMinHeight;
- this.bottomIframeHeight = Math.max(
- this.bottomIframeMinHeight,
- Math.min(currentBottom, this.availableHeight)
- );
- this.topIframeHeight = Math.max(
- 0,
- this.availableHeight - this.bottomIframeHeight
- );
- }
- this.layoutCalculated = true;
- this.applyIframeHeights();
- this.bindLayoutObserver();
- } catch (error) {
- setTimeout(waitForHeaderSection, 180);
- }
- };
- setTimeout(waitForHeaderSection, 80);
- });
- },
- recalculateLayoutMetrics() {
- const viewportHeight = window.innerHeight || 0;
- const bottomBar = document.querySelector("#app .ss-bottom");
- this.bottomBarHeight = bottomBar ? bottomBar.offsetHeight : 0;
- this.availableHeight = Math.max(
- 0,
- viewportHeight - this.bottomBarHeight
- );
- },
- handleLayoutResize() {
- if (!this.layoutCalculated) return;
- this.recalculateLayoutMetrics();
- const bottomActualHeight = Math.max(
- this.bottomIframeMinHeight,
- Math.min(
- this.bottomIframeHeight || this.bottomIframeMinHeight,
- this.availableHeight
- )
- );
- this.bottomIframeHeight = bottomActualHeight;
- this.topIframeHeight = Math.max(
- 0,
- this.availableHeight - bottomActualHeight
- );
- this.applyIframeHeights();
- },
- bindLayoutObserver() {
- if (!this.layoutObserver) {
- this.layoutObserver = () => this.handleLayoutResize();
- window.addEventListener("resize", this.layoutObserver);
- }
- if (
- !this.bottomResizeObserver &&
- typeof window.ResizeObserver === "function"
- ) {
- const bottomBar = document.querySelector("#app .ss-bottom");
- if (bottomBar) {
- this.bottomResizeObserver = new ResizeObserver(() => {
- this.handleLayoutResize();
- });
- this.bottomResizeObserver.observe(bottomBar);
- }
- }
- },
- unbindLayoutObserver() {
- if (this.layoutObserver) {
- window.removeEventListener("resize", this.layoutObserver);
- this.layoutObserver = null;
- }
- if (this.bottomResizeObserver) {
- this.bottomResizeObserver.disconnect();
- this.bottomResizeObserver = null;
- }
- },
- applyIframeHeights() {
- const topIframe = this.$refs.topIframe;
- const bottomIframe = this.$refs.bottomIframe;
- if (!topIframe || !bottomIframe) return;
- topIframe.style.height = `${this.topIframeHeight}px`;
- bottomIframe.style.height = `${this.bottomIframeHeight}px`;
- },
- applyIframeHeightsFast() {
- const topIframe = this.$refs.topIframe;
- const bottomIframe = this.$refs.bottomIframe;
- if (!topIframe || !bottomIframe) return;
- topIframe.style.height = `${this.topIframeHeight}px`;
- bottomIframe.style.height = `${this.bottomIframeHeight}px`;
- },
- calculateHeights(bottomHeight) {
- const bottomActualHeight = Math.max(
- this.bottomIframeMinHeight,
- Math.min(bottomHeight, this.availableHeight)
- );
- this.bottomIframeHeight = bottomActualHeight;
- this.topIframeHeight = Math.max(
- 0,
- this.availableHeight - bottomActualHeight
- );
- this.applyIframeHeights();
- },
- toggleExpand() {
- if (!this.layoutCalculated || this.isDragging) return;
- if (Date.now() - this.lastDragEndAt < 180) return;
- this.isExpanded = !this.isExpanded;
- if (this.isExpanded) {
- this.calculateHeights(this.availableHeight);
- } else {
- this.calculateHeights(this.bottomIframeMinHeight);
- }
- },
- handleIframeMessage(event) {
- if (event.origin !== window.location.origin) return;
- const payload = event.data || {};
- const { type, data } = payload;
- if (type === "header-section-click") {
- this.toggleExpand();
- return;
- }
- if (type === "header-section-drag-start") {
- this.handleDragStart(data || {});
- return;
- }
- if (type === "header-section-drag-move") {
- this.handleDragMove((data && data.deltaY) || 0);
- return;
- }
- if (type === "header-section-drag-end") {
- this.handleDragEnd();
- }
- },
- handleDragStart(data) {
- if (!this.layoutCalculated) return;
- this.isDragging = true;
- this.dragStartY = Number(data && data.startY) || 0;
- this.dragStartBottomHeight = this.bottomIframeHeight;
- this.pendingDeltaY = 0;
- if (this.dragRafId) {
- cancelAnimationFrame(this.dragRafId);
- this.dragRafId = 0;
- }
- },
- handleDragMove(deltaY) {
- if (!this.isDragging || !this.layoutCalculated) return;
- this.pendingDeltaY = Number(deltaY || 0);
- if (this.dragRafId) return;
- this.dragRafId = requestAnimationFrame(() => {
- this.dragRafId = 0;
- const nextBottomHeight =
- this.dragStartBottomHeight - this.pendingDeltaY;
- const bottomActualHeight = Math.max(
- this.bottomIframeMinHeight,
- Math.min(nextBottomHeight, this.availableHeight)
- );
- this.bottomIframeHeight = bottomActualHeight;
- this.topIframeHeight = Math.max(
- 0,
- this.availableHeight - bottomActualHeight
- );
- this.applyIframeHeightsFast();
- });
- },
- handleDragEnd() {
- this.isDragging = false;
- this.dragStartY = 0;
- this.dragStartBottomHeight = 0;
- this.pendingDeltaY = 0;
- this.lastDragEndAt = Date.now();
- if (this.dragRafId) {
- cancelAnimationFrame(this.dragRafId);
- this.dragRafId = 0;
- }
- this.applyIframeHeights();
- },
- async callApi() {
- this.loading = true;
- this.infoData = null;
- this.agrAddData = null;
- this.rejAddData = null;
- this.bottomButtons = [];
- this.topIframeSrc = "";
- this.bottomIframeSrc = "";
- this.missingParams = [];
- this.setInitStatus(
- "loading",
- "页面初始化中",
- "正在加载审核数据,请稍候..."
- );
- let apiResponse = null;
- try {
- if (this.pageParams.ssToken) {
- const tokenUrl = `/service?ssToken=${this.pageParams.ssToken}`;
- apiResponse = await request.post(
- tokenUrl,
- {},
- { loading: false }
- );
- }
- const context = this.resolveBusinessContext(apiResponse);
- this.sqid = context.sqid;
- this.shid = context.shid;
- this.ssObjName = context.ssObjName;
- this.ssObjId = context.ssObjId;
- this.jdmc = context.jdmc || "";
- const requiredKeys = ["sqid", "shid", "ssObjId"];
- this.missingParams = requiredKeys.filter((key) => !this[key]);
- const query = this.buildCommonQuery();
- const infoUrl = `/service?ssServ=dataTag&ssDest=data&name=info&ssObjName=${encodeURIComponent(
- this.ssObjName
- )}&ssObjId=${encodeURIComponent(
- this.ssObjId
- )}&sqid=${encodeURIComponent(
- this.sqid
- )}&shid=${encodeURIComponent(this.shid)}`;
- const infoRes = await request.post(
- infoUrl,
- {},
- { loading: false, formData: true }
- );
- this.infoData =
- infoRes && infoRes.data ? infoRes.data.info : null;
- this.topIframeSrc = this.buildInfoIframeSrc(
- this.infoData,
- query
- );
- this.bottomIframeSrc = this.buildIframeSrc(
- "/page/mp_shList.html",
- query
- );
- this.setInitStatus("ready", "页面已就绪", "审核数据加载完成");
- this.$nextTick(() => {
- this.initializeLayout();
- });
- const agrUrl = `/service?ssServ=dataTag&ssDest=data&name=agrAdd&ssObjName=${encodeURIComponent(
- this.ssObjName
- )}&ssObjId=${encodeURIComponent(
- this.ssObjId
- )}&sqid=${encodeURIComponent(
- this.sqid
- )}&shid=${encodeURIComponent(this.shid)}`;
- const dataTagRes = await request.post(
- agrUrl,
- {},
- { loading: false, formData: true }
- );
- const rejUrl = `/service?ssServ=dataTag&ssDest=data&name=rejAdd&ssObjName=${encodeURIComponent(
- this.ssObjName
- )}&ssObjId=${encodeURIComponent(
- this.ssObjId
- )}&sqid=${encodeURIComponent(
- this.sqid
- )}&shid=${encodeURIComponent(this.shid)}`;
- const dataTagResRej = await request.post(
- rejUrl,
- {},
- { loading: false, formData: true }
- );
- this.agrAddData =
- dataTagRes && dataTagRes.data ? dataTagRes.data.agrAdd : null;
- this.rejAddData =
- dataTagResRej && dataTagResRej.data
- ? dataTagResRej.data.rejAdd
- : null;
- if (
- this.agrAddData &&
- !this.agrAddData.service &&
- this.agrAddData.servName
- ) {
- this.agrAddData.service = this.agrAddData.servName;
- }
- if (
- this.rejAddData &&
- !this.rejAddData.service &&
- this.rejAddData.servName
- ) {
- this.rejAddData.service = this.rejAddData.servName;
- }
- const btns = [];
- if (
- this.rejAddData &&
- this.rejAddData.service &&
- this.rejAddData.dest
- ) {
- btns.push({ text: "退回", action: "reject" });
- }
- if (
- this.agrAddData &&
- this.agrAddData.service &&
- this.agrAddData.dest
- ) {
- btns.push({ text: "同意", action: "agree" });
- }
- this.bottomButtons = btns;
- this.$nextTick(() => {
- this.initializeLayout();
- });
- } catch (error) {
- const normalized = this.normalizeError(error);
- this.setInitStatus(
- "error",
- "页面初始化失败",
- normalized.message || "页面初始化失败,请稍后重试"
- );
- console.error("[mp_addChk] 初始化失败", error);
- if (typeof showToastEffect === "function") {
- showToastEffect("页面初始化失败,请稍后重试", 2200, "error");
- }
- } finally {
- this.loading = false;
- }
- },
- buildSubmitPayload(actionPayload) {
- const submitPayload = {};
- if (this.shid) {
- submitPayload.shid = this.shid;
- }
- if (this.sqid) {
- submitPayload.sqid = this.sqid;
- }
- if (this.ssObjName) {
- submitPayload.ssObjName = this.ssObjName;
- }
- if (this.ssObjId) {
- submitPayload.ssObjId = this.ssObjId;
- }
- const payloadObj =
- actionPayload && typeof actionPayload === "object"
- ? actionPayload
- : {};
- const reviewValue = this.pickFirstValue(
- [payloadObj],
- [
- "shsm",
- "shyjValue",
- "shyj",
- "spyj",
- "opinion",
- "comment",
- "remark",
- "reason",
- "yj",
- ]
- );
- if (
- reviewValue !== undefined &&
- reviewValue !== null &&
- reviewValue !== ""
- ) {
- submitPayload.shsm = String(reviewValue);
- }
- return submitPayload;
- },
- navigateToMiniProgramHome() {
- const homePath = "/pages/main/index";
- const wxObj =
- typeof wx !== "undefined" ? wx : window.wx ? window.wx : null;
- const fallbackBack = () => {
- if (
- window.NavigationManager &&
- typeof window.NavigationManager.goBack === "function"
- ) {
- window.NavigationManager.goBack({ refreshParent: true });
- } else {
- window.history.back();
- }
- };
- if (!wxObj || !wxObj.miniProgram) {
- fallbackBack();
- return;
- }
- if (typeof wxObj.miniProgram.switchTab === "function") {
- wxObj.miniProgram.switchTab({
- url: homePath,
- fail: () => {
- if (typeof wxObj.miniProgram.reLaunch === "function") {
- wxObj.miniProgram.reLaunch({
- url: homePath,
- fail: fallbackBack,
- });
- return;
- }
- fallbackBack();
- },
- });
- return;
- }
- if (typeof wxObj.miniProgram.reLaunch === "function") {
- wxObj.miniProgram.reLaunch({
- url: homePath,
- fail: fallbackBack,
- });
- return;
- }
- fallbackBack();
- },
- async submitByConfig(conf, actionPayload) {
- const serviceName = conf && (conf.service || conf.servName);
- const destName = conf && conf.dest;
- if (!conf || !serviceName || !destName) {
- if (typeof showToastEffect === "function") {
- showToastEffect("缺少提交配置", 2200, "error");
- }
- return;
- }
- if (this.submitting) return;
- try {
- this.submitting = true;
- const submitUrl = `/service?ssServ=${encodeURIComponent(
- serviceName
- )}&ssDest=${encodeURIComponent(destName)}`;
- const submitPayload = this.buildSubmitPayload(actionPayload);
- await request.post(submitUrl, submitPayload, {
- loading: true,
- formData: true,
- });
- if (typeof showToastEffect === "function") {
- showToastEffect("提交成功", 1200, "success");
- }
- setTimeout(() => {
- this.navigateToMiniProgramHome();
- }, 300);
- } catch (error) {
- console.error("[mp_addChk] 提交失败", error);
- if (typeof showToastEffect === "function") {
- showToastEffect("提交失败,请稍后重试", 2200, "error");
- }
- } finally {
- this.submitting = false;
- }
- },
- showCurrentUrls() {
- const topIframe = this.$refs.topIframe;
- const bottomIframe = this.$refs.bottomIframe;
- const lines = [
- `page: ${window.location.href}`,
- `top: ${
- (topIframe && topIframe.src) || this.topIframeSrc || "(empty)"
- }`,
- `bottom: ${
- (bottomIframe && bottomIframe.src) ||
- this.bottomIframeSrc ||
- "(empty)"
- }`,
- ];
- this.urlLogText = lines.join("\n");
- this.urlLogVisible = true;
- },
- handleBottomAction(payload) {
- if (!payload || !payload.action) return;
- if (payload.action === "agree") {
- this.submitByConfig(this.agrAddData, payload);
- return;
- }
- if (payload.action === "reject") {
- this.submitByConfig(this.rejAddData, payload);
- }
- },
- },
- });
- });
- </script>
- </body>
- </html>
|