mp_addSure.html 8.4 KB

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