|
|
@@ -1,9 +1,15 @@
|
|
|
<!DOCTYPE html>
|
|
|
<html lang="zh-CN">
|
|
|
<head>
|
|
|
- <!-- 2026-09-29 社团小程序录入页。配合通用壳页 mp_objInp.html 使用:
|
|
|
- 壳页按 include_input(/page/st_inp.jsp)推导出 /page/mp_st_inp.html,
|
|
|
- 本页只负责渲染表单并把字段交给壳页提交。 -->
|
|
|
+ <!-- 2026-09-29 社团小程序录入页。
|
|
|
+
|
|
|
+ 为什么本页自带「保存并提交」按钮,而不像 mp_zssq_inp.html 那样只用壳页底部按钮:
|
|
|
+ 平台只在对象【没有普通二级对象】时才给录入页返回 saveAndCommit / saveAndCommitDest
|
|
|
+ (见 InpServ.initInp:遍历 vo.childMap 发现 typeList 含 "normal" 就不写)。
|
|
|
+ 社团 st 有普通二级对象 stStwcy(社团委成员),所以壳页 mp_objInp 拿不到提交配置,
|
|
|
+ 点它的按钮只会提示「当前页面不支持保存并提交」。
|
|
|
+ 本页因此:进入时隐藏壳页底部按钮,改用自己的按钮直接调用 st_save(= PC 端的「保存」,
|
|
|
+ 方案A:保存即生效、不写草稿、不走流程)。 -->
|
|
|
<meta charset="UTF-8" />
|
|
|
<meta
|
|
|
name="viewport"
|
|
|
@@ -17,10 +23,18 @@
|
|
|
display: none !important;
|
|
|
}
|
|
|
|
|
|
- #app {
|
|
|
+ html,
|
|
|
+ body {
|
|
|
+ margin: 0;
|
|
|
background: #f5f5f5;
|
|
|
+ }
|
|
|
+
|
|
|
+ #app {
|
|
|
min-height: 100vh;
|
|
|
box-sizing: border-box;
|
|
|
+ /* 给固定在底部的操作栏留位置 */
|
|
|
+ padding-bottom: calc(76px + env(safe-area-inset-bottom));
|
|
|
+ background: #f5f5f5;
|
|
|
}
|
|
|
|
|
|
table {
|
|
|
@@ -55,6 +69,49 @@
|
|
|
padding-top: 8px;
|
|
|
padding-bottom: 8px;
|
|
|
}
|
|
|
+
|
|
|
+ .bottom-bar {
|
|
|
+ position: fixed;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ bottom: 0;
|
|
|
+ z-index: 20;
|
|
|
+ display: flex;
|
|
|
+ gap: 10px;
|
|
|
+ padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
|
|
|
+ background: #ffffff;
|
|
|
+ box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.08);
|
|
|
+ box-sizing: border-box;
|
|
|
+ }
|
|
|
+
|
|
|
+ .bottom-bar button {
|
|
|
+ flex: 1;
|
|
|
+ height: 44px;
|
|
|
+ border: 0;
|
|
|
+ border-radius: 6px;
|
|
|
+ font-size: 16px;
|
|
|
+ font-family: inherit;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+
|
|
|
+ .bottom-bar button:disabled {
|
|
|
+ opacity: 0.6;
|
|
|
+ }
|
|
|
+
|
|
|
+ .btn-close {
|
|
|
+ flex: 0 0 34% !important;
|
|
|
+ background: #f0f1f3;
|
|
|
+ color: #333333;
|
|
|
+ }
|
|
|
+
|
|
|
+ .btn-submit {
|
|
|
+ background: #575d6d;
|
|
|
+ color: #ffffff;
|
|
|
+ }
|
|
|
+
|
|
|
+ .hidden {
|
|
|
+ display: none !important;
|
|
|
+ }
|
|
|
</style>
|
|
|
</head>
|
|
|
<body>
|
|
|
@@ -109,9 +166,47 @@
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
+
|
|
|
+ <div class="bottom-bar" :class="{ hidden: hideOwnBar }">
|
|
|
+ <button type="button" class="btn-close" @click="handleClose">
|
|
|
+ 关闭
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ class="btn-submit"
|
|
|
+ :disabled="submitting"
|
|
|
+ @click="submitForm"
|
|
|
+ >
|
|
|
+ {{ submitting ? "提交中..." : "保存并提交" }}
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
<script>
|
|
|
+ // 本页提交目标:st_save(biz.xy.StServ.saveByA)
|
|
|
+ // - 无主键 = 新增(写 JLZTM=51 直接生效,不产生 SQ 草稿)
|
|
|
+ // - 有主键 = 修改该条
|
|
|
+ const SAVE_SERV = "st_save";
|
|
|
+ const SAVE_DEST = "info";
|
|
|
+ const OBJ_NAME = "st";
|
|
|
+
|
|
|
+ // 尽早隐藏壳页底部按钮:base.js 要依次加载 20 多个依赖才会触发 SS.ready,
|
|
|
+ // 若等到 mounted 再隐藏,用户会先看到壳页那个只会报错的「保存并提交」。
|
|
|
+ (function hideShellBottomBarEarly() {
|
|
|
+ try {
|
|
|
+ const embedded =
|
|
|
+ new URLSearchParams(window.location.search).get("embed") === "1";
|
|
|
+ const parentWin = window.parent;
|
|
|
+ if (
|
|
|
+ embedded &&
|
|
|
+ parentWin &&
|
|
|
+ typeof parentWin.__mpObjInpSetBottomVisible === "function"
|
|
|
+ ) {
|
|
|
+ parentWin.__mpObjInpSetBottomVisible(false);
|
|
|
+ }
|
|
|
+ } catch (_) {}
|
|
|
+ })();
|
|
|
+
|
|
|
window.SS.ready(function () {
|
|
|
window.SS.dom.initializeFormApp({
|
|
|
el: "#app",
|
|
|
@@ -124,24 +219,24 @@
|
|
|
fzryid: "",
|
|
|
ms: "",
|
|
|
},
|
|
|
+ submitting: false,
|
|
|
+ embedded: false,
|
|
|
+ hideOwnBar: false,
|
|
|
};
|
|
|
},
|
|
|
async mounted() {
|
|
|
this.pageParams = this.getUrlParams();
|
|
|
this.initFormFromParams();
|
|
|
+ this.embedded = String(this.pageParams.embed || "") === "1";
|
|
|
+ this.hideShellBottomBar();
|
|
|
|
|
|
- // 功能说明:交给通用壳页 mp_objInp.html 取值并提交(与 mp_zssq_inp.html 同一套约定)
|
|
|
+ // 兼容壳页 mp_objInp 的取值协议(本页已自带按钮,保留以防后续复用)
|
|
|
window.__mpObjInpGetFormData = async () => {
|
|
|
const message = this.validateForm();
|
|
|
return {
|
|
|
valid: !message,
|
|
|
message: message || "",
|
|
|
- data: {
|
|
|
- mc: String(this.formData.mc || "").trim(),
|
|
|
- stlbm: this.formData.stlbm,
|
|
|
- fzryid: this.formData.fzryid,
|
|
|
- ms: String(this.formData.ms || "").trim(),
|
|
|
- },
|
|
|
+ data: this.buildPayload(),
|
|
|
};
|
|
|
};
|
|
|
},
|
|
|
@@ -173,12 +268,168 @@
|
|
|
this.formData.ms = String(params.ms || "").trim();
|
|
|
},
|
|
|
|
|
|
+ // 功能说明:隐藏壳页底部那对按钮,避免用户点到只会报错的「保存并提交」
|
|
|
+ hideShellBottomBar() {
|
|
|
+ if (!this.embedded) {
|
|
|
+ this.hideOwnBar = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ const parentWin = window.parent;
|
|
|
+ if (
|
|
|
+ parentWin &&
|
|
|
+ typeof parentWin.__mpObjInpSetBottomVisible === "function"
|
|
|
+ ) {
|
|
|
+ parentWin.__mpObjInpSetBottomVisible(false);
|
|
|
+ this.hideOwnBar = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } catch (_) {}
|
|
|
+ // 壳页没暴露接口(或跨窗口异常)时,保留本页按钮兜底
|
|
|
+ this.hideOwnBar = false;
|
|
|
+ },
|
|
|
+
|
|
|
validateForm() {
|
|
|
- if (!String(this.formData.mc || "").trim()) return "请输入社团名称";
|
|
|
+ if (!String(this.formData.mc || "").trim())
|
|
|
+ return "请输入社团名称";
|
|
|
if (!String(this.formData.fzryid || "").trim())
|
|
|
return "请选择负责人员";
|
|
|
return "";
|
|
|
},
|
|
|
+
|
|
|
+ buildPayload() {
|
|
|
+ const payload = {
|
|
|
+ ssObjName: OBJ_NAME,
|
|
|
+ mc: String(this.formData.mc || "").trim(),
|
|
|
+ stlbm: this.formData.stlbm || "",
|
|
|
+ fzryid: this.formData.fzryid || "",
|
|
|
+ ms: String(this.formData.ms || "").trim(),
|
|
|
+ };
|
|
|
+ // 有主键时按修改提交;新增不带主键,由 StServ.saveByA 走 insert
|
|
|
+ const id =
|
|
|
+ this.pageParams.stid ||
|
|
|
+ this.pageParams.ssObjId ||
|
|
|
+ "";
|
|
|
+ if (String(id).trim() && Number(String(id).trim()) > 0) {
|
|
|
+ payload.stid = String(id).trim();
|
|
|
+ }
|
|
|
+ return payload;
|
|
|
+ },
|
|
|
+
|
|
|
+ toast(message, type) {
|
|
|
+ try {
|
|
|
+ if (typeof showToastEffect === "function") {
|
|
|
+ showToastEffect(message, 1800, type || "info");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } catch (_) {}
|
|
|
+ try {
|
|
|
+ if (typeof showToast === "function") {
|
|
|
+ showToast(message, type || "info");
|
|
|
+ }
|
|
|
+ } catch (_) {}
|
|
|
+ },
|
|
|
+
|
|
|
+ async submitForm() {
|
|
|
+ if (this.submitting) return;
|
|
|
+
|
|
|
+ const message = this.validateForm();
|
|
|
+ if (message) {
|
|
|
+ this.toast(message, "warning");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.submitting = true;
|
|
|
+ try {
|
|
|
+ const req = window.request;
|
|
|
+ if (!req || typeof req.post !== "function") {
|
|
|
+ throw new Error("request 未就绪");
|
|
|
+ }
|
|
|
+ const res = await req.post(
|
|
|
+ `/service?ssServ=${SAVE_SERV}&ssDest=${SAVE_DEST}`,
|
|
|
+ this.buildPayload(),
|
|
|
+ { loading: true, formData: true }
|
|
|
+ );
|
|
|
+
|
|
|
+ // 小程序/微信 UA 下平台返回 JSON(MdU.isReqByMd),这里把服务端的失败信息透出来,
|
|
|
+ // 避免"其实没保存成功却提示成功"。
|
|
|
+ const data = res && res.data ? res.data : null;
|
|
|
+ const serverMsg =
|
|
|
+ data && typeof data === "object"
|
|
|
+ ? String(data.msg || data.message || "").trim()
|
|
|
+ : "";
|
|
|
+ if (
|
|
|
+ serverMsg &&
|
|
|
+ /失败|错误|异常|不能为空|缺少|不存在|无权|不合法/.test(serverMsg)
|
|
|
+ ) {
|
|
|
+ throw new Error(serverMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.toast("提交成功", "success");
|
|
|
+ setTimeout(() => this.goBackAndRefresh(), 900);
|
|
|
+ } catch (error) {
|
|
|
+ console.error("[mp_st_inp] 提交失败", error);
|
|
|
+ const raw = error && error.message ? String(error.message) : "";
|
|
|
+ // 只把可读的中文提示透出来,其余(网络/解析类英文报错)统一给通用文案
|
|
|
+ const readable = /[\u4e00-\u9fa5]/.test(raw) && raw.length <= 60;
|
|
|
+ this.toast(readable ? raw : "提交失败,请稍后重试", "error");
|
|
|
+ } finally {
|
|
|
+ this.submitting = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ handleClose() {
|
|
|
+ this.goBackAndRefresh();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 功能说明:让外层壳页执行返回(并通知列表刷新)。
|
|
|
+ // 壳页 URL 带 _needRefresh=1,由壳页做 localStorage 通知 + history.back 最可靠。
|
|
|
+ goBackAndRefresh() {
|
|
|
+ const hostWin = this.embedded ? window.parent : window;
|
|
|
+
|
|
|
+ const goBack = (win) => {
|
|
|
+ try {
|
|
|
+ if (
|
|
|
+ win &&
|
|
|
+ win.NavigationManager &&
|
|
|
+ typeof win.NavigationManager.goBack === "function"
|
|
|
+ ) {
|
|
|
+ win.NavigationManager.goBack({ refreshParent: true });
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } catch (_) {}
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+
|
|
|
+ if (!goBack(hostWin)) {
|
|
|
+ try {
|
|
|
+ hostWin.history.back();
|
|
|
+ } catch (_) {}
|
|
|
+ }
|
|
|
+
|
|
|
+ // 兜底:1.2 秒后若壳页仍是当前可见文档(说明返回没生效、或返回后列表没刷新),
|
|
|
+ // 直接把外层整页 replace 回列表页并带时间戳,确保新记录一定出现。
|
|
|
+ // 壳页已被卸载/挂起时这个定时器不会生效(JS 上下文已销毁或不可见)。
|
|
|
+ if (!this.embedded) return;
|
|
|
+ setTimeout(() => {
|
|
|
+ try {
|
|
|
+ const shellWin = window.parent;
|
|
|
+ if (!shellWin || shellWin === window) return;
|
|
|
+ const doc = shellWin.document;
|
|
|
+ if (!doc || doc.visibilityState !== "visible") return;
|
|
|
+
|
|
|
+ const p = new URLSearchParams(shellWin.location.search || "");
|
|
|
+ p.delete("dest");
|
|
|
+ p.delete("ssDest");
|
|
|
+ p.delete("_needRefresh");
|
|
|
+ p.set("service", OBJ_NAME + "_cx");
|
|
|
+ p.set("_t", String(Date.now()));
|
|
|
+ shellWin.location.replace(
|
|
|
+ "/page/mp_objList.html?" + p.toString()
|
|
|
+ );
|
|
|
+ } catch (_) {}
|
|
|
+ }, 1200);
|
|
|
+ },
|
|
|
},
|
|
|
});
|
|
|
});
|