mp_objInp.html 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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=20261201-list-return-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(() => returnToListAfterSubmit(), 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 returnToListAfterSubmit = () => {
  209. const returnTo = String(
  210. state.pageParams.returnTo
  211. || (document.referrer
  212. && /(?:^|\/)(?:mp_objList|mp_[^/]+_list)\.html(?:[?#]|$)/i.test(document.referrer)
  213. ? document.referrer
  214. : '')
  215. ).trim();
  216. if (returnTo && window.NavigationManager
  217. && typeof window.NavigationManager.returnToList === 'function') {
  218. window.NavigationManager.returnToList(returnTo, {
  219. refreshData: {
  220. service: state.service,
  221. ssObjName: state.ssObjName,
  222. },
  223. });
  224. return;
  225. }
  226. goBack(true);
  227. };
  228. const ensureRequest = () => {
  229. if (!window.request || typeof window.request.post !== 'function') {
  230. throw new Error('request 未就绪');
  231. }
  232. return window.request;
  233. };
  234. // 功能说明:内容区高度按 100vh 减去 ss-bottom 实际高度计算 by xu 2026-02-28
  235. const updateContentHeight = () => {
  236. const contentWrap = document.getElementById('contentWrap');
  237. if (!contentWrap) return;
  238. const bottom = document.querySelector('#app .ss-bottom');
  239. const bottomHeight = bottom ? bottom.offsetHeight : 0;
  240. contentWrap.style.height = `calc(100vh - ${bottomHeight}px)`;
  241. };
  242. // 功能说明:学校违纪录入使用其他移动端入口一致的默认底部按钮和文案
  243. const isSchoolViolationEntry = (serviceName = '', objName = '') => {
  244. const service = String(serviceName || state.service || getUrlParams().service || '').trim();
  245. const objectName = String(objName || state.ssObjName || '').trim();
  246. return objectName === 'xxwjjl' || service.startsWith('xxwjjl_');
  247. };
  248. const isDisciplineAppearanceEntry = (serviceName = '', objName = '') => {
  249. const service = String(serviceName || state.service || getUrlParams().service || '').trim();
  250. const objectName = String(objName || state.ssObjName || '').trim();
  251. return objectName === 'fjyrjc' || service.startsWith('fjyrjc_');
  252. };
  253. const makeCloseBottomButton = (serviceName = '', objName = '') => ({
  254. text: isSchoolViolationEntry(serviceName, objName) || isDisciplineAppearanceEntry(serviceName, objName) ? '取消' : '关闭',
  255. action: 'close'
  256. });
  257. const makeSubmitBottomButton = (text, serviceName = '', objName = '') => {
  258. const button = {
  259. text: text || '保存并提交',
  260. action: 'saveSubmit'
  261. };
  262. if (!isSchoolViolationEntry(serviceName, objName)
  263. && !isDisciplineAppearanceEntry(serviceName, objName)) {
  264. button.backgroundColor = '#575d6d';
  265. button.color = '#fff';
  266. }
  267. return button;
  268. };
  269. const updateBottomButtons = (submitTitle) => {
  270. if (!state.vm) return;
  271. state.vm.bottomButtons = [
  272. makeCloseBottomButton(state.service, state.ssObjName),
  273. makeSubmitBottomButton(submitTitle, state.service, state.ssObjName)
  274. ];
  275. setTimeout(updateContentHeight, 0);
  276. };
  277. // 功能说明:供 iframe 子页调用,控制父页底部按钮显隐(解决日期弹层被底部按钮遮挡) by xu 2026-02-28
  278. const setBottomVisible = (visible) => {
  279. if (!state.vm) return;
  280. state.vm.showBottom = visible !== false;
  281. setTimeout(updateContentHeight, 0);
  282. };
  283. const getFrameFormData = async () => {
  284. const frame = document.getElementById('objInpFrame');
  285. const frameWindow = frame ? frame.contentWindow : null;
  286. if (!frameWindow) return { valid: false, message: '表单页面未加载完成', data: {} };
  287. // 功能说明:优先走子页面暴露方法,尽量减少表单页工作量 by xu 2026-02-28
  288. if (typeof frameWindow.__mpObjInpGetFormData === 'function') {
  289. // 功能说明:支持子页异步取值(如提交前补查关联字段),确保提交参数完整 by xu 2026-03-01
  290. const result = await Promise.resolve(frameWindow.__mpObjInpGetFormData());
  291. if (result && typeof result === 'object') {
  292. return {
  293. valid: result.valid !== false,
  294. message: result.message || '',
  295. data: result.data && typeof result.data === 'object' ? result.data : {},
  296. };
  297. }
  298. }
  299. const doc = frameWindow.document;
  300. const data = {};
  301. const nodes = doc.querySelectorAll('input[name],select[name],textarea[name]');
  302. nodes.forEach((node) => {
  303. const name = node.getAttribute('name');
  304. if (!name || node.disabled) return;
  305. const type = (node.getAttribute('type') || '').toLowerCase();
  306. if ((type === 'checkbox' || type === 'radio') && !node.checked) return;
  307. data[name] = node.value;
  308. });
  309. return { valid: true, message: '', data };
  310. };
  311. const getSubmitConfig = () => {
  312. const p = state.initPayload || {};
  313. const saveServiceName = String(p.saveAndCommit || '').trim();
  314. const saveDest = String(p.saveAndCommitDest || '').trim();
  315. const routeServiceName = String(state.service || state.pageParams.service || state.pageParams.ssServ || '').trim();
  316. const routeDest = String(state.pageParams.dest || state.pageParams.ssDest || '').trim();
  317. const routeParamObj = parseJsonString(state.pageParams.param);
  318. const routeDataType = String(state.pageParams.dataType || routeParamObj.dataType || '').trim().toLowerCase();
  319. // 功能说明:变动页签若第一接口没回 saveAndCommitDest,则回退用当前 service+objInp+param 提交 by xu 2026-03-06
  320. const canUseRouteSubmit = routeDataType === 'change' && routeDest.toLowerCase() === 'objinp' && !!routeServiceName;
  321. const serviceName = saveServiceName || (canUseRouteSubmit ? routeServiceName : '');
  322. const dest = saveDest || (canUseRouteSubmit ? routeDest : '');
  323. const enabled = !!(serviceName && dest);
  324. return {
  325. enabled,
  326. serviceName,
  327. dest,
  328. title: String(p.saveAndCommitButtonValue || '保存并提交'),
  329. paramObj: pruneParams({
  330. ...(canUseRouteSubmit ? {
  331. ...routeParamObj,
  332. sqid: state.pageParams.sqid,
  333. shid: state.pageParams.shid,
  334. shyjm: state.pageParams.shyjm,
  335. bdlbm: state.pageParams.bdlbm,
  336. dataType: state.pageParams.dataType,
  337. } : {}),
  338. ...parseJsonString(p.saveAndCommitParam),
  339. }),
  340. };
  341. };
  342. const renderFormFrame = () => {
  343. const includeInput = (state.dataTagPayload && state.dataTagPayload.include_input) || '';
  344. const fallbackFormPath = resolveFallbackFormPath();
  345. const formPath = includeToMpFormPath(includeInput) || fallbackFormPath;
  346. console.log('[mp_objInp][renderFormFrame] include_input =', includeInput);
  347. console.log('[mp_objInp][renderFormFrame] fallbackFormPath =', fallbackFormPath);
  348. console.log('[mp_objInp][renderFormFrame] formPath =', formPath);
  349. if (!formPath) {
  350. if (state.vm) {
  351. state.vm.iframeSrc = '';
  352. state.vm.placeholderText = '未获取到 include_input,且未命中对象表单页';
  353. }
  354. state.submitEnabled = false;
  355. console.warn('[mp_objInp][renderFormFrame] formPath为空,终止渲染iframe');
  356. return;
  357. }
  358. const childParams = new URLSearchParams();
  359. Object.entries(state.pageParams || {}).forEach(([key, value]) => {
  360. if (value === undefined || value === null || value === '') return;
  361. childParams.set(key, value);
  362. });
  363. childParams.set('embed', '1');
  364. childParams.set('ssObjName', state.ssObjName || '');
  365. childParams.set('ssObjId', state.ssObjId || '');
  366. const iframeSrc = `${formPath}?${childParams.toString()}`;
  367. console.log('[mp_objInp][renderFormFrame] iframe src =', iframeSrc);
  368. if (state.vm) {
  369. state.vm.iframeSrc = iframeSrc;
  370. }
  371. const submitCfg = getSubmitConfig();
  372. state.submitEnabled = !!submitCfg.enabled;
  373. updateBottomButtons(submitCfg.title);
  374. setTimeout(updateContentHeight, 0);
  375. };
  376. const loadInitPayload = async () => {
  377. const req = ensureRequest();
  378. const postData = {
  379. ...state.pageParams,
  380. management: state.pageParams.management || '1',
  381. isReady: '1',
  382. };
  383. const res = await req.post(
  384. `/service?ssServ=${state.service}&management=1&isReady=1`,
  385. postData,
  386. { loading: false, formData: true }
  387. );
  388. state.initPayload = unwrapData(res ? res.data : null);
  389. state.ssObjName = String(state.initPayload.ssObjName || state.pageParams.ssObjName || '').trim();
  390. state.ssObjId = resolveObjIdFromInit(state.initPayload, state.ssObjName, state.pageParams);
  391. console.log('[mp_objInp] init响应', state.initPayload);
  392. };
  393. const loadDataTagPayload = async () => {
  394. const req = ensureRequest();
  395. const dataTagParams = {
  396. ...state.pageParams,
  397. ssObjName: state.ssObjName,
  398. ssObjId: state.ssObjId,
  399. };
  400. const res = await req.post(
  401. `/service?ssServ=dataTag&ssDest=data&name=inp&ssObjName=${encodeURIComponent(state.ssObjName)}&ssObjId=${encodeURIComponent(state.ssObjId)}`,
  402. dataTagParams,
  403. { loading: false, formData: true }
  404. );
  405. state.dataTagPayload = unwrapData(res ? res.data : null);
  406. console.log('[mp_objInp] dataTag响应', state.dataTagPayload);
  407. console.log('[mp_objInp] dataTag include_input =', (state.dataTagPayload && state.dataTagPayload.include_input) || '');
  408. };
  409. const submitSaveAndCommit = async () => {
  410. const alignDormitorySubmit = isDisciplineAppearanceEntry(state.service, state.ssObjName);
  411. if (alignDormitorySubmit && state.vm && state.vm.bottomSubmitting) return;
  412. try {
  413. if (alignDormitorySubmit && state.vm) state.vm.bottomSubmitting = true;
  414. const cfg = getSubmitConfig();
  415. if (!state.submitEnabled || !cfg.enabled) {
  416. if (typeof showToastEffect === 'function') showToastEffect('当前页面不支持保存并提交', 1800, 'warning');
  417. return;
  418. }
  419. if (!cfg.serviceName || !cfg.dest) {
  420. if (typeof showToastEffect === 'function') showToastEffect('提交配置缺失', 1800, 'error');
  421. return;
  422. }
  423. const formResult = await getFrameFormData();
  424. if (!formResult.valid) {
  425. if (typeof showToastEffect === 'function') showToastEffect(formResult.message || '表单校验未通过', 2000, 'warning');
  426. return;
  427. }
  428. const req = ensureRequest();
  429. const payload = pruneParams({
  430. ...(cfg.paramObj || {}),
  431. ...(formResult.data || {}),
  432. ssObjName: state.ssObjName || undefined,
  433. ssObjId: state.ssObjId || undefined,
  434. [((state.initPayload && state.initPayload.ssObjIdName) || 'ssObjId')]: state.ssObjId || undefined,
  435. });
  436. const res = await req.post(
  437. `/service?ssServ=${cfg.serviceName}&ssDest=${encodeURIComponent(cfg.dest)}`,
  438. payload,
  439. { loading: true, formData: true }
  440. );
  441. console.log('[mp_objInp] saveAndCommit响应', res);
  442. assertServiceSuccess(res && res.data !== undefined
  443. ? res.data
  444. : res);
  445. const submitResp = unwrapData(res ? res.data : null);
  446. // 功能说明:保存并提交后若目标为 addSure,则在 inp 页二次确认并直接调最终提交接口 by xu 2026-03-01
  447. if (String(cfg.dest || '').trim().toLowerCase() === 'addsure') {
  448. const finalObjName = String((submitResp && submitResp.ssObjName) || state.ssObjName || '').trim();
  449. const finalObjIdName = String((submitResp && submitResp.ssObjIdName) || (state.initPayload && state.initPayload.ssObjIdName) || 'ssObjId').trim();
  450. const finalObjId = String((submitResp && submitResp.ssObjId) || state.ssObjId || '').trim();
  451. if (!finalObjName || !finalObjId) {
  452. if (typeof showToastEffect === 'function') showToastEffect('缺少提交参数,无法确认提交', 2200, 'error');
  453. return;
  454. }
  455. const finalServ = `${finalObjName}_lr_tj_qr`;
  456. const finalPayload = pruneParams({
  457. ssObjName: finalObjName,
  458. [finalObjIdName]: finalObjId,
  459. });
  460. // 功能说明:先缓存最终提交参数,再弹 ss-confirm 确认 by xu 2026-03-01
  461. state.pendingFinalSubmit = {
  462. serviceName: finalServ,
  463. payload: finalPayload,
  464. };
  465. if (alignDormitorySubmit) {
  466. await submitFinalConfirm();
  467. return;
  468. }
  469. if (state.vm) {
  470. state.vm.showSubmitConfirm = true;
  471. }
  472. return;
  473. }
  474. if (typeof showToastEffect === 'function') showToastEffect('提交成功', 1400, 'success');
  475. setTimeout(() => returnToListAfterSubmit(), 600);
  476. } catch (err) {
  477. console.error('[mp_objInp] 提交失败', err);
  478. if (typeof showToastEffect === 'function') showToastEffect(
  479. err && err.message ? err.message : '提交失败,请稍后重试',
  480. 2200,
  481. 'error'
  482. );
  483. } finally {
  484. if (alignDormitorySubmit && state.vm) state.vm.bottomSubmitting = false;
  485. }
  486. };
  487. const init = async () => {
  488. try {
  489. setStatus('正在初始化录入页...');
  490. state.pageParams = getUrlParams();
  491. state.service = String(state.pageParams.service || '').trim();
  492. if (!state.service) throw new Error('缺少 service 参数');
  493. setStatus('正在加载业务配置...');
  494. await loadInitPayload();
  495. if (!state.ssObjName) throw new Error('第一接口未返回 ssObjName');
  496. setStatus('正在加载 dataTag...');
  497. await loadDataTagPayload();
  498. setStatus('正在加载表单页面...');
  499. renderFormFrame();
  500. setTimeout(updateContentHeight, 0);
  501. } catch (err) {
  502. console.error('[mp_objInp] 初始化失败', err);
  503. setStatus(`初始化失败:${err && err.message ? err.message : err}`);
  504. state.submitEnabled = false;
  505. }
  506. };
  507. window.addEventListener('resize', updateContentHeight);
  508. // 功能说明:使用 ss-bottom 统一底部样式与交互 by xu 2026-02-28
  509. window.SS.dom.initializeFormApp({
  510. el: '#app',
  511. data() {
  512. return {
  513. iframeSrc: '',
  514. placeholderText: '正在加载录入页面...',
  515. showBottom: true,
  516. showSubmitConfirm: false,
  517. bottomSubmitting: false,
  518. bottomButtons: [
  519. makeCloseBottomButton(getUrlParams().service),
  520. makeSubmitBottomButton('保存并提交', getUrlParams().service)
  521. ]
  522. }
  523. },
  524. methods: {
  525. handleFrameLoad() {
  526. console.log('[mp_objInp][renderFormFrame] iframe onload');
  527. setTimeout(updateContentHeight, 0);
  528. },
  529. handleBottomAction(payload) {
  530. if (this.bottomSubmitting) return;
  531. if (payload && payload.action === 'close') {
  532. goBack(false);
  533. return;
  534. }
  535. if (payload && payload.action === 'saveSubmit') {
  536. submitSaveAndCommit();
  537. }
  538. },
  539. // 功能说明:二次确认弹窗点击“确认”后执行最终提交 by xu 2026-03-01
  540. handleConfirmSubmit() {
  541. submitFinalConfirm();
  542. }
  543. },
  544. mounted() {
  545. state.vm = this;
  546. window.__mpObjInpSetBottomVisible = setBottomVisible;
  547. init();
  548. },
  549. beforeUnmount() {
  550. window.removeEventListener('resize', updateContentHeight);
  551. try {
  552. if (window.__mpObjInpSetBottomVisible === setBottomVisible) {
  553. delete window.__mpObjInpSetBottomVisible;
  554. }
  555. } catch (_) {}
  556. }
  557. });
  558. };
  559. // 功能说明:SS.ready 某些场景可能不触发,增加超时兜底启动 by xu 2026-02-28
  560. let booted = false;
  561. let tries = 0;
  562. const maxTries = 20;
  563. const safeBoot = function () {
  564. if (booted) return;
  565. const ready = !!(window.SS && window.SS.dom && typeof window.SS.dom.initializeFormApp === 'function');
  566. if (!ready) {
  567. tries += 1;
  568. if (tries >= maxTries) {
  569. const ph = document.getElementById('placeholder');
  570. if (ph) ph.textContent = '初始化失败:ss 组件未就绪';
  571. return;
  572. }
  573. setTimeout(safeBoot, 200);
  574. return;
  575. }
  576. booted = true;
  577. boot();
  578. };
  579. if (window.SS && typeof window.SS.ready === 'function') {
  580. window.SS.ready(safeBoot);
  581. setTimeout(safeBoot, 1600);
  582. } else {
  583. setTimeout(safeBoot, 0);
  584. }
  585. })();
  586. </script>
  587. </body>
  588. </html>