report-management.vue 6.4 KB

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