mp_objInp.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
  6. <title>录入</title>
  7. <script src="/js/mp_base/base.js?v=20261127-auth-refresh-v1"></script>
  8. <style>
  9. body {
  10. margin: 0;
  11. background: #f5f5f5;
  12. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  13. }
  14. #app {
  15. min-height: 100vh;
  16. background: #f5f5f5;
  17. overflow: hidden;
  18. }
  19. .content {
  20. width: 100%;
  21. height: 100vh;
  22. min-height: 0;
  23. }
  24. .form-frame {
  25. width: 100%;
  26. height: 100%;
  27. border: 0;
  28. display: block;
  29. background: #fff;
  30. }
  31. .placeholder {
  32. padding: 28px 16px;
  33. color: #666;
  34. font-size: 14px;
  35. text-align: center;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div id="app">
  41. <div class="content" id="contentWrap">
  42. <iframe
  43. v-if="iframeSrc"
  44. id="objInpFrame"
  45. class="form-frame"
  46. :src="iframeSrc"
  47. @load="handleFrameLoad"
  48. ></iframe>
  49. <div v-else class="placeholder" id="placeholder">{{ placeholderText }}</div>
  50. </div>
  51. <ss-bottom
  52. v-if="showBottom"
  53. :buttons="bottomSubmitting ? [{ text: '提交中...', action: 'saveSubmit' }] : bottomButtons"
  54. @button-click="handleBottomAction"
  55. :disabled="bottomSubmitting"
  56. >
  57. </ss-bottom>
  58. <!-- 功能说明:inp 保存并提交后使用统一样式二次确认弹窗,不再使用浏览器原生 confirm by xu 2026-03-01 -->
  59. <ss-confirm
  60. v-model="showSubmitConfirm"
  61. title="提示"
  62. @confirm="handleConfirmSubmit"
  63. >
  64. <div style="text-align:center;padding:16px 0;font-size: 16px;">是否提交?</div>
  65. </ss-confirm>
  66. </div>
  67. <script>
  68. // 功能说明:公共录入壳页(先调业务接口+dataTag,再按 include_input 装载 mp_ 表单页) by xu 2026-02-28
  69. (function () {
  70. const boot = function () {
  71. const setStatus = (text) => {
  72. if (state.vm) {
  73. state.vm.placeholderText = text;
  74. return;
  75. }
  76. const placeholder = document.getElementById('placeholder');
  77. if (placeholder) placeholder.textContent = text;
  78. };
  79. const state = {
  80. pageParams: {},
  81. service: '',
  82. initPayload: {},
  83. dataTagPayload: {},
  84. ssObjName: '',
  85. ssObjId: '',
  86. iframe: null,
  87. submitEnabled: false,
  88. vm: null,
  89. pendingFinalSubmit: null,
  90. finalSubmitting: false,
  91. };
  92. // 功能说明:执行 inp 二次确认后的最终提交(${ssObjName}_lr_tj_qr) by xu 2026-03-01
  93. const submitFinalConfirm = async () => {
  94. if (state.finalSubmitting) return;
  95. const pending = state.pendingFinalSubmit;
  96. if (!pending || typeof pending !== 'object') {
  97. if (typeof showToastEffect === 'function') showToastEffect('提交参数缺失', 1800, 'error');
  98. return;
  99. }
  100. const req = ensureRequest();
  101. state.finalSubmitting = true;
  102. try {
  103. const response = await req.post(
  104. `/service?ssServ=${encodeURIComponent(pending.serviceName)}`,
  105. pending.payload,
  106. { loading: true, formData: true }
  107. );
  108. assertServiceSuccess(response && response.data !== undefined
  109. ? response.data
  110. : response);
  111. state.pendingFinalSubmit = null;
  112. if (typeof showToastEffect === 'function') showToastEffect('提交成功', 1400, 'success');
  113. setTimeout(() => goBack(true), 600);
  114. } catch (error) {
  115. console.error('[mp_objInp] 二次确认提交失败', error);
  116. if (typeof showToastEffect === 'function') showToastEffect(
  117. error && error.message
  118. ? error.message
  119. : '提交失败,请稍后重试',
  120. 2200,
  121. 'error'
  122. );
  123. } finally {
  124. state.finalSubmitting = false;
  125. }
  126. };
  127. const getUrlParams = () => {
  128. const params = {};
  129. const search = new URLSearchParams(window.location.search || '');
  130. for (const [key, value] of search.entries()) {
  131. params[key] = decodeURIComponent(value || '');
  132. }
  133. return params;
  134. };
  135. const unwrapData = (data) => {
  136. if (!data || typeof data !== 'object') return {};
  137. if (data.ssData && typeof data.ssData === 'object') return data.ssData;
  138. return data;
  139. };
  140. const assertServiceSuccess = (data) => {
  141. const payload = data && typeof data === 'object' ? data : {};
  142. if (payload.ssCode !== undefined && Number(payload.ssCode) !== 0) {
  143. throw new Error(payload.ssMsg || payload.msg || '提交失败');
  144. }
  145. return payload;
  146. };
  147. const parseJsonString = (text) => {
  148. if (!text || typeof text !== 'string') return {};
  149. try {
  150. const obj = JSON.parse(text);
  151. return obj && typeof obj === 'object' ? obj : {};
  152. } catch (_) {
  153. return {};
  154. }
  155. };
  156. const pruneParams = (obj) => {
  157. const out = {};
  158. Object.entries(obj || {}).forEach(([key, value]) => {
  159. if (value === undefined || value === null || value === '') return;
  160. out[key] = value;
  161. });
  162. return out;
  163. };
  164. // 功能说明:新增场景 id=0 统一按空处理,和你要求保持一致 by xu 2026-02-28
  165. const resolveObjIdFromInit = (payload, ssObjName, urlParams) => {
  166. const fromUrl = String(urlParams.ssObjId || '').trim();
  167. if (fromUrl) return fromUrl;
  168. if (!payload || typeof payload !== 'object') return '';
  169. const objName = String(ssObjName || '').trim();
  170. if (!objName) return '';
  171. const objData = payload[objName];
  172. if (!objData || typeof objData !== 'object') return '';
  173. const idField = String(payload.ssObjIdName || objData.idName || '').trim();
  174. if (!idField) return '';
  175. const rawId = objData[idField];
  176. if (rawId === undefined || rawId === null || rawId === '' || Number(rawId) === 0) return '';
  177. return String(rawId);
  178. };
  179. // 功能说明:/page/xyqj_inp.jsp -> /page/mp_xyqj_inp.html by xu 2026-02-28
  180. const includeToMpFormPath = (includeInput) => {
  181. const raw = String(includeInput || '').trim();
  182. if (!raw) return '';
  183. const noPrefix = raw.replace(/^\/page\//i, '');
  184. const base = noPrefix.replace(/\.ss\.jsp$/i, '').replace(/\.jsp$/i, '');
  185. if (!base) return '';
  186. return `/page/mp_${base}.html`;
  187. };
  188. // 功能说明:变动页签里的 objInp 可能拿不到 include_input,此时按对象名兜底到 mp_xxx_inp.html by xu 2026-03-06
  189. const resolveFallbackFormPath = () => {
  190. const objName = String(state.ssObjName || state.pageParams.ssObjName || '').trim();
  191. if (objName) {
  192. return `/page/mp_${objName}_inp.html`;
  193. }
  194. const serviceName = String(state.service || state.pageParams.service || state.pageParams.ssServ || '').trim();
  195. const match = serviceName.match(/^([a-zA-Z0-9_]+?)_/);
  196. if (match && match[1]) {
  197. return `/page/mp_${match[1]}_inp.html`;
  198. }
  199. return '';
  200. };
  201. const goBack = (refreshParent) => {
  202. if (window.NavigationManager && typeof window.NavigationManager.goBack === 'function') {
  203. window.NavigationManager.goBack({ refreshParent: !!refreshParent });
  204. } else {
  205. window.history.back();
  206. }
  207. };
  208. const ensureRequest = () => {
  209. if (!window.request || typeof window.request.post !== 'function') {
  210. throw new Error('request 未就绪');
  211. }
  212. return window.request;
  213. };
  214. // 功能说明:内容区高度按 100vh 减去 ss-bottom 实际高度计算 by xu 2026-02-28
  215. const updateContentHeight = () => {
  216. const contentWrap = document.getElementById('contentWrap');
  217. if (!contentWrap) return;
  218. const bottom = document.querySelector('#app .ss-bottom');
  219. const bottomHeight = bottom ? bottom.offsetHeight : 0;
  220. contentWrap.style.height = `calc(100vh - ${bottomHeight}px)`;
  221. };
  222. // 功能说明:学校违纪录入使用其他移动端入口一致的默认底部按钮和文案
  223. const isSchoolViolationEntry = (serviceName = '', objName = '') => {
  224. const service = String(serviceName || state.service || getUrlParams().service || '').trim();
  225. const objectName = String(objName || state.ssObjName || '').trim();
  226. return objectName === 'xxwjjl' || service.startsWith('xxwjjl_');
  227. };
  228. const isDisciplineAppearanceEntry = (serviceName = '', objName = '') => {
  229. const service = String(serviceName || state.service || getUrlParams().service || '').trim();
  230. const objectName = String(objName || state.ssObjName || '').trim();
  231. return objectName === 'fjyrjc' || service.startsWith('fjyrjc_');
  232. };
  233. const makeCloseBottomButton = (serviceName = '', objName = '') => ({
  234. text: isSchoolViolationEntry(serviceName, objName) || isDisciplineAppearanceEntry(serviceName, objName) ? '取消' : '关闭',
  235. action: 'close'
  236. });
  237. const makeSubmitBottomButton = (text, serviceName = '', objName = '') => {
  238. const button = {
  239. text: text || '保存并提交',
  240. action: 'saveSubmit'
  241. };
  242. if (!isSchoolViolationEntry(serviceName, objName) && !isDisciplineAppearanceEntry(serviceName, objName)) {
  243. button.backgroundColor = '#575d6d';
  244. button.color = '#fff';
  245. }
  246. return button;
  247. };
  248. const updateBottomButtons = (submitTitle) => {
  249. if (!state.vm) return;
  250. state.vm.bottomButtons = [
  251. makeCloseBottomButton(state.service, state.ssObjName),
  252. makeSubmitBottomButton(submitTitle, state.service, state.ssObjName)
  253. ];
  254. setTimeout(updateContentHeight, 0);
  255. };
  256. // 功能说明:供 iframe 子页调用,控制父页底部按钮显隐(解决日期弹层被底部按钮遮挡) by xu 2026-02-28
  257. const setBottomVisible = (visible) => {
  258. if (!state.vm) return;
  259. state.vm.showBottom = visible !== false;
  260. setTimeout(updateContentHeight, 0);
  261. };
  262. const getFrameFormData = async () => {
  263. const frame = document.getElementById('objInpFrame');
  264. const frameWindow = frame ? frame.contentWindow : null;
  265. if (!frameWindow) return { valid: false, message: '表单页面未加载完成', data: {} };
  266. // 功能说明:优先走子页面暴露方法,尽量减少表单页工作量 by xu 2026-02-28
  267. if (typeof frameWindow.__mpObjInpGetFormData === 'function') {
  268. // 功能说明:支持子页异步取值(如提交前补查关联字段),确保提交参数完整 by xu 2026-03-01
  269. const result = await Promise.resolve(frameWindow.__mpObjInpGetFormData());
  270. if (result && typeof result === 'object') {
  271. return {
  272. valid: result.valid !== false,
  273. message: result.message || '',
  274. data: result.data && typeof result.data === 'object' ? result.data : {},
  275. };
  276. }
  277. }
  278. const doc = frameWindow.document;
  279. const data = {};
  280. const nodes = doc.querySelectorAll('input[name],select[name],textarea[name]');
  281. nodes.forEach((node) => {
  282. const name = node.getAttribute('name');
  283. if (!name || node.disabled) return;
  284. const type = (node.getAttribute('type') || '').toLowerCase();
  285. if ((type === 'checkbox' || type === 'radio') && !node.checked) return;
  286. data[name] = node.value;
  287. });
  288. return { valid: true, message: '', data };
  289. };
  290. const getSubmitConfig = () => {
  291. const p = state.initPayload || {};
  292. const saveServiceName = String(p.saveAndCommit || '').trim();
  293. const saveDest = String(p.saveAndCommitDest || '').trim();
  294. const routeServiceName = String(state.service || state.pageParams.service || state.pageParams.ssServ || '').trim();
  295. const routeDest = String(state.pageParams.dest || state.pageParams.ssDest || '').trim();
  296. const routeParamObj = parseJsonString(state.pageParams.param);
  297. const routeDataType = String(state.pageParams.dataType || routeParamObj.dataType || '').trim().toLowerCase();
  298. // 功能说明:变动页签若第一接口没回 saveAndCommitDest,则回退用当前 service+objInp+param 提交 by xu 2026-03-06
  299. const canUseRouteSubmit = routeDataType === 'change' && routeDest.toLowerCase() === 'objinp' && !!routeServiceName;
  300. const serviceName = saveServiceName || (canUseRouteSubmit ? routeServiceName : '');
  301. const dest = saveDest || (canUseRouteSubmit ? routeDest : '');
  302. const enabled = !!(serviceName && dest);
  303. return {
  304. enabled,
  305. serviceName,
  306. dest,
  307. title: String(p.saveAndCommitButtonValue || '保存并提交'),
  308. paramObj: pruneParams({
  309. ...(canUseRouteSubmit ? {
  310. ...routeParamObj,
  311. sqid: state.pageParams.sqid,
  312. shid: state.pageParams.shid,
  313. shyjm: state.pageParams.shyjm,
  314. bdlbm: state.pageParams.bdlbm,
  315. dataType: state.pageParams.dataType,
  316. } : {}),
  317. ...parseJsonString(p.saveAndCommitParam),
  318. }),
  319. };
  320. };
  321. const renderFormFrame = () => {
  322. const includeInput = (state.dataTagPayload && state.dataTagPayload.include_input) || '';
  323. const fallbackFormPath = resolveFallbackFormPath();
  324. const formPath = includeToMpFormPath(includeInput) || fallbackFormPath;
  325. console.log('[mp_objInp][renderFormFrame] include_input =', includeInput);
  326. console.log('[mp_objInp][renderFormFrame] fallbackFormPath =', fallbackFormPath);
  327. console.log('[mp_objInp][renderFormFrame] formPath =', formPath);
  328. if (!formPath) {
  329. if (state.vm) {
  330. state.vm.iframeSrc = '';
  331. state.vm.placeholderText = '未获取到 include_input,且未命中对象表单页';
  332. }
  333. state.submitEnabled = false;
  334. console.warn('[mp_objInp][renderFormFrame] formPath为空,终止渲染iframe');
  335. return;
  336. }
  337. const childParams = new URLSearchParams();
  338. Object.entries(state.pageParams || {}).forEach(([key, value]) => {
  339. if (value === undefined || value === null || value === '') return;
  340. childParams.set(key, value);
  341. });
  342. childParams.set('embed', '1');
  343. childParams.set('ssObjName', state.ssObjName || '');
  344. childParams.set('ssObjId', state.ssObjId || '');
  345. const iframeSrc = `${formPath}?${childParams.toString()}`;
  346. console.log('[mp_objInp][renderFormFrame] iframe src =', iframeSrc);
  347. if (state.vm) {
  348. state.vm.iframeSrc = iframeSrc;
  349. }
  350. const submitCfg = getSubmitConfig();
  351. state.submitEnabled = !!submitCfg.enabled;
  352. updateBottomButtons(submitCfg.title);
  353. setTimeout(updateContentHeight, 0);
  354. };
  355. const loadInitPayload = async () => {
  356. const req = ensureRequest();
  357. const postData = {
  358. ...state.pageParams,
  359. management: state.pageParams.management || '1',
  360. isReady: '1',
  361. };
  362. const res = await req.post(
  363. `/service?ssServ=${state.service}&management=1&isReady=1`,
  364. postData,
  365. { loading: false, formData: true }
  366. );
  367. state.initPayload = unwrapData(res ? res.data : null);
  368. state.ssObjName = String(state.initPayload.ssObjName || state.pageParams.ssObjName || '').trim();
  369. state.ssObjId = resolveObjIdFromInit(state.initPayload, state.ssObjName, state.pageParams);
  370. console.log('[mp_objInp] init响应', state.initPayload);
  371. };
  372. const loadDataTagPayload = async () => {
  373. const req = ensureRequest();
  374. const dataTagParams = {
  375. ...state.pageParams,
  376. ssObjName: state.ssObjName,
  377. ssObjId: state.ssObjId,
  378. };
  379. const res = await req.post(
  380. `/service?ssServ=dataTag&ssDest=data&name=inp&ssObjName=${encodeURIComponent(state.ssObjName)}&ssObjId=${encodeURIComponent(state.ssObjId)}`,
  381. dataTagParams,
  382. { loading: false, formData: true }
  383. );
  384. state.dataTagPayload = unwrapData(res ? res.data : null);
  385. console.log('[mp_objInp] dataTag响应', state.dataTagPayload);
  386. console.log('[mp_objInp] dataTag include_input =', (state.dataTagPayload && state.dataTagPayload.include_input) || '');
  387. };
  388. const submitSaveAndCommit = async () => {
  389. const alignDormitorySubmit = isDisciplineAppearanceEntry(state.service, state.ssObjName);
  390. if (alignDormitorySubmit && state.vm && state.vm.bottomSubmitting) return;
  391. try {
  392. if (alignDormitorySubmit && state.vm) state.vm.bottomSubmitting = true;
  393. const cfg = getSubmitConfig();
  394. if (!state.submitEnabled || !cfg.enabled) {
  395. if (typeof showToastEffect === 'function') showToastEffect('当前页面不支持保存并提交', 1800, 'warning');
  396. return;
  397. }
  398. if (!cfg.serviceName || !cfg.dest) {
  399. if (typeof showToastEffect === 'function') showToastEffect('提交配置缺失', 1800, 'error');
  400. return;
  401. }
  402. const formResult = await getFrameFormData();
  403. if (!formResult.valid) {
  404. if (typeof showToastEffect === 'function') showToastEffect(formResult.message || '表单校验未通过', 2000, 'warning');
  405. return;
  406. }
  407. const req = ensureRequest();
  408. const payload = pruneParams({
  409. ...(cfg.paramObj || {}),
  410. ...(formResult.data || {}),
  411. ssObjName: state.ssObjName || undefined,
  412. ssObjId: state.ssObjId || undefined,
  413. [((state.initPayload && state.initPayload.ssObjIdName) || 'ssObjId')]: state.ssObjId || undefined,
  414. });
  415. const res = await req.post(
  416. `/service?ssServ=${cfg.serviceName}&ssDest=${encodeURIComponent(cfg.dest)}`,
  417. payload,
  418. { loading: true, formData: true }
  419. );
  420. console.log('[mp_objInp] saveAndCommit响应', res);
  421. assertServiceSuccess(res && res.data !== undefined
  422. ? res.data
  423. : res);
  424. const submitResp = unwrapData(res ? res.data : null);
  425. // 功能说明:保存并提交后若目标为 addSure,则在 inp 页二次确认并直接调最终提交接口 by xu 2026-03-01
  426. if (String(cfg.dest || '').trim().toLowerCase() === 'addsure') {
  427. const finalObjName = String((submitResp && submitResp.ssObjName) || state.ssObjName || '').trim();
  428. const finalObjIdName = String((submitResp && submitResp.ssObjIdName) || (state.initPayload && state.initPayload.ssObjIdName) || 'ssObjId').trim();
  429. const finalObjId = String((submitResp && submitResp.ssObjId) || state.ssObjId || '').trim();
  430. if (!finalObjName || !finalObjId) {
  431. if (typeof showToastEffect === 'function') showToastEffect('缺少提交参数,无法确认提交', 2200, 'error');
  432. return;
  433. }
  434. const finalServ = `${finalObjName}_lr_tj_qr`;
  435. const finalPayload = pruneParams({
  436. ssObjName: finalObjName,
  437. [finalObjIdName]: finalObjId,
  438. });
  439. // 功能说明:先缓存最终提交参数,再弹 ss-confirm 确认 by xu 2026-03-01
  440. state.pendingFinalSubmit = {
  441. serviceName: finalServ,
  442. payload: finalPayload,
  443. };
  444. if (alignDormitorySubmit) {
  445. await submitFinalConfirm();
  446. return;
  447. }
  448. if (state.vm) {
  449. state.vm.showSubmitConfirm = true;
  450. }
  451. return;
  452. }
  453. if (typeof showToastEffect === 'function') showToastEffect('提交成功', 1400, 'success');
  454. setTimeout(() => goBack(true), 600);
  455. } catch (err) {
  456. console.error('[mp_objInp] 提交失败', err);
  457. if (typeof showToastEffect === 'function') showToastEffect(
  458. err && err.message ? err.message : '提交失败,请稍后重试',
  459. 2200,
  460. 'error'
  461. );
  462. } finally {
  463. if (alignDormitorySubmit && state.vm) state.vm.bottomSubmitting = false;
  464. }
  465. };
  466. const init = async () => {
  467. try {
  468. setStatus('正在初始化录入页...');
  469. state.pageParams = getUrlParams();
  470. state.service = String(state.pageParams.service || '').trim();
  471. if (!state.service) throw new Error('缺少 service 参数');
  472. setStatus('正在加载业务配置...');
  473. await loadInitPayload();
  474. if (!state.ssObjName) throw new Error('第一接口未返回 ssObjName');
  475. setStatus('正在加载 dataTag...');
  476. await loadDataTagPayload();
  477. setStatus('正在加载表单页面...');
  478. renderFormFrame();
  479. setTimeout(updateContentHeight, 0);
  480. } catch (err) {
  481. console.error('[mp_objInp] 初始化失败', err);
  482. setStatus(`初始化失败:${err && err.message ? err.message : err}`);
  483. state.submitEnabled = false;
  484. }
  485. };
  486. window.addEventListener('resize', updateContentHeight);
  487. // 功能说明:使用 ss-bottom 统一底部样式与交互 by xu 2026-02-28
  488. window.SS.dom.initializeFormApp({
  489. el: '#app',
  490. data() {
  491. return {
  492. iframeSrc: '',
  493. placeholderText: '正在加载录入页面...',
  494. showBottom: true,
  495. showSubmitConfirm: false,
  496. bottomSubmitting: false,
  497. bottomButtons: [
  498. makeCloseBottomButton(getUrlParams().service),
  499. makeSubmitBottomButton('保存并提交', getUrlParams().service)
  500. ]
  501. }
  502. },
  503. methods: {
  504. handleFrameLoad() {
  505. console.log('[mp_objInp][renderFormFrame] iframe onload');
  506. setTimeout(updateContentHeight, 0);
  507. },
  508. handleBottomAction(payload) {
  509. if (this.bottomSubmitting) return;
  510. if (payload && payload.action === 'close') {
  511. goBack(false);
  512. return;
  513. }
  514. if (payload && payload.action === 'saveSubmit') {
  515. submitSaveAndCommit();
  516. }
  517. },
  518. // 功能说明:二次确认弹窗点击“确认”后执行最终提交 by xu 2026-03-01
  519. handleConfirmSubmit() {
  520. submitFinalConfirm();
  521. }
  522. },
  523. mounted() {
  524. state.vm = this;
  525. window.__mpObjInpSetBottomVisible = setBottomVisible;
  526. init();
  527. },
  528. beforeUnmount() {
  529. window.removeEventListener('resize', updateContentHeight);
  530. try {
  531. if (window.__mpObjInpSetBottomVisible === setBottomVisible) {
  532. delete window.__mpObjInpSetBottomVisible;
  533. }
  534. } catch (_) {}
  535. }
  536. });
  537. };
  538. // 功能说明:SS.ready 某些场景可能不触发,增加超时兜底启动 by xu 2026-02-28
  539. let booted = false;
  540. let tries = 0;
  541. const maxTries = 20;
  542. const safeBoot = function () {
  543. if (booted) return;
  544. const ready = !!(window.SS && window.SS.dom && typeof window.SS.dom.initializeFormApp === 'function');
  545. if (!ready) {
  546. tries += 1;
  547. if (tries >= maxTries) {
  548. const ph = document.getElementById('placeholder');
  549. if (ph) ph.textContent = '初始化失败:ss 组件未就绪';
  550. return;
  551. }
  552. setTimeout(safeBoot, 200);
  553. return;
  554. }
  555. booted = true;
  556. boot();
  557. };
  558. if (window.SS && typeof window.SS.ready === 'function') {
  559. window.SS.ready(safeBoot);
  560. setTimeout(safeBoot, 1600);
  561. } else {
  562. setTimeout(safeBoot, 0);
  563. }
  564. })();
  565. </script>
  566. </body>
  567. </html>