legworkStatistics.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="legwork-statistics">
  3. <view class="filter" @click="handleToggleFilter">
  4. <view class="left">
  5. 时间范围
  6. </view>
  7. <view class="right">
  8. <text class="time">
  9. {{ filterObj.timeStr }}
  10. </text>
  11. <text class="wk wk-arrow-right" />
  12. </view>
  13. </view>
  14. <wk-scroll-view
  15. :status="listStatus"
  16. class="list-scroll"
  17. @refresh="getList(true)"
  18. @loadmore="getList()">
  19. <sign-user-info
  20. v-for="(item, index) in listData"
  21. :key="index"
  22. :item-data="item"
  23. @click="handleTo(item)">
  24. <template
  25. v-slot:default="{ scopeData }">
  26. <span class="text">{{ scopeData.count }}位</span>
  27. </template>
  28. </sign-user-info>
  29. </wk-scroll-view>
  30. <filter-section
  31. v-if="showFilter"
  32. :filter-data="filterObj"
  33. @change="handleChangeFilter"
  34. @close="handleToggleFilter" />
  35. </view>
  36. </template>
  37. <script>
  38. import { LegworkStatistics } from 'API/oa/legwork'
  39. import SignUserInfo from '../../component/signUserInfo'
  40. import FilterSection from './filterSection.vue'
  41. import moment from 'moment'
  42. import mainListMixins from '@/mixins/mainList.js'
  43. export default {
  44. name: 'LegworkStatistics',
  45. components: {
  46. SignUserInfo,
  47. FilterSection
  48. },
  49. mixins: [mainListMixins],
  50. data() {
  51. return {
  52. loading: false,
  53. showFilter: false,
  54. filterObj: {
  55. data: {
  56. startTime: moment().format('YYYY-MM-DD') + ' 00:00:00',
  57. endTime: moment().format('YYYY-MM-DD') + ' 23:59:59'
  58. },
  59. timeIndex: 0,
  60. timeStr: '今天'
  61. }
  62. }
  63. },
  64. created() {
  65. this.getList()
  66. },
  67. methods: {
  68. getList(flag = false) {
  69. if (this.loading) return
  70. this.loading = true
  71. if (flag) {
  72. this.listParams.page = 0
  73. }
  74. this.listParams.page++
  75. this.listStatus = 'loading'
  76. LegworkStatistics({
  77. ...this.listParams,
  78. ...this.filterObj.data
  79. }).then(res => {
  80. this.loading = false
  81. console.log('static list: ', res)
  82. if (this.listParams.page === 1) {
  83. this.listData = []
  84. }
  85. this.listData = this.listData.concat(res.list)
  86. if (res.hasOwnProperty('lastPage')) {
  87. this.listStatus = res.lastPage ? 'noMore' : 'more'
  88. } else {
  89. this.listStatus = res.list.length === 0 ? 'noMore' : 'more'
  90. }
  91. }).catch(() => {
  92. this.loading = false
  93. this.listStatus = 'more'
  94. })
  95. },
  96. handleToggleFilter() {
  97. this.showFilter = !this.showFilter
  98. },
  99. handleChangeFilter(data) {
  100. console.log(data)
  101. this.filterObj = data
  102. this.getList(true)
  103. },
  104. handleTo(item) {
  105. let title = `${item.realname}(${this.filterObj.timeStr})`
  106. this.$Router.navigateTo({
  107. url: '/pages_oa/legwork/statisticsDetail',
  108. query: {
  109. userId: item.userId,
  110. title: title,
  111. ...this.filterObj.data
  112. }
  113. })
  114. }
  115. }
  116. }
  117. </script>
  118. <style scoped lang="scss">
  119. .text {
  120. font-size: 30rpx;
  121. color: $light;
  122. }
  123. .legwork-statistics {
  124. position: relative;
  125. width: 100%;
  126. height: 100%;
  127. display: flex;
  128. flex-direction: column;
  129. .filter {
  130. width: 100%;
  131. font-size: 26rpx;
  132. color: $dark;
  133. background-color: white;
  134. box-shadow: 0 8rpx 8rpx 0 rgba(28,108,255,0.1);
  135. padding: 18rpx 32rpx;
  136. @include left;
  137. .left {
  138. flex: 1;
  139. font-size: $wk-font-base;
  140. }
  141. .right {
  142. @include left;
  143. .time {
  144. font-size: $wk-font-base;
  145. }
  146. .wk-arrow-right {
  147. font-size: $wk-font-sm;
  148. margin-left: 20rpx;
  149. }
  150. }
  151. }
  152. .list-scroll {
  153. flex: 1;
  154. overflow: hidden;
  155. margin-top: 20rpx;
  156. }
  157. }
  158. </style>