mp_fjjc_inp.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  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=20261201-list-return-v1"></script>
  9. <style>
  10. [v-cloak] { display: none !important; }
  11. :root {
  12. --line: #e5e7eb;
  13. --text: #222;
  14. --muted: #8b95a5;
  15. --green: #222222;
  16. --danger: #e5484d;
  17. --danger-soft: #fff0f0;
  18. --blue: #2f6fed;
  19. }
  20. * { box-sizing: border-box; }
  21. body {
  22. margin: 0;
  23. color: var(--text);
  24. background: #f3f4f6;
  25. font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
  26. "Microsoft YaHei", sans-serif;
  27. }
  28. #app { min-height: 100vh; }
  29. .loading-container {
  30. display: flex;
  31. min-height: 65vh;
  32. align-items: center;
  33. justify-content: center;
  34. color: var(--muted);
  35. font-size: 14px;
  36. }
  37. .loading-spinner {
  38. width: 34px;
  39. height: 34px;
  40. margin-right: 10px;
  41. border: 4px solid #e6e8ec;
  42. border-top-color: var(--green);
  43. border-radius: 50%;
  44. animation: spin .9s linear infinite;
  45. }
  46. @keyframes spin { to { transform: rotate(360deg); } }
  47. .page-content { padding: 12px 14px 18px; }
  48. .error-box, .hint-box {
  49. margin-bottom: 12px;
  50. padding: 11px 12px;
  51. border-radius: 6px;
  52. line-height: 1.5;
  53. font-size: 14px;
  54. }
  55. .error-box { color: var(--danger); background: var(--danger-soft); border: 1px solid #ffd0d0; }
  56. .hint-box { color: #66758b; background: #eef4ff; border: 1px solid #d7e4ff; }
  57. .form-table, .section-card {
  58. overflow: hidden;
  59. margin-bottom: 12px;
  60. background: #fff;
  61. border: 1px solid var(--line);
  62. border-radius: 6px;
  63. }
  64. .form-row {
  65. display: grid;
  66. grid-template-columns: 92px minmax(0, 1fr);
  67. min-height: 58px;
  68. border-bottom: 1px solid var(--line);
  69. }
  70. .form-row:last-child { border-bottom: 0; }
  71. .form-label {
  72. display: flex;
  73. align-items: center;
  74. justify-content: flex-end;
  75. padding: 12px;
  76. color: var(--muted);
  77. background: #fbfbfc;
  78. border-right: 1px solid var(--line);
  79. font-size: 15px;
  80. }
  81. .form-value {
  82. display: flex;
  83. align-items: center;
  84. min-width: 0;
  85. padding: 10px 12px;
  86. font-size: 15px;
  87. }
  88. .select-cell, .select-cell > .ss-select-container { width: 100%; min-width: 0; }
  89. .native-textarea {
  90. width: 100%;
  91. min-height: 94px;
  92. padding: 10px 0;
  93. color: var(--text);
  94. background: #fff;
  95. border: 0;
  96. outline: none;
  97. resize: vertical;
  98. font: inherit;
  99. font-size: 15px;
  100. }
  101. .section-head {
  102. display: flex;
  103. min-height: 46px;
  104. align-items: center;
  105. justify-content: space-between;
  106. padding: 0 13px;
  107. color: #3c4a61;
  108. background: #fbfbfc;
  109. border-bottom: 1px solid var(--line);
  110. font-size: 15px;
  111. font-weight: 600;
  112. }
  113. .section-summary { color: var(--muted); font-size: 13px; font-weight: 400; }
  114. .check-row {
  115. display: grid;
  116. grid-template-columns: 34px minmax(0, 1fr) auto;
  117. min-height: 54px;
  118. align-items: center;
  119. padding: 8px 12px;
  120. border-bottom: 1px solid var(--line);
  121. }
  122. .check-row:last-child { border-bottom: 0; }
  123. .check-box {
  124. width: 21px;
  125. height: 21px;
  126. margin: 0;
  127. accent-color: var(--green);
  128. }
  129. .row-main { min-width: 0; }
  130. .row-title { font-size: 15px; line-height: 1.45; word-break: break-all; }
  131. .row-sub { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; }
  132. .row-state { margin-left: 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }
  133. .row-state.has-violation { color: var(--danger); }
  134. .row-state.checked { color: var(--blue); }
  135. .empty { padding: 28px 12px; color: var(--muted); text-align: center; font-size: 14px; }
  136. .violation-score { color: var(--danger); }
  137. .bottom-spacer { height: 70px; }
  138. </style>
  139. </head>
  140. <body>
  141. <div id="app" v-cloak>
  142. <div v-if="loading" class="loading-container">
  143. <div class="loading-spinner"></div><span>加载中...</span>
  144. </div>
  145. <template v-else>
  146. <div class="page-content">
  147. <div v-if="errorMsg" class="error-box">{{ errorMsg }}</div>
  148. <div class="hint-box">
  149. 每个已选班级都会保存检查结果。未关联违纪记录的班级按“已检查,无违纪”保存。
  150. </div>
  151. <div class="form-table">
  152. <div class="form-row">
  153. <div class="form-label">检查日期</div>
  154. <div class="form-value">
  155. <div class="select-cell">
  156. <ss-datetime-picker
  157. v-model="form.jcrq"
  158. mode="date"
  159. min-date="2020-01-01"
  160. max-date="2035-12-31"
  161. @change="loadAll"/>
  162. </div>
  163. </div>
  164. </div>
  165. <div class="form-row">
  166. <div class="form-label">检查类型</div>
  167. <div class="form-value">
  168. <div class="select-cell">
  169. <ss-select
  170. v-model="form.fjlx"
  171. :options="typeOptions"
  172. @change="loadViolations"/>
  173. </div>
  174. </div>
  175. </div>
  176. <div class="form-row">
  177. <div class="form-label">责任部门</div>
  178. <div class="form-value">{{ bmmc || '当前账号责任部门' }}</div>
  179. </div>
  180. <div class="form-row">
  181. <div class="form-label">说明</div>
  182. <div class="form-value" style="padding-top:0;padding-bottom:0;">
  183. <textarea v-model="form.ms" class="native-textarea" maxlength="1000"></textarea>
  184. </div>
  185. </div>
  186. </div>
  187. <div class="section-card">
  188. <div class="section-head">
  189. <span>检查班级</span>
  190. <span class="section-summary">已选 {{ selectedClasses.length }} 个</span>
  191. </div>
  192. <div v-if="!classes.length" class="empty">当前账号没有可检查的班级</div>
  193. <div v-for="item in classes" :key="item.bjid" class="check-row">
  194. <input class="check-box" type="checkbox"
  195. :checked="selectedClasses.includes(String(item.bjid))"
  196. @change="toggleClass(String(item.bjid), $event.target.checked)"/>
  197. <div class="row-main">
  198. <div class="row-title">{{ item.bjmc }}</div>
  199. <div class="row-sub">{{ item.bmmc || bmmc || '' }}</div>
  200. </div>
  201. <div class="row-state"
  202. :class="{checked: isClassSelected(item.bjid), 'has-violation': hasClassViolation(item.bjid)}">
  203. {{ classState(item.bjid) }}
  204. </div>
  205. </div>
  206. </div>
  207. <div class="section-card">
  208. <div class="section-head">
  209. <span>当天风纪违纪记录</span>
  210. <span class="section-summary">已关联 {{ selectedViolations.length }} 条</span>
  211. </div>
  212. <div v-if="!violations.length" class="empty">当天没有可关联的风纪违纪记录</div>
  213. <div v-for="item in violations" :key="item.wjjlid" class="check-row">
  214. <input class="check-box" type="checkbox"
  215. :checked="selectedViolations.includes(String(item.wjjlid))"
  216. @change="toggleViolation(item, $event.target.checked)"/>
  217. <div class="row-main">
  218. <div class="row-title">{{ item.bjmc }} · {{ item.wjlbmc }}</div>
  219. <div class="row-sub">
  220. {{ item.xm || '未登记学员' }} · {{ item.wjsj }}
  221. <span class="violation-score">-{{ item.bjfk }}</span>
  222. </div>
  223. </div>
  224. <div class="row-state has-violation">扣分</div>
  225. </div>
  226. </div>
  227. <div class="bottom-spacer"></div>
  228. </div>
  229. <ss-bottom
  230. :show-shyj="false"
  231. :buttons="submitting ? [{text:'提交中...',action:'submit'}] : bottomButtons"
  232. @button-click="handleBottomAction"
  233. :disabled="submitting"/>
  234. </template>
  235. </div>
  236. <script>
  237. function formatLocalDateText(date) {
  238. const local = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
  239. return local.toISOString().slice(0, 10);
  240. }
  241. function initialInspectionDate() {
  242. try {
  243. const value = new URLSearchParams(window.location.search).get("jcrq");
  244. if (/^\d{4}-\d{2}-\d{2}$/.test(value || ""))
  245. return value;
  246. } catch (_) {
  247. }
  248. return formatLocalDateText(new Date());
  249. }
  250. window.SS.ready(function () {
  251. const LIST_PAGE = "/page/mp/mp_fjjc_list.html";
  252. window.SS.dom.initializeFormApp({
  253. el: "#app",
  254. data() {
  255. return {
  256. loading: true,
  257. submitting: false,
  258. errorMsg: "",
  259. bmid: "",
  260. bmmc: "",
  261. classes: [],
  262. types: [],
  263. violations: [],
  264. selectedClasses: [],
  265. selectedViolations: [],
  266. form: {
  267. jcrq: initialInspectionDate(),
  268. fjlx: "1",
  269. ms: ""
  270. },
  271. bottomButtons: [
  272. {text: "取消", action: "cancel"},
  273. {text: "保存并提交", action: "submit"}
  274. ]
  275. };
  276. },
  277. computed: {
  278. typeOptions() {
  279. return this.types.map((item) => ({n: item.name, v: String(item.code)}));
  280. }
  281. },
  282. async mounted() {
  283. try {
  284. if (typeof window.ensureMiniProgramSessionFresh === "function") {
  285. await window.ensureMiniProgramSessionFresh({
  286. page: "mp_fjjc_inp",
  287. service: "fjjc_mpInit",
  288. force: true
  289. });
  290. }
  291. } catch (error) {
  292. this.errorMsg = error && error.message
  293. ? error.message
  294. : "登录状态刷新失败,请返回小程序重新进入";
  295. this.loading = false;
  296. return;
  297. }
  298. await this.loadAll();
  299. },
  300. methods: {
  301. getRequest() {
  302. return window.request || (typeof request !== "undefined" ? request : null);
  303. },
  304. async postService(url, data) {
  305. const req = this.getRequest();
  306. if (!req || typeof req.post !== "function")
  307. throw new Error("请求组件未加载");
  308. const response = await req.post(url, data, {loading: false, formData: true});
  309. const raw = response && response.data !== undefined ? response.data : response;
  310. if (raw && raw.ssCode !== undefined && Number(raw.ssCode) !== 0)
  311. throw new Error(raw.ssMsg || "请求失败");
  312. return raw && raw.ssData !== undefined ? raw.ssData : raw;
  313. },
  314. async loadAll() {
  315. this.loading = true;
  316. this.errorMsg = "";
  317. try {
  318. const data = await this.postService(
  319. "/service?ssServ=fjjc_mpInit&ssDest=data",
  320. {jcrq: this.form.jcrq, bmid: this.bmid}
  321. ) || {};
  322. this.bmid = data.bmid == null ? "" : String(data.bmid);
  323. this.classes = (data.classes || []).map((item) => ({
  324. bjid: String(item.bjid || item.BJID),
  325. bjmc: item.bjmc || item.BJMC || "",
  326. bmmc: item.bmmc || item.BMMC || ""
  327. }));
  328. if (this.classes.length && !this.bmmc)
  329. this.bmmc = this.classes[0].bmmc || "";
  330. this.types = data.types || [];
  331. if (!this.types.some((item) => String(item.code) === String(this.form.fjlx)))
  332. this.form.fjlx = this.types.length ? String(this.types[0].code) : "1";
  333. this.selectedClasses = [];
  334. this.selectedViolations = [];
  335. await this.loadViolations();
  336. } catch (error) {
  337. this.errorMsg = error.message || "风纪检查初始化失败";
  338. } finally {
  339. this.loading = false;
  340. }
  341. },
  342. async loadViolations() {
  343. if (!this.bmid || !this.form.jcrq)
  344. return;
  345. try {
  346. const data = await this.postService(
  347. "/service?ssServ=fjjc_mpViolations&ssDest=data",
  348. {jcrq: this.form.jcrq, bmid: this.bmid}
  349. ) || {};
  350. this.violations = data.list || [];
  351. this.selectedViolations = this.selectedViolations.filter((id) =>
  352. this.violations.some((item) => String(item.wjjlid) === id));
  353. } catch (error) {
  354. this.violations = [];
  355. this.showToast(error.message || "风纪违纪记录加载失败", "fail");
  356. }
  357. },
  358. isClassSelected(bjid) {
  359. return this.selectedClasses.includes(String(bjid));
  360. },
  361. hasClassViolation(bjid) {
  362. return this.violations.some((item) =>
  363. String(item.bjid) === String(bjid)
  364. && this.selectedViolations.includes(String(item.wjjlid)));
  365. },
  366. classState(bjid) {
  367. if (!this.isClassSelected(bjid))
  368. return "未检查";
  369. return this.hasClassViolation(bjid) ? "有违纪" : "无违纪";
  370. },
  371. toggleClass(bjid, checked) {
  372. const id = String(bjid);
  373. if (checked && !this.selectedClasses.includes(id)) {
  374. this.selectedClasses.push(id);
  375. } else if (!checked) {
  376. this.selectedClasses = this.selectedClasses.filter((item) => item !== id);
  377. this.selectedViolations = this.selectedViolations.filter((violationId) => {
  378. const item = this.violations.find((row) => String(row.wjjlid) === violationId);
  379. return item && String(item.bjid) !== id;
  380. });
  381. }
  382. },
  383. toggleViolation(item, checked) {
  384. const id = String(item.wjjlid);
  385. if (checked) {
  386. const bjid = String(item.bjid);
  387. if (!this.selectedClasses.includes(bjid))
  388. this.selectedClasses.push(bjid);
  389. if (!this.selectedViolations.includes(id))
  390. this.selectedViolations.push(id);
  391. } else {
  392. this.selectedViolations = this.selectedViolations.filter((value) => value !== id);
  393. }
  394. },
  395. validateForm() {
  396. if (!this.form.jcrq)
  397. return "请选择检查日期";
  398. if (!this.selectedClasses.length)
  399. return "请至少选择一个检查班级";
  400. return "";
  401. },
  402. async handleBottomAction(data) {
  403. if (data && data.action === "cancel") {
  404. this.goBack();
  405. return;
  406. }
  407. if (data && data.action && data.action !== "submit")
  408. return;
  409. if (this.submitting)
  410. return;
  411. const message = this.validateForm();
  412. if (message) {
  413. this.showToast(message, "fail");
  414. return;
  415. }
  416. this.submitting = true;
  417. this.errorMsg = "";
  418. try {
  419. const result = await this.postService(
  420. "/service?ssServ=fjjc_mpSubm&ssDest=data",
  421. {
  422. jcrq: this.form.jcrq,
  423. fjlx: this.form.fjlx,
  424. bmid: this.bmid,
  425. ms: this.form.ms,
  426. bjidStr: this.selectedClasses.join(","),
  427. wjjlidStr: this.selectedViolations.join(",")
  428. }
  429. ) || {};
  430. if (result.warnMsg) {
  431. this.errorMsg = result.warnMsg;
  432. this.showToast(result.warnMsg, "warn");
  433. } else {
  434. this.showToast("提交成功", "success");
  435. }
  436. setTimeout(() => {
  437. window.NavigationManager.returnToList(LIST_PAGE, {
  438. refreshData: { date: this.form.jcrq },
  439. storageValues: {
  440. "mp_fjjc_list_refresh": "1",
  441. "mp_fjjc_list_date": this.form.jcrq
  442. }
  443. });
  444. }, 900);
  445. } catch (error) {
  446. this.errorMsg = error.message || "提交失败";
  447. this.showToast(this.errorMsg, "fail");
  448. } finally {
  449. this.submitting = false;
  450. }
  451. },
  452. goBack() {
  453. if (window.NavigationManager
  454. && typeof window.NavigationManager.goBack === "function") {
  455. window.NavigationManager.goBack({listPage: LIST_PAGE});
  456. } else if (window.history.length > 1) {
  457. window.history.back();
  458. } else {
  459. window.location.replace(LIST_PAGE);
  460. }
  461. },
  462. showToast(message, type) {
  463. if (window.toast && typeof window.toast === "function")
  464. window.toast(message, type);
  465. else
  466. console[type === "fail" ? "error" : "log"](message);
  467. }
  468. }
  469. });
  470. });
  471. </script>
  472. </body>
  473. </html>