index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <route lang="json5" type="page">
  2. {
  3. layout: 'default',
  4. style: {
  5. navigationBarTitleText: '报告审批预览',
  6. navigationStyle: 'custom',
  7. },
  8. }
  9. </route>
  10. <template>
  11. <view class="preview-container">
  12. <!-- 导航栏 -->
  13. <NavBar title="报告审批预览" />
  14. <!-- 头部视图 -->
  15. <HeadView
  16. v-if="reportList.length > 0"
  17. :report-list="reportList"
  18. :select-report="selectReport"
  19. @update:select-report="handleReportSelect"
  20. />
  21. <!-- PDF 预览区域 -->
  22. <view class="pdf-container">
  23. <text class="preview-tip">报告预览功能待完善</text>
  24. <text class="preview-info">当前报告:{{ selectReport?.reportName || '-' }}</text>
  25. <text class="preview-info">报告类型:{{ getReportTypeName(selectReport?.reportType) }}</text>
  26. </view>
  27. <!-- 操作按钮 -->
  28. <view class="action-buttons">
  29. <view class="button-row">
  30. <button class="action-btn reject-btn" @click="handleReject">
  31. <text class="action-btn-text">退回</text>
  32. </button>
  33. <button class="action-btn approve-btn" @click="handleApprove">
  34. <text class="action-btn-text">通过审批</text>
  35. </button>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script lang="ts" setup>
  41. import { ref, onMounted } from 'vue'
  42. import { finishApi, rollbackApi } from '@/api/pendingRatify'
  43. import HeadView from '@/pages/pendingVerification/preViewReport/HeadView.vue'
  44. import NavBar from '@/components/NavBar/NavBar.vue'
  45. defineOptions({
  46. name: 'PendingRatifyPreview',
  47. })
  48. // 从路由参数获取数据
  49. const pages = getCurrentPages()
  50. const currentPage = pages[pages.length - 1] as any
  51. const options = currentPage.options || {}
  52. const id = ref(options.id || '')
  53. const orderId = ref(options.orderId || '')
  54. const reportDOList = ref<any[]>([])
  55. const equipCode = ref(options.equipCode || '')
  56. // 解析报告列表
  57. try {
  58. if (options.reportDOList) {
  59. reportDOList.value = JSON.parse(decodeURIComponent(options.reportDOList))
  60. }
  61. } catch (error) {
  62. console.error('解析报告列表失败:', error)
  63. }
  64. const reportList = ref<any[]>(reportDOList.value)
  65. const selectReport = ref<any>(reportList.value?.[0] || null)
  66. // 处理报告选择
  67. const handleReportSelect = (report: any) => {
  68. selectReport.value = report
  69. console.log('选择报告:', report)
  70. }
  71. // 获取报告类型名称
  72. const getReportTypeName = (reportType: string) => {
  73. const typeMap: Record<string, string> = {
  74. '100': '主报告',
  75. '200': '附件报告',
  76. }
  77. return typeMap[reportType] || reportType
  78. }
  79. // 退回
  80. const handleReject = async () => {
  81. if (!selectReport.value) {
  82. return uni.showToast({ title: '请选择报告', icon: 'error' })
  83. }
  84. uni.showModal({
  85. title: '退回确认',
  86. content: '确定要退回该报告吗?',
  87. success: async (res) => {
  88. if (res.confirm) {
  89. uni.showLoading({ title: '退回中...' })
  90. try {
  91. const result: any = await rollbackApi({
  92. id: selectReport.value.reportId,
  93. reason: '审批退回',
  94. })
  95. uni.hideLoading()
  96. if (result?.code === 0) {
  97. uni.showToast({ title: '退回成功', icon: 'success' })
  98. setTimeout(() => {
  99. uni.navigateBack()
  100. }, 1000)
  101. } else {
  102. uni.showToast({ title: result?.msg || '退回失败', icon: 'error' })
  103. }
  104. } catch (error) {
  105. console.error('退回失败:', error)
  106. uni.hideLoading()
  107. uni.showToast({ title: '退回失败,请重试', icon: 'error' })
  108. }
  109. }
  110. },
  111. })
  112. }
  113. // 通过审批
  114. const handleApprove = async () => {
  115. if (!selectReport.value) {
  116. return uni.showToast({ title: '请选择报告', icon: 'error' })
  117. }
  118. uni.showModal({
  119. title: '通过确认',
  120. content: '确定要通过该报告的审批吗?',
  121. success: async (res) => {
  122. if (res.confirm) {
  123. uni.showLoading({ title: '提交中...' })
  124. try {
  125. const result: any = await finishApi({
  126. id: selectReport.value.reportId,
  127. })
  128. uni.hideLoading()
  129. if (result?.code === 0) {
  130. uni.showToast({ title: '审批通过', icon: 'success' })
  131. setTimeout(() => {
  132. uni.navigateBack()
  133. }, 1000)
  134. } else {
  135. uni.showToast({ title: result?.msg || '审批失败', icon: 'error' })
  136. }
  137. } catch (error) {
  138. console.error('审批失败:', error)
  139. uni.hideLoading()
  140. uni.showToast({ title: '审批失败,请重试', icon: 'error' })
  141. }
  142. }
  143. },
  144. })
  145. }
  146. onMounted(() => {
  147. console.log('报告列表:', reportList.value)
  148. console.log('当前选择:', selectReport.value)
  149. })
  150. </script>
  151. <style lang="scss" scoped>
  152. .preview-container {
  153. display: flex;
  154. flex-direction: column;
  155. min-height: 100vh;
  156. background-color: #f5f5f5;
  157. }
  158. .navigate-view {
  159. display: flex;
  160. justify-content: center;
  161. align-items: center;
  162. height: 44px;
  163. background-color: #fff;
  164. border-bottom: 1px solid #eee;
  165. }
  166. .navigate-title {
  167. font-size: 17px;
  168. font-weight: 500;
  169. color: #333;
  170. }
  171. .pdf-container {
  172. flex: 1;
  173. display: flex;
  174. flex-direction: column;
  175. justify-content: center;
  176. align-items: center;
  177. padding: 20px;
  178. background-color: #fff;
  179. margin: 10px;
  180. border-radius: 5px;
  181. }
  182. .preview-tip {
  183. font-size: 18px;
  184. color: #666;
  185. margin-bottom: 20px;
  186. }
  187. .preview-info {
  188. font-size: 14px;
  189. color: #999;
  190. margin: 5px 0;
  191. }
  192. .action-buttons {
  193. padding: 20px;
  194. background-color: #fff;
  195. }
  196. .button-row {
  197. display: flex;
  198. flex-direction: row;
  199. justify-content: space-between;
  200. gap: 15px;
  201. }
  202. .action-btn {
  203. flex: 1;
  204. height: 44px;
  205. border-radius: 5px;
  206. display: flex;
  207. justify-content: center;
  208. align-items: center;
  209. border: none;
  210. font-size: 16px;
  211. }
  212. .reject-btn {
  213. background-color: #FF4445;
  214. color: #fff;
  215. }
  216. .approve-btn {
  217. background-color: #2f8eff;
  218. color: #fff;
  219. }
  220. .action-btn-text {
  221. color: #fff;
  222. font-size: 16px;
  223. }
  224. </style>