| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8"/>
- <meta name="viewport"
- content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
- <title>团体录入</title>
- <script src="/js/mp_base/base.js?v=20261117-select-font-v4"></script>
- <style>
- [v-cloak] { display: none !important; }
- :root { --line: #e5e7eb; --text: #222; --muted: #8b95a5; }
- * { box-sizing: border-box; }
- body { margin: 0; color: var(--text); background: #f5f5f5;
- font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
- "Microsoft YaHei", sans-serif; }
- #app { min-height: 100vh; padding: 8px 8px calc(78px + env(safe-area-inset-bottom)); }
- .form-table { overflow: hidden; background: #fff; border-radius: 6px;
- border: 1px solid var(--line); }
- .form-row { display: grid; grid-template-columns: 112px minmax(0, 1fr);
- min-height: 58px; border-bottom: 1px solid var(--line); }
- .form-row:last-child { border-bottom: 0; }
- .form-label { display: flex; align-items: center; justify-content: center;
- padding: 12px; color: var(--muted); background: #fbfbfc;
- border-right: 1px solid var(--line); font-size: 15px; }
- .form-value { display: flex; align-items: center; min-width: 0;
- padding: 10px 12px; font-size: 15px; }
- .form-value > .ss-select-container { width: 100%; }
- .native-input, .native-textarea { width: 100%; color: var(--text);
- background: #fff; border: 0; outline: none; font: inherit; font-size: 15px; }
- .native-input { height: 38px; }
- .native-textarea { min-height: 110px; resize: vertical; }
- .native-input::placeholder, .native-textarea::placeholder { color: #b4bbc6; }
- .description-row .form-value { padding: 0; align-items: stretch; }
- .description-cell { position: relative; width: 100%; min-height: 110px; }
- .description-cell .native-textarea { min-height: 110px; padding: 12px 76px 12px 12px; }
- .pms-attachment-button { position: absolute; top: 0; right: 0; bottom: 0;
- width: 64px; display: flex; align-items: center; justify-content: center;
- flex-direction: column; gap: 5px; padding: 0; color: #666;
- background: #f0f0f0; border: 0; border-left: 1px solid #ddd;
- border-radius: 0; font: inherit; font-size: 13px; z-index: 1; }
- .pms-attachment-button:disabled { color: #aaa; background: #f5f5f5; }
- .pms-attachment-button .common-icon { font-size: 18px; }
- .submit-error { margin: 10px 2px 0; padding: 10px 12px; color: #e5484d;
- background: #fff0f0; border: 1px solid #ffd0d0; border-radius: 6px;
- font-size: 14px; }
- .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: #fff; box-shadow: 0 -1px 6px rgba(0,0,0,.08); }
- .bottom-bar button { flex: 1; height: 44px; border: 0; border-radius: 6px;
- font: inherit; font-size: 16px; }
- .btn-close { flex: 0 0 34% !important; color: #333; background: #f0f1f3; }
- .btn-submit { color: #fff; background: #575d6d; }
- .hidden { display: none !important; }
- .attachment-modal { position: fixed; z-index: 9999; inset: 0;
- display: flex; flex-direction: column; background: #fff; }
- .attachment-modal-head { display: flex; height: 48px; align-items: center;
- justify-content: space-between; padding: 0 14px;
- border-bottom: 1px solid var(--line); font-size: 16px; font-weight: 700; }
- .attachment-close { padding: 8px 4px 8px 14px; color: #19a463;
- background: transparent; border: 0; font: inherit; font-size: 15px; }
- .attachment-frame { flex: 1; width: 100%; border: 0; }
- </style>
- </head>
- <body>
- <div id="app" v-cloak>
- <div class="form-table">
- <div class="form-row"><div class="form-label">名称</div><div class="form-value">
- <input v-model="form.mc" class="native-input" maxlength="128" placeholder="请输入团体名称"/>
- </div></div>
- <div class="form-row"><div class="form-label">类别</div><div class="form-value">
- <ss-select v-model="form.ttlbm" cb="ttlb" placeholder="" empty-option searchable clearable></ss-select>
- </div></div>
- <div class="form-row"><div class="form-label">负责人员</div><div class="form-value">
- <ss-select v-model="form.fzryid" cb="ry" inp="true" placeholder="" empty-option searchable clearable></ss-select>
- </div></div>
- <div class="form-row"><div class="form-label">负责部门</div><div class="form-value">
- <ss-select v-model="form.fzbmid" cb="bm" placeholder="" empty-option searchable clearable></ss-select>
- </div></div>
- <div class="form-row"><div class="form-label">生效日期</div><div class="form-value">
- <ss-datetime-picker v-model="form.ksrq" mode="date" placeholder=""></ss-datetime-picker>
- </div></div>
- <div class="form-row"><div class="form-label">结束日期</div><div class="form-value">
- <ss-datetime-picker v-model="form.jsrq" mode="date" :min-date="form.ksrq" placeholder=""></ss-datetime-picker>
- </div></div>
- <div class="form-row"><div class="form-label">学年</div><div class="form-value">
- <input v-model="form.xndm" class="native-input" maxlength="9" placeholder="如 2026-2027"/>
- </div></div>
- <div class="form-row description-row"><div class="form-label">描述</div><div class="form-value">
- <div class="description-cell">
- <textarea v-model="form.ms" class="native-textarea" maxlength="2048" placeholder="请输入描述"></textarea>
- <button class="pms-attachment-button" type="button"
- :disabled="attachmentLoading"
- :aria-label="form.fjid ? '管理附件' : '添加附件'"
- @click="openAttachment">
- <ss-common-icon class="common-icon-paper-clip"></ss-common-icon>
- <span>{{ attachmentLoading ? '处理中' : '附件' }}</span>
- </button>
- </div>
- </div></div>
- </div>
- <div v-if="errorMsg" class="submit-error">{{ errorMsg }}</div>
- <div class="bottom-bar" :class="{hidden: hideOwnBar}">
- <button type="button" class="btn-close" @click="goBack">关闭</button>
- <button type="button" class="btn-submit" :disabled="submitting" @click="submitForm">
- {{ submitting ? "提交中..." : "保存并提交" }}
- </button>
- </div>
- <div v-if="attachmentVisible" class="attachment-modal">
- <div class="attachment-modal-head">
- <span>附件管理</span>
- <button class="attachment-close" type="button" @click="attachmentVisible=false">关闭</button>
- </div>
- <iframe class="attachment-frame" :src="attachmentUrl"></iframe>
- </div>
- </div>
- <script>
- (function hideShellBottomBarEarly() {
- try {
- const embedded = new URLSearchParams(location.search).get("embed") === "1";
- if (embedded && window.parent &&
- typeof window.parent.__mpObjInpSetBottomVisible === "function")
- window.parent.__mpObjInpSetBottomVisible(false);
- } catch (_) {}
- })();
- window.SS.ready(function () {
- window.SS.dom.initializeFormApp({
- el: "#app",
- data() {
- return {
- pageParams: {},
- form: {ttid:"", mc:"", ttlbm:"", fzryid:"", fzbmid:"", ksrq:"", jsrq:"", xndm:"", ms:"", fjid:""},
- submitting: false,
- errorMsg: "",
- hideOwnBar: false,
- attachmentVisible: false,
- attachmentLoading: false,
- attachmentUrl: ""
- };
- },
- mounted() {
- this.pageParams = this.getUrlParams();
- const param = this.parseParamObject(this.pageParams.param);
- const ttid = String(param.ttid || param.ssObjId ||
- this.pageParams.ttid || this.pageParams.ssObjId || "").trim();
- this.form.ttid = Number(ttid) > 0 ? ttid : "";
- ["mc","ttlbm","fzryid","fzbmid","ksrq","jsrq","xndm","ms","fjid"].forEach(key => {
- const value = param[key] !== undefined ? param[key] : this.pageParams[key];
- if (value !== undefined && value !== null) this.form[key] = String(value);
- });
- window.__mpObjInpGetFormData = async () => {
- const message = this.validateForm();
- return {valid: !message, message: message || "", data: this.buildPayload()};
- };
- },
- beforeUnmount() {
- try { delete window.__mpObjInpGetFormData; } catch (_) {}
- },
- methods: {
- getUrlParams() {
- const params = {};
- new URLSearchParams(location.search).forEach((value, key) => {
- try { params[key] = decodeURIComponent(value); }
- catch (_) { params[key] = value; }
- });
- return params;
- },
- parseParamObject(raw) {
- if (!raw) return {};
- if (typeof raw === "object") return raw;
- try { return JSON.parse(raw); } catch (_) {
- try {
- return JSON.parse(String(raw)
- .replace(/([{,]\s*)([A-Za-z0-9_]+)\s*:/g, '$1"$2":')
- .replace(/'/g, '"'));
- } catch (__) { return {}; }
- }
- },
- validateForm() {
- if (!this.form.mc.trim()) return "请输入团体名称";
- if (!this.form.ttlbm) return "请选择团体类别";
- if (!this.form.fzryid) return "请选择负责人员";
- if (this.form.ksrq && this.form.jsrq && this.form.jsrq < this.form.ksrq)
- return "结束日期不能早于生效日期";
- return "";
- },
- buildPayload() {
- const cleanDate = value => String(value || "").slice(0, 10);
- return {
- ssObjName: "xsh",
- ttid: this.form.ttid,
- mc: this.form.mc.trim(),
- ttlbm: this.form.ttlbm,
- fzryid: this.form.fzryid,
- fzbmid: this.form.fzbmid,
- ksrq: cleanDate(this.form.ksrq),
- jsrq: cleanDate(this.form.jsrq),
- xndm: this.form.xndm.trim(),
- ms: this.form.ms.trim(),
- fjid: this.form.fjid
- };
- },
- async submitForm() {
- if (this.submitting) return;
- this.errorMsg = this.validateForm();
- if (this.errorMsg) return;
- this.submitting = true;
- try {
- const service = this.form.ttid ? "xsh_upd" : "xsh_save";
- const response = await window.request.post(
- `/service?ssServ=${service}&ssDest=info&wdConfirmationCaptchaService=0`,
- this.buildPayload(), {loading: true, formData: true});
- const raw = response && response.data !== undefined ? response.data : response;
- if (raw && raw.ssCode !== undefined && Number(raw.ssCode) !== 0)
- throw new Error(raw.ssMsg || "保存失败");
- if (typeof showToastEffect === "function")
- showToastEffect("提交成功", 1400, "success");
- setTimeout(() => this.goBack(), 800);
- } catch (error) {
- this.errorMsg = error.message || "提交失败,请稍后重试";
- } finally {
- this.submitting = false;
- }
- },
- async openAttachment() {
- if (this.attachmentLoading) return;
- this.attachmentLoading = true;
- try {
- if (!this.form.fjid) {
- const response = await window.request.post(
- "/service?ssServ=makeAttCms&wdConfirmationCaptchaService=0",
- {name:"fjid", ssNrObjName:"sh", ssNrObjId:""},
- {loading:false, formData:true});
- const raw = response && response.data !== undefined ? response.data : response;
- const candidate = raw && typeof raw === "object"
- ? (raw.data ?? raw.ssData ?? raw.result) : raw;
- const fjid = String(candidate == null ? "" : candidate).trim();
- if (!/^\d+$/.test(fjid)) throw new Error("附件初始化失败");
- this.form.fjid = fjid;
- }
- const fjid = encodeURIComponent(this.form.fjid);
- this.attachmentUrl =
- "/service?ssServ=regCms&ssDest=cmsEdit&wdConfirmationCaptchaService=0"
- + "&nrid=T-" + fjid + "&objectId=" + fjid
- + "&objectName=fjid&mode=edit&callback=";
- this.attachmentVisible = true;
- } catch (error) {
- if (typeof showToastEffect === "function")
- showToastEffect(error.message || "附件初始化失败", 2200, "error");
- } finally {
- this.attachmentLoading = false;
- }
- },
- goBack() {
- const host = window.parent !== window ? window.parent : window;
- try {
- if (host.NavigationManager &&
- typeof host.NavigationManager.goBack === "function") {
- host.NavigationManager.goBack({refreshParent: true});
- return;
- }
- } catch (_) {}
- history.back();
- }
- }
- });
- });
- </script>
- </body>
- </html>
|