particulars.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <view class="container">
  3. <view class="placeholder"></view>
  4. <!-- 顶部搜索框区域 -->
  5. <view class="search"><uni-search-bar bgColor="#fff" placeholder="请输入打卡规则名称" cancelButton="none" v-model="searchValue" @input="input"></uni-search-bar></view>
  6. <!-- 规则列表区域 -->
  7. <view class="list" v-if="list.length">
  8. <!-- 每一个规则区域 -->
  9. <view class="box" v-for="(item, index) in list" :key="index" @click="handleLook(item)">
  10. <view class="icon"><img src="./imgs/rule.png" /></view>
  11. <view class="info">
  12. <view class="title">{{ item.name }}</view>
  13. <view class="status">
  14. <span class="right">全勤:{{ item.peopleTotal - item.failCount }}人</span>
  15. <span>异常:{{ item.failCount }}人</span>
  16. </view>
  17. </view>
  18. <!-- 右上角图标区域 -->
  19. <view class="image">
  20. <img v-if="item.failCount == 0" src="./imgs/finished.png" />
  21. <img v-else src="./imgs/unfinished.png" />
  22. </view>
  23. </view>
  24. </view>
  25. <view class="list2" v-else>
  26. <img src="../../static/imgs/nodata.png" />
  27. <view class="info">暂无数据</view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. // 当前页
  36. page: 1,
  37. // 总条数
  38. total: 0,
  39. // 当前时间
  40. nowTime: '',
  41. // 当前时间-每一天
  42. nowTime_day: '',
  43. // 搜索框绑定数值
  44. searchValue: '',
  45. // 列表数组
  46. list: [],
  47. type: ''
  48. }
  49. },
  50. onLoad(options) {
  51. if (options.nowTime_day) {
  52. this.nowTime_day = options.nowTime_day
  53. }
  54. this.type = options.type
  55. if (this.type == 1) {
  56. uni.setNavigationBarTitle({
  57. title: '日汇总明细'
  58. })
  59. } else {
  60. uni.setNavigationBarTitle({
  61. title: '月汇总明细'
  62. })
  63. }
  64. this.getTime()
  65. this.getData()
  66. },
  67. onReachBottom() {
  68. if (this.list.length < this.total) {
  69. this.page++
  70. this.getData()
  71. } else {
  72. uni.showToast({
  73. title: '没有更多数据了',
  74. icon: 'none'
  75. })
  76. }
  77. },
  78. methods: {
  79. // 获取当前年 月 日
  80. getTime() {
  81. let date = new Date()
  82. let year = date.getFullYear()
  83. let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
  84. let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
  85. this.nowTime = year + '-' + month + '-' + day + ' ' + '00:00:00'
  86. },
  87. // 获取列表数据
  88. async getData() {
  89. let res = await this.$myRequest_clockIn({
  90. url: '/attendance/api/sign/check/in/summary',
  91. data: {
  92. name: this.searchValue,
  93. page: this.page,
  94. time: this.type == 1 ? this.nowTime_day : this.nowTime,
  95. type: this.type
  96. }
  97. })
  98. // console.log(res);
  99. if (res.code == 200) {
  100. this.list = [...this.list, ...res.data.list]
  101. this.total = res.data.total
  102. }
  103. },
  104. // 点击每一个规则回调
  105. handleLook(item) {
  106. // console.log(item);
  107. let info = JSON.stringify(item)
  108. uni.navigateTo({
  109. url: `/pages/rulesDetail/rulesDetail?info=${info}`
  110. })
  111. },
  112. // 搜索框输入时的回调
  113. input(res) {
  114. this.list = []
  115. this.page = 1
  116. this.getData()
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. .container {
  123. min-width: 100vw;
  124. min-height: 100vh;
  125. background-color: #f2f2f2;
  126. .placeholder {
  127. height: 20rpx;
  128. }
  129. .search {
  130. margin: 0 auto;
  131. width: 690rpx;
  132. height: 90rpx;
  133. border-radius: 171rpx;
  134. background-color: #fff;
  135. }
  136. .list {
  137. margin-top: 20rpx;
  138. padding-bottom: 30rpx;
  139. .box {
  140. display: flex;
  141. margin: 0 auto;
  142. margin-bottom: 20rpx;
  143. width: 690rpx;
  144. height: 130rpx;
  145. background-color: #fff;
  146. .icon {
  147. flex: 1;
  148. display: flex;
  149. justify-content: center;
  150. align-items: center;
  151. img {
  152. width: 60rpx;
  153. height: 60rpx;
  154. }
  155. }
  156. .info {
  157. flex: 6;
  158. display: flex;
  159. flex-direction: column;
  160. justify-content: space-evenly;
  161. .title {
  162. font-size: 30rpx;
  163. }
  164. .status {
  165. font-size: 24rpx;
  166. font-weight: 500;
  167. color: #a6a6a6;
  168. .right {
  169. margin-right: 20rpx;
  170. }
  171. }
  172. }
  173. .image {
  174. margin-top: -5rpx;
  175. margin-right: -5rpx;
  176. width: 83rpx;
  177. height: 83rpx;
  178. img {
  179. width: 100%;
  180. height: 100%;
  181. }
  182. }
  183. }
  184. }
  185. .list2 {
  186. margin-top: 260rpx;
  187. text-align: center;
  188. img {
  189. width: 480rpx;
  190. height: 508rpx;
  191. }
  192. .info {
  193. color: #5792f0;
  194. }
  195. }
  196. }
  197. // 解决输入框不居中问题
  198. ::v-deep .uni-searchbar {
  199. padding: 10rpx;
  200. }
  201. </style>