report-management.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <view class="container">
  3. <view class="tab-bar">
  4. <view
  5. v-for="(tab, idx) in tabs"
  6. :key="idx"
  7. class="tab-item"
  8. :class="{ 'tab-active': activeTab === idx }"
  9. @click="activeTab = idx; loadData()"
  10. >
  11. <text>{{ tab.label }}</text>
  12. </view>
  13. </view>
  14. <view class="search-bar">
  15. <input
  16. class="search-input"
  17. v-model="keyword"
  18. placeholder="搜索报告标题或成员名称..."
  19. @confirm="loadData()"
  20. />
  21. </view>
  22. <scroll-view scroll-y class="report-list" @scrolltolower="loadMore">
  23. <view
  24. v-for="item in reports"
  25. :key="item.id"
  26. class="report-card"
  27. :class="'card-' + getCardClass(item.reportType)"
  28. @click="goToDetail(item)"
  29. >
  30. <view class="card-left">
  31. <view class="type-badge" :class="'badge-' + getCardClass(item.reportType)">
  32. <text>{{ item.reportTypeName }}</text>
  33. </view>
  34. <text class="card-title">{{ item.title }}</text>
  35. <view class="card-meta">
  36. <text class="subject-name">{{ item.subjectName }}</text>
  37. <text class="date-text">{{ formatDate(item.reportDate) }}</text>
  38. </view>
  39. </view>
  40. <view class="card-right">
  41. <text v-if="item.overallScore !== null && item.overallScore !== undefined" class="score">{{ item.overallScore }}<text class="score-unit">分</text></text>
  42. <text v-else class="score-text">{{ item.hasFile ? '有文件' : '结构化数据' }}</text>
  43. <text class="arrow">›</text>
  44. </view>
  45. </view>
  46. <view v-if="reports.length === 0 && !loading" class="empty">
  47. <text class="empty-icon">📋</text>
  48. <text class="empty-title">暂无报告</text>
  49. </view>
  50. </scroll-view>
  51. </view>
  52. </template>
  53. <script>
  54. import { getReportSummaryList } from '../../utils/api.js'
  55. export default {
  56. data() {
  57. return {
  58. tabs: [
  59. { label: '全部', type: 'all' },
  60. { label: '菌群', type: 'gut_flora' },
  61. { label: '体检', type: 'physical_exam' },
  62. { label: 'DAN', type: 'dan' },
  63. { label: '保单', type: 'insurance' },
  64. { label: '周报', type: 'fortune' }
  65. ],
  66. activeTab: 0,
  67. keyword: '',
  68. reports: [],
  69. page: 1,
  70. loading: false,
  71. hasMore: true
  72. }
  73. },
  74. onLoad() {
  75. this.loadData()
  76. },
  77. onPullDownRefresh() {
  78. this.page = 1
  79. this.reports = []
  80. this.hasMore = true
  81. this.loadData()
  82. },
  83. methods: {
  84. loadData() {
  85. var self = this
  86. if (self.loading) return
  87. if (!self.hasMore) return
  88. self.loading = true
  89. var params = {
  90. page: self.page,
  91. size: 20,
  92. type: self.tabs[self.activeTab].type,
  93. keyword: self.keyword
  94. }
  95. getReportSummaryList(params).then(function(res) {
  96. var list = res && res.data && res.data.records ? res.data.records : []
  97. if (self.page === 1) {
  98. self.reports = list
  99. } else {
  100. self.reports = self.reports.concat(list)
  101. }
  102. self.hasMore = list.length >= 20
  103. self.page++
  104. }).catch(function(e) {
  105. console.log('获取报告列表失败', e)
  106. uni.showToast({ title: '加载失败', icon: 'none' })
  107. }).finally(function() {
  108. self.loading = false
  109. uni.stopPullDownRefresh()
  110. })
  111. },
  112. loadMore() {
  113. if (!this.loading && this.hasMore) {
  114. this.loadData()
  115. }
  116. },
  117. goToDetail(item) {
  118. uni.navigateTo({
  119. url: '/pages/profile/report-detail?id=' + item.id + '&title=' + encodeURIComponent(item.title)
  120. })
  121. },
  122. getCardClass(reportType) {
  123. return reportType || 'default'
  124. },
  125. formatDate(dateStr) {
  126. if (!dateStr) return '--'
  127. try {
  128. var d = new Date(dateStr)
  129. var y = d.getFullYear()
  130. var m = ('' + (d.getMonth() + 1)).padStart(2, '0')
  131. var day = ('' + d.getDate()).padStart(2, '0')
  132. return y + '-' + m + '-' + day
  133. } catch (e) {
  134. return dateStr
  135. }
  136. }
  137. }
  138. }
  139. </script>
  140. <style scoped>
  141. .container {
  142. min-height: 100vh;
  143. background: #f5f7fa;
  144. display: flex;
  145. flex-direction: column;
  146. }
  147. .tab-bar {
  148. display: flex;
  149. flex-direction: row;
  150. background: #fff;
  151. padding: 20rpx 0;
  152. border-bottom: 1rpx solid #eee;
  153. overflow-x: auto;
  154. white-space: nowrap;
  155. }
  156. .tab-item {
  157. padding: 12rpx 24rpx;
  158. font-size: 26rpx;
  159. color: #666;
  160. margin: 0 8rpx;
  161. border-radius: 20rpx;
  162. }
  163. .tab-active {
  164. background: #5B9BD5;
  165. color: #fff;
  166. }
  167. .search-bar {
  168. padding: 16rpx 24rpx;
  169. background: #fff;
  170. }
  171. .search-input {
  172. background: #f5f5f5;
  173. border-radius: 12rpx;
  174. padding: 16rpx 24rpx;
  175. font-size: 26rpx;
  176. }
  177. .report-list {
  178. flex: 1;
  179. padding: 16rpx 24rpx;
  180. }
  181. .report-card {
  182. background: #fff;
  183. border-radius: 16rpx;
  184. padding: 24rpx;
  185. margin-bottom: 16rpx;
  186. display: flex;
  187. flex-direction: row;
  188. align-items: center;
  189. justify-content: space-between;
  190. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  191. }
  192. .card-left {
  193. display: flex;
  194. flex-direction: column;
  195. flex: 1;
  196. min-width: 0;
  197. }
  198. .type-badge {
  199. display: inline-block;
  200. font-size: 20rpx;
  201. padding: 4rpx 16rpx;
  202. border-radius: 12rpx;
  203. align-self: flex-start;
  204. margin-bottom: 8rpx;
  205. }
  206. .badge-gut_flora { background: #E8F5E9; color: #2E7D32; }
  207. .badge-physical_exam { background: #E3F2FD; color: #1565C0; }
  208. .badge-dan { background: #F3E5F5; color: #7B1FA2; }
  209. .badge-insurance { background: #FFF3E0; color: #E65100; }
  210. .badge-fortune { background: #FCE4EC; color: #C62828; }
  211. .card-title {
  212. font-size: 28rpx;
  213. font-weight: bold;
  214. color: #333;
  215. margin-bottom: 8rpx;
  216. overflow: hidden;
  217. text-overflow: ellipsis;
  218. white-space: nowrap;
  219. }
  220. .card-meta {
  221. display: flex;
  222. flex-direction: row;
  223. align-items: center;
  224. }
  225. .subject-name {
  226. font-size: 24rpx;
  227. color: #888;
  228. margin-right: 16rpx;
  229. }
  230. .date-text {
  231. font-size: 24rpx;
  232. color: #aaa;
  233. }
  234. .card-right {
  235. display: flex;
  236. flex-direction: row;
  237. align-items: center;
  238. gap: 8rpx;
  239. margin-left: 16rpx;
  240. }
  241. .score {
  242. font-size: 32rpx;
  243. font-weight: bold;
  244. color: #333;
  245. }
  246. .score-unit {
  247. font-size: 20rpx;
  248. color: #999;
  249. font-weight: normal;
  250. margin-left: 4rpx;
  251. }
  252. .score-text {
  253. font-size: 24rpx;
  254. color: #888;
  255. }
  256. .arrow {
  257. font-size: 32rpx;
  258. color: #ccc;
  259. }
  260. .empty {
  261. display: flex;
  262. flex-direction: column;
  263. align-items: center;
  264. padding: 100rpx 0;
  265. }
  266. .empty-icon {
  267. font-size: 80rpx;
  268. margin-bottom: 20rpx;
  269. }
  270. .empty-title {
  271. font-size: 28rpx;
  272. color: #999;
  273. }
  274. </style>