| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 |
- <!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=20261117-select-font-v4"></script>
- <style>
- [v-cloak] {
- display: none !important;
- }
- html,
- body {
- margin: 0;
- background: #f5f5f5;
- font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
- "Microsoft YaHei", sans-serif;
- }
- #app {
- min-height: 100vh;
- box-sizing: border-box;
- padding-bottom: calc(76px + env(safe-area-inset-bottom));
- }
- table {
- margin-top: 8px;
- }
- th {
- width: 126px;
- }
- .nature-switch {
- display: flex;
- gap: 8px;
- }
- .nature-btn {
- min-width: 76px;
- height: 36px;
- color: #333;
- background: #f3f4f6;
- border: 1px solid #d7dbe2;
- border-radius: 5px;
- font-size: 15px;
- }
- .nature-btn.active {
- color: #fff;
- background: #575d6d;
- border-color: #575d6d;
- }
- .participant-row {
- display: grid;
- grid-template-columns: minmax(0, 1fr) 82px;
- gap: 8px;
- align-items: center;
- }
- .add-btn {
- height: 38px;
- color: #333;
- background: #f0f1f3;
- border: 1px solid #d7dbe2;
- border-radius: 5px;
- font-size: 15px;
- }
- .participants {
- display: flex;
- flex-wrap: wrap;
- gap: 8px;
- margin-top: 8px;
- }
- .participant {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- padding: 6px 9px;
- color: #333;
- background: #f3f4f6;
- border: 1px solid #d7dbe2;
- border-radius: 4px;
- font-size: 14px;
- }
- .participant-remove {
- padding: 0;
- color: #8b95a5;
- background: transparent;
- border: 0;
- font-size: 18px;
- line-height: 1;
- }
- .ms-textarea {
- width: 100%;
- min-height: 72px;
- padding: 8px 0;
- color: #333;
- background: transparent;
- border: 0;
- outline: none;
- font: inherit;
- resize: none;
- }
- .bottom-bar {
- position: fixed;
- left: 0;
- right: 0;
- bottom: 0;
- z-index: 20;
- display: flex;
- gap: 10px;
- padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
- background: #fff;
- box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.08);
- box-sizing: border-box;
- }
- .bottom-bar button {
- flex: 1;
- height: 44px;
- border: 0;
- border-radius: 6px;
- font-size: 16px;
- }
- .bottom-bar button:disabled {
- opacity: 0.6;
- }
- .btn-close {
- flex: 0 0 34% !important;
- color: #333;
- background: #f0f1f3;
- }
- .btn-submit {
- color: #fff;
- background: #575d6d;
- }
- </style>
- </head>
- <body>
- <div id="app" v-cloak>
- <table class="table">
- <tr>
- <th>获奖性质</th>
- <td>
- <div class="nature-switch">
- <button type="button" class="nature-btn"
- :class="{active: formData.hjxz === '1'}"
- @click="changeNature('1')">个人</button>
- <button type="button" class="nature-btn"
- :class="{active: formData.hjxz === '2'}"
- @click="changeNature('2')">集体</button>
- </div>
- </td>
- </tr>
- <tr>
- <th>获奖类别</th>
- <td>
- <ss-select
- v-model="formData.hjlbm"
- cb="hjlb"
- clearable
- placeholder="请选择"
- />
- </td>
- </tr>
- <tr>
- <th>获奖日期</th>
- <td>
- <ss-datetime-picker
- v-model="formData.hjrq"
- mode="date"
- placeholder="请选择日期"
- />
- </td>
- </tr>
- <tr v-if="formData.hjxz === '1'">
- <th>获奖学生</th>
- <td>
- <ss-select
- v-model="formData.ryid"
- cb="xy"
- inp="true"
- clearable
- placeholder="输入姓名查询"
- />
- </td>
- </tr>
- <tr v-if="formData.hjxz === '2'">
- <th>参与学生</th>
- <td>
- <div class="participant-row">
- <ss-select
- v-model="participantToAdd"
- cb="xy"
- inp="true"
- clearable
- placeholder="输入姓名查询"
- @loaded="onStudentOptionsLoaded"
- />
- <button type="button" class="add-btn" @click="addParticipant">
- 添加
- </button>
- </div>
- <div v-if="participants.length" class="participants">
- <span v-for="item in participants" :key="item.ryid"
- class="participant">
- {{ item.name || item.ryid }}
- <button type="button" class="participant-remove"
- @click="removeParticipant(item.ryid)">×</button>
- </span>
- </div>
- </td>
- </tr>
- <tr class="ms-row">
- <th>描述</th>
- <td>
- <textarea
- v-model="formData.ms"
- class="ms-textarea"
- placeholder="请录入获奖说明"
- ></textarea>
- </td>
- </tr>
- </table>
- <div class="bottom-bar">
- <button type="button" class="btn-close" @click="goBack">关闭</button>
- <button type="button" class="btn-submit" :disabled="submitting"
- @click="submitForm">
- {{ submitting ? '提交中...' : '保存并提交' }}
- </button>
- </div>
- </div>
- <script>
- const formatLocalDate = (date) => {
- const year = date.getFullYear();
- const month = String(date.getMonth() + 1).padStart(2, "0");
- const day = String(date.getDate()).padStart(2, "0");
- return `${year}-${month}-${day}`;
- };
- (function hideShellBottomBarEarly() {
- try {
- const embedded =
- new URLSearchParams(window.location.search).get("embed") === "1";
- const parentWin = window.parent;
- if (embedded && parentWin &&
- typeof parentWin.__mpObjInpSetBottomVisible === "function") {
- parentWin.__mpObjInpSetBottomVisible(false);
- }
- } catch (_) {}
- })();
- window.SS.ready(function () {
- window.SS.dom.initializeFormApp({
- el: "#app",
- data() {
- return {
- formData: {
- hjxz: "1",
- hjlbm: "",
- hjrq: formatLocalDate(new Date()),
- ryid: "",
- ms: ""
- },
- participantToAdd: "",
- participants: [],
- studentOptions: [],
- submitting: false
- };
- },
- methods: {
- changeNature(value) {
- this.formData.hjxz = value;
- if (value === "1") {
- this.participants = [];
- this.participantToAdd = "";
- } else {
- this.formData.ryid = "";
- }
- },
- onStudentOptionsLoaded(options) {
- this.studentOptions = Array.isArray(options) ? options : [];
- },
- addParticipant() {
- const ryid = String(this.participantToAdd || "").trim();
- if (!ryid) {
- this.toast("请选择参与学生", "warning");
- return;
- }
- if (this.participants.some((item) => item.ryid === ryid)) {
- this.toast("该学生已添加", "warning");
- return;
- }
- const option = this.studentOptions.find(
- (item) => String(item.v) === ryid
- );
- this.participants.push({
- ryid: ryid,
- name: option ? String(option.n || ryid) : ryid
- });
- this.participantToAdd = "";
- },
- removeParticipant(ryid) {
- this.participants = this.participants.filter(
- (item) => item.ryid !== ryid
- );
- },
- validateForm() {
- if (!this.formData.hjxz) return "请选择获奖性质";
- if (!this.formData.hjlbm) return "请选择获奖类别";
- if (!this.formData.hjrq) return "请选择获奖日期";
- if (this.formData.hjxz === "1" && !this.formData.ryid)
- return "请选择获奖学生";
- if (this.formData.hjxz === "2" && !this.participants.length)
- return "请至少添加一名参与学生";
- return "";
- },
- buildPayload() {
- return {
- ssObjName: "xxhjjl",
- hjxz: this.formData.hjxz,
- hjxzm: this.formData.hjxz === "2" ? "5" : "1",
- hjlbm: this.formData.hjlbm,
- hjrq: this.formData.hjrq,
- ryid: this.formData.ryid,
- ryids: this.formData.hjxz === "2"
- ? this.participants.map((item) => item.ryid).join(",")
- : "",
- ms: String(this.formData.ms || "").trim()
- };
- },
- async submitForm() {
- if (this.submitting) return;
- const message = this.validateForm();
- if (message) {
- this.toast(message, "warning");
- return;
- }
- this.submitting = true;
- try {
- const req = window.request;
- if (!req || typeof req.post !== "function")
- throw new Error("request 未就绪");
- const response = await req.post(
- "/service?ssServ=xxhjjlMp_save",
- this.buildPayload(),
- { loading: true, formData: true }
- );
- const body = response && response.data ? response.data : {};
- const result = body.ssData || body;
- const code = body.ssCode;
- if (code !== undefined && Number(code) !== 0) {
- throw new Error(body.msg || body.message || "提交失败");
- }
- if (result && result.warnMsg) {
- this.toast(result.warnMsg, "warning");
- } else {
- this.toast("提交成功", "success");
- }
- setTimeout(() => this.goBack(), 800);
- } catch (error) {
- console.error("[mp_xxhjjl_inp] 提交失败", error);
- const raw = error && error.message ? String(error.message) : "";
- const readable = /[\u4e00-\u9fa5]/.test(raw) && raw.length <= 60;
- this.toast(readable ? raw : "提交失败,请稍后重试", "error");
- } finally {
- this.submitting = false;
- }
- },
- toast(message, type) {
- try {
- if (typeof showToastEffect === "function") {
- showToastEffect(message, 1800, type || "info");
- return;
- }
- } catch (_) {}
- try {
- if (typeof showToast === "function")
- showToast(message, type || "info");
- } catch (_) {}
- },
- goBack() {
- const hostWin =
- window.parent && window.parent !== window
- ? window.parent
- : window;
- try {
- if (hostWin.NavigationManager &&
- typeof hostWin.NavigationManager.goBack === "function") {
- hostWin.NavigationManager.goBack({ refreshParent: true });
- return;
- }
- } catch (_) {}
- try {
- hostWin.history.back();
- } catch (_) {}
- }
- }
- });
- });
- </script>
- </body>
- </html>
|