rulesDetail.vue 4.7 KB

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