rulesDetail.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view class="container">
  3. <!-- 顶部搜索框区域 -->
  4. <view class="search"><uni-search-bar bgColor="#fff" placeholder="请输入名字或院系" cancelButton="none" v-model="searchValue" @input="input"></uni-search-bar></view>
  5. <view class="list">
  6. <!-- 分段器区域 -->
  7. <view class="control">
  8. <uni-segmented-control :current="current" :values="items" styleType="text" @clickItem="onClickItem" activeColor="#0082FC"></uni-segmented-control>
  9. </view>
  10. <!-- 列表区域 -->
  11. <view class="listbox" v-if="list.length">
  12. <!-- 每一个盒子区域 -->
  13. <view class="item" v-for="item in list" :key="item.id" @click="handleGoStatDetail(item.userId)">
  14. <view class="left"><img :src="item.headImage || '../../static/imgs/headImage.png'" /></view>
  15. <view class="center">
  16. <view class="name">{{ item.name }}</view>
  17. <view class="college">{{ item.college ? item.college : '南昌交通学院' }}</view>
  18. </view>
  19. <view class="right">{{ item.status == 4 ? '正常' : '缺卡' }}</view>
  20. </view>
  21. </view>
  22. <view class="listbox2" v-else>
  23. <img src="../../static/imgs/nodata.png" />
  24. <view class="info">暂无数据</view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. // 总人数
  34. peopleTotal: 0,
  35. // 打卡失败人数
  36. failCount: 0,
  37. // 打卡成功人数
  38. successCount: 0,
  39. // 搜索框绑定值
  40. searchValue: '',
  41. // 分段器绑定数组
  42. items: ['打卡成功', '打卡失败'],
  43. // 当前分段器所在的索引
  44. current: 0,
  45. // 列表数组
  46. list: [],
  47. // 规则ID
  48. taskId: '',
  49. // 打卡状态 3代表失败 4代表成功
  50. status: 4,
  51. // 当前页
  52. page: 1,
  53. // 列表总条数
  54. total: 0
  55. }
  56. },
  57. onLoad(options) {
  58. let info = JSON.parse(options.info)
  59. // console.log(info);
  60. this.peopleTotal = info.peopleTotal
  61. this.failCount = info.failCount
  62. this.successCount = info.peopleTotal - info.failCount
  63. this.items[0] = `打卡成功(${this.successCount}/${this.peopleTotal}人)`
  64. this.items[1] = `打卡失败(${this.failCount}/${this.peopleTotal}人)`
  65. this.taskId = info.taskId
  66. this.getData()
  67. },
  68. onReachBottom() {
  69. if (this.list.length < this.total) {
  70. this.page++
  71. this.getData()
  72. } else {
  73. uni.showToast({
  74. title: '没有更多数据了',
  75. icon: 'none'
  76. })
  77. }
  78. },
  79. methods: {
  80. handleGoStatDetail(id) {
  81. // console.log(id);
  82. uni.navigateTo({
  83. url: `/pages/statDetail/statDetail?id=${id}`
  84. })
  85. },
  86. // 获取列表数据
  87. async getData() {
  88. let res = await this.$myRequest_clockIn({
  89. url: '/attendance/api/sign/check/in/rule',
  90. data: {
  91. name: this.searchValue,
  92. page: this.page,
  93. status: this.status,
  94. taskId: this.taskId
  95. }
  96. })
  97. // console.log(res);
  98. if (res.code == 200) {
  99. this.total = res.data.total
  100. this.list = [...this.list, ...res.data.list]
  101. }
  102. },
  103. // 点击分段器回调
  104. onClickItem(e) {
  105. // console.log(e.currentIndex);
  106. this.list = []
  107. this.page = 1
  108. if (e.currentIndex == 0) {
  109. this.status = 4
  110. } else {
  111. this.status = 3
  112. }
  113. this.getData()
  114. },
  115. // 搜索框输入时的回调
  116. input() {
  117. this.list = []
  118. this.page = 1
  119. this.getData()
  120. }
  121. }
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. .container {
  126. padding-top: 20rpx;
  127. background-color: #f2f2f2;
  128. .search {
  129. width: 750rpx;
  130. height: 90rpx;
  131. border-radius: 171rpx;
  132. background-color: #fff;
  133. }
  134. .list {
  135. margin-top: 20rpx;
  136. width: 750rpx;
  137. min-height: 85vh;
  138. background-color: #fff;
  139. .control {
  140. display: flex;
  141. flex-direction: column;
  142. justify-content: center;
  143. width: 750rpx;
  144. height: 102rpx;
  145. }
  146. .listbox {
  147. .item {
  148. display: flex;
  149. align-items: center;
  150. margin: 0 30rpx;
  151. height: 114rpx;
  152. border-bottom: 1rpx solid #e5e5e5;
  153. background-color: #fff;
  154. .left {
  155. flex: 1;
  156. display: flex;
  157. justify-content: center;
  158. align-items: center;
  159. img {
  160. width: 70rpx;
  161. height: 70rpx;
  162. border-radius: 35rpx;
  163. }
  164. }
  165. .center {
  166. flex: 5;
  167. display: flex;
  168. flex-direction: column;
  169. justify-content: space-evenly;
  170. margin-left: 10rpx;
  171. height: 90rpx;
  172. .name {
  173. font-size: 28rpx;
  174. }
  175. .college {
  176. font-size: 24rpx;
  177. color: #808080;
  178. }
  179. }
  180. .right {
  181. flex: 1;
  182. display: flex;
  183. justify-content: center;
  184. align-items: center;
  185. font-size: 28rpx;
  186. }
  187. }
  188. }
  189. .listbox2 {
  190. margin-top: 230rpx;
  191. text-align: center;
  192. img {
  193. width: 480rpx;
  194. height: 508rpx;
  195. }
  196. .info {
  197. color: #5792f0;
  198. }
  199. }
  200. }
  201. }
  202. // 解决输入框不居中问题
  203. ::v-deep .uni-searchbar {
  204. padding: 10rpx;
  205. }
  206. </style>