| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <!-- 2026-09-24 升旗礼检查小程序专用页面。样式与 mp_ssnwjc_inp.html 保持一致。 -->
- <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=20261127-auth-refresh-v1"></script>
- <style>
- [v-cloak] {
- display: none !important;
- }
- :root {
- --line: #e5e7eb;
- --text: #222222;
- --muted: #8b95a5;
- --soft: #f7f8fa;
- --green: #19a463;
- --green-soft: #eaf8f1;
- --danger: #e5484d;
- --danger-soft: #fff0f0;
- }
- * {
- 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;
- padding-bottom: 86px;
- }
- .loading-container {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- min-height: 65vh;
- color: var(--muted);
- }
- .loading-spinner {
- width: 38px;
- height: 38px;
- margin-bottom: 12px;
- border: 4px solid #e6e8ec;
- border-top-color: var(--green);
- border-radius: 50%;
- animation: spin 0.9s linear infinite;
- }
- @keyframes spin {
- to {
- transform: rotate(360deg);
- }
- }
- .error-box {
- margin: 18px 14px;
- padding: 18px;
- color: var(--danger);
- background: var(--danger-soft);
- border: 1px solid #ffd0d0;
- border-radius: 6px;
- line-height: 1.6;
- }
- .page-content {
- padding: 12px 14px 0;
- }
- .info-table,
- .score-table {
- overflow: hidden;
- background: #fff;
- border: 1px solid var(--line);
- border-radius: 6px;
- }
- .info-row {
- display: grid;
- grid-template-columns: 92px 1fr;
- min-height: 58px;
- border-bottom: 1px solid var(--line);
- }
- .info-row:last-child {
- border-bottom: none;
- }
- .info-label {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- padding: 12px 14px;
- color: var(--muted);
- background: #fbfbfc;
- border-right: 1px solid var(--line);
- font-size: 15px;
- }
- .info-value {
- display: flex;
- align-items: center;
- min-width: 0;
- padding: 11px 12px;
- font-size: 15px;
- }
- .select-cell {
- width: 100%;
- min-width: 0;
- }
- .select-cell > .ss-select-container {
- width: 100%;
- min-width: 0;
- }
- .info-text {
- align-items: flex-start;
- line-height: 1.55;
- overflow-wrap: anywhere;
- }
- .clickable {
- justify-content: space-between;
- gap: 10px;
- cursor: pointer;
- }
- .clickable-text {
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .chevron {
- flex: 0 0 auto;
- color: #9aa3b2;
- font-size: 25px;
- line-height: 1;
- }
- .score-value {
- color: var(--green);
- font-weight: 700;
- font-size: 18px;
- }
- .veto-value {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 12px;
- width: 100%;
- }
- .native-input {
- width: 100%;
- height: 38px;
- padding: 0 10px;
- color: var(--text);
- background: #fff;
- border: 0;
- outline: none;
- font: inherit;
- }
- .native-input::placeholder {
- color: #b4bbc6;
- }
- .score-table {
- margin-top: 12px;
- }
- .score-row {
- display: grid;
- grid-template-columns: minmax(0, 1fr) 132px;
- min-height: 68px;
- overflow: visible;
- border-bottom: 1px solid var(--line);
- }
- .score-row:last-child {
- border-bottom: none;
- }
- .score-name {
- display: flex;
- align-items: center;
- padding: 10px 12px;
- line-height: 1.45;
- font-size: 15px;
- }
- .score-max {
- display: flex;
- align-items: center;
- justify-content: center;
- color: var(--muted);
- border-left: 1px solid var(--line);
- font-size: 16px;
- }
- .stepper {
- display: grid;
- grid-template-columns: 48px minmax(0, 1fr) 40px;
- align-items: center;
- width: auto;
- min-width: 0;
- margin: 10px 7px;
- background: #fff;
- border: 1px solid #cfd4dc;
- border-radius: 5px;
- overflow: hidden;
- }
- .stepper-btn {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- gap: 1px;
- height: 44px;
- padding: 0;
- color: #596273;
- background: #f3f4f6;
- border: 0;
- font-size: 24px;
- line-height: 1;
- appearance: none;
- }
- .stepper-btn:disabled {
- color: #c8cdd5;
- background: #eceff2;
- }
- .stepper-deduct-num {
- font-size: 15px;
- font-weight: 400;
- line-height: 1;
- }
- .stepper-btn-symbol {
- line-height: 1;
- }
- .stepper-value {
- width: 100%;
- min-width: 0;
- height: 44px;
- padding: 0 4px;
- text-align: center;
- background: #fff;
- border: 0;
- border-left: 1px solid #e1e4e9;
- border-right: 1px solid #e1e4e9;
- outline: none;
- font: inherit;
- font-size: 15px;
- font-weight: 400;
- }
- .score-total {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 14px 4px 0;
- color: var(--muted);
- font-size: 14px;
- }
- .score-total strong {
- color: var(--green);
- font-size: 18px;
- }
- .formula-note {
- padding: 4px 4px 0;
- color: var(--muted);
- text-align: right;
- font-size: 13px;
- }
- .empty-tip {
- padding: 16px 12px;
- color: var(--muted);
- text-align: center;
- font-size: 14px;
- }
- .warning-bar {
- margin: 12px 14px 0;
- padding: 11px 12px;
- color: #9a6700;
- background: #fff8e6;
- border: 1px solid #ffe8a3;
- border-radius: 6px;
- line-height: 1.5;
- font-size: 14px;
- }
- .submit-hint {
- margin: 12px 14px 0;
- padding: 11px 12px;
- color: var(--danger);
- background: var(--danger-soft);
- border: 1px solid #ffd0d0;
- border-radius: 6px;
- line-height: 1.5;
- font-size: 14px;
- }
- .bottom-spacer {
- height: 16px;
- }
- </style>
- </head>
- <body>
- <div id="app" v-cloak>
- <div v-if="loading" class="loading-container">
- <div class="loading-spinner"></div>
- <div>加载中...</div>
- </div>
- <div v-else-if="errorMsg" class="error-box">
- {{ errorMsg }}
- </div>
- <template v-else>
- <div v-if="warnMsg" class="warning-bar">{{ warnMsg }}</div>
- <div v-if="submitHint" class="submit-hint">{{ submitHint }}</div>
- <div class="page-content">
- <div class="info-table">
- <div class="info-row">
- <div class="info-label">检查人</div>
- <div class="info-value">{{ jcryxm || '—' }}</div>
- </div>
- <div class="info-row">
- <div class="info-label">检查日期</div>
- <div class="info-value">{{ inspectionDate }}</div>
- </div>
- <div class="info-row">
- <div class="info-label">入学年度</div>
- <div class="info-value">
- <div class="select-cell">
- <ss-select
- v-model="form.rxnd"
- cb="rxnd"
- placeholder=""
- @change="onRxndChange"
- />
- </div>
- </div>
- </div>
- <div class="info-row">
- <div class="info-label">班级</div>
- <div class="info-value">
- <div class="select-cell">
- <ss-select
- :key="'bj-' + form.rxnd"
- v-model="form.bjid"
- :cb="form.rxnd ? 'bjByRxnd' : ''"
- :url="bjUrl"
- :filter="{cascadingLevel: 'rxnd,bjid'}"
- :disabled="!form.rxnd"
- placeholder=""
- @change="onBjChange"
- />
- </div>
- </div>
- </div>
- <div class="info-row">
- <div class="info-label">说明</div>
- <div class="info-value">
- <input
- v-model="form.ms"
- class="native-input"
- maxlength="500"
- placeholder="请输入"
- />
- </div>
- </div>
- </div>
- <div class="score-table">
- <div v-if="!jcxmList.length" class="empty-tip">暂无检查项目</div>
- <div v-for="item in jcxmList" :key="item.sqljcxmm" class="score-row">
- <div class="score-name">
- {{ item.mc }}<span v-if="isScoreItem(item)"> ({{ item.mfz }})</span>
- </div>
- <div class="stepper">
- <button
- class="stepper-btn"
- type="button"
- :disabled="Number(item.value) <= 0"
- @click="changeStep(item, -1)"
- >
- <span class="stepper-btn-symbol">-</span><span
- v-if="deductedFs(item) > 0"
- class="stepper-deduct-num">{{ deductedFs(item) }}</span>
- </button>
- <input
- class="stepper-value"
- inputmode="numeric"
- :value="item.value"
- :min="0"
- :max="isScoreItem(item) ? item.mfz : null"
- @input="onStepInput(item, $event)"
- @blur="normalizeStep(item, $event)"
- />
- <button
- class="stepper-btn"
- type="button"
- :disabled="isScoreItem(item) && Number(item.value) >= Number(item.mfz)"
- @click="changeStep(item, 1)"
- >
- +
- </button>
- </div>
- </div>
- </div>
- <div class="score-total">
- <span>升旗礼总分</span>
- <strong>{{ totalFs }}</strong>
- </div>
- <div class="formula-note">{{ formulaNote }}</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>
- window.SS.ready(function () {
- window.SS.dom.initializeFormApp({
- el: "#app",
- data() {
- return {
- loading: true,
- submitting: false,
- fromList: false,
- errorMsg: "",
- warnMsg: "",
- submitHint: "",
- recordsToday: 0,
- bmmc: "",
- jcryxm: "",
- inspectionDate: "",
- formulaNote: "出勤率×25% + 队列分×20% + 风貌分×40% + 纪律分×15%",
- jcxmList: [],
- form: {
- rxnd: "",
- bjid: "",
- ms: ""
- },
- bottomButtons: [
- { text: "取消", action: "cancel" },
- { text: "保存并提交", action: "submit" }
- ]
- };
- },
- computed: {
- bjUrl() {
- const base = "/service?ssServ=loadObjpOpt&objectpickerdropdown1=1";
- const year = String(this.form.rxnd || "").trim();
- return year ? base + "&upperValue=" + encodeURIComponent(year) : base;
- },
- expectedStudents() {
- const countCodes = [3, 4, 5, 6, 7, 8];
- const exempt = countCodes.reduce(
- (sum, code) => sum + this.valueOfCode(code), 0);
- return Math.max(0, this.valueOfCode(1) - exempt);
- },
- attendanceRate() {
- if (this.expectedStudents <= 0)
- return 0;
- return Math.min(100, this.round2(
- this.valueOfCode(2) * 100 / this.expectedStudents));
- },
- totalFs() {
- const queueScore = this.valueOfCode(11);
- const demeanorScore = this.valueOfCode(21) + this.valueOfCode(22);
- const disciplineScore = this.valueOfCode(31);
- return this.round2(
- this.attendanceRate * 0.25
- + queueScore * 0.20
- + demeanorScore * 0.40
- + disciplineScore * 0.15);
- },
- },
- async mounted() {
- this.inspectionDate = this.formatLocalDate(new Date());
- // 从列表页「新增」进来时带 ?from=list:提交后直接回列表。Lin
- try {
- const params = new URLSearchParams(window.location.search);
- this.fromList = String(params.get("from") || "") === "list";
- } catch (_) {
- this.fromList = false;
- }
- try {
- const sessionOk = await this.ensureSession();
- if (!sessionOk)
- return;
- await this.loadInit();
- } catch (error) {
- console.error("[mp_sqljc_inp] 初始化失败", error);
- this.errorMsg = error && error.message ? error.message : "页面初始化失败";
- } finally {
- this.loading = false;
- }
- },
- methods: {
- getUrlParams() {
- const params = {};
- const search = new URLSearchParams(window.location.search);
- for (const [key, value] of search) {
- params[key] = decodeURIComponent(value);
- }
- return params;
- },
- getRequest() {
- return (window && window.request) || request;
- },
- // 小程序切换账号后,旧 H5 会话会写到别人名下,必须先刷新会话。Lin
- async ensureSession() {
- if (typeof window.ensureMiniProgramSessionFresh !== "function")
- return true;
- try {
- await window.ensureMiniProgramSessionFresh({
- page: "mp_sqljc_inp",
- service: "sqljc_mpInit",
- force: true
- });
- return true;
- } catch (error) {
- this.errorMsg = "登录状态刷新失败,请返回小程序重新进入";
- return false;
- }
- },
- async loadInit() {
- const data = await this.postService(
- "/service?ssServ=sqljc_mpInit&ssDest=data", {});
- this.bmmc = (data && data.bmmc) || "";
- this.jcryxm = (data && data.jcryxm) || "";
- this.jcxmList = ((data && data.jcxmList) || []).map((item) => {
- const mfz = item.mfz === null || item.mfz === undefined || item.mfz === ""
- ? null : Number(item.mfz);
- return {
- sqljcxmm: Number(item.sqljcxmm),
- mc: item.mc,
- mfz: mfz,
- defaultValue: item.defaultValue === null
- || item.defaultValue === undefined
- ? (mfz === null ? 0 : mfz)
- : Number(item.defaultValue),
- value: item.defaultValue === null
- || item.defaultValue === undefined
- ? (mfz === null ? 0 : mfz)
- : Number(item.defaultValue)
- };
- });
- },
- valueOfCode(code) {
- const item = this.jcxmList.find(
- (row) => Number(row.sqljcxmm) === Number(code));
- return item ? Number(item.value || 0) : 0;
- },
- round2(value) {
- const number = Number(value || 0);
- return Math.round(number * 100) / 100;
- },
- isScoreItem(item) {
- return item.mfz !== null && item.mfz !== undefined;
- },
- onRxndChange(value) {
- this.form.rxnd = value || "";
- this.form.bjid = "";
- },
- onBjChange(value) {
- this.form.bjid = value || "";
- },
- 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;
- },
- // 打分项显示累计扣分;人数项没有满分,不显示扣分。Lin
- deductedFs(item) {
- if (!this.isScoreItem(item))
- return 0;
- const mfz = Number(item.mfz || 0);
- return Math.max(0, mfz - Number(item.value || 0));
- },
- // 所有数字项左右都可加减:打分项限 0..MFZ,人数项只限 >= 0。Lin
- changeStep(item, step) {
- let value = Number(item.value || 0) + step;
- if (value < 0)
- value = 0;
- if (this.isScoreItem(item) && value > Number(item.mfz || 0))
- value = Number(item.mfz || 0);
- item.value = value;
- },
- onStepInput(item, event) {
- const raw = String(event.target.value || "").replace(/[^0-9]/g, "");
- item.value = raw === "" ? "" : Number(raw);
- },
- normalizeStep(item, event) {
- let value = Number(String(event.target.value || "").replace(/[^0-9]/g, ""));
- if (!Number.isFinite(value) || value < 0)
- value = 0;
- if (this.isScoreItem(item) && value > Number(item.mfz || 0))
- value = Number(item.mfz || 0);
- item.value = value;
- },
- validateForm() {
- if (!this.form.rxnd)
- return "请选择入学年度";
- if (!this.form.bjid)
- return "请选择班级";
- if (!this.jcxmList.length)
- return "检查项目未配置";
- if (this.valueOfCode(1) <= 0)
- return "学员总人数必须大于0";
- if (this.expectedStudents <= 0)
- return "有效应到人数必须大于0";
- if (this.valueOfCode(2) > this.expectedStudents)
- return "队列人数不能大于有效应到人数";
- for (const item of this.jcxmList) {
- const value = Number(item.value || 0);
- if (value < 0)
- return item.mc + " 不能为负数";
- if (this.isScoreItem(item) && value > Number(item.mfz || 0))
- return item.mc + " 分值超出满分";
- }
- return "";
- },
- async submit() {
- if (this.submitting)
- return;
- const message = this.validateForm();
- if (message) {
- this.submitHint = message;
- this.warnMsg = "";
- this.showToast(message, "fail");
- return;
- }
- try {
- this.submitting = true;
- this.warnMsg = "";
- this.submitHint = "";
- const payload = {
- bjid: this.form.bjid,
- ms: this.form.ms
- };
- this.jcxmList.forEach((item) => {
- payload["sqljcxmm" + item.sqljcxmm] =
- item.value === "" ? 0 : Number(item.value);
- });
- const result = await this.postService(
- "/service?ssServ=sqljc_mpSubm&ssDest=data", payload);
- this.recordsToday = Number(result && result.recordsToday || this.recordsToday + 1);
- this.markListRefresh();
- if (this.fromList) {
- this.resetAfterSubmit();
- this.warnMsg = "";
- this.showToast("提交成功", "success");
- setTimeout(() => this.goBack(), 900);
- return;
- }
- this.resetAfterSubmit();
- this.warnMsg = "已提交,可继续录入下一个班级(今天已录入 "
- + this.recordsToday + " 条)";
- this.showToast("提交成功", "success");
- } catch (error) {
- console.error("[mp_sqljc_inp] 提交失败", error);
- this.submitHint = error && error.message ? error.message : "提交失败";
- this.showToast(this.submitHint, "fail");
- } finally {
- this.submitting = false;
- }
- },
- resetAfterSubmit() {
- this.form.bjid = "";
- this.form.ms = "";
- this.jcxmList.forEach((item) => {
- item.value = Number(item.defaultValue || 0);
- });
- },
- // 通知列表页刷新(回到列表时由 mp_sqljc_list.html 的 pageshow 处理读取)。Lin
- markListRefresh() {
- try {
- sessionStorage.setItem("mp_sqljc_list_refresh", "1");
- sessionStorage.setItem("mp_sqljc_list_date", this.formatLocalDate(new Date()));
- } catch (_) {
- }
- },
- formatLocalDate(date) {
- const d = date instanceof Date ? date : new Date(date);
- const pad = (v) => String(v).padStart(2, "0");
- return d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate());
- },
- handleBottomAction(data) {
- if (data && data.action === "cancel")
- this.goBack();
- else if (data && data.action === "submit")
- this.submit();
- },
- goBack() {
- if (window.wx && window.wx.miniProgram) {
- window.wx.miniProgram.navigateBack({ delta: 1 });
- } else if (window.history.length > 1) {
- window.history.back();
- }
- },
- showToast(message, type) {
- const toastType = type === "success" ? "success" : "error";
- if (window.wx && window.wx.miniProgram && window.wx.miniProgram.showToast) {
- window.wx.miniProgram.showToast({ title: message, icon: toastType });
- } else if (window.SS && window.SS.dom && typeof window.SS.dom.showToast === "function") {
- window.SS.dom.showToast({ message: message, type: toastType });
- }
- }
- }
- });
- });
- </script>
- </body>
- </html>
|