late.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view class="container">
  3. <!-- 背景图片区域 -->
  4. <img class="img_bg" src="../../static/images/center-bg.png" />
  5. <!-- 选择年级区域 -->
  6. <view class="grade">
  7. <uni-data-picker
  8. placeholder="请选择班级"
  9. popup-title="请选择班级"
  10. :clear-icon="false"
  11. :map="{ text: 'name', value: 'classId' }"
  12. :localdata="dataTree_student"
  13. v-model="classes_student"
  14. @change="onchange_student"
  15. ></uni-data-picker>
  16. </view>
  17. <!-- 时间筛选区域 -->
  18. <view class="time">
  19. 迟到时间
  20. <view class="time_rang">
  21. <uni-datetime-picker v-model="timeRang" type="daterange" @change="changeTime" />
  22. </view>
  23. </view>
  24. <!-- 迟到列表区域 -->
  25. <view class="list" v-if="list.length">
  26. <uni-swipe-action>
  27. <view v-for="item in list" :key="item.id">
  28. <uni-swipe-action-item :right-options="options" @click="onClickItem(item)">
  29. <!-- 每一个迟到记录区域 -->
  30. <view class="item_box">
  31. <view class="box_info">
  32. <image v-if="item.image" class="info_img" :src="item.image" mode="aspectFill" @click="clickImage(item.image)"></image>
  33. <image
  34. v-else
  35. class="info_img"
  36. src="https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com/excelModel/nupp7VVnHWpVa413437dba82ce85374b2a4ee1a6b973.png"
  37. mode="aspectFill"
  38. ></image>
  39. <view class="info_msg">
  40. <view class="msg_name">
  41. {{ item.name }}
  42. </view>
  43. <view class="msg_no">
  44. {{ item.cardNo }}
  45. </view>
  46. </view>
  47. </view>
  48. <view class="box_time">{{ item.dateTime }}</view>
  49. </view>
  50. </uni-swipe-action-item>
  51. <view style="height: 20rpx"></view>
  52. </view>
  53. </uni-swipe-action>
  54. </view>
  55. <NoData v-else />
  56. </view>
  57. </template>
  58. <script setup>
  59. import { ref } from 'vue'
  60. import { onLoad } from '@dcloudio/uni-app'
  61. import NoData from '@/components/noData.vue'
  62. import { myRequest } from '@/utils/api.js'
  63. import { decryptDes } from '@/utils/des.js'
  64. // 班级数组
  65. const dataTree_student = ref([])
  66. // 选择的班级
  67. const classes_student = ref()
  68. const options = [
  69. {
  70. text: '删除',
  71. style: {
  72. backgroundColor: '#D43030'
  73. }
  74. }
  75. ]
  76. // 迟到时间筛选
  77. const timeRang = ref([])
  78. // 迟到数据
  79. const list = ref([])
  80. onLoad(() => {
  81. const id = uni.getStorageSync('userInfo').id
  82. getManageClass(id)
  83. })
  84. // 获取管理的班级数组
  85. const getManageClass = async (id) => {
  86. const res = await myRequest({
  87. url: '/wanzai/api/smartUser/getManageClass',
  88. data: {
  89. id
  90. }
  91. })
  92. // console.log(res)
  93. const result = JSON.parse(decryptDes(res.data))
  94. // console.log(result)
  95. dataTree_student.value = result
  96. classes_student.value = result[0].classId
  97. getData()
  98. }
  99. // 获取迟到数据
  100. const getData = async () => {
  101. const res = await myRequest({
  102. url: '/wanzai/api/smartLate/listApp',
  103. data: {
  104. currentPage: 1,
  105. pageCount: 1000,
  106. classId: classes_student.value,
  107. startTime: timeRang.value.length ? timeRang.value[0] + ' 00:00:00' : '',
  108. endTime: timeRang.value.length ? timeRang.value[1] + ' 00:00:00' : ''
  109. }
  110. })
  111. // console.log(res)
  112. const result = JSON.parse(decryptDes(res.data))
  113. console.log(result)
  114. list.value = result.list
  115. }
  116. // 点击图片回调
  117. const clickImage = (url) => {
  118. uni.previewImage({
  119. urls: [url],
  120. current: 1
  121. })
  122. }
  123. // 点击每一项删除回调
  124. const onClickItem = (item) => {
  125. uni.showModal({
  126. title: '提示',
  127. content: `确定把${item.name}的迟到记录移除吗?`,
  128. success: (res) => {
  129. if (res.confirm) {
  130. handleDeleteReq(item.id)
  131. }
  132. }
  133. })
  134. }
  135. // 删除请求
  136. const handleDeleteReq = async (id) => {
  137. const res = await myRequest({
  138. url: '/wanzai/api/smartLate/delete?id=1',
  139. data: {
  140. id
  141. }
  142. })
  143. // console.log(res)
  144. if (res.code == 200) {
  145. uni.showToast({
  146. title: '删除成功',
  147. icon: 'success'
  148. })
  149. setTimeout(() => {
  150. getData()
  151. }, 1500)
  152. }
  153. }
  154. // 切换时间回调
  155. const changeTime = (e) => {
  156. timeRang.value = e
  157. getData()
  158. }
  159. // 学生部门筛选框选择时的回调
  160. const onchange_student = (e) => {
  161. // console.log(e.detail.value)
  162. // console.log(classes_student.value)
  163. getData()
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. .container {
  168. box-sizing: border-box;
  169. padding: 30rpx 20rpx;
  170. height: 100vh;
  171. background: linear-gradient(180deg, rgba(242, 247, 255, 1) 0%, rgba(242, 247, 255, 0) 100%);
  172. // 背景图片区域样式
  173. .img_bg {
  174. position: absolute;
  175. top: -70rpx;
  176. right: 0;
  177. width: 589rpx;
  178. height: 320rpx;
  179. pointer-events: none;
  180. }
  181. .grade {
  182. margin-bottom: 20rpx;
  183. height: 70rpx;
  184. }
  185. .time {
  186. display: flex;
  187. align-items: center;
  188. margin-bottom: 30rpx;
  189. height: 70rpx;
  190. font-size: 28rpx;
  191. .time_rang {
  192. margin-left: 20rpx;
  193. width: 500rpx;
  194. }
  195. }
  196. .list {
  197. height: calc(100vh - 250rpx);
  198. overflow-y: auto;
  199. .item_box {
  200. display: flex;
  201. justify-content: space-between;
  202. align-items: center;
  203. padding: 0 20rpx;
  204. height: 167rpx;
  205. font-size: 28rpx;
  206. border-radius: 8rpx;
  207. background-color: #fff;
  208. .box_info {
  209. display: flex;
  210. .info_img {
  211. width: 100rpx;
  212. height: 100rpx;
  213. border-radius: 50%;
  214. }
  215. .info_msg {
  216. display: flex;
  217. flex-direction: column;
  218. justify-content: space-between;
  219. margin-left: 28rpx;
  220. .msg_name {
  221. font-size: 32rpx;
  222. }
  223. .msg_no {
  224. color: #808080;
  225. }
  226. }
  227. }
  228. .box_time {
  229. }
  230. }
  231. }
  232. }
  233. </style>