mp_sqljc_inp.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  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. .info-text {
  106. align-items: flex-start;
  107. line-height: 1.55;
  108. overflow-wrap: anywhere;
  109. }
  110. .clickable {
  111. justify-content: space-between;
  112. gap: 10px;
  113. cursor: pointer;
  114. }
  115. .clickable-text {
  116. min-width: 0;
  117. overflow: hidden;
  118. text-overflow: ellipsis;
  119. white-space: nowrap;
  120. }
  121. .chevron {
  122. flex: 0 0 auto;
  123. color: #9aa3b2;
  124. font-size: 25px;
  125. line-height: 1;
  126. }
  127. .score-value {
  128. color: var(--green);
  129. font-weight: 700;
  130. font-size: 18px;
  131. }
  132. .veto-value {
  133. display: flex;
  134. align-items: center;
  135. justify-content: space-between;
  136. gap: 12px;
  137. width: 100%;
  138. }
  139. .native-input {
  140. width: 100%;
  141. height: 38px;
  142. padding: 0 10px;
  143. color: var(--text);
  144. background: #fff;
  145. border: 0;
  146. outline: none;
  147. font: inherit;
  148. }
  149. .native-input::placeholder {
  150. color: #b4bbc6;
  151. }
  152. .score-table {
  153. margin-top: 12px;
  154. }
  155. .score-row {
  156. display: grid;
  157. grid-template-columns: minmax(0, 1fr) 132px;
  158. min-height: 68px;
  159. overflow: visible;
  160. border-bottom: 1px solid var(--line);
  161. }
  162. .score-row:last-child {
  163. border-bottom: none;
  164. }
  165. .score-name {
  166. display: flex;
  167. align-items: center;
  168. padding: 10px 12px;
  169. line-height: 1.45;
  170. font-size: 15px;
  171. }
  172. .score-max {
  173. display: flex;
  174. align-items: center;
  175. justify-content: center;
  176. color: var(--muted);
  177. border-left: 1px solid var(--line);
  178. font-size: 16px;
  179. }
  180. .stepper {
  181. display: grid;
  182. grid-template-columns: 48px minmax(0, 1fr) 40px;
  183. align-items: center;
  184. width: auto;
  185. min-width: 0;
  186. margin: 10px 7px;
  187. background: #fff;
  188. border: 1px solid #cfd4dc;
  189. border-radius: 5px;
  190. overflow: hidden;
  191. }
  192. .stepper-btn {
  193. display: inline-flex;
  194. align-items: center;
  195. justify-content: center;
  196. gap: 1px;
  197. height: 44px;
  198. padding: 0;
  199. color: #596273;
  200. background: #f3f4f6;
  201. border: 0;
  202. font-size: 24px;
  203. line-height: 1;
  204. appearance: none;
  205. }
  206. .stepper-btn:disabled {
  207. color: #c8cdd5;
  208. background: #eceff2;
  209. }
  210. .stepper-deduct-num {
  211. font-size: 15px;
  212. font-weight: 400;
  213. line-height: 1;
  214. }
  215. .stepper-btn-symbol {
  216. line-height: 1;
  217. }
  218. .stepper-value {
  219. width: 100%;
  220. min-width: 0;
  221. height: 44px;
  222. padding: 0 4px;
  223. text-align: center;
  224. background: #fff;
  225. border: 0;
  226. border-left: 1px solid #e1e4e9;
  227. border-right: 1px solid #e1e4e9;
  228. outline: none;
  229. font: inherit;
  230. font-size: 15px;
  231. font-weight: 400;
  232. }
  233. .score-total {
  234. display: flex;
  235. align-items: center;
  236. justify-content: space-between;
  237. padding: 14px 4px 0;
  238. color: var(--muted);
  239. font-size: 14px;
  240. }
  241. .score-total strong {
  242. color: var(--green);
  243. font-size: 18px;
  244. }
  245. .formula-note {
  246. padding: 4px 4px 0;
  247. color: var(--muted);
  248. text-align: right;
  249. font-size: 13px;
  250. }
  251. .empty-tip {
  252. padding: 16px 12px;
  253. color: var(--muted);
  254. text-align: center;
  255. font-size: 14px;
  256. }
  257. .warning-bar {
  258. margin: 12px 14px 0;
  259. padding: 11px 12px;
  260. color: #9a6700;
  261. background: #fff8e6;
  262. border: 1px solid #ffe8a3;
  263. border-radius: 6px;
  264. line-height: 1.5;
  265. font-size: 14px;
  266. }
  267. .submit-hint {
  268. margin: 12px 14px 0;
  269. padding: 11px 12px;
  270. color: var(--danger);
  271. background: var(--danger-soft);
  272. border: 1px solid #ffd0d0;
  273. border-radius: 6px;
  274. line-height: 1.5;
  275. font-size: 14px;
  276. }
  277. .bottom-spacer {
  278. height: 16px;
  279. }
  280. </style>
  281. </head>
  282. <body>
  283. <div id="app" v-cloak>
  284. <div v-if="loading" class="loading-container">
  285. <div class="loading-spinner"></div>
  286. <div>加载中...</div>
  287. </div>
  288. <div v-else-if="errorMsg" class="error-box">
  289. {{ errorMsg }}
  290. </div>
  291. <template v-else>
  292. <div v-if="warnMsg" class="warning-bar">{{ warnMsg }}</div>
  293. <div v-if="submitHint" class="submit-hint">{{ submitHint }}</div>
  294. <div class="page-content">
  295. <div class="info-table">
  296. <div class="info-row">
  297. <div class="info-label">部门</div>
  298. <div class="info-value">{{ bmmc || '—' }}</div>
  299. </div>
  300. <div class="info-row">
  301. <div class="info-label">检查人</div>
  302. <div class="info-value">{{ jcryxm || '—' }}</div>
  303. </div>
  304. <div class="info-row">
  305. <div class="info-label">检查日期</div>
  306. <div class="info-value">{{ inspectionDate }}</div>
  307. </div>
  308. <div class="info-row">
  309. <div class="info-label">学员总人数</div>
  310. <div class="info-value">{{ totalStudents }}</div>
  311. </div>
  312. <div class="info-row">
  313. <div class="info-label">有效应到人数</div>
  314. <div class="info-value">{{ expectedStudents }}</div>
  315. </div>
  316. <div class="info-row">
  317. <div class="info-label">同步班级</div>
  318. <div class="info-value info-text">
  319. {{ classNamesText || '当前部门暂无有效班级' }}
  320. </div>
  321. </div>
  322. <div class="info-row">
  323. <div class="info-label">说明</div>
  324. <div class="info-value">
  325. <input
  326. v-model="form.ms"
  327. class="native-input"
  328. maxlength="500"
  329. placeholder="请输入"
  330. />
  331. </div>
  332. </div>
  333. </div>
  334. <div class="score-table">
  335. <div v-if="!jcxmList.length" class="empty-tip">暂无检查项目</div>
  336. <div v-for="item in jcxmList" :key="item.sqljcxmm" class="score-row">
  337. <div class="score-name">
  338. {{ item.mc }}<span v-if="isScoreItem(item)"> ({{ item.mfz }})</span>
  339. </div>
  340. <div class="stepper">
  341. <button
  342. class="stepper-btn"
  343. type="button"
  344. :disabled="Number(item.value) <= 0"
  345. @click="changeStep(item, -1)"
  346. >
  347. <span class="stepper-btn-symbol">-</span><span
  348. v-if="deductedFs(item) > 0"
  349. class="stepper-deduct-num">{{ deductedFs(item) }}</span>
  350. </button>
  351. <input
  352. class="stepper-value"
  353. inputmode="numeric"
  354. :value="item.value"
  355. :min="0"
  356. :max="isScoreItem(item) ? item.mfz : null"
  357. @input="onStepInput(item, $event)"
  358. @blur="normalizeStep(item, $event)"
  359. />
  360. <button
  361. class="stepper-btn"
  362. type="button"
  363. :disabled="isScoreItem(item) && Number(item.value) >= Number(item.mfz)"
  364. @click="changeStep(item, 1)"
  365. >
  366. +
  367. </button>
  368. </div>
  369. </div>
  370. </div>
  371. <div class="score-total">
  372. <span>升旗礼总分</span>
  373. <strong>{{ totalFs }}</strong>
  374. </div>
  375. <div class="formula-note">{{ formulaNote }}</div>
  376. <div class="bottom-spacer"></div>
  377. </div>
  378. <ss-bottom
  379. :show-shyj="false"
  380. :buttons="submitting ? [{ text: '提交中...', action: 'submit' }] : bottomButtons"
  381. @button-click="handleBottomAction"
  382. :disabled="submitting"
  383. />
  384. </template>
  385. </div>
  386. <script>
  387. window.SS.ready(function () {
  388. window.SS.dom.initializeFormApp({
  389. el: "#app",
  390. data() {
  391. return {
  392. loading: true,
  393. submitting: false,
  394. fromList: false,
  395. errorMsg: "",
  396. warnMsg: "",
  397. submitHint: "",
  398. bmmc: "",
  399. jcryxm: "",
  400. inspectionDate: "",
  401. totalStudents: 0,
  402. leaveStudents: 0,
  403. classCount: 0,
  404. classes: [],
  405. formulaNote: "出勤率×25% + 队列分×20% + 风貌分×40% + 纪律分×15%",
  406. jcxmList: [],
  407. form: {
  408. ms: ""
  409. },
  410. bottomButtons: [
  411. { text: "取消", action: "cancel" },
  412. { text: "保存并提交", action: "submit" }
  413. ]
  414. };
  415. },
  416. computed: {
  417. expectedStudents() {
  418. const countCodes = [3, 4, 5, 6, 7, 8];
  419. const exempt = countCodes.reduce(
  420. (sum, code) => sum + this.valueOfCode(code), 0);
  421. return Math.max(0, this.valueOfCode(1) - exempt);
  422. },
  423. attendanceRate() {
  424. if (this.expectedStudents <= 0)
  425. return 0;
  426. return Math.min(100, this.round2(
  427. this.valueOfCode(2) * 100 / this.expectedStudents));
  428. },
  429. totalFs() {
  430. const queueScore = this.valueOfCode(11);
  431. const demeanorScore = this.valueOfCode(21) + this.valueOfCode(22);
  432. const disciplineScore = this.valueOfCode(31);
  433. return this.round2(
  434. this.attendanceRate * 0.25
  435. + queueScore * 0.20
  436. + demeanorScore * 0.40
  437. + disciplineScore * 0.15);
  438. },
  439. classNamesText() {
  440. return this.classes.map((item) => item.bjmc).filter(Boolean).join("、");
  441. }
  442. },
  443. async mounted() {
  444. this.inspectionDate = this.formatLocalDate(new Date());
  445. // 从列表页「新增」进来时带 ?from=list:提交后直接回列表。Lin
  446. try {
  447. const params = new URLSearchParams(window.location.search);
  448. this.fromList = String(params.get("from") || "") === "list";
  449. } catch (_) {
  450. this.fromList = false;
  451. }
  452. try {
  453. const sessionOk = await this.ensureSession();
  454. if (!sessionOk)
  455. return;
  456. await this.loadInit();
  457. } catch (error) {
  458. console.error("[mp_sqljc_inp] 初始化失败", error);
  459. this.errorMsg = error && error.message ? error.message : "页面初始化失败";
  460. } finally {
  461. this.loading = false;
  462. }
  463. },
  464. methods: {
  465. getUrlParams() {
  466. const params = {};
  467. const search = new URLSearchParams(window.location.search);
  468. for (const [key, value] of search) {
  469. params[key] = decodeURIComponent(value);
  470. }
  471. return params;
  472. },
  473. getRequest() {
  474. return (window && window.request) || request;
  475. },
  476. // 小程序切换账号后,旧 H5 会话会写到别人名下,必须先刷新会话。Lin
  477. async ensureSession() {
  478. if (typeof window.ensureMiniProgramSessionFresh !== "function")
  479. return true;
  480. try {
  481. await window.ensureMiniProgramSessionFresh({
  482. page: "mp_sqljc_inp",
  483. service: "sqljc_mpInit",
  484. force: true
  485. });
  486. return true;
  487. } catch (error) {
  488. this.errorMsg = "登录状态刷新失败,请返回小程序重新进入";
  489. return false;
  490. }
  491. },
  492. async loadInit() {
  493. const data = await this.postService(
  494. "/service?ssServ=sqljc_mpInit&ssDest=data",
  495. { jcsjDate: this.inspectionDate });
  496. this.bmmc = (data && data.bmmc) || "";
  497. this.jcryxm = (data && data.jcryxm) || "";
  498. this.inspectionDate = (data && data.jcsjDate) || this.inspectionDate;
  499. this.totalStudents = Number(data && data.totalStudents || 0);
  500. this.leaveStudents = Number(data && data.leaveStudents || 0);
  501. this.classCount = Number(data && data.classCount || 0);
  502. this.classes = (data && data.classes) || [];
  503. this.formulaNote = (data && data.formulaNote) || this.formulaNote;
  504. this.jcxmList = ((data && data.jcxmList) || []).map((item) => {
  505. const mfz = item.mfz === null || item.mfz === undefined || item.mfz === ""
  506. ? null : Number(item.mfz);
  507. return {
  508. sqljcxmm: Number(item.sqljcxmm),
  509. mc: item.mc,
  510. mfz: mfz,
  511. defaultValue: item.defaultValue === null
  512. || item.defaultValue === undefined
  513. ? (mfz === null ? 0 : mfz)
  514. : Number(item.defaultValue),
  515. value: item.defaultValue === null
  516. || item.defaultValue === undefined
  517. ? (mfz === null ? 0 : mfz)
  518. : Number(item.defaultValue)
  519. };
  520. });
  521. },
  522. valueOfCode(code) {
  523. const item = this.jcxmList.find(
  524. (row) => Number(row.sqljcxmm) === Number(code));
  525. return item ? Number(item.value || 0) : 0;
  526. },
  527. round2(value) {
  528. const number = Number(value || 0);
  529. return Math.round(number * 100) / 100;
  530. },
  531. isScoreItem(item) {
  532. return item.mfz !== null && item.mfz !== undefined;
  533. },
  534. async postService(url, data) {
  535. const req = this.getRequest();
  536. if (!req || typeof req.post !== "function")
  537. throw new Error("请求组件未加载");
  538. const response = await req.post(url, data, {
  539. loading: false,
  540. formData: true
  541. });
  542. const raw = response && response.data !== undefined ? response.data : response;
  543. if (raw && raw.ssCode !== undefined && Number(raw.ssCode) !== 0)
  544. throw new Error(raw.ssMsg || "请求失败");
  545. return raw && raw.ssData !== undefined ? raw.ssData : raw;
  546. },
  547. // 打分项显示累计扣分;人数项没有满分,不显示扣分。Lin
  548. deductedFs(item) {
  549. if (!this.isScoreItem(item))
  550. return 0;
  551. const mfz = Number(item.mfz || 0);
  552. return Math.max(0, mfz - Number(item.value || 0));
  553. },
  554. // 所有数字项左右都可加减:打分项限 0..MFZ,人数项只限 >= 0。Lin
  555. changeStep(item, step) {
  556. let value = Number(item.value || 0) + step;
  557. if (value < 0)
  558. value = 0;
  559. if (this.isScoreItem(item) && value > Number(item.mfz || 0))
  560. value = Number(item.mfz || 0);
  561. item.value = value;
  562. },
  563. onStepInput(item, event) {
  564. const raw = String(event.target.value || "").replace(/[^0-9]/g, "");
  565. item.value = raw === "" ? "" : Number(raw);
  566. },
  567. normalizeStep(item, event) {
  568. let value = Number(String(event.target.value || "").replace(/[^0-9]/g, ""));
  569. if (!Number.isFinite(value) || value < 0)
  570. value = 0;
  571. if (this.isScoreItem(item) && value > Number(item.mfz || 0))
  572. value = Number(item.mfz || 0);
  573. item.value = value;
  574. },
  575. validateForm() {
  576. if (!this.classCount)
  577. return "当前部门没有有效班级";
  578. if (!this.jcxmList.length)
  579. return "检查项目未配置";
  580. if (this.valueOfCode(1) <= 0)
  581. return "学员总人数必须大于0";
  582. if (this.expectedStudents <= 0)
  583. return "有效应到人数必须大于0";
  584. if (this.valueOfCode(2) > this.expectedStudents)
  585. return "队列人数不能大于有效应到人数";
  586. for (const item of this.jcxmList) {
  587. const value = Number(item.value || 0);
  588. if (value < 0)
  589. return item.mc + " 不能为负数";
  590. if (this.isScoreItem(item) && value > Number(item.mfz || 0))
  591. return item.mc + " 分值超出满分";
  592. }
  593. return "";
  594. },
  595. async submit() {
  596. if (this.submitting)
  597. return;
  598. const message = this.validateForm();
  599. if (message) {
  600. this.submitHint = message;
  601. this.warnMsg = "";
  602. this.showToast(message, "fail");
  603. return;
  604. }
  605. try {
  606. this.submitting = true;
  607. this.warnMsg = "";
  608. this.submitHint = "";
  609. const payload = {
  610. jcsjDate: this.inspectionDate,
  611. ms: this.form.ms
  612. };
  613. this.jcxmList.forEach((item) => {
  614. payload["sqljcxmm" + item.sqljcxmm] =
  615. item.value === "" ? 0 : Number(item.value);
  616. });
  617. const result = await this.postService(
  618. "/service?ssServ=sqljc_mpSubm&ssDest=data", payload);
  619. this.markListRefresh();
  620. const savedCount = Number(result && result.classCount || this.classCount);
  621. const savedScore = this.round2(result && result.zfs);
  622. if (this.fromList) {
  623. this.warnMsg = "";
  624. this.showToast("已同步" + savedCount + "个班级", "success");
  625. setTimeout(() => this.goBack(), 900);
  626. return;
  627. }
  628. this.form.ms = "";
  629. await this.loadInit();
  630. this.warnMsg = "保存成功:已同步" + savedCount
  631. + "个班级,升旗礼总分" + savedScore;
  632. this.showToast("已同步" + savedCount + "个班级", "success");
  633. } catch (error) {
  634. console.error("[mp_sqljc_inp] 提交失败", error);
  635. this.submitHint = error && error.message ? error.message : "提交失败";
  636. this.showToast(this.submitHint, "fail");
  637. } finally {
  638. this.submitting = false;
  639. }
  640. },
  641. // 通知列表页刷新(回到列表时由 mp_sqljc_list.html 的 pageshow 处理读取)。Lin
  642. markListRefresh() {
  643. try {
  644. sessionStorage.setItem("mp_sqljc_list_refresh", "1");
  645. sessionStorage.setItem("mp_sqljc_list_date", this.formatLocalDate(new Date()));
  646. } catch (_) {
  647. }
  648. },
  649. formatLocalDate(date) {
  650. const d = date instanceof Date ? date : new Date(date);
  651. const pad = (v) => String(v).padStart(2, "0");
  652. return d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate());
  653. },
  654. handleBottomAction(data) {
  655. if (data && data.action === "cancel")
  656. this.goBack();
  657. else if (data && data.action === "submit")
  658. this.submit();
  659. },
  660. goBack() {
  661. if (window.wx && window.wx.miniProgram) {
  662. window.wx.miniProgram.navigateBack({ delta: 1 });
  663. } else if (window.history.length > 1) {
  664. window.history.back();
  665. }
  666. },
  667. showToast(message, type) {
  668. const toastType = type === "success" ? "success" : "error";
  669. if (window.wx && window.wx.miniProgram && window.wx.miniProgram.showToast) {
  670. window.wx.miniProgram.showToast({ title: message, icon: toastType });
  671. } else if (window.SS && window.SS.dom && typeof window.SS.dom.showToast === "function") {
  672. window.SS.dom.showToast({ message: message, type: toastType });
  673. }
  674. }
  675. }
  676. });
  677. });
  678. </script>
  679. </body>
  680. </html>