mp_addSure.html 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
  6. <title>确认提交</title>
  7. <script src="/js/mp_base/base.js"></script>
  8. <style>
  9. [v-cloak] {
  10. display: none !important;
  11. }
  12. #app {
  13. min-height: 100vh;
  14. background: #f5f5f5;
  15. box-sizing: border-box;
  16. }
  17. .form-wrap {
  18. background: #fff;
  19. }
  20. .table th {
  21. width: 140px;
  22. max-width: 170px;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <div id="app" v-cloak>
  28. <form id="tjform" class="form-wrap" @submit.prevent>
  29. <table class="table">
  30. <tr v-if="showPostRow">
  31. <th>岗位</th>
  32. <td>
  33. <!-- 功能说明:岗位下拉使用组件内置 cb 拉取(对齐PC addSure 的 objp.ss cb=bpmtjgwid) by xu 2026-02-28 -->
  34. <ss-select
  35. v-model="formData.bpmtjgwid"
  36. cb="bpmtjgwid"
  37. :auto-select-first="true"
  38. placeholder="请选择提交岗位"
  39. @loaded="handlePostOptionsLoaded"
  40. >
  41. </ss-select>
  42. </td>
  43. </tr>
  44. <tr class="desc-row">
  45. <th>{{ descLabel }}</th>
  46. <td>
  47. <!-- 功能说明:addSure 说明改为普通录入字段 ms,按当前移动端需求不使用富文本 by xu 2026-03-01 -->
  48. <ss-input
  49. v-model="formData.ms"
  50. name="ms"
  51. placeholder="请输入说明"
  52. />
  53. </td>
  54. </tr>
  55. </table>
  56. </form>
  57. <ss-bottom
  58. :buttons="bottomButtons"
  59. @button-click="handleBottomAction"
  60. >
  61. </ss-bottom>
  62. </div>
  63. <script>
  64. window.SS.ready(function () {
  65. window.SS.dom.initializeFormApp({
  66. el: '#app',
  67. data() {
  68. return {
  69. pageParams: {},
  70. submitting: false,
  71. showPostRow: true,
  72. descLabel: '说明',
  73. formData: {
  74. bpmtjgwid: '',
  75. ms: '',
  76. },
  77. bottomButtons: [
  78. {
  79. text: '确定',
  80. action: 'confirm',
  81. backgroundColor: '#575d6d',
  82. color: '#fff'
  83. }
  84. ]
  85. }
  86. },
  87. mounted() {
  88. this.pageParams = this.getUrlParams()
  89. // 功能说明:addSure 说明预填走通用字段优先级(sqms/sqmswj/ms),避免仅适配某个业务 by xu 2026-02-28
  90. const presetDesc = this.pageParams.sqms || this.pageParams.sqmswj || this.pageParams.ms || ''
  91. if (presetDesc) {
  92. this.formData.ms = String(presetDesc)
  93. }
  94. // 功能说明:对齐PC addSure:ssObjName=ws 时标题为“拟办意见”,否则为“说明” by xu 2026-02-28
  95. this.descLabel = String(this.pageParams.ssObjName || '').trim() === 'ws' ? '拟办意见' : '说明'
  96. // 功能说明:对齐PC addSure:print 非空时显示打印按钮 by xu 2026-02-28
  97. if (this.pageParams.print !== undefined && this.pageParams.print !== null && this.pageParams.print !== '') {
  98. this.bottomButtons = [
  99. { text: '打印', action: 'print' },
  100. {
  101. text: '确定',
  102. action: 'confirm',
  103. backgroundColor: '#575d6d',
  104. color: '#fff'
  105. }
  106. ]
  107. }
  108. },
  109. methods: {
  110. getUrlParams() {
  111. const params = {}
  112. const urlSearchParams = new URLSearchParams(window.location.search)
  113. for (const [key, value] of urlSearchParams) {
  114. params[key] = decodeURIComponent(value)
  115. }
  116. return params
  117. },
  118. goBack(refreshParent = false) {
  119. if (window.NavigationManager && typeof window.NavigationManager.goBack === 'function') {
  120. window.NavigationManager.goBack({ refreshParent })
  121. } else {
  122. window.history.back()
  123. }
  124. },
  125. // 功能说明:addSure 提交成功后优先回退两级返回 objList,避免停留在 objInp by xu 2026-03-01
  126. goBackToObjList() {
  127. try {
  128. if (window.NavigationManager && typeof window.NavigationManager.notifyParentRefresh === 'function') {
  129. window.NavigationManager.notifyParentRefresh()
  130. }
  131. } catch (_) {}
  132. const fromObjInp = String(this.pageParams.fromObjInp || '') === '1'
  133. if (fromObjInp && window.history.length > 2) {
  134. window.history.go(-2)
  135. return
  136. }
  137. this.goBack(true)
  138. },
  139. // 功能说明:对齐PC addSure:岗位下拉无选项时隐藏整行 by xu 2026-02-28
  140. handlePostOptionsLoaded(options) {
  141. const arr = Array.isArray(options) ? options : []
  142. this.showPostRow = arr.length > 0
  143. },
  144. handlePrint() {
  145. try {
  146. window.print()
  147. } catch (_) {}
  148. },
  149. // 功能说明:移动端 addSure “确定”提交 tjform 对应参数到 sureAdd 接口 by xu 2026-02-28
  150. async submitTjForm() {
  151. if (this.submitting) return
  152. const ssObjName = String(this.pageParams.ssObjName || '').trim()
  153. const ssObjIdName = String(this.pageParams.ssObjIdName || 'ssObjId').trim()
  154. const ssObjId = String(this.pageParams.ssObjId || '').trim()
  155. if (!ssObjName || !ssObjId) {
  156. if (typeof showToastEffect === 'function') showToastEffect('缺少对象参数,无法确认提交', 2200, 'error')
  157. return
  158. }
  159. this.submitting = true
  160. try {
  161. // 功能说明:addSure 提交接口改为 ${ssObjName}_lr_tj_qr(后缀固定) by xu 2026-03-01
  162. const confirmServ = `${ssObjName}_lr_tj_qr`
  163. const payload = {
  164. ssObjName,
  165. [ssObjIdName]: ssObjId,
  166. bpmtjgwid: this.formData.bpmtjgwid || '',
  167. ms: this.formData.ms || '',
  168. }
  169. const response = await request.post(
  170. `/service?ssServ=${encodeURIComponent(confirmServ)}`,
  171. payload,
  172. { loading: true, formData: true }
  173. )
  174. console.log('[mp_addSure] sureAdd响应', response)
  175. if (typeof showToastEffect === 'function') {
  176. showToastEffect('确认提交成功', 1500, 'success')
  177. }
  178. setTimeout(() => this.goBackToObjList(), 600)
  179. } catch (error) {
  180. console.error('[mp_addSure] sureAdd提交失败', error)
  181. if (typeof showToastEffect === 'function') {
  182. showToastEffect('确认提交失败,请稍后重试', 2200, 'error')
  183. }
  184. } finally {
  185. this.submitting = false
  186. }
  187. },
  188. handleBottomAction(payload) {
  189. if (!payload || !payload.action) return
  190. if (payload.action === 'print') {
  191. this.handlePrint()
  192. return
  193. }
  194. if (payload.action === 'confirm') {
  195. this.submitTjForm()
  196. }
  197. }
  198. }
  199. })
  200. })
  201. </script>
  202. </body>
  203. </html>