| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 |
- <!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=20261201-list-return-v1"></script>
- <style>
- [v-cloak] { display: none !important; }
- :root {
- --line: #e5e7eb;
- --text: #222;
- --muted: #8b95a5;
- --green: #222222;
- --danger: #e5484d;
- --danger-soft: #fff0f0;
- --blue: #2f6fed;
- }
- * { box-sizing: border-box; }
- body {
- margin: 0;
- color: var(--text);
- background: #f3f4f6;
- font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
- "Microsoft YaHei", sans-serif;
- }
- #app { min-height: 100vh; }
- .loading-container {
- display: flex;
- min-height: 65vh;
- align-items: center;
- justify-content: center;
- color: var(--muted);
- font-size: 14px;
- }
- .loading-spinner {
- width: 34px;
- height: 34px;
- margin-right: 10px;
- border: 4px solid #e6e8ec;
- border-top-color: var(--green);
- border-radius: 50%;
- animation: spin .9s linear infinite;
- }
- @keyframes spin { to { transform: rotate(360deg); } }
- .page-content { padding: 12px 14px 18px; }
- .error-box, .hint-box {
- margin-bottom: 12px;
- padding: 11px 12px;
- border-radius: 6px;
- line-height: 1.5;
- font-size: 14px;
- }
- .error-box { color: var(--danger); background: var(--danger-soft); border: 1px solid #ffd0d0; }
- .hint-box { color: #66758b; background: #eef4ff; border: 1px solid #d7e4ff; }
- .form-table, .section-card {
- overflow: hidden;
- margin-bottom: 12px;
- background: #fff;
- border: 1px solid var(--line);
- border-radius: 6px;
- }
- .form-row {
- display: grid;
- grid-template-columns: 92px 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: flex-end;
- 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;
- }
- .select-cell, .select-cell > .ss-select-container { width: 100%; min-width: 0; }
- .native-textarea {
- width: 100%;
- min-height: 94px;
- padding: 10px 0;
- color: var(--text);
- background: #fff;
- border: 0;
- outline: none;
- resize: vertical;
- font: inherit;
- font-size: 15px;
- }
- .section-head {
- display: flex;
- min-height: 46px;
- align-items: center;
- justify-content: space-between;
- padding: 0 13px;
- color: #3c4a61;
- background: #fbfbfc;
- border-bottom: 1px solid var(--line);
- font-size: 15px;
- font-weight: 600;
- }
- .section-summary { color: var(--muted); font-size: 13px; font-weight: 400; }
- .check-row {
- display: grid;
- grid-template-columns: 34px minmax(0, 1fr) auto;
- min-height: 54px;
- align-items: center;
- padding: 8px 12px;
- border-bottom: 1px solid var(--line);
- }
- .check-row:last-child { border-bottom: 0; }
- .check-box {
- width: 21px;
- height: 21px;
- margin: 0;
- accent-color: var(--green);
- }
- .row-main { min-width: 0; }
- .row-title { font-size: 15px; line-height: 1.45; word-break: break-all; }
- .row-sub { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; }
- .row-state { margin-left: 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }
- .row-state.has-violation { color: var(--danger); }
- .row-state.checked { color: var(--blue); }
- .empty { padding: 28px 12px; color: var(--muted); text-align: center; font-size: 14px; }
- .violation-score { color: var(--danger); }
- .bottom-spacer { height: 70px; }
- </style>
- </head>
- <body>
- <div id="app" v-cloak>
- <div v-if="loading" class="loading-container">
- <div class="loading-spinner"></div><span>加载中...</span>
- </div>
- <template v-else>
- <div class="page-content">
- <div v-if="errorMsg" class="error-box">{{ errorMsg }}</div>
- <div class="hint-box">
- 每个已选班级都会保存检查结果。未关联违纪记录的班级按“已检查,无违纪”保存。
- </div>
- <div class="form-table">
- <div class="form-row">
- <div class="form-label">检查日期</div>
- <div class="form-value">
- <div class="select-cell">
- <ss-datetime-picker
- v-model="form.jcrq"
- mode="date"
- min-date="2020-01-01"
- max-date="2035-12-31"
- @change="loadAll"/>
- </div>
- </div>
- </div>
- <div class="form-row">
- <div class="form-label">检查类型</div>
- <div class="form-value">
- <div class="select-cell">
- <ss-select
- v-model="form.fjlx"
- :options="typeOptions"
- @change="loadViolations"/>
- </div>
- </div>
- </div>
- <div class="form-row">
- <div class="form-label">责任部门</div>
- <div class="form-value">{{ bmmc || '当前账号责任部门' }}</div>
- </div>
- <div class="form-row">
- <div class="form-label">说明</div>
- <div class="form-value" style="padding-top:0;padding-bottom:0;">
- <textarea v-model="form.ms" class="native-textarea" maxlength="1000"></textarea>
- </div>
- </div>
- </div>
- <div class="section-card">
- <div class="section-head">
- <span>检查班级</span>
- <span class="section-summary">已选 {{ selectedClasses.length }} 个</span>
- </div>
- <div v-if="!classes.length" class="empty">当前账号没有可检查的班级</div>
- <div v-for="item in classes" :key="item.bjid" class="check-row">
- <input class="check-box" type="checkbox"
- :checked="selectedClasses.includes(String(item.bjid))"
- @change="toggleClass(String(item.bjid), $event.target.checked)"/>
- <div class="row-main">
- <div class="row-title">{{ item.bjmc }}</div>
- <div class="row-sub">{{ item.bmmc || bmmc || '' }}</div>
- </div>
- <div class="row-state"
- :class="{checked: isClassSelected(item.bjid), 'has-violation': hasClassViolation(item.bjid)}">
- {{ classState(item.bjid) }}
- </div>
- </div>
- </div>
- <div class="section-card">
- <div class="section-head">
- <span>当天风纪违纪记录</span>
- <span class="section-summary">已关联 {{ selectedViolations.length }} 条</span>
- </div>
- <div v-if="!violations.length" class="empty">当天没有可关联的风纪违纪记录</div>
- <div v-for="item in violations" :key="item.wjjlid" class="check-row">
- <input class="check-box" type="checkbox"
- :checked="selectedViolations.includes(String(item.wjjlid))"
- @change="toggleViolation(item, $event.target.checked)"/>
- <div class="row-main">
- <div class="row-title">{{ item.bjmc }} · {{ item.wjlbmc }}</div>
- <div class="row-sub">
- {{ item.xm || '未登记学员' }} · {{ item.wjsj }}
- <span class="violation-score">-{{ item.bjfk }}</span>
- </div>
- </div>
- <div class="row-state has-violation">扣分</div>
- </div>
- </div>
- <div class="bottom-spacer"></div>
- </div>
- <ss-bottom
- :show-shyj="false"
- :buttons="submitting ? [{text:'提交中...',action:'submit'}] : bottomButtons"
- @button-click="handleBottomAction"
- :disabled="submitting"/>
- </template>
- </div>
- <script>
- function formatLocalDateText(date) {
- const local = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
- return local.toISOString().slice(0, 10);
- }
- function initialInspectionDate() {
- try {
- const value = new URLSearchParams(window.location.search).get("jcrq");
- if (/^\d{4}-\d{2}-\d{2}$/.test(value || ""))
- return value;
- } catch (_) {
- }
- return formatLocalDateText(new Date());
- }
- window.SS.ready(function () {
- const LIST_PAGE = "/page/mp/mp_fjjc_list.html";
- window.SS.dom.initializeFormApp({
- el: "#app",
- data() {
- return {
- loading: true,
- submitting: false,
- errorMsg: "",
- bmid: "",
- bmmc: "",
- classes: [],
- types: [],
- violations: [],
- selectedClasses: [],
- selectedViolations: [],
- form: {
- jcrq: initialInspectionDate(),
- fjlx: "1",
- ms: ""
- },
- bottomButtons: [
- {text: "取消", action: "cancel"},
- {text: "保存并提交", action: "submit"}
- ]
- };
- },
- computed: {
- typeOptions() {
- return this.types.map((item) => ({n: item.name, v: String(item.code)}));
- }
- },
- async mounted() {
- try {
- if (typeof window.ensureMiniProgramSessionFresh === "function") {
- await window.ensureMiniProgramSessionFresh({
- page: "mp_fjjc_inp",
- service: "fjjc_mpInit",
- force: true
- });
- }
- } catch (error) {
- this.errorMsg = error && error.message
- ? error.message
- : "登录状态刷新失败,请返回小程序重新进入";
- this.loading = false;
- return;
- }
- await this.loadAll();
- },
- methods: {
- getRequest() {
- return window.request || (typeof request !== "undefined" ? request : null);
- },
- async postService(url, data) {
- const req = this.getRequest();
- if (!req || typeof req.post !== "function")
- throw new Error("请求组件未加载");
- const response = await req.post(url, data, {loading: false, 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 || "请求失败");
- return raw && raw.ssData !== undefined ? raw.ssData : raw;
- },
- async loadAll() {
- this.loading = true;
- this.errorMsg = "";
- try {
- const data = await this.postService(
- "/service?ssServ=fjjc_mpInit&ssDest=data",
- {jcrq: this.form.jcrq, bmid: this.bmid}
- ) || {};
- this.bmid = data.bmid == null ? "" : String(data.bmid);
- this.classes = (data.classes || []).map((item) => ({
- bjid: String(item.bjid || item.BJID),
- bjmc: item.bjmc || item.BJMC || "",
- bmmc: item.bmmc || item.BMMC || ""
- }));
- if (this.classes.length && !this.bmmc)
- this.bmmc = this.classes[0].bmmc || "";
- this.types = data.types || [];
- if (!this.types.some((item) => String(item.code) === String(this.form.fjlx)))
- this.form.fjlx = this.types.length ? String(this.types[0].code) : "1";
- this.selectedClasses = [];
- this.selectedViolations = [];
- await this.loadViolations();
- } catch (error) {
- this.errorMsg = error.message || "风纪检查初始化失败";
- } finally {
- this.loading = false;
- }
- },
- async loadViolations() {
- if (!this.bmid || !this.form.jcrq)
- return;
- try {
- const data = await this.postService(
- "/service?ssServ=fjjc_mpViolations&ssDest=data",
- {jcrq: this.form.jcrq, bmid: this.bmid}
- ) || {};
- this.violations = data.list || [];
- this.selectedViolations = this.selectedViolations.filter((id) =>
- this.violations.some((item) => String(item.wjjlid) === id));
- } catch (error) {
- this.violations = [];
- this.showToast(error.message || "风纪违纪记录加载失败", "fail");
- }
- },
- isClassSelected(bjid) {
- return this.selectedClasses.includes(String(bjid));
- },
- hasClassViolation(bjid) {
- return this.violations.some((item) =>
- String(item.bjid) === String(bjid)
- && this.selectedViolations.includes(String(item.wjjlid)));
- },
- classState(bjid) {
- if (!this.isClassSelected(bjid))
- return "未检查";
- return this.hasClassViolation(bjid) ? "有违纪" : "无违纪";
- },
- toggleClass(bjid, checked) {
- const id = String(bjid);
- if (checked && !this.selectedClasses.includes(id)) {
- this.selectedClasses.push(id);
- } else if (!checked) {
- this.selectedClasses = this.selectedClasses.filter((item) => item !== id);
- this.selectedViolations = this.selectedViolations.filter((violationId) => {
- const item = this.violations.find((row) => String(row.wjjlid) === violationId);
- return item && String(item.bjid) !== id;
- });
- }
- },
- toggleViolation(item, checked) {
- const id = String(item.wjjlid);
- if (checked) {
- const bjid = String(item.bjid);
- if (!this.selectedClasses.includes(bjid))
- this.selectedClasses.push(bjid);
- if (!this.selectedViolations.includes(id))
- this.selectedViolations.push(id);
- } else {
- this.selectedViolations = this.selectedViolations.filter((value) => value !== id);
- }
- },
- validateForm() {
- if (!this.form.jcrq)
- return "请选择检查日期";
- if (!this.selectedClasses.length)
- return "请至少选择一个检查班级";
- return "";
- },
- async handleBottomAction(data) {
- if (data && data.action === "cancel") {
- this.goBack();
- return;
- }
- if (data && data.action && data.action !== "submit")
- return;
- if (this.submitting)
- return;
- const message = this.validateForm();
- if (message) {
- this.showToast(message, "fail");
- return;
- }
- this.submitting = true;
- this.errorMsg = "";
- try {
- const result = await this.postService(
- "/service?ssServ=fjjc_mpSubm&ssDest=data",
- {
- jcrq: this.form.jcrq,
- fjlx: this.form.fjlx,
- bmid: this.bmid,
- ms: this.form.ms,
- bjidStr: this.selectedClasses.join(","),
- wjjlidStr: this.selectedViolations.join(",")
- }
- ) || {};
- if (result.warnMsg) {
- this.errorMsg = result.warnMsg;
- this.showToast(result.warnMsg, "warn");
- } else {
- this.showToast("提交成功", "success");
- }
- setTimeout(() => {
- window.NavigationManager.returnToList(LIST_PAGE, {
- refreshData: { date: this.form.jcrq },
- storageValues: {
- "mp_fjjc_list_refresh": "1",
- "mp_fjjc_list_date": this.form.jcrq
- }
- });
- }, 900);
- } catch (error) {
- this.errorMsg = error.message || "提交失败";
- this.showToast(this.errorMsg, "fail");
- } finally {
- this.submitting = false;
- }
- },
- goBack() {
- if (window.NavigationManager
- && typeof window.NavigationManager.goBack === "function") {
- window.NavigationManager.goBack({listPage: LIST_PAGE});
- } else if (window.history.length > 1) {
- window.history.back();
- } else {
- window.location.replace(LIST_PAGE);
- }
- },
- showToast(message, type) {
- if (window.toast && typeof window.toast === "function")
- window.toast(message, type);
- else
- console[type === "fail" ? "error" : "log"](message);
- }
- }
- });
- });
- </script>
- </body>
- </html>
|