statistics.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <template>
  2. <view class="statistics">
  3. <!-- 背景图片区域 -->
  4. <img class="img" src="../../static/images/center-bg.png" />
  5. <!-- 时间选择区域 -->
  6. <div class="picker">
  7. <uni-datetime-picker type="date" :clear-icon="false" v-model="time" @change="changeTime"></uni-datetime-picker>
  8. </div>
  9. <view class="school">
  10. <uni-data-picker
  11. placeholder="请选择班级"
  12. popup-title="请选择班级"
  13. :clear-icon="false"
  14. :map="{ text: 'name', value: 'classId' }"
  15. :localdata="dataTree_student"
  16. v-model="classes_student"
  17. @change="onchange_student"
  18. ></uni-data-picker>
  19. </view>
  20. <!-- 状态选择区域 -->
  21. <div class="type">
  22. <div class="type_box" :class="{ active: currentType === 1 }" @click="changeType(1)">未监听({{ info?.abnormal?.count }})</div>
  23. <div class="type_box" :class="{ active: currentType === 2 }" @click="changeType(2)">监听({{ info?.normal?.count }})</div>
  24. <div class="type_box" :class="{ active: currentType === 3 }" @click="changeType(3)">请假({{ info?.ack?.count }})</div>
  25. </div>
  26. <!-- 列表数据 -->
  27. <div class="list" v-if="listData.length">
  28. <div class="list_header">
  29. <div class="header_box">姓名</div>
  30. <div class="header_box">学号</div>
  31. <div v-if="currentType != 1" class="header_box">操作</div>
  32. </div>
  33. <div class="list_content">
  34. <div class="list_box" v-for="item in listData" :key="item.userId">
  35. <div class="box" @click="clickName(item)">{{ item.name }}</div>
  36. <div class="box">{{ item.cardNo }}</div>
  37. <div v-if="currentType != 1" class="box color" @click="clickDetail(item)">详情</div>
  38. </div>
  39. </div>
  40. </div>
  41. <!-- 没有数据时展示的页面 -->
  42. <NoData v-else />
  43. <!-- 详情弹窗区域 -->
  44. <uni-popup ref="popup" type="center" :is-mask-click="false">
  45. <view class="popup_box">
  46. <!-- 弹窗标题区域 -->
  47. <view class="pop_header">
  48. 请假详情
  49. <view class="header_icon" @click="popup.close()">×</view>
  50. </view>
  51. <!-- 弹窗详细信息区域 -->
  52. <view class="pop_info">
  53. <view class="info_key">请假人姓名:</view>
  54. <view class="info_value">{{ askInfo.name }}</view>
  55. </view>
  56. <view class="pop_info">
  57. <view class="info_key">学号:</view>
  58. <view class="info_value">{{ askInfo.cardNo }}</view>
  59. </view>
  60. <view class="pop_info">
  61. <view class="info_key">请假时间:</view>
  62. <view class="info_value">{{ dayjs(askInfo.startTime).format('YYYY-MM-DD hh:mm:ss') }} - {{ dayjs(askInfo.endTime).format('YYYY-MM-DD hh:mm:ss') }}</view>
  63. </view>
  64. <view class="pop_info">
  65. <view class="info_key">请假说明:</view>
  66. <view class="info_value">{{ askInfo.reason }}</view>
  67. </view>
  68. <view class="pop_info">
  69. <view class="info_key">创建时间:</view>
  70. <view class="info_value">{{ dayjs(askInfo.initiateTime).format('YYYY-MM-DD hh:mm:ss') }}</view>
  71. </view>
  72. </view>
  73. </uni-popup>
  74. </view>
  75. </template>
  76. <script setup>
  77. import { ref } from 'vue'
  78. import { onLoad } from '@dcloudio/uni-app'
  79. import { myRequest } from '@/utils/api.js'
  80. import dayjs from 'dayjs'
  81. import { decryptDes } from '@/utils/des.js'
  82. import NoData from '@/components/noData.vue'
  83. // 时间选择框绑定数据
  84. const time = ref('')
  85. // 当前状态
  86. const currentType = ref(1)
  87. // 展示的列表数据
  88. const listData = ref([])
  89. // 全部数据
  90. const info = ref({})
  91. // 弹窗元素标记
  92. const popup = ref(null)
  93. // 弹窗请假信息
  94. const askInfo = ref({})
  95. const dataTree_student = ref([])
  96. const classes_student = ref()
  97. onLoad(() => {
  98. // 获取当前时间
  99. time.value = dayjs(Date.now()).format('YYYY-MM-DD') + ' 00:00:00'
  100. const manageGrade = uni.getStorageSync('userInfo').manageGrade
  101. const manageSchoolClass = uni.getStorageSync('userInfo').manageSchoolClass
  102. getManageClass(manageSchoolClass, manageGrade)
  103. })
  104. // 获取管理的班级数组
  105. const getManageClass = async (manageSchoolClass, manageGrade) => {
  106. const res = await myRequest({
  107. url: '/wanzai/api/smartUser/getManageClass',
  108. data: {
  109. manageSchoolClass,
  110. manageGrade
  111. }
  112. })
  113. // console.log(res)
  114. const result = JSON.parse(decryptDes(res.data))
  115. // console.log(result)
  116. dataTree_student.value = result
  117. classes_student.value = result[0].classId
  118. getData()
  119. }
  120. // 获取列表数据
  121. const getData = async () => {
  122. const res = await myRequest({
  123. url: '/wanzai/api/smartUser/statisticsCampus',
  124. data: {
  125. // classId: uni.getStorageSync('userInfo').schoolClass,
  126. classId: classes_student.value,
  127. dateTime: time.value
  128. }
  129. })
  130. // console.log(res)
  131. if (res.code == 200) {
  132. const result = JSON.parse(decryptDes(res.data))
  133. // console.log(result)
  134. info.value = result
  135. if (currentType.value === 1) {
  136. listData.value = result.abnormal.date
  137. } else if (currentType.value === 2) {
  138. listData.value = result.normal.date
  139. } else if (currentType.value === 3) {
  140. listData.value = result.ack.date
  141. }
  142. }
  143. }
  144. // 切换时间时的回调
  145. const changeTime = (v) => {
  146. time.value = v + ' 00:00:00'
  147. getData()
  148. }
  149. // 切换状态时的回调
  150. const changeType = (v) => {
  151. if (currentType.value != v) {
  152. currentType.value = v
  153. getData()
  154. }
  155. }
  156. // 点击姓名时触发的回调
  157. const clickName = async (item) => {
  158. // 获取学生相关的信息
  159. const res = await myRequest({
  160. url: '/wanzai/api/smartUser/addressBook',
  161. data: {
  162. userId: item.userId
  163. }
  164. })
  165. // console.log(res)
  166. if (res.code == 200) {
  167. const result = JSON.parse(decryptDes(res.data))
  168. console.log(result)
  169. uni.navigateTo({
  170. url: `/pages/student/student?msg=${encodeURIComponent(JSON.stringify(result))}`
  171. })
  172. }
  173. }
  174. // 点击详情时触发的回调
  175. const clickDetail = (item) => {
  176. // console.log(item)
  177. if (currentType.value === 2) {
  178. // 跳转 轨迹
  179. uni.navigateTo({
  180. url: `/pages/track/track?id=${item.userId}&time=${time.value}`
  181. })
  182. } else if (currentType.value === 3) {
  183. // 弹窗
  184. askInfo.value = {}
  185. // 获取请假信息
  186. getAskInfo(item.userId)
  187. popup.value.open()
  188. }
  189. }
  190. const getAskInfo = async (userId) => {
  191. const res = await myRequest({
  192. url: '/wanzai/api/smartAttendance/ackDetail',
  193. data: {
  194. userId,
  195. dateTime: time.value
  196. }
  197. })
  198. // console.log(res)
  199. if (res.code == 200) {
  200. const result = JSON.parse(decryptDes(res.data))
  201. // console.log(result)
  202. askInfo.value = result[0]
  203. }
  204. }
  205. // 班级筛选框选择时的回调
  206. const onchange_student = (e) => {
  207. // console.log(e.detail.value)
  208. // console.log(classes_student.value)
  209. getData()
  210. }
  211. </script>
  212. <style lang="scss" scoped>
  213. .statistics {
  214. position: relative;
  215. box-sizing: border-box;
  216. padding: 130rpx 20rpx 0;
  217. height: 100vh;
  218. overflow: hidden;
  219. background-color: #f1f6fe;
  220. .img {
  221. position: absolute;
  222. top: -50rpx;
  223. right: -50rpx;
  224. width: 589rpx;
  225. height: 320rpx;
  226. }
  227. .picker {
  228. position: absolute;
  229. top: 30rpx;
  230. right: 20rpx;
  231. width: 273rpx;
  232. height: 80rpx;
  233. }
  234. .school {
  235. margin-bottom: 30rpx;
  236. }
  237. .type {
  238. position: relative;
  239. display: flex;
  240. justify-content: space-evenly;
  241. align-items: center;
  242. width: 710rpx;
  243. height: 122rpx;
  244. background-color: #fff;
  245. .type_box {
  246. display: flex;
  247. justify-content: center;
  248. align-items: center;
  249. width: 210rpx;
  250. height: 90rpx;
  251. font-size: 28rpx;
  252. border-radius: 10rpx;
  253. background-color: #f2f6fc;
  254. }
  255. .active {
  256. background-color: #3464ff;
  257. color: #fff;
  258. }
  259. }
  260. .list {
  261. padding: 30rpx 20rpx;
  262. margin-top: 20rpx;
  263. max-height: calc(100vh - 532rpx);
  264. font-size: 28rpx;
  265. background-color: #fff;
  266. overflow-y: auto;
  267. .list_header {
  268. display: flex;
  269. justify-content: space-evenly;
  270. align-items: center;
  271. height: 73rpx;
  272. background-color: #f2f6fc;
  273. .header_box {
  274. width: 33%;
  275. text-align: center;
  276. }
  277. }
  278. .list_content {
  279. max-height: calc(100vh - 605rpx);
  280. overflow-y: auto;
  281. .list_box {
  282. display: flex;
  283. justify-content: space-evenly;
  284. align-items: center;
  285. height: 85rpx;
  286. border-bottom: 2rpx solid #e5e5e5;
  287. .box {
  288. width: 33%;
  289. text-align: center;
  290. }
  291. .color {
  292. color: #0061ff;
  293. }
  294. }
  295. }
  296. }
  297. .popup_box {
  298. padding-bottom: 50rpx;
  299. width: 710rpx;
  300. border-radius: 22rpx;
  301. background-color: #fff;
  302. .pop_header {
  303. display: flex;
  304. justify-content: center;
  305. align-items: center;
  306. position: relative;
  307. height: 94rpx;
  308. font-size: 28rpx;
  309. border-bottom: 1rpx solid #e6e6e6;
  310. .header_icon {
  311. position: absolute;
  312. top: 18rpx;
  313. right: 25rpx;
  314. font-size: 40rpx;
  315. }
  316. }
  317. .pop_info {
  318. display: flex;
  319. box-sizing: border-box;
  320. margin-top: 22rpx;
  321. padding: 0 35rpx;
  322. width: 100%;
  323. line-height: 42rpx;
  324. font-size: 28rpx;
  325. .info_key {
  326. color: #999999;
  327. }
  328. .info_value {
  329. flex: 1;
  330. }
  331. }
  332. }
  333. }
  334. </style>