index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. <button class="action-btn submit-btn" @click="handleSubmit">
  30. <text class="action-btn-text">提交报告</text>
  31. </button>
  32. </view>
  33. </view>
  34. </template>
  35. <script lang="ts" setup>
  36. import { ref, onMounted } from 'vue'
  37. import { submitApi } from '@/api/pendingPreparation'
  38. import HeadView from '@/pages/pendingVerification/preViewReport/HeadView.vue'
  39. import NavBar from '@/components/NavBar/NavBar.vue'
  40. defineOptions({
  41. name: 'PendingPreparationPreview',
  42. })
  43. // 从路由参数获取数据
  44. const pages = getCurrentPages()
  45. const currentPage = pages[pages.length - 1] as any
  46. const options = currentPage.options || {}
  47. const id = ref(options.id || '')
  48. const orderId = ref(options.orderId || '')
  49. const reportDOList = ref<any[]>([])
  50. const equipCode = ref(options.equipCode || '')
  51. // 解析报告列表
  52. try {
  53. if (options.reportDOList) {
  54. reportDOList.value = JSON.parse(decodeURIComponent(options.reportDOList))
  55. }
  56. } catch (error) {
  57. console.error('解析报告列表失败:', error)
  58. }
  59. const reportList = ref<any[]>(reportDOList.value)
  60. const selectReport = ref<any>(reportList.value?.[0] || null)
  61. // 处理报告选择
  62. const handleReportSelect = (report: any) => {
  63. selectReport.value = report
  64. console.log('选择报告:', report)
  65. }
  66. // 获取报告类型名称
  67. const getReportTypeName = (reportType: string) => {
  68. const typeMap: Record<string, string> = {
  69. '100': '主报告',
  70. '200': '附件报告',
  71. }
  72. return typeMap[reportType] || reportType
  73. }
  74. // 提交报告
  75. const handleSubmit = async () => {
  76. if (!selectReport.value) {
  77. return uni.showToast({ title: '请选择报告', icon: 'error' })
  78. }
  79. uni.showLoading({ title: '提交中...' })
  80. try {
  81. const result: any = await submitApi({
  82. id: selectReport.value.id,
  83. // 添加其他必要的参数
  84. })
  85. uni.hideLoading()
  86. if (result?.code === 0) {
  87. uni.showToast({ title: '提交成功', icon: 'success' })
  88. // 返回上一页
  89. setTimeout(() => {
  90. uni.navigateBack()
  91. }, 1000)
  92. } else {
  93. uni.showToast({ title: result?.msg || '提交失败', icon: 'error' })
  94. }
  95. } catch (error) {
  96. console.error('提交失败:', error)
  97. uni.hideLoading()
  98. uni.showToast({ title: '提交失败,请重试', icon: 'error' })
  99. }
  100. }
  101. onMounted(() => {
  102. console.log('报告列表:', reportList.value)
  103. console.log('当前选择:', selectReport.value)
  104. })
  105. </script>
  106. <style lang="scss" scoped>
  107. .preview-container {
  108. display: flex;
  109. flex-direction: column;
  110. min-height: 100vh;
  111. background-color: #f5f5f5;
  112. }
  113. .navigate-view {
  114. display: flex;
  115. justify-content: center;
  116. align-items: center;
  117. height: 44px;
  118. background-color: #fff;
  119. border-bottom: 1px solid #eee;
  120. }
  121. .navigate-title {
  122. font-size: 17px;
  123. font-weight: 500;
  124. color: #333;
  125. }
  126. .pdf-container {
  127. flex: 1;
  128. display: flex;
  129. flex-direction: column;
  130. justify-content: center;
  131. align-items: center;
  132. padding: 20px;
  133. background-color: #fff;
  134. margin: 10px;
  135. border-radius: 5px;
  136. }
  137. .preview-tip {
  138. font-size: 18px;
  139. color: #666;
  140. margin-bottom: 20px;
  141. }
  142. .preview-info {
  143. font-size: 14px;
  144. color: #999;
  145. margin: 5px 0;
  146. }
  147. .action-buttons {
  148. padding: 20px;
  149. background-color: #fff;
  150. }
  151. .action-btn {
  152. height: 44px;
  153. border-radius: 5px;
  154. display: flex;
  155. justify-content: center;
  156. align-items: center;
  157. border: none;
  158. font-size: 16px;
  159. }
  160. .submit-btn {
  161. background-color: #2f8eff;
  162. color: #fff;
  163. }
  164. .action-btn-text {
  165. color: #fff;
  166. font-size: 16px;
  167. }
  168. </style>