| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- <template>
- <view class="statistics">
- <!-- 背景图片区域 -->
- <img class="img" src="../../static/images/center-bg.png" />
- <!-- 时间选择区域 -->
- <div class="picker">
- <uni-datetime-picker type="date" :clear-icon="false" v-model="time" @change="changeTime"></uni-datetime-picker>
- </div>
- <view class="school">
- <uni-data-picker
- placeholder="请选择班级"
- popup-title="请选择班级"
- :clear-icon="false"
- :map="{ text: 'name', value: 'classId' }"
- :localdata="dataTree_student"
- v-model="classes_student"
- @change="onchange_student"
- ></uni-data-picker>
- </view>
- <!-- 状态选择区域 -->
- <div class="type">
- <div class="type_box" :class="{ active: currentType === 1 }" @click="changeType(1)">未监听({{ info?.abnormal?.count }})</div>
- <div class="type_box" :class="{ active: currentType === 2 }" @click="changeType(2)">监听({{ info?.normal?.count }})</div>
- <div class="type_box" :class="{ active: currentType === 3 }" @click="changeType(3)">请假({{ info?.ack?.count }})</div>
- </div>
- <!-- 列表数据 -->
- <div class="list" v-if="listData.length">
- <div class="list_header">
- <div class="header_box">姓名</div>
- <div class="header_box">学号</div>
- <div v-if="currentType != 1" class="header_box">操作</div>
- </div>
- <div class="list_content">
- <div class="list_box" v-for="item in listData" :key="item.userId">
- <div class="box" @click="clickName(item)">{{ item.name }}</div>
- <div class="box">{{ item.cardNo }}</div>
- <div v-if="currentType != 1" class="box color" @click="clickDetail(item)">详情</div>
- </div>
- </div>
- </div>
- <!-- 没有数据时展示的页面 -->
- <NoData v-else />
- <!-- 详情弹窗区域 -->
- <uni-popup ref="popup" type="center" :is-mask-click="false">
- <view class="popup_box">
- <!-- 弹窗标题区域 -->
- <view class="pop_header">
- 请假详情
- <view class="header_icon" @click="popup.close()">×</view>
- </view>
- <!-- 弹窗详细信息区域 -->
- <view class="pop_info">
- <view class="info_key">请假人姓名:</view>
- <view class="info_value">{{ askInfo.name }}</view>
- </view>
- <view class="pop_info">
- <view class="info_key">学号:</view>
- <view class="info_value">{{ askInfo.cardNo }}</view>
- </view>
- <view class="pop_info">
- <view class="info_key">请假时间:</view>
- <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>
- </view>
- <view class="pop_info">
- <view class="info_key">请假说明:</view>
- <view class="info_value">{{ askInfo.reason }}</view>
- </view>
- <view class="pop_info">
- <view class="info_key">创建时间:</view>
- <view class="info_value">{{ dayjs(askInfo.initiateTime).format('YYYY-MM-DD hh:mm:ss') }}</view>
- </view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script setup>
- import { ref } from 'vue'
- import { onLoad } from '@dcloudio/uni-app'
- import { myRequest } from '@/utils/api.js'
- import dayjs from 'dayjs'
- import { decryptDes } from '@/utils/des.js'
- import NoData from '@/components/noData.vue'
- // 时间选择框绑定数据
- const time = ref('')
- // 当前状态
- const currentType = ref(1)
- // 展示的列表数据
- const listData = ref([])
- // 全部数据
- const info = ref({})
- // 弹窗元素标记
- const popup = ref(null)
- // 弹窗请假信息
- const askInfo = ref({})
- const dataTree_student = ref([])
- const classes_student = ref()
- onLoad(() => {
- // 获取当前时间
- time.value = dayjs(Date.now()).format('YYYY-MM-DD') + ' 00:00:00'
- const id = uni.getStorageSync('userInfo').id
- getManageClass(id)
- })
- // 获取管理的班级数组
- const getManageClass = async (id) => {
- const res = await myRequest({
- url: '/wanzai/api/smartUser/getManageClass',
- data: {
- id
- }
- })
- // console.log(res)
- const result = JSON.parse(decryptDes(res.data))
- // console.log(result)
- dataTree_student.value = result
- classes_student.value = result[0].classId
- getData()
- }
- // 获取列表数据
- const getData = async () => {
- const res = await myRequest({
- url: '/wanzai/api/smartUser/statisticsCampus',
- data: {
- // classId: uni.getStorageSync('userInfo').schoolClass,
- classId: classes_student.value,
- dateTime: time.value
- }
- })
- // console.log(res)
- if (res.code == 200) {
- const result = JSON.parse(decryptDes(res.data))
- // console.log(result)
- info.value = result
- if (currentType.value === 1) {
- listData.value = result.abnormal.date
- } else if (currentType.value === 2) {
- listData.value = result.normal.date
- } else if (currentType.value === 3) {
- listData.value = result.ack.date
- }
- }
- }
- // 切换时间时的回调
- const changeTime = (v) => {
- time.value = v + ' 00:00:00'
- getData()
- }
- // 切换状态时的回调
- const changeType = (v) => {
- if (currentType.value != v) {
- currentType.value = v
- getData()
- }
- }
- // 点击姓名时触发的回调
- const clickName = async (item) => {
- // 获取学生相关的信息
- const res = await myRequest({
- url: '/wanzai/api/smartUser/addressBook',
- data: {
- userId: item.userId
- }
- })
- // console.log(res)
- if (res.code == 200) {
- const result = JSON.parse(decryptDes(res.data))
- console.log(result)
- uni.navigateTo({
- url: `/pages/student/student?msg=${encodeURIComponent(JSON.stringify(result))}`
- })
- }
- }
- // 点击详情时触发的回调
- const clickDetail = (item) => {
- // console.log(item)
- if (currentType.value === 2) {
- // 跳转 轨迹
- uni.navigateTo({
- url: `/pages/track/track?id=${item.userId}&time=${time.value}`
- })
- } else if (currentType.value === 3) {
- // 弹窗
- askInfo.value = {}
- // 获取请假信息
- getAskInfo(item.userId)
- popup.value.open()
- }
- }
- const getAskInfo = async (userId) => {
- const res = await myRequest({
- url: '/wanzai/api/smartAttendance/ackDetail',
- data: {
- userId,
- dateTime: time.value
- }
- })
- // console.log(res)
- if (res.code == 200) {
- const result = JSON.parse(decryptDes(res.data))
- // console.log(result)
- askInfo.value = result[0]
- }
- }
- // 班级筛选框选择时的回调
- const onchange_student = (e) => {
- // console.log(e.detail.value)
- // console.log(classes_student.value)
- getData()
- }
- </script>
- <style lang="scss" scoped>
- .statistics {
- position: relative;
- box-sizing: border-box;
- padding: 130rpx 20rpx 0;
- height: 100vh;
- overflow: hidden;
- background-color: #f1f6fe;
- .img {
- position: absolute;
- top: -50rpx;
- right: -50rpx;
- width: 589rpx;
- height: 320rpx;
- }
- .picker {
- position: absolute;
- top: 30rpx;
- right: 20rpx;
- width: 273rpx;
- height: 80rpx;
- }
- .school {
- margin-bottom: 30rpx;
- }
- .type {
- position: relative;
- display: flex;
- justify-content: space-evenly;
- align-items: center;
- width: 710rpx;
- height: 122rpx;
- background-color: #fff;
- .type_box {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 210rpx;
- height: 90rpx;
- font-size: 28rpx;
- border-radius: 10rpx;
- background-color: #f2f6fc;
- }
- .active {
- background-color: #3464ff;
- color: #fff;
- }
- }
- .list {
- padding: 30rpx 20rpx;
- margin-top: 20rpx;
- max-height: calc(100vh - 532rpx);
- font-size: 28rpx;
- background-color: #fff;
- overflow-y: auto;
- .list_header {
- display: flex;
- justify-content: space-evenly;
- align-items: center;
- height: 73rpx;
- background-color: #f2f6fc;
- .header_box {
- width: 33%;
- text-align: center;
- }
- }
- .list_content {
- max-height: calc(100vh - 605rpx);
- overflow-y: auto;
- .list_box {
- display: flex;
- justify-content: space-evenly;
- align-items: center;
- height: 85rpx;
- border-bottom: 2rpx solid #e5e5e5;
- .box {
- width: 33%;
- text-align: center;
- }
- .color {
- color: #0061ff;
- }
- }
- }
- }
- .popup_box {
- padding-bottom: 50rpx;
- width: 710rpx;
- border-radius: 22rpx;
- background-color: #fff;
- .pop_header {
- display: flex;
- justify-content: center;
- align-items: center;
- position: relative;
- height: 94rpx;
- font-size: 28rpx;
- border-bottom: 1rpx solid #e6e6e6;
- .header_icon {
- position: absolute;
- top: 18rpx;
- right: 25rpx;
- font-size: 40rpx;
- }
- }
- .pop_info {
- display: flex;
- box-sizing: border-box;
- margin-top: 22rpx;
- padding: 0 35rpx;
- width: 100%;
- line-height: 42rpx;
- font-size: 28rpx;
- .info_key {
- color: #999999;
- }
- .info_value {
- flex: 1;
- }
- }
- }
- }
- </style>
|