mp_ssnwjc_inp.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <!-- 2026-09-18 宿舍内务检查小程序专用页面。 -->
  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=20261201-list-return-v1"></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: #222222;
  20. --green-soft: #f5f6f8;
  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. position: relative;
  81. display: grid;
  82. grid-template-columns: 92px 1fr;
  83. min-height: 58px;
  84. border-bottom: 1px solid var(--line);
  85. }
  86. .info-row.required::before {
  87. content: "";
  88. position: absolute;
  89. left: 92px;
  90. top: 0;
  91. bottom: 0;
  92. width: 2px;
  93. background: #ff3b30;
  94. z-index: 1;
  95. }
  96. .info-row:last-child {
  97. border-bottom: none;
  98. }
  99. .info-label {
  100. display: flex;
  101. align-items: center;
  102. justify-content: flex-end;
  103. padding: 12px 14px;
  104. color: var(--muted);
  105. background: #fbfbfc;
  106. border-right: 1px solid var(--line);
  107. font-size: 15px;
  108. }
  109. .info-value {
  110. display: flex;
  111. align-items: center;
  112. min-width: 0;
  113. padding: 11px 12px;
  114. font-size: 15px;
  115. }
  116. .select-cell {
  117. width: 100%;
  118. min-width: 0;
  119. }
  120. .select-cell > .ss-select-container {
  121. width: 100%;
  122. min-width: 0;
  123. }
  124. .clickable {
  125. justify-content: space-between;
  126. gap: 10px;
  127. cursor: pointer;
  128. }
  129. .clickable-text {
  130. min-width: 0;
  131. overflow: hidden;
  132. text-overflow: ellipsis;
  133. white-space: nowrap;
  134. }
  135. .chevron {
  136. flex: 0 0 auto;
  137. color: #9aa3b2;
  138. font-size: 25px;
  139. line-height: 1;
  140. }
  141. .score-value {
  142. color: var(--green);
  143. font-weight: 700;
  144. font-size: 18px;
  145. }
  146. .veto-value {
  147. display: flex;
  148. align-items: center;
  149. justify-content: space-between;
  150. gap: 12px;
  151. width: 100%;
  152. }
  153. .veto-buttons {
  154. display: flex;
  155. align-items: center;
  156. gap: 10px;
  157. }
  158. .native-input {
  159. width: 100%;
  160. height: 38px;
  161. padding: 0 10px;
  162. color: var(--text);
  163. background: #fff;
  164. border: 0;
  165. outline: none;
  166. font: inherit;
  167. }
  168. .native-input::placeholder {
  169. color: #b4bbc6;
  170. }
  171. .score-table {
  172. margin-top: 12px;
  173. }
  174. .score-row {
  175. display: grid;
  176. grid-template-columns: minmax(0, 1fr) 132px;
  177. min-height: 68px;
  178. overflow: visible;
  179. border-bottom: 1px solid var(--line);
  180. }
  181. .score-row:last-child {
  182. border-bottom: none;
  183. }
  184. .score-name {
  185. display: flex;
  186. align-items: center;
  187. padding: 10px 12px;
  188. line-height: 1.45;
  189. font-size: 15px;
  190. }
  191. .score-max {
  192. display: flex;
  193. align-items: center;
  194. justify-content: center;
  195. color: var(--muted);
  196. border-left: 1px solid var(--line);
  197. font-size: 16px;
  198. }
  199. .stepper {
  200. display: grid;
  201. grid-template-columns: 48px minmax(0, 1fr) 40px;
  202. align-items: center;
  203. width: auto;
  204. min-width: 0;
  205. margin: 10px 7px;
  206. background: #fff;
  207. border: 1px solid #cfd4dc;
  208. border-radius: 5px;
  209. overflow: hidden;
  210. }
  211. .stepper-btn {
  212. display: inline-flex;
  213. align-items: center;
  214. justify-content: center;
  215. gap: 1px;
  216. height: 44px;
  217. padding: 0;
  218. color: #596273;
  219. background: #f3f4f6;
  220. border: 0;
  221. font-size: 24px;
  222. line-height: 1;
  223. appearance: none;
  224. }
  225. .stepper-btn:disabled {
  226. color: #c8cdd5;
  227. background: #eceff2;
  228. }
  229. .stepper-deduct-num {
  230. font-size: 15px;
  231. font-weight: 400;
  232. line-height: 1;
  233. }
  234. .stepper-btn-symbol {
  235. line-height: 1;
  236. }
  237. .stepper-value {
  238. width: 100%;
  239. min-width: 0;
  240. height: 44px;
  241. padding: 0 4px;
  242. text-align: center;
  243. background: #fff;
  244. border: 0;
  245. border-left: 1px solid #e1e4e9;
  246. border-right: 1px solid #e1e4e9;
  247. outline: none;
  248. font: inherit;
  249. font-size: 15px;
  250. font-weight: 400;
  251. }
  252. .score-total {
  253. display: flex;
  254. align-items: center;
  255. justify-content: space-between;
  256. padding: 14px 4px 0;
  257. color: var(--muted);
  258. font-size: 14px;
  259. }
  260. .score-total strong {
  261. color: var(--green);
  262. font-size: 18px;
  263. }
  264. .empty-tip {
  265. padding: 16px 12px;
  266. color: var(--muted);
  267. text-align: center;
  268. font-size: 14px;
  269. }
  270. .sheet {
  271. max-height: 72vh;
  272. padding: 18px 16px 24px;
  273. background: #fff;
  274. }
  275. .sheet-mask {
  276. position: fixed;
  277. z-index: 9999;
  278. top: 0;
  279. right: 0;
  280. bottom: 0;
  281. left: 0;
  282. display: flex;
  283. align-items: flex-end;
  284. background: rgba(0, 0, 0, 0.35);
  285. }
  286. .sheet-mask .sheet {
  287. width: 100%;
  288. border-radius: 8px 8px 0 0;
  289. }
  290. .sheet-title {
  291. margin: 0 0 14px;
  292. font-size: 17px;
  293. font-weight: 700;
  294. }
  295. .sheet-list {
  296. overflow-y: auto;
  297. max-height: 58vh;
  298. }
  299. .sheet-item {
  300. padding: 13px 0;
  301. border-bottom: 1px solid #eef0f3;
  302. }
  303. .sheet-item:last-child {
  304. border-bottom: none;
  305. }
  306. .sheet-main {
  307. font-size: 15px;
  308. font-weight: 600;
  309. }
  310. .sheet-sub {
  311. margin-top: 4px;
  312. color: var(--muted);
  313. font-size: 13px;
  314. }
  315. .class-option {
  316. display: flex;
  317. align-items: center;
  318. justify-content: space-between;
  319. cursor: pointer;
  320. }
  321. .class-option.selected {
  322. color: var(--green);
  323. }
  324. .warning-bar {
  325. margin: 12px 14px 0;
  326. padding: 11px 12px;
  327. color: #9a6700;
  328. background: #fff8e6;
  329. border: 1px solid #ffe8a3;
  330. border-radius: 6px;
  331. line-height: 1.5;
  332. font-size: 14px;
  333. }
  334. .submit-hint {
  335. margin: 12px 14px 0;
  336. padding: 11px 12px;
  337. color: var(--danger);
  338. background: var(--danger-soft);
  339. border: 1px solid #ffd0d0;
  340. border-radius: 6px;
  341. line-height: 1.5;
  342. font-size: 14px;
  343. }
  344. .bottom-spacer {
  345. height: 16px;
  346. }
  347. </style>
  348. </head>
  349. <body>
  350. <div id="app" v-cloak>
  351. <div v-if="loading" class="loading-container">
  352. <div class="loading-spinner"></div>
  353. <div>加载中...</div>
  354. </div>
  355. <div v-else-if="errorMsg" class="error-box">
  356. {{ errorMsg }}
  357. </div>
  358. <template v-else>
  359. <div v-if="warnMsg" class="warning-bar">{{ warnMsg }}</div>
  360. <div v-if="submitHint" class="submit-hint">{{ submitHint }}</div>
  361. <div class="page-content">
  362. <div class="info-table">
  363. <div class="info-row required">
  364. <div class="info-label">建筑物</div>
  365. <div class="info-value">
  366. <div class="select-cell">
  367. <ss-select
  368. v-model="form.jzwid"
  369. cb="xyssl"
  370. placeholder=""
  371. @change="onJzwChange"
  372. />
  373. </div>
  374. </div>
  375. </div>
  376. <div class="info-row required">
  377. <div class="info-label">房间</div>
  378. <div class="info-value">
  379. <div class="select-cell">
  380. <ss-select
  381. :key="'room-' + form.jzwid"
  382. v-model="form.kfid"
  383. :options="roomOptions"
  384. :disabled="!form.jzwid || roomLoading"
  385. :placeholder="roomLoading ? '加载中...' : (form.jzwid ? '房间' : '')"
  386. @change="onKfChange"
  387. />
  388. </div>
  389. </div>
  390. </div>
  391. <div class="info-row">
  392. <div class="info-label">分数</div>
  393. <div class="info-value">
  394. <span class="score-value">{{ totalFs }}</span>
  395. <span class="score-max">/ {{ maxFs }}</span>
  396. </div>
  397. </div>
  398. <div class="info-row">
  399. <div class="info-label">一票否决</div>
  400. <div class="info-value">
  401. <div class="veto-buttons">
  402. <ss-onoff-button v-model="vetoValue" name="vetoY" label="是" value="1" @change="onVetoBtnChange"></ss-onoff-button>
  403. <ss-onoff-button v-model="vetoValue" name="vetoN" label="否" value="0" @change="onVetoBtnChange"></ss-onoff-button>
  404. </div>
  405. </div>
  406. </div>
  407. <div class="info-row">
  408. <div class="info-label">说明</div>
  409. <div class="info-value">
  410. <input
  411. v-model="form.ms"
  412. class="native-input"
  413. maxlength="500"
  414. placeholder=""
  415. />
  416. </div>
  417. </div>
  418. </div>
  419. <div class="score-table">
  420. <div v-if="!jcxmList.length" class="empty-tip">暂无评分项目</div>
  421. <div v-for="item in jcxmList" :key="item.ssnwjcxmm" class="score-row">
  422. <!-- 项目名称后固定展示满分,不随当前得分变化。 -->
  423. <div class="score-name">{{ item.mc }} ({{ item.mfz }})</div>
  424. <div class="stepper">
  425. <button
  426. class="stepper-btn"
  427. type="button"
  428. :disabled="form.veto || Number(item.value) <= 0"
  429. @click="changeScore(item, -5)"
  430. >
  431. <span class="stepper-btn-symbol">-</span><span
  432. v-if="deductedFs(item) > 0"
  433. class="stepper-deduct-num">{{ deductedFs(item) }}</span>
  434. </button>
  435. <input
  436. class="stepper-value"
  437. inputmode="numeric"
  438. :value="item.value"
  439. :min="0"
  440. :max="item.mfz"
  441. :disabled="form.veto"
  442. @input="onScoreInput(item, $event)"
  443. @blur="normalizeScore(item, $event)"
  444. />
  445. <button
  446. class="stepper-btn"
  447. type="button"
  448. :disabled="form.veto || Number(item.value) >= Number(item.mfz)"
  449. @click="changeScore(item, 5)"
  450. >
  451. +
  452. </button>
  453. </div>
  454. </div>
  455. </div>
  456. <div class="score-total">
  457. <span>评分合计</span>
  458. <strong>{{ totalFs }}</strong>
  459. </div>
  460. <div class="bottom-spacer"></div>
  461. </div>
  462. <ss-bottom
  463. :show-shyj="false"
  464. :buttons="submitting ? [{ text: '提交中...', action: 'submit' }] : bottomButtons"
  465. @button-click="handleBottomAction"
  466. :disabled="submitting"
  467. />
  468. </template>
  469. </div>
  470. <script>
  471. window.SS.ready(function () {
  472. const LIST_PAGE = "/page/mp/mp_ssnwjc_list.html";
  473. window.SS.dom.initializeFormApp({
  474. el: "#app",
  475. data() {
  476. return {
  477. loading: true,
  478. submitting: false,
  479. errorMsg: "",
  480. warnMsg: "",
  481. submitHint: "",
  482. pageParams: {},
  483. jcxmList: [],
  484. beforeVetoScores: [],
  485. roomOptions: [],
  486. roomLoading: false,
  487. form: {
  488. jzwid: "",
  489. kfid: "",
  490. ms: "",
  491. veto: false
  492. },
  493. vetoValue: "0",
  494. bottomButtons: [
  495. { text: "取消", action: "cancel" },
  496. { text: "保存并提交", action: "submit" }
  497. ]
  498. };
  499. },
  500. computed: {
  501. totalFs() {
  502. return this.jcxmList.reduce((sum, item) => sum + Number(item.value || 0), 0);
  503. },
  504. maxFs() {
  505. return this.jcxmList.reduce((sum, item) => sum + Number(item.mfz || 0), 0);
  506. }
  507. },
  508. async mounted() {
  509. this.pageParams = this.getUrlParams();
  510. window.addEventListener("pageshow", this.onPageShow);
  511. try {
  512. const sessionOk = await this.ensureSession();
  513. if (!sessionOk) return;
  514. await this.loadJcxm();
  515. this.restoreState();
  516. } catch (error) {
  517. console.error("[mp_ssnwjc_inp] 初始化失败", error);
  518. this.errorMsg = error && error.message ? error.message : "页面初始化失败";
  519. } finally {
  520. this.loading = false;
  521. }
  522. },
  523. methods: {
  524. onPageShow() {
  525. this.restoreState();
  526. },
  527. getUrlParams() {
  528. const params = {};
  529. const search = new URLSearchParams(window.location.search);
  530. for (const [key, value] of search) {
  531. params[key] = decodeURIComponent(value);
  532. }
  533. return params;
  534. },
  535. getRequest() {
  536. return (window && window.request) || request;
  537. },
  538. async ensureSession() {
  539. if (typeof window.ensureMiniProgramSessionFresh !== "function") {
  540. return true;
  541. }
  542. try {
  543. const result = await window.ensureMiniProgramSessionFresh({
  544. page: "mp_ssnwjc_inp",
  545. service: "ssnwjc_excelInitAdd",
  546. force: true
  547. });
  548. if (result && result.skipped && result.reason === "NO_URL_AUTH") {
  549. return true;
  550. }
  551. return true;
  552. } catch (error) {
  553. this.errorMsg = "登录状态刷新失败,请返回小程序重新进入";
  554. return false;
  555. }
  556. },
  557. async loadJcxm() {
  558. const result = await this.postService(
  559. "/service?ssServ=ssnwjc_excelInitAdd&ssDest=data",
  560. {}
  561. );
  562. this.jcxmList = (result || []).map((item) => ({
  563. ssnwjcxmm: Number(item.ssnwjcxmm),
  564. mc: item.mc,
  565. mfz: Number(item.mfz),
  566. value: Number(item.mfz)
  567. }));
  568. },
  569. async postService(url, data) {
  570. const req = this.getRequest();
  571. if (!req || typeof req.post !== "function") {
  572. throw new Error("请求组件未加载");
  573. }
  574. const response = await req.post(url, data, {
  575. loading: false,
  576. formData: true
  577. });
  578. const raw = response && response.data !== undefined ? response.data : response;
  579. if (raw && raw.ssCode !== undefined && Number(raw.ssCode) !== 0) {
  580. throw new Error(raw.ssMsg || "请求失败");
  581. }
  582. return raw && raw.ssData !== undefined ? raw.ssData : raw;
  583. },
  584. async onJzwChange(value) {
  585. this.form.jzwid = String(value || "");
  586. this.form.kfid = "";
  587. this.roomOptions = [];
  588. if (!this.form.jzwid) return;
  589. try {
  590. this.roomLoading = true;
  591. const data = await this.postService(
  592. "/service?ssServ=ssnwjc_mpLoadRoom&ssDest=data",
  593. { jzwid: this.form.jzwid }
  594. );
  595. this.roomOptions = (data && data.rooms ? data.rooms : []).map((room) => ({
  596. n: room.mc,
  597. v: String(room.cdid)
  598. }));
  599. } catch (error) {
  600. this.roomOptions = [];
  601. this.showToast(error.message || "房间加载失败", "fail");
  602. } finally {
  603. this.roomLoading = false;
  604. }
  605. },
  606. async onKfChange(value) {
  607. this.form.kfid = String(value || "");
  608. if (!this.form.kfid) return;
  609. try {
  610. await this.postService(
  611. "/service?ssServ=ssnwjc_mpLoadRoom&ssDest=data",
  612. {
  613. jzwid: this.form.jzwid,
  614. kfid: this.form.kfid
  615. }
  616. );
  617. } catch (error) {
  618. this.showToast(error.message || "房间信息加载失败", "fail");
  619. }
  620. },
  621. saveState() {
  622. try {
  623. sessionStorage.setItem("mp_ssnwjc_inp_state", JSON.stringify({
  624. form: this.form,
  625. jcxmList: this.jcxmList,
  626. roomOptions: this.roomOptions,
  627. beforeVetoScores: this.beforeVetoScores
  628. }));
  629. } catch (error) {
  630. console.warn("[mp_ssnwjc_inp] 保存页面状态失败", error);
  631. }
  632. },
  633. restoreState() {
  634. try {
  635. const raw = sessionStorage.getItem("mp_ssnwjc_inp_state");
  636. if (!raw) return;
  637. const state = JSON.parse(raw);
  638. if (state.form) this.form = { ...this.form, ...state.form };
  639. this.vetoValue = this.form.veto ? "1" : "0";
  640. if (Array.isArray(state.roomOptions)) this.roomOptions = state.roomOptions;
  641. if (Array.isArray(state.beforeVetoScores)) this.beforeVetoScores = state.beforeVetoScores;
  642. if (Array.isArray(state.jcxmList)) {
  643. const valueMap = new Map(
  644. state.jcxmList.map((item) => [String(item.ssnwjcxmm), item.value])
  645. );
  646. this.jcxmList = this.jcxmList.map((item) => ({
  647. ...item,
  648. value: valueMap.has(String(item.ssnwjcxmm))
  649. ? valueMap.get(String(item.ssnwjcxmm))
  650. : item.value
  651. }));
  652. }
  653. } catch (error) {
  654. console.warn("[mp_ssnwjc_inp] 恢复页面状态失败", error);
  655. }
  656. },
  657. clearState() {
  658. try {
  659. sessionStorage.removeItem("mp_ssnwjc_inp_state");
  660. } catch (_) {
  661. }
  662. },
  663. changeScore(item, delta) {
  664. if (this.form.veto) return;
  665. const next = Number(item.value || 0) + delta;
  666. item.value = Math.max(0, Math.min(Number(item.mfz), next));
  667. },
  668. deductedFs(item) {
  669. return Math.max(0, Number(item.mfz || 0) - Number(item.value || 0));
  670. },
  671. onScoreInput(item, event) {
  672. const raw = String(event.target.value || "").replace(/[^\d]/g, "");
  673. const next = raw === "" ? 0 : Number(raw);
  674. item.value = Math.max(0, Math.min(Number(item.mfz), next || 0));
  675. event.target.value = item.value;
  676. },
  677. normalizeScore(item, event) {
  678. const value = Number(item.value || 0);
  679. item.value = Math.max(0, Math.min(Number(item.mfz), value || 0));
  680. if (event && event.target) event.target.value = item.value;
  681. },
  682. onVetoChange(value) {
  683. if (value) {
  684. this.beforeVetoScores = this.jcxmList.map((item) => Number(item.value || 0));
  685. this.jcxmList.forEach((item) => {
  686. item.value = 0;
  687. });
  688. } else if (this.beforeVetoScores.length === this.jcxmList.length) {
  689. this.jcxmList.forEach((item, index) => {
  690. item.value = this.beforeVetoScores[index];
  691. });
  692. this.beforeVetoScores = [];
  693. } else {
  694. this.jcxmList.forEach((item) => {
  695. item.value = Number(item.mfz);
  696. });
  697. }
  698. },
  699. onVetoBtnChange(value) {
  700. const isVeto = String(value) === "1";
  701. if (isVeto === this.form.veto) return;
  702. this.form.veto = isVeto;
  703. this.onVetoChange(isVeto);
  704. },
  705. handleBottomAction(data) {
  706. if (data.action === "cancel") {
  707. this.goBack();
  708. } else if (data.action === "submit") {
  709. this.submit();
  710. }
  711. },
  712. validateForm() {
  713. if (!this.form.jzwid) return "请选择建筑物";
  714. if (!this.form.kfid) return "请选择房间";
  715. if (!this.jcxmList.length) return "评分项目未配置";
  716. return "";
  717. },
  718. buildSubmitData() {
  719. const data = {
  720. jzwid: this.form.jzwid,
  721. kfid: this.form.kfid,
  722. fs: this.totalFs,
  723. ms: (this.form.ms || "").trim(),
  724. veto: this.form.veto ? "1" : "0"
  725. };
  726. this.jcxmList.forEach((item) => {
  727. data["ssnwjcxmm" + item.ssnwjcxmm] = item.value;
  728. });
  729. return data;
  730. },
  731. async submit() {
  732. if (this.submitting) return;
  733. const message = this.validateForm();
  734. if (message) {
  735. this.submitHint = message;
  736. this.showToast(message, "fail");
  737. return;
  738. }
  739. try {
  740. this.submitting = true;
  741. this.warnMsg = "";
  742. this.submitHint = "";
  743. const result = await this.postService(
  744. "/service?ssServ=ssnwjc_mpSubmAdd&ssDest=data",
  745. this.buildSubmitData()
  746. );
  747. if (result && result.warnMsg) {
  748. this.warnMsg = result.warnMsg;
  749. this.submitHint = result.warnMsg;
  750. this.showToast(result.warnMsg, "fail");
  751. return;
  752. }
  753. this.clearState();
  754. this.showToast("提交成功", "success");
  755. const listDate = this.formatLocalDate(new Date());
  756. setTimeout(() => {
  757. window.NavigationManager.returnToList(LIST_PAGE, {
  758. refreshData: { date: listDate },
  759. storageValues: {
  760. "mp_ssnwjc_list_refresh": "1",
  761. "mp_ssnwjc_list_date": listDate
  762. }
  763. });
  764. }, 900);
  765. } catch (error) {
  766. this.submitHint = error.message || "提交失败";
  767. this.showToast(this.submitHint, "fail");
  768. } finally {
  769. this.submitting = false;
  770. }
  771. },
  772. goBack() {
  773. this.clearState();
  774. if (this.pageParams && this.pageParams.from === "list") {
  775. if (window.history.length > 1) {
  776. window.history.back();
  777. } else {
  778. window.location.href = "/page/mp/mp_ssnwjc_list.html";
  779. }
  780. return;
  781. }
  782. if (window.wx && window.wx.miniProgram) {
  783. window.wx.miniProgram.navigateBack({ delta: 1 });
  784. } else if (window.history.length > 1) {
  785. window.history.back();
  786. }
  787. },
  788. formatLocalDate(date) {
  789. const year = date.getFullYear();
  790. const month = String(date.getMonth() + 1).padStart(2, "0");
  791. const day = String(date.getDate()).padStart(2, "0");
  792. return `${year}-${month}-${day}`;
  793. },
  794. showToast(message, type) {
  795. const toastType = type === "success" ? "success" : "error";
  796. if (typeof window.showToastEffect === "function") {
  797. window.showToastEffect(message, 2200, toastType);
  798. return;
  799. }
  800. console.log(type, message);
  801. }
  802. }
  803. });
  804. });
  805. </script>
  806. </body>
  807. </html>