mp_xsh_inp.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8"/>
  5. <meta name="viewport"
  6. content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  7. <title>团体录入</title>
  8. <script src="/js/mp_base/base.js?v=20261117-select-font-v4"></script>
  9. <style>
  10. [v-cloak] { display: none !important; }
  11. :root { --line: #e5e7eb; --text: #222; --muted: #8b95a5; }
  12. * { box-sizing: border-box; }
  13. body { margin: 0; color: var(--text); background: #f5f5f5;
  14. font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
  15. "Microsoft YaHei", sans-serif; }
  16. #app { min-height: 100vh; padding: 8px 8px calc(78px + env(safe-area-inset-bottom)); }
  17. .form-table { overflow: hidden; background: #fff; border-radius: 6px;
  18. border: 1px solid var(--line); }
  19. .form-row { display: grid; grid-template-columns: 112px minmax(0, 1fr);
  20. min-height: 58px; border-bottom: 1px solid var(--line); }
  21. .form-row:last-child { border-bottom: 0; }
  22. .form-label { display: flex; align-items: center; justify-content: center;
  23. padding: 12px; color: var(--muted); background: #fbfbfc;
  24. border-right: 1px solid var(--line); font-size: 15px; }
  25. .form-value { display: flex; align-items: center; min-width: 0;
  26. padding: 10px 12px; font-size: 15px; }
  27. .form-value > .ss-select-container { width: 100%; }
  28. .native-input, .native-textarea { width: 100%; color: var(--text);
  29. background: #fff; border: 0; outline: none; font: inherit; font-size: 15px; }
  30. .native-input { height: 38px; }
  31. .native-textarea { min-height: 110px; resize: vertical; }
  32. .native-input::placeholder, .native-textarea::placeholder { color: #b4bbc6; }
  33. .description-row .form-value { padding: 0; align-items: stretch; }
  34. .description-cell { position: relative; width: 100%; min-height: 110px; }
  35. .description-cell .native-textarea { min-height: 110px; padding: 12px 76px 12px 12px; }
  36. .pms-attachment-button { position: absolute; top: 0; right: 0; bottom: 0;
  37. width: 64px; display: flex; align-items: center; justify-content: center;
  38. flex-direction: column; gap: 5px; padding: 0; color: #666;
  39. background: #f0f0f0; border: 0; border-left: 1px solid #ddd;
  40. border-radius: 0; font: inherit; font-size: 13px; z-index: 1; }
  41. .pms-attachment-button:disabled { color: #aaa; background: #f5f5f5; }
  42. .pms-attachment-button .common-icon { font-size: 18px; }
  43. .submit-error { margin: 10px 2px 0; padding: 10px 12px; color: #e5484d;
  44. background: #fff0f0; border: 1px solid #ffd0d0; border-radius: 6px;
  45. font-size: 14px; }
  46. .bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  47. display: flex; gap: 10px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  48. background: #fff; box-shadow: 0 -1px 6px rgba(0,0,0,.08); }
  49. .bottom-bar button { flex: 1; height: 44px; border: 0; border-radius: 6px;
  50. font: inherit; font-size: 16px; }
  51. .btn-close { flex: 0 0 34% !important; color: #333; background: #f0f1f3; }
  52. .btn-submit { color: #fff; background: #575d6d; }
  53. .hidden { display: none !important; }
  54. .attachment-modal { position: fixed; z-index: 9999; inset: 0;
  55. display: flex; flex-direction: column; background: #fff; }
  56. .attachment-modal-head { display: flex; height: 48px; align-items: center;
  57. justify-content: space-between; padding: 0 14px;
  58. border-bottom: 1px solid var(--line); font-size: 16px; font-weight: 700; }
  59. .attachment-close { padding: 8px 4px 8px 14px; color: #19a463;
  60. background: transparent; border: 0; font: inherit; font-size: 15px; }
  61. .attachment-frame { flex: 1; width: 100%; border: 0; }
  62. </style>
  63. </head>
  64. <body>
  65. <div id="app" v-cloak>
  66. <div class="form-table">
  67. <div class="form-row"><div class="form-label">名称</div><div class="form-value">
  68. <input v-model="form.mc" class="native-input" maxlength="128" placeholder="请输入团体名称"/>
  69. </div></div>
  70. <div class="form-row"><div class="form-label">类别</div><div class="form-value">
  71. <ss-select v-model="form.ttlbm" cb="ttlb" placeholder="" empty-option searchable clearable></ss-select>
  72. </div></div>
  73. <div class="form-row"><div class="form-label">负责人员</div><div class="form-value">
  74. <ss-select v-model="form.fzryid" cb="ry" inp="true" placeholder="" empty-option searchable clearable></ss-select>
  75. </div></div>
  76. <div class="form-row"><div class="form-label">负责部门</div><div class="form-value">
  77. <ss-select v-model="form.fzbmid" cb="bm" placeholder="" empty-option searchable clearable></ss-select>
  78. </div></div>
  79. <div class="form-row"><div class="form-label">生效日期</div><div class="form-value">
  80. <ss-datetime-picker v-model="form.ksrq" mode="date" placeholder=""></ss-datetime-picker>
  81. </div></div>
  82. <div class="form-row"><div class="form-label">结束日期</div><div class="form-value">
  83. <ss-datetime-picker v-model="form.jsrq" mode="date" :min-date="form.ksrq" placeholder=""></ss-datetime-picker>
  84. </div></div>
  85. <div class="form-row"><div class="form-label">学年</div><div class="form-value">
  86. <input v-model="form.xndm" class="native-input" maxlength="9" placeholder="如 2026-2027"/>
  87. </div></div>
  88. <div class="form-row description-row"><div class="form-label">描述</div><div class="form-value">
  89. <div class="description-cell">
  90. <textarea v-model="form.ms" class="native-textarea" maxlength="2048" placeholder="请输入描述"></textarea>
  91. <button class="pms-attachment-button" type="button"
  92. :disabled="attachmentLoading"
  93. :aria-label="form.fjid ? '管理附件' : '添加附件'"
  94. @click="openAttachment">
  95. <ss-common-icon class="common-icon-paper-clip"></ss-common-icon>
  96. <span>{{ attachmentLoading ? '处理中' : '附件' }}</span>
  97. </button>
  98. </div>
  99. </div></div>
  100. </div>
  101. <div v-if="errorMsg" class="submit-error">{{ errorMsg }}</div>
  102. <div class="bottom-bar" :class="{hidden: hideOwnBar}">
  103. <button type="button" class="btn-close" @click="goBack">关闭</button>
  104. <button type="button" class="btn-submit" :disabled="submitting" @click="submitForm">
  105. {{ submitting ? "提交中..." : "保存并提交" }}
  106. </button>
  107. </div>
  108. <div v-if="attachmentVisible" class="attachment-modal">
  109. <div class="attachment-modal-head">
  110. <span>附件管理</span>
  111. <button class="attachment-close" type="button" @click="attachmentVisible=false">关闭</button>
  112. </div>
  113. <iframe class="attachment-frame" :src="attachmentUrl"></iframe>
  114. </div>
  115. </div>
  116. <script>
  117. (function hideShellBottomBarEarly() {
  118. try {
  119. const embedded = new URLSearchParams(location.search).get("embed") === "1";
  120. if (embedded && window.parent &&
  121. typeof window.parent.__mpObjInpSetBottomVisible === "function")
  122. window.parent.__mpObjInpSetBottomVisible(false);
  123. } catch (_) {}
  124. })();
  125. window.SS.ready(function () {
  126. window.SS.dom.initializeFormApp({
  127. el: "#app",
  128. data() {
  129. return {
  130. pageParams: {},
  131. form: {ttid:"", mc:"", ttlbm:"", fzryid:"", fzbmid:"", ksrq:"", jsrq:"", xndm:"", ms:"", fjid:""},
  132. submitting: false,
  133. errorMsg: "",
  134. hideOwnBar: false,
  135. attachmentVisible: false,
  136. attachmentLoading: false,
  137. attachmentUrl: ""
  138. };
  139. },
  140. mounted() {
  141. this.pageParams = this.getUrlParams();
  142. const param = this.parseParamObject(this.pageParams.param);
  143. const ttid = String(param.ttid || param.ssObjId ||
  144. this.pageParams.ttid || this.pageParams.ssObjId || "").trim();
  145. this.form.ttid = Number(ttid) > 0 ? ttid : "";
  146. ["mc","ttlbm","fzryid","fzbmid","ksrq","jsrq","xndm","ms","fjid"].forEach(key => {
  147. const value = param[key] !== undefined ? param[key] : this.pageParams[key];
  148. if (value !== undefined && value !== null) this.form[key] = String(value);
  149. });
  150. window.__mpObjInpGetFormData = async () => {
  151. const message = this.validateForm();
  152. return {valid: !message, message: message || "", data: this.buildPayload()};
  153. };
  154. },
  155. beforeUnmount() {
  156. try { delete window.__mpObjInpGetFormData; } catch (_) {}
  157. },
  158. methods: {
  159. getUrlParams() {
  160. const params = {};
  161. new URLSearchParams(location.search).forEach((value, key) => {
  162. try { params[key] = decodeURIComponent(value); }
  163. catch (_) { params[key] = value; }
  164. });
  165. return params;
  166. },
  167. parseParamObject(raw) {
  168. if (!raw) return {};
  169. if (typeof raw === "object") return raw;
  170. try { return JSON.parse(raw); } catch (_) {
  171. try {
  172. return JSON.parse(String(raw)
  173. .replace(/([{,]\s*)([A-Za-z0-9_]+)\s*:/g, '$1"$2":')
  174. .replace(/'/g, '"'));
  175. } catch (__) { return {}; }
  176. }
  177. },
  178. validateForm() {
  179. if (!this.form.mc.trim()) return "请输入团体名称";
  180. if (!this.form.ttlbm) return "请选择团体类别";
  181. if (!this.form.fzryid) return "请选择负责人员";
  182. if (this.form.ksrq && this.form.jsrq && this.form.jsrq < this.form.ksrq)
  183. return "结束日期不能早于生效日期";
  184. return "";
  185. },
  186. buildPayload() {
  187. const cleanDate = value => String(value || "").slice(0, 10);
  188. return {
  189. ssObjName: "xsh",
  190. ttid: this.form.ttid,
  191. mc: this.form.mc.trim(),
  192. ttlbm: this.form.ttlbm,
  193. fzryid: this.form.fzryid,
  194. fzbmid: this.form.fzbmid,
  195. ksrq: cleanDate(this.form.ksrq),
  196. jsrq: cleanDate(this.form.jsrq),
  197. xndm: this.form.xndm.trim(),
  198. ms: this.form.ms.trim(),
  199. fjid: this.form.fjid
  200. };
  201. },
  202. async submitForm() {
  203. if (this.submitting) return;
  204. this.errorMsg = this.validateForm();
  205. if (this.errorMsg) return;
  206. this.submitting = true;
  207. try {
  208. const service = this.form.ttid ? "xsh_upd" : "xsh_save";
  209. const response = await window.request.post(
  210. `/service?ssServ=${service}&ssDest=info&wdConfirmationCaptchaService=0`,
  211. this.buildPayload(), {loading: true, formData: true});
  212. const raw = response && response.data !== undefined ? response.data : response;
  213. if (raw && raw.ssCode !== undefined && Number(raw.ssCode) !== 0)
  214. throw new Error(raw.ssMsg || "保存失败");
  215. if (typeof showToastEffect === "function")
  216. showToastEffect("提交成功", 1400, "success");
  217. setTimeout(() => this.goBack(), 800);
  218. } catch (error) {
  219. this.errorMsg = error.message || "提交失败,请稍后重试";
  220. } finally {
  221. this.submitting = false;
  222. }
  223. },
  224. async openAttachment() {
  225. if (this.attachmentLoading) return;
  226. this.attachmentLoading = true;
  227. try {
  228. if (!this.form.fjid) {
  229. const response = await window.request.post(
  230. "/service?ssServ=makeAttCms&wdConfirmationCaptchaService=0",
  231. {name:"fjid", ssNrObjName:"sh", ssNrObjId:""},
  232. {loading:false, formData:true});
  233. const raw = response && response.data !== undefined ? response.data : response;
  234. const candidate = raw && typeof raw === "object"
  235. ? (raw.data ?? raw.ssData ?? raw.result) : raw;
  236. const fjid = String(candidate == null ? "" : candidate).trim();
  237. if (!/^\d+$/.test(fjid)) throw new Error("附件初始化失败");
  238. this.form.fjid = fjid;
  239. }
  240. const fjid = encodeURIComponent(this.form.fjid);
  241. this.attachmentUrl =
  242. "/service?ssServ=regCms&ssDest=cmsEdit&wdConfirmationCaptchaService=0"
  243. + "&nrid=T-" + fjid + "&objectId=" + fjid
  244. + "&objectName=fjid&mode=edit&callback=";
  245. this.attachmentVisible = true;
  246. } catch (error) {
  247. if (typeof showToastEffect === "function")
  248. showToastEffect(error.message || "附件初始化失败", 2200, "error");
  249. } finally {
  250. this.attachmentLoading = false;
  251. }
  252. },
  253. goBack() {
  254. const host = window.parent !== window ? window.parent : window;
  255. try {
  256. if (host.NavigationManager &&
  257. typeof host.NavigationManager.goBack === "function") {
  258. host.NavigationManager.goBack({refreshParent: true});
  259. return;
  260. }
  261. } catch (_) {}
  262. history.back();
  263. }
  264. }
  265. });
  266. });
  267. </script>
  268. </body>
  269. </html>