mp_sqljc_inp.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <!-- 2026-09-24 升旗礼检查小程序专用页面。样式与 mp_ssnwjc_inp.html 保持一致。 -->
  5. <meta charset="UTF-8"/>
  6. <meta name="viewport"
  7. content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  8. <title>升旗礼检查</title>
  9. <script src="/js/mp_base/base.js?v=20261117-select-font-v4"></script>
  10. <style>
  11. [v-cloak] {
  12. display: none !important;
  13. }
  14. :root {
  15. --line: #e5e7eb;
  16. --text: #222222;
  17. --muted: #8b95a5;
  18. --soft: #f7f8fa;
  19. --green: #19a463;
  20. --green-soft: #eaf8f1;
  21. --danger: #e5484d;
  22. --danger-soft: #fff0f0;
  23. }
  24. * {
  25. box-sizing: border-box;
  26. }
  27. body {
  28. margin: 0;
  29. color: var(--text);
  30. background: #f3f4f6;
  31. font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
  32. "Microsoft YaHei", sans-serif;
  33. }
  34. #app {
  35. min-height: 100vh;
  36. padding-bottom: 86px;
  37. }
  38. .loading-container {
  39. display: flex;
  40. flex-direction: column;
  41. align-items: center;
  42. justify-content: center;
  43. min-height: 65vh;
  44. color: var(--muted);
  45. }
  46. .loading-spinner {
  47. width: 38px;
  48. height: 38px;
  49. margin-bottom: 12px;
  50. border: 4px solid #e6e8ec;
  51. border-top-color: var(--green);
  52. border-radius: 50%;
  53. animation: spin 0.9s linear infinite;
  54. }
  55. @keyframes spin {
  56. to {
  57. transform: rotate(360deg);
  58. }
  59. }
  60. .error-box {
  61. margin: 18px 14px;
  62. padding: 18px;
  63. color: var(--danger);
  64. background: var(--danger-soft);
  65. border: 1px solid #ffd0d0;
  66. border-radius: 6px;
  67. line-height: 1.6;
  68. }
  69. .page-content {
  70. padding: 12px 14px 0;
  71. }
  72. .info-table,
  73. .score-table {
  74. overflow: hidden;
  75. background: #fff;
  76. border: 1px solid var(--line);
  77. border-radius: 6px;
  78. }
  79. .info-row {
  80. display: grid;
  81. grid-template-columns: 92px 1fr;
  82. min-height: 58px;
  83. border-bottom: 1px solid var(--line);
  84. }
  85. .info-row:last-child {
  86. border-bottom: none;
  87. }
  88. .info-label {
  89. display: flex;
  90. align-items: center;
  91. justify-content: flex-end;
  92. padding: 12px 14px;
  93. color: var(--muted);
  94. background: #fbfbfc;
  95. border-right: 1px solid var(--line);
  96. font-size: 15px;
  97. }
  98. .info-value {
  99. display: flex;
  100. align-items: center;
  101. min-width: 0;
  102. padding: 11px 12px;
  103. font-size: 15px;
  104. }
  105. .select-cell {
  106. width: 100%;
  107. min-width: 0;
  108. }
  109. .select-cell > .ss-select-container {
  110. width: 100%;
  111. min-width: 0;
  112. }
  113. .clickable {
  114. justify-content: space-between;
  115. gap: 10px;
  116. cursor: pointer;
  117. }
  118. .clickable-text {
  119. min-width: 0;
  120. overflow: hidden;
  121. text-overflow: ellipsis;
  122. white-space: nowrap;
  123. }
  124. .chevron {
  125. flex: 0 0 auto;
  126. color: #9aa3b2;
  127. font-size: 25px;
  128. line-height: 1;
  129. }
  130. .score-value {
  131. color: var(--green);
  132. font-weight: 700;
  133. font-size: 18px;
  134. }
  135. .veto-value {
  136. display: flex;
  137. align-items: center;
  138. justify-content: space-between;
  139. gap: 12px;
  140. width: 100%;
  141. }
  142. .native-input {
  143. width: 100%;
  144. height: 38px;
  145. padding: 0 10px;
  146. color: var(--text);
  147. background: #fff;
  148. border: 0;
  149. outline: none;
  150. font: inherit;
  151. }
  152. .native-input::placeholder {
  153. color: #b4bbc6;
  154. }
  155. .score-table {
  156. margin-top: 12px;
  157. }
  158. .score-row {
  159. display: grid;
  160. grid-template-columns: minmax(0, 1fr) 132px;
  161. min-height: 68px;
  162. overflow: visible;
  163. border-bottom: 1px solid var(--line);
  164. }
  165. .score-row:last-child {
  166. border-bottom: none;
  167. }
  168. .score-name {
  169. display: flex;
  170. align-items: center;
  171. padding: 10px 12px;
  172. line-height: 1.45;
  173. font-size: 15px;
  174. }
  175. .score-max {
  176. display: flex;
  177. align-items: center;
  178. justify-content: center;
  179. color: var(--muted);
  180. border-left: 1px solid var(--line);
  181. font-size: 16px;
  182. }
  183. .stepper {
  184. display: grid;
  185. grid-template-columns: 48px minmax(0, 1fr) 40px;
  186. align-items: center;
  187. width: auto;
  188. min-width: 0;
  189. margin: 10px 7px;
  190. background: #fff;
  191. border: 1px solid #cfd4dc;
  192. border-radius: 5px;
  193. overflow: hidden;
  194. }
  195. .stepper-btn {
  196. display: inline-flex;
  197. align-items: center;
  198. justify-content: center;
  199. gap: 1px;
  200. height: 44px;
  201. padding: 0;
  202. color: #596273;
  203. background: #f3f4f6;
  204. border: 0;
  205. font-size: 24px;
  206. line-height: 1;
  207. appearance: none;
  208. }
  209. .stepper-btn:disabled {
  210. color: #c8cdd5;
  211. background: #eceff2;
  212. }
  213. .stepper-deduct-num {
  214. font-size: 15px;
  215. font-weight: 400;
  216. line-height: 1;
  217. }
  218. .stepper-btn-symbol {
  219. line-height: 1;
  220. }
  221. .stepper-value {
  222. width: 100%;
  223. min-width: 0;
  224. height: 44px;
  225. padding: 0 4px;
  226. text-align: center;
  227. background: #fff;
  228. border: 0;
  229. border-left: 1px solid #e1e4e9;
  230. border-right: 1px solid #e1e4e9;
  231. outline: none;
  232. font: inherit;
  233. font-size: 15px;
  234. font-weight: 400;
  235. }
  236. .score-total {
  237. display: flex;
  238. align-items: center;
  239. justify-content: space-between;
  240. padding: 14px 4px 0;
  241. color: var(--muted);
  242. font-size: 14px;
  243. }
  244. .score-total strong {
  245. color: var(--green);
  246. font-size: 18px;
  247. }
  248. .empty-tip {
  249. padding: 16px 12px;
  250. color: var(--muted);
  251. text-align: center;
  252. font-size: 14px;
  253. }
  254. .sheet {
  255. max-height: 72vh;
  256. padding: 18px 16px 24px;
  257. background: #fff;
  258. }
  259. .sheet-mask {
  260. position: fixed;
  261. z-index: 9999;
  262. top: 0;
  263. right: 0;
  264. bottom: 0;
  265. left: 0;
  266. display: flex;
  267. align-items: flex-end;
  268. background: rgba(0, 0, 0, 0.35);
  269. }
  270. .sheet-mask .sheet {
  271. width: 100%;
  272. border-radius: 8px 8px 0 0;
  273. }
  274. .sheet-title {
  275. margin: 0 0 14px;
  276. font-size: 17px;
  277. font-weight: 700;
  278. }
  279. .sheet-list {
  280. overflow-y: auto;
  281. max-height: 58vh;
  282. }
  283. .sheet-item {
  284. padding: 13px 0;
  285. border-bottom: 1px solid #eef0f3;
  286. }
  287. .sheet-item:last-child {
  288. border-bottom: none;
  289. }
  290. .sheet-main {
  291. font-size: 15px;
  292. font-weight: 600;
  293. }
  294. .sheet-sub {
  295. margin-top: 4px;
  296. color: var(--muted);
  297. font-size: 13px;
  298. }
  299. .class-option {
  300. display: flex;
  301. align-items: center;
  302. justify-content: space-between;
  303. cursor: pointer;
  304. }
  305. .class-option.selected {
  306. color: var(--green);
  307. }
  308. .warning-bar {
  309. margin: 12px 14px 0;
  310. padding: 11px 12px;
  311. color: #9a6700;
  312. background: #fff8e6;
  313. border: 1px solid #ffe8a3;
  314. border-radius: 6px;
  315. line-height: 1.5;
  316. font-size: 14px;
  317. }
  318. .submit-hint {
  319. margin: 12px 14px 0;
  320. padding: 11px 12px;
  321. color: var(--danger);
  322. background: var(--danger-soft);
  323. border: 1px solid #ffd0d0;
  324. border-radius: 6px;
  325. line-height: 1.5;
  326. font-size: 14px;
  327. }
  328. .bottom-spacer {
  329. height: 16px;
  330. }
  331. </style>
  332. </head>
  333. <body>
  334. <div id="app" v-cloak>
  335. <div v-if="loading" class="loading-container">
  336. <div class="loading-spinner"></div>
  337. <div>加载中...</div>
  338. </div>
  339. <div v-else-if="errorMsg" class="error-box">
  340. {{ errorMsg }}
  341. </div>
  342. <template v-else>
  343. <div v-if="warnMsg" class="warning-bar">{{ warnMsg }}</div>
  344. <div v-if="submitHint" class="submit-hint">{{ submitHint }}</div>
  345. <div class="page-content">
  346. <div class="info-table">
  347. <div class="info-row">
  348. <div class="info-label">部门</div>
  349. <div class="info-value">{{ bmmc || '—' }}</div>
  350. </div>
  351. <div class="info-row">
  352. <div class="info-label">检查人</div>
  353. <div class="info-value">{{ jcryxm || '—' }}</div>
  354. </div>
  355. <div class="info-row">
  356. <div class="info-label">检查时间</div>
  357. <div class="info-value">{{ todayText }}</div>
  358. </div>
  359. <div class="info-row">
  360. <div class="info-label">入学年度</div>
  361. <div class="info-value">
  362. <div class="select-cell">
  363. <ss-select
  364. v-model="form.rxnd"
  365. cb="rxnd"
  366. placeholder="入学年度"
  367. @change="onRxndChange"
  368. />
  369. </div>
  370. </div>
  371. </div>
  372. <div class="info-row">
  373. <div class="info-label">班级</div>
  374. <div class="info-value">
  375. <div class="select-cell">
  376. <ss-select
  377. :key="'bj-' + form.rxnd"
  378. v-model="form.bjid"
  379. :cb="form.rxnd ? 'bjByRxnd' : ''"
  380. :url="bjUrl"
  381. :filter="{cascadingLevel: 'rxnd,bjid'}"
  382. :disabled="!form.rxnd"
  383. :placeholder="form.rxnd ? '班级' : '请先选择入学年度'"
  384. @change="onBjChange"
  385. />
  386. </div>
  387. </div>
  388. </div>
  389. <div class="info-row">
  390. <div class="info-label">说明</div>
  391. <div class="info-value">
  392. <input
  393. v-model="form.ms"
  394. class="native-input"
  395. maxlength="500"
  396. placeholder="请输入"
  397. />
  398. </div>
  399. </div>
  400. </div>
  401. <div class="score-table">
  402. <div v-if="!jcxmList.length" class="empty-tip">暂无检查项目</div>
  403. <div v-for="item in jcxmList" :key="item.sqljcxmm" class="score-row">
  404. <div class="score-name">
  405. {{ item.mc }}<span v-if="isScoreItem(item)"> ({{ item.mfz }})</span>
  406. </div>
  407. <div class="stepper">
  408. <button
  409. class="stepper-btn"
  410. type="button"
  411. :disabled="Number(item.value) <= 0"
  412. @click="changeStep(item, -1)"
  413. >
  414. <span class="stepper-btn-symbol">-</span><span
  415. v-if="deductedFs(item) > 0"
  416. class="stepper-deduct-num">{{ deductedFs(item) }}</span>
  417. </button>
  418. <input
  419. class="stepper-value"
  420. inputmode="numeric"
  421. :value="item.value"
  422. :min="0"
  423. :max="isScoreItem(item) ? item.mfz : null"
  424. @input="onStepInput(item, $event)"
  425. @blur="normalizeStep(item, $event)"
  426. />
  427. <button
  428. class="stepper-btn"
  429. type="button"
  430. :disabled="isScoreItem(item) && Number(item.value) >= Number(item.mfz)"
  431. @click="changeStep(item, 1)"
  432. >
  433. +
  434. </button>
  435. </div>
  436. </div>
  437. </div>
  438. <div class="score-total">
  439. <span>总分数(打分项合计)</span>
  440. <strong>{{ totalFs }}<span v-if="maxFs"> / {{ maxFs }}</span></strong>
  441. </div>
  442. <div class="bottom-spacer"></div>
  443. </div>
  444. <ss-bottom
  445. :show-shyj="false"
  446. :buttons="submitting ? [{ text: '提交中...', action: 'submit' }] : bottomButtons"
  447. @button-click="handleBottomAction"
  448. :disabled="submitting"
  449. />
  450. </template>
  451. </div>
  452. <script>
  453. window.SS.ready(function () {
  454. window.SS.dom.initializeFormApp({
  455. el: "#app",
  456. data() {
  457. return {
  458. loading: true,
  459. submitting: false,
  460. fromList: false,
  461. errorMsg: "",
  462. warnMsg: "",
  463. submitHint: "",
  464. recordsToday: 0,
  465. bmmc: "",
  466. jcryxm: "",
  467. todayText: "",
  468. jcxmList: [],
  469. form: {
  470. rxnd: "",
  471. bjid: "",
  472. ms: ""
  473. },
  474. bottomButtons: [
  475. { text: "取消", action: "cancel" },
  476. { text: "保存并提交", action: "submit" }
  477. ]
  478. };
  479. },
  480. computed: {
  481. /**
  482. * 2026-09-29 修复「选完入学年度班级不出来」。
  483. *
  484. * 原因:码本 bjByRxnd 的 SQL 是
  485. * select BJID,MC from BJ where BJZTM!=81 and trunc(RXND,'YYYY')=trunc(:rxnd,'YYYY')
  486. * <parm name="rxnd" type="date"/>
  487. * 而平台 loadObjpOpt 在【非级联】方式下会把 objectpickerparam 里的筛选值按字符串
  488. * 绑到 SQL 参数上(ss.objp.ObjpServ.loadOptByA → ss.db.Db.doSelMapByC),
  489. * 字符串绑到 DATE 参数上 → Oracle 报
  490. * ORA-00932: expression (TRUNC(TO_NUMBER(:1),TO_NUMBER('YYYY'))) is of type NUMBER,
  491. * incompatible with expected type DATE
  492. * → 码本查询失败 → loadObjpOpt 返回「*** 页面执行时错误 ***」→ 班级下拉为空。
  493. * 入学年度能用,是因为它的码本 rxnd 是"服务型码本"(DwServ.rxnd),不走 SQL 参数绑定。
  494. *
  495. * 解法:改用平台的【级联】方式取班级 —— 带上 cascadingLevel,
  496. * 并把上级值通过 URL 的 upperValue 传给后端(PC 的 入学年度>班级 就是这么走的,
  497. * 后端在级联分支里会按参数声明的类型正确绑定日期)。只改前端,不动平台与码本。
  498. */
  499. bjUrl() {
  500. const base = "/service?ssServ=loadObjpOpt&objectpickerdropdown1=1";
  501. const y = String(this.form.rxnd || "").trim();
  502. return y ? base + "&upperValue=" + encodeURIComponent(y) : base;
  503. },
  504. totalFs() {
  505. return this.jcxmList.reduce(
  506. (sum, item) => sum + (this.isScoreItem(item) ? Number(item.value || 0) : 0), 0);
  507. },
  508. maxFs() {
  509. return this.jcxmList.reduce(
  510. (sum, item) => sum + (this.isScoreItem(item) ? Number(item.mfz || 0) : 0), 0);
  511. }
  512. },
  513. async mounted() {
  514. this.todayText = this.formatNow();
  515. // 从列表页「新增」进来时带 ?from=list:提交后直接回列表。Lin
  516. try {
  517. const params = new URLSearchParams(window.location.search);
  518. this.fromList = String(params.get("from") || "") === "list";
  519. } catch (_) {
  520. this.fromList = false;
  521. }
  522. try {
  523. const sessionOk = await this.ensureSession();
  524. if (!sessionOk)
  525. return;
  526. await this.loadInit();
  527. } catch (error) {
  528. console.error("[mp_sqljc_inp] 初始化失败", error);
  529. this.errorMsg = error && error.message ? error.message : "页面初始化失败";
  530. } finally {
  531. this.loading = false;
  532. }
  533. },
  534. methods: {
  535. getUrlParams() {
  536. const params = {};
  537. const search = new URLSearchParams(window.location.search);
  538. for (const [key, value] of search) {
  539. params[key] = decodeURIComponent(value);
  540. }
  541. return params;
  542. },
  543. getRequest() {
  544. return (window && window.request) || request;
  545. },
  546. // 小程序切换账号后,旧 H5 会话会写到别人名下,必须先刷新会话。Lin
  547. async ensureSession() {
  548. if (typeof window.ensureMiniProgramSessionFresh !== "function")
  549. return true;
  550. try {
  551. await window.ensureMiniProgramSessionFresh({
  552. page: "mp_sqljc_inp",
  553. service: "sqljc_mpInit",
  554. force: true
  555. });
  556. return true;
  557. } catch (error) {
  558. this.errorMsg = "登录状态刷新失败,请返回小程序重新进入";
  559. return false;
  560. }
  561. },
  562. async loadInit() {
  563. const data = await this.postService(
  564. "/service?ssServ=sqljc_mpInit&ssDest=data", {});
  565. this.bmmc = (data && data.bmmc) || "";
  566. this.jcryxm = (data && data.jcryxm) || "";
  567. this.jcxmList = ((data && data.jcxmList) || []).map((item) => {
  568. const mfz = item.mfz === null || item.mfz === undefined || item.mfz === ""
  569. ? null : Number(item.mfz);
  570. return {
  571. sqljcxmm: Number(item.sqljcxmm),
  572. mc: item.mc,
  573. mfz: mfz,
  574. defaultValue: item.defaultValue === null
  575. || item.defaultValue === undefined
  576. ? (mfz === null ? 0 : mfz)
  577. : Number(item.defaultValue),
  578. value: item.defaultValue === null
  579. || item.defaultValue === undefined
  580. ? (mfz === null ? 0 : mfz)
  581. : Number(item.defaultValue)
  582. };
  583. });
  584. },
  585. isScoreItem(item) {
  586. return item.mfz !== null && item.mfz !== undefined;
  587. },
  588. async postService(url, data) {
  589. const req = this.getRequest();
  590. if (!req || typeof req.post !== "function")
  591. throw new Error("请求组件未加载");
  592. const response = await req.post(url, data, {
  593. loading: false,
  594. formData: true
  595. });
  596. const raw = response && response.data !== undefined ? response.data : response;
  597. if (raw && raw.ssCode !== undefined && Number(raw.ssCode) !== 0)
  598. throw new Error(raw.ssMsg || "请求失败");
  599. return raw && raw.ssData !== undefined ? raw.ssData : raw;
  600. },
  601. onRxndChange(value) {
  602. this.form.rxnd = value || "";
  603. this.form.bjid = ""; // 换入学年度后清空班级,避免串档。Lin
  604. },
  605. onBjChange(value) {
  606. this.form.bjid = value || "";
  607. },
  608. // 打分项显示累计扣分;人数项没有满分,不显示扣分。Lin
  609. deductedFs(item) {
  610. if (!this.isScoreItem(item))
  611. return 0;
  612. const mfz = Number(item.mfz || 0);
  613. return Math.max(0, mfz - Number(item.value || 0));
  614. },
  615. // 所有数字项左右都可加减:打分项限 0..MFZ,人数项只限 >= 0。Lin
  616. changeStep(item, step) {
  617. let value = Number(item.value || 0) + step;
  618. if (value < 0)
  619. value = 0;
  620. if (this.isScoreItem(item) && value > Number(item.mfz || 0))
  621. value = Number(item.mfz || 0);
  622. item.value = value;
  623. },
  624. onStepInput(item, event) {
  625. const raw = String(event.target.value || "").replace(/[^0-9]/g, "");
  626. item.value = raw === "" ? "" : Number(raw);
  627. },
  628. normalizeStep(item, event) {
  629. let value = Number(String(event.target.value || "").replace(/[^0-9]/g, ""));
  630. if (!Number.isFinite(value) || value < 0)
  631. value = 0;
  632. if (this.isScoreItem(item) && value > Number(item.mfz || 0))
  633. value = Number(item.mfz || 0);
  634. item.value = value;
  635. },
  636. validateForm() {
  637. if (!this.form.rxnd)
  638. return "请选择入学年度";
  639. if (!this.form.bjid)
  640. return "请选择班级";
  641. if (!this.jcxmList.length)
  642. return "检查项目未配置";
  643. for (const item of this.jcxmList) {
  644. const value = Number(item.value || 0);
  645. if (value < 0)
  646. return item.mc + " 不能为负数";
  647. if (this.isScoreItem(item) && value > Number(item.mfz || 0))
  648. return item.mc + " 分值超出满分";
  649. }
  650. return "";
  651. },
  652. async submit() {
  653. if (this.submitting)
  654. return;
  655. const message = this.validateForm();
  656. if (message) {
  657. this.submitHint = message;
  658. this.warnMsg = "";
  659. this.showToast(message, "fail");
  660. return;
  661. }
  662. try {
  663. this.submitting = true;
  664. this.warnMsg = "";
  665. this.submitHint = "";
  666. const payload = {
  667. bjid: this.form.bjid,
  668. ms: this.form.ms
  669. };
  670. this.jcxmList.forEach((item) => {
  671. payload["sqljcxmm" + item.sqljcxmm] =
  672. item.value === "" ? 0 : Number(item.value);
  673. });
  674. const result = await this.postService(
  675. "/service?ssServ=sqljc_mpSubm&ssDest=data", payload);
  676. this.recordsToday = (result && result.recordsToday) || this.recordsToday + 1;
  677. this.markListRefresh();
  678. if (this.fromList) {
  679. // 从列表页进来的:提交完直接回列表(列表会自动刷新),与宿舍内务检查一致。Lin
  680. this.resetAfterSubmit();
  681. this.warnMsg = "";
  682. this.showToast("提交成功", "success");
  683. setTimeout(() => this.goBack(), 900);
  684. return;
  685. }
  686. // 直接入口进来的:保留连续录入(今天已录入 N 条)。Lin
  687. this.resetAfterSubmit();
  688. this.warnMsg = "已提交,可继续录入下一个班级(今天已录入 "
  689. + this.recordsToday + " 条)";
  690. this.showToast("提交成功", "success");
  691. } catch (error) {
  692. console.error("[mp_sqljc_inp] 提交失败", error);
  693. this.submitHint = error && error.message ? error.message : "提交失败";
  694. this.showToast(this.submitHint, "fail");
  695. } finally {
  696. this.submitting = false;
  697. }
  698. },
  699. // 连续录入:保留入学年度,清空班级与说明,评分恢复默认(打分项满分、人数 0)。Lin
  700. resetAfterSubmit() {
  701. this.form.bjid = "";
  702. this.form.ms = "";
  703. this.jcxmList.forEach((item) => {
  704. item.value = Number(item.defaultValue || 0);
  705. });
  706. },
  707. // 通知列表页刷新(回到列表时由 mp_sqljc_list.html 的 pageshow 处理读取)。Lin
  708. markListRefresh() {
  709. try {
  710. sessionStorage.setItem("mp_sqljc_list_refresh", "1");
  711. sessionStorage.setItem("mp_sqljc_list_date", this.formatLocalDate(new Date()));
  712. } catch (_) {
  713. }
  714. },
  715. formatLocalDate(date) {
  716. const d = date instanceof Date ? date : new Date(date);
  717. const pad = (v) => String(v).padStart(2, "0");
  718. return d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate());
  719. },
  720. handleBottomAction(data) {
  721. if (data && data.action === "cancel")
  722. this.goBack();
  723. else if (data && data.action === "submit")
  724. this.submit();
  725. },
  726. goBack() {
  727. if (window.wx && window.wx.miniProgram) {
  728. window.wx.miniProgram.navigateBack({ delta: 1 });
  729. } else if (window.history.length > 1) {
  730. window.history.back();
  731. }
  732. },
  733. formatNow() {
  734. const now = new Date();
  735. const pad = (v) => String(v).padStart(2, "0");
  736. return now.getFullYear() + "-" + pad(now.getMonth() + 1) + "-" + pad(now.getDate())
  737. + " " + pad(now.getHours()) + ":" + pad(now.getMinutes());
  738. },
  739. showToast(message, type) {
  740. const toastType = type === "success" ? "success" : "error";
  741. if (window.wx && window.wx.miniProgram && window.wx.miniProgram.showToast) {
  742. window.wx.miniProgram.showToast({ title: message, icon: toastType });
  743. } else if (window.SS && window.SS.dom && typeof window.SS.dom.showToast === "function") {
  744. window.SS.dom.showToast({ message: message, type: toastType });
  745. }
  746. }
  747. }
  748. });
  749. });
  750. </script>
  751. </body>
  752. </html>