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