statistics.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. <template>
  2. <view class="container">
  3. <!-- 日期范围和筛选 -->
  4. <view class="date-filter-bar mb16">
  5. <view class="date-range" @click="showDatePicker = true">
  6. <image class="w32 h32" src="@/static/image/icon_time.png" mode=""></image>
  7. <text class="date-text">{{ dateRangeText }}</text>
  8. <text class="arrow-down">▼</text>
  9. </view>
  10. <view class="filter-btn" @click="showFilter = true">
  11. <image class="w32 h32" src="@/static/image/icon_select.png" mode=""></image>
  12. <text>筛选</text>
  13. </view>
  14. </view>
  15. <!-- 内容区域 -->
  16. <scroll-view class="content" scroll-y>
  17. <!-- 数据汇总 -->
  18. <view class="summary-section x-bc">
  19. <view class="summary-header">
  20. <view class="summary-indicator"></view>
  21. <text class="summary-title">数据汇总</text>
  22. </view>
  23. <view class="summary-stats">
  24. <view class="stat-item">
  25. <text class="stat-label">任务数</text>
  26. <text class="stat-value">{{ summaryData.taskCount }}</text>
  27. </view>
  28. <view class="stat-item">
  29. <text class="stat-label">总积分</text>
  30. <text class="stat-value">{{ summaryData.totalPoints }}</text>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 数据表格 -->
  35. <view class="table-section">
  36. <view class="table-header">
  37. <view class="table-col" style="width: 20%;">任务类型</view>
  38. <view class="table-col" style="width: 15%;">积分</view>
  39. <view class="table-col" style="width: 20%;">申请人员</view>
  40. <view class="table-col" style="width: 20%;">任务状态</view>
  41. <view class="table-col" style="width: 25%;">接收时间</view>
  42. </view>
  43. <view class="table-body">
  44. <view class="table-row" v-for="(item, index) in tableData" :key="index">
  45. <view class="table-col" style="width: 20%;">{{ item.taskType }}</view>
  46. <view class="table-col" style="width: 15%;">{{ item.points }}</view>
  47. <view class="table-col" style="width: 20%;">{{ item.applicant }}</view>
  48. <view class="table-col" style="width: 20%;">
  49. <text class="status-tag" :class="item.status">{{ item.statusText }}</text>
  50. </view>
  51. <view class="table-col" style="width: 25%;">{{ item.receiveTime }}</view>
  52. </view>
  53. </view>
  54. </view>
  55. <!-- 底部提示 -->
  56. <view class="no-more">没有更多了~</view>
  57. </scroll-view>
  58. <!-- 日期选择弹窗 -->
  59. <view class="date-picker-popup" v-if="showDatePicker" @click="showDatePicker = false">
  60. <view class="date-picker-content" @click.stop>
  61. <view class="picker-header">
  62. <view class="picker-cancel" @click="showDatePicker = false">取消</view>
  63. <view class="picker-title">选择日期范围</view>
  64. <view class="picker-confirm" @click="confirmDateRange">确定</view>
  65. </view>
  66. <view class="picker-body">
  67. <view class="date-item">
  68. <text class="date-label">开始日期</text>
  69. <picker mode="date" :value="tempDateRange.startDate" @change="onStartDateChange">
  70. <view class="date-value">{{ tempDateRange.startDate || '请选择' }}</view>
  71. </picker>
  72. </view>
  73. <view class="date-item">
  74. <text class="date-label">结束日期</text>
  75. <picker mode="date" :value="tempDateRange.endDate" @change="onEndDateChange">
  76. <view class="date-value">{{ tempDateRange.endDate || '请选择' }}</view>
  77. </picker>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <!-- 筛选弹窗 -->
  83. <view class="filter-popup" v-if="showFilter" @click="closeFilter">
  84. <view class="filter-content" @click.stop>
  85. <view class="filter-header">
  86. <view class="filter-title">筛选</view>
  87. <view class="filter-close-btn" @click="closeFilter">×</view>
  88. </view>
  89. <!-- 任务类型筛选 -->
  90. <view class="filter-group">
  91. <view class="group-label">任务类型</view>
  92. <view class="filter-tags">
  93. <view
  94. class="filter-tag"
  95. :class="{ active: tempSelectedTaskType === item.value }"
  96. v-for="(item, index) in taskTypeOptions"
  97. :key="index"
  98. @click="selectTaskType(item.value)">
  99. {{ item.label }}
  100. </view>
  101. </view>
  102. </view>
  103. <!-- 任务状态筛选 -->
  104. <view class="filter-group">
  105. <view class="group-label">任务状态</view>
  106. <view class="filter-tags">
  107. <view
  108. class="filter-tag"
  109. :class="{ active: tempSelectedTaskStatus === item.value }"
  110. v-for="(item, index) in taskStatusOptions"
  111. :key="index"
  112. @click="selectTaskStatus(item.value)">
  113. {{ item.label }}
  114. </view>
  115. </view>
  116. </view>
  117. <!-- 操作按钮 -->
  118. <view class="filter-actions">
  119. <view class="reset-btn" @click="resetFilters">重置</view>
  120. <view class="confirm-btn" @click="confirmFilters">确定</view>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. </template>
  126. <script>
  127. // import { getStatisticsData } from '@/api-js/statistics'
  128. export default {
  129. data() {
  130. return {
  131. statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
  132. showDatePicker: false,
  133. showFilter: false,
  134. dateRange: {
  135. startDate: '2025-12-01',
  136. endDate: '2025-12-25'
  137. },
  138. tempDateRange: {
  139. startDate: '2025-12-01',
  140. endDate: '2025-12-25'
  141. },
  142. selectedTaskType: 'academicLecture', // 默认选中学术讲座
  143. selectedTaskStatus: '',
  144. taskTypeOptions: [
  145. { label: '医生坐诊', value: 'doctorConsultation' },
  146. { label: '科普讲座', value: 'popularScienceLecture' },
  147. { label: '学术讲座', value: 'academicLecture' },
  148. { label: '科普文章', value: 'popularScienceArticle' },
  149. { label: '科普短视频', value: 'popularScienceShortVideo' },
  150. { label: '科普长视频', value: 'popularScienceLongVideo' },
  151. { label: '空中课堂', value: 'airClassroom' },
  152. { label: '用药调研', value: 'medicationSurvey' },
  153. { label: '问卷调研', value: 'questionnaireSurvey' },
  154. { label: '社群咨询', value: 'communityConsultation' },
  155. { label: '健康问答', value: 'healthQA' }
  156. ],
  157. taskStatusOptions: [
  158. { label: '未完成', value: 'uncompleted' },
  159. { label: '待审核', value: 'pendingReview' },
  160. { label: '已驳回', value: 'rejected' },
  161. { label: '已完成', value: 'completed' },
  162. { label: '已完结', value: 'finished' }
  163. ],
  164. tempSelectedTaskType: 'academicLecture',
  165. tempSelectedTaskStatus: '',
  166. summaryData: {
  167. taskCount: 6,
  168. totalPoints: 300
  169. },
  170. tableData: [
  171. { taskType: '用药调研', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  172. { taskType: '科普短视频', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  173. { taskType: '用药调研', points: '100', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  174. { taskType: '科普短视频', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  175. { taskType: '用药调研', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  176. { taskType: '科普短视频', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  177. { taskType: '用药调研', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  178. { taskType: '科普短视频', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  179. { taskType: '用药调研', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  180. { taskType: '科普短视频', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' }
  181. ]
  182. }
  183. },
  184. computed: {
  185. dateRangeText() {
  186. return `${this.dateRange.startDate} 至 ${this.dateRange.endDate}`
  187. }
  188. },
  189. watch: {
  190. showFilter(newVal) {
  191. if (newVal) {
  192. // 打开弹窗时,同步临时选择值
  193. this.tempSelectedTaskType = this.selectedTaskType
  194. this.tempSelectedTaskStatus = this.selectedTaskStatus
  195. }
  196. }
  197. },
  198. onLoad() {
  199. this.tempSelectedTaskType = this.selectedTaskType
  200. this.tempSelectedTaskStatus = this.selectedTaskStatus
  201. //this.loadData()
  202. },
  203. onReachBottom() {
  204. this.loadMore()
  205. },
  206. methods: {
  207. goBack() {
  208. uni.navigateBack()
  209. },
  210. onStartDateChange(e) {
  211. this.tempDateRange.startDate = e.detail.value
  212. },
  213. onEndDateChange(e) {
  214. this.tempDateRange.endDate = e.detail.value
  215. },
  216. confirmDateRange() {
  217. if (!this.tempDateRange.startDate || !this.tempDateRange.endDate) {
  218. uni.showToast({ icon: 'none', title: '请选择完整的日期范围' })
  219. return
  220. }
  221. if (new Date(this.tempDateRange.startDate) > new Date(this.tempDateRange.endDate)) {
  222. uni.showToast({ icon: 'none', title: '开始日期不能大于结束日期' })
  223. return
  224. }
  225. this.dateRange = { ...this.tempDateRange }
  226. this.showDatePicker = false
  227. this.loadData()
  228. },
  229. closeFilter() {
  230. // 关闭弹窗时,恢复临时选择值为当前选择值
  231. this.tempSelectedTaskType = this.selectedTaskType
  232. this.tempSelectedTaskStatus = this.selectedTaskStatus
  233. this.showFilter = false
  234. },
  235. selectTaskType(value) {
  236. // 如果点击的是已选中的,则取消选择
  237. if (this.tempSelectedTaskType === value) {
  238. this.tempSelectedTaskType = ''
  239. } else {
  240. this.tempSelectedTaskType = value
  241. }
  242. },
  243. selectTaskStatus(value) {
  244. // 如果点击的是已选中的,则取消选择
  245. if (this.tempSelectedTaskStatus === value) {
  246. this.tempSelectedTaskStatus = ''
  247. } else {
  248. this.tempSelectedTaskStatus = value
  249. }
  250. },
  251. resetFilters() {
  252. this.tempSelectedTaskType = ''
  253. this.tempSelectedTaskStatus = ''
  254. },
  255. confirmFilters() {
  256. this.selectedTaskType = this.tempSelectedTaskType
  257. this.selectedTaskStatus = this.tempSelectedTaskStatus
  258. this.showFilter = false
  259. //this.loadData()
  260. },
  261. async loadData() {
  262. try {
  263. uni.showLoading({ title: '加载中...' })
  264. const res = await getStatisticsData({
  265. startDate: this.dateRange.startDate,
  266. endDate: this.dateRange.endDate,
  267. taskType: this.selectedTaskType,
  268. taskStatus: this.selectedTaskStatus
  269. })
  270. uni.hideLoading()
  271. if (res.code === 200 && res.data) {
  272. this.summaryData = {
  273. taskCount: res.data.taskCount || 6,
  274. totalPoints: res.data.totalPoints || 300
  275. }
  276. this.tableData = res.data.list || this.getDefaultData()
  277. } else {
  278. this.tableData = this.getDefaultData()
  279. }
  280. } catch (e) {
  281. uni.hideLoading()
  282. console.error('加载数据失败', e)
  283. this.tableData = this.getDefaultData()
  284. }
  285. },
  286. async loadMore() {
  287. // 加载更多数据
  288. },
  289. getDefaultData() {
  290. // 默认数据,根据图片中的示例
  291. return [
  292. { taskType: '用药调研', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  293. { taskType: '科普短视频', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  294. { taskType: '用药调研', points: '100', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  295. { taskType: '科普短视频', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  296. { taskType: '用药调研', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  297. { taskType: '科普短视频', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  298. { taskType: '用药调研', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  299. { taskType: '科普短视频', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  300. { taskType: '用药调研', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' },
  301. { taskType: '科普短视频', points: '20', applicant: '王*明', status: 'uncompleted', statusText: '未完成', receiveTime: '2025-09-25' }
  302. ]
  303. }
  304. }
  305. }
  306. </script>
  307. <style lang="scss" scoped>
  308. .container {
  309. min-height: 100vh;
  310. display: flex;
  311. flex-direction: column;
  312. }
  313. .status-bar {
  314. width: 100%;
  315. background: #fff;
  316. }
  317. .header {
  318. position: relative;
  319. height: 88rpx;
  320. display: flex;
  321. align-items: center;
  322. justify-content: center;
  323. background: #fff;
  324. border-bottom: 1rpx solid #f0f0f0;
  325. .back-btn {
  326. position: absolute;
  327. left: 24rpx;
  328. width: 40rpx;
  329. height: 40rpx;
  330. image {
  331. width: 100%;
  332. height: 100%;
  333. }
  334. }
  335. .title {
  336. font-size: 36rpx;
  337. font-weight: bold;
  338. color: #333;
  339. }
  340. .header-right {
  341. position: absolute;
  342. right: 24rpx;
  343. display: flex;
  344. align-items: center;
  345. gap: 16rpx;
  346. .more-icon {
  347. font-size: 32rpx;
  348. color: #333;
  349. }
  350. }
  351. }
  352. .date-filter-bar {
  353. display: flex;
  354. align-items: center;
  355. justify-content: space-between;
  356. padding: 24rpx;
  357. background: #fff;
  358. // border-bottom: 1rpx solid #f0f0f0;
  359. .date-range {
  360. display: flex;
  361. align-items: center;
  362. gap: 8rpx;
  363. .clock-icon {
  364. font-size: 28rpx;
  365. }
  366. .date-text {
  367. font-family: PingFang SC, PingFang SC;
  368. font-weight: 500;
  369. font-size: 28rpx;
  370. color: #333333;
  371. }
  372. .arrow-down {
  373. font-size: 20rpx;
  374. color: #333333;
  375. }
  376. }
  377. .filter-btn {
  378. display: flex;
  379. align-items: center;
  380. gap: 8rpx;
  381. font-size: 28rpx;
  382. color: #333;
  383. .filter-icon {
  384. font-size: 24rpx;
  385. }
  386. }
  387. }
  388. .content {
  389. flex: 1;
  390. background: #fff;
  391. }
  392. .summary-section {
  393. background: #fff;
  394. padding: 24rpx;
  395. margin-bottom: 32rpx;
  396. .summary-header {
  397. display: flex;
  398. align-items: center;
  399. // margin-bottom: 24rpx;
  400. .summary-indicator {
  401. width: 6rpx;
  402. height: 32rpx;
  403. background: #388BFF;
  404. border-radius: 3rpx;
  405. margin-right: 16rpx;
  406. }
  407. .summary-title {
  408. font-size: 32rpx;
  409. font-weight: bold;
  410. color: #333;
  411. }
  412. }
  413. .summary-stats {
  414. display: flex;
  415. gap: 48rpx;
  416. .stat-item {
  417. display: flex;
  418. flex-direction: row;
  419. align-items: center;
  420. gap: 16rpx;
  421. .stat-label {
  422. font-size: 24rpx;
  423. color: #999;
  424. }
  425. .stat-value {
  426. font-size: 36rpx;
  427. font-weight: bold;
  428. color: #388BFF;
  429. }
  430. }
  431. }
  432. }
  433. .table-section {
  434. background: #fff;
  435. padding: 0 24rpx;
  436. .table-header {
  437. display: flex;
  438. background: #E3EFFF;
  439. padding: 24rpx 16rpx;
  440. .table-col {
  441. font-family: PingFang SC, PingFang SC;
  442. font-weight: 500;
  443. font-size: 26rpx;
  444. color: #333333;
  445. line-height: 40rpx;
  446. text-align: left;
  447. }
  448. }
  449. .table-body {
  450. .table-row {
  451. display: flex;
  452. padding: 24rpx 16rpx;
  453. &:nth-child(2n) {
  454. background: #F7F8FA;
  455. border-radius: 8rpx 8rpx 8rpx 8rpx;
  456. }
  457. .table-col {
  458. font-size: 26rpx;
  459. color: #333;
  460. display: flex;
  461. align-items: center;
  462. text-align: left;
  463. font-family: PingFang SC, PingFang SC;
  464. font-weight: 400;
  465. font-size: 26rpx;
  466. line-height: 40rpx;
  467. // .status-tag {
  468. // padding: 4rpx 12rpx;
  469. // border-radius: 4rpx;
  470. // font-size: 24rpx;
  471. // &.uncompleted {
  472. // background: #FFF3E0;
  473. // color: #FF9800;
  474. // }
  475. // &.completed {
  476. // background: #E8F5E9;
  477. // color: #4CAF50;
  478. // }
  479. // }
  480. }
  481. }
  482. }
  483. }
  484. .no-more {
  485. text-align: center;
  486. padding: 48rpx 0;
  487. font-size: 24rpx;
  488. color: #999;
  489. }
  490. .date-picker-popup {
  491. position: fixed;
  492. top: 0;
  493. left: 0;
  494. right: 0;
  495. bottom: 0;
  496. background: rgba(0, 0, 0, 0.5);
  497. z-index: 999;
  498. display: flex;
  499. align-items: flex-end;
  500. }
  501. .date-picker-content {
  502. width: 100%;
  503. background: #fff;
  504. border-radius: 24rpx 24rpx 0 0;
  505. .picker-header {
  506. display: flex;
  507. align-items: center;
  508. justify-content: space-between;
  509. padding: 24rpx;
  510. border-bottom: 1rpx solid #f0f0f0;
  511. .picker-cancel {
  512. font-size: 30rpx;
  513. color: #666;
  514. }
  515. .picker-title {
  516. font-size: 32rpx;
  517. font-weight: bold;
  518. color: #333;
  519. }
  520. .picker-confirm {
  521. font-size: 30rpx;
  522. color: #388BFF;
  523. }
  524. }
  525. .picker-body {
  526. padding: 24rpx;
  527. .date-item {
  528. display: flex;
  529. align-items: center;
  530. justify-content: space-between;
  531. padding: 24rpx 0;
  532. border-bottom: 1rpx solid #f0f0f0;
  533. &:last-child {
  534. border-bottom: none;
  535. }
  536. .date-label {
  537. font-size: 30rpx;
  538. color: #333;
  539. }
  540. .date-value {
  541. font-size: 30rpx;
  542. color: #388BFF;
  543. }
  544. }
  545. }
  546. }
  547. .filter-popup {
  548. position: fixed;
  549. top: 0;
  550. left: 0;
  551. right: 0;
  552. bottom: 0;
  553. background: rgba(0, 0, 0, 0.5);
  554. z-index: 999;
  555. display: flex;
  556. align-items: flex-end;
  557. }
  558. .filter-content {
  559. width: 100%;
  560. background: #fff;
  561. border-radius: 24rpx 24rpx 0 0;
  562. padding: 24rpx;
  563. max-height: 80vh;
  564. overflow-y: auto;
  565. .filter-header {
  566. display: flex;
  567. align-items: center;
  568. justify-content: space-between;
  569. margin-bottom: 32rpx;
  570. .filter-title {
  571. font-size: 32rpx;
  572. font-weight: bold;
  573. color: #333;
  574. }
  575. .filter-close-btn {
  576. width: 48rpx;
  577. height: 48rpx;
  578. display: flex;
  579. align-items: center;
  580. justify-content: center;
  581. font-size: 40rpx;
  582. color: #999;
  583. }
  584. }
  585. .filter-group {
  586. margin-bottom: 40rpx;
  587. &:last-of-type {
  588. margin-bottom: 0;
  589. }
  590. .group-label {
  591. font-size: 28rpx;
  592. font-weight: bold;
  593. color: #333;
  594. margin-bottom: 20rpx;
  595. }
  596. .filter-tags {
  597. display: flex;
  598. flex-wrap: wrap;
  599. gap: 16rpx;
  600. .filter-tag {
  601. padding: 12rpx 24rpx;
  602. background: #f5f5f5;
  603. border-radius: 8rpx;
  604. font-size: 26rpx;
  605. color: #666;
  606. border: 1rpx solid transparent;
  607. &.active {
  608. background: #E6F7FF;
  609. color: #388BFF;
  610. border-color: #388BFF;
  611. }
  612. }
  613. }
  614. }
  615. .filter-actions {
  616. display: flex;
  617. gap: 24rpx;
  618. margin-top: 40rpx;
  619. padding-top: 24rpx;
  620. border-top: 1rpx solid #f0f0f0;
  621. .reset-btn,
  622. .confirm-btn {
  623. flex: 1;
  624. height: 88rpx;
  625. line-height: 88rpx;
  626. text-align: center;
  627. border-radius: 8rpx;
  628. font-size: 30rpx;
  629. }
  630. .reset-btn {
  631. background: #fff;
  632. color: #666;
  633. border: 1rpx solid #e0e0e0;
  634. }
  635. .confirm-btn {
  636. background: #388BFF;
  637. color: #fff;
  638. }
  639. }
  640. }
  641. </style>