rulesDetail.vue 4.7 KB

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