exception.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="page">
  3. <view class="header">
  4. <text class="header-title">异常登记{{ xm ? `(${xm})` : '' }}</text>
  5. </view>
  6. <view class="body">
  7. <textarea class="textarea" v-model="remark" />
  8. </view>
  9. <SsBottom :buttons="bottomButtons" @button-click="handleBottomAction" />
  10. </view>
  11. </template>
  12. <script setup>
  13. import { ref } from 'vue'
  14. import { onLoad } from '@dcloudio/uni-app'
  15. import SsBottom from '@/components/SsBottom/index.vue'
  16. import { xcdmApi } from '@/api/xcdm'
  17. const ryid = ref('')
  18. const xm = ref('')
  19. const site = ref('')
  20. const xcdmlbm = ref('1')
  21. const xcid = ref('')
  22. const jskssj = ref('')
  23. const jsjssj = ref('')
  24. const remark = ref('')
  25. onLoad((options) => {
  26. const safeDecode = (v) => {
  27. try {
  28. return decodeURIComponent(v || '')
  29. } catch (e) {
  30. return v || ''
  31. }
  32. }
  33. ryid.value = safeDecode(options?.zdryid || options?.ryid)
  34. xm.value = safeDecode(options?.xm)
  35. site.value = safeDecode(options?.site)
  36. xcdmlbm.value = safeDecode(options?.xcdmlbm || options?.mode || '1')
  37. xcid.value = safeDecode(options?.xcid)
  38. jskssj.value = safeDecode(options?.jskssj)
  39. jsjssj.value = safeDecode(options?.jsjssj)
  40. })
  41. const bottomButtons = [
  42. { text: '取消', action: 'cancel' },
  43. { text: '保存并提交', action: 'submit' }
  44. ]
  45. const handleBottomAction = ({ action }) => {
  46. if (action === 'cancel') {
  47. uni.navigateBack()
  48. return
  49. }
  50. if (action === 'submit') {
  51. handleSubmit()
  52. }
  53. }
  54. const handleSubmit = async () => {
  55. try {
  56. const to = Number(xcdmlbm.value) === 51 ? 61 : 11
  57. const payload = {
  58. xcid: xcid.value,
  59. xcdmlbm: Number(xcdmlbm.value) || 1,
  60. jskssj: jskssj.value,
  61. jsjssj: jsjssj.value,
  62. zdryid: ryid.value,
  63. xcjslbm: to,
  64. sm: remark.value
  65. }
  66. const res = await xcdmApi.mp_xcdmHomep_swState(payload)
  67. console.log('mp_xcdmHomep_swState (exception):', payload, res)
  68. uni.showToast({ title: '提交成功', icon: 'success' })
  69. setTimeout(() => {
  70. uni.navigateBack()
  71. }, 200)
  72. } catch (e) {
  73. console.warn('mp_xcdmHomep_swState (exception) failed:', e)
  74. uni.showToast({ title: '提交失败', icon: 'none' })
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .page {
  80. min-height: 100vh;
  81. background: #f2f3f4;
  82. box-sizing: border-box;
  83. position: relative;
  84. }
  85. .header {
  86. position: fixed;
  87. top: 0;
  88. left: 0;
  89. right: 0;
  90. height: 104rpx; // 约 52px
  91. background: #f2f3f4;
  92. display: flex;
  93. align-items: center;
  94. justify-content: center;
  95. z-index: 10;
  96. border-bottom: 1rpx solid #e8e8e8;
  97. }
  98. .header-title {
  99. font-size: 32rpx;
  100. color: #666;
  101. line-height: 1;
  102. }
  103. .body {
  104. position: absolute;
  105. top: 104rpx; // header
  106. left: 0;
  107. right: 0;
  108. bottom: 100rpx; // bottom buttons
  109. background: #fff;
  110. }
  111. .textarea {
  112. width: 100%;
  113. height: 100%;
  114. font-size: 30rpx;
  115. box-sizing: border-box;
  116. background: #fff;
  117. border: none;
  118. border-radius: 0;
  119. padding: 24rpx;
  120. }
  121. </style>