qa-prevention-xgf-app/pages/train_management/index.vue

259 lines
6.4 KiB
Vue
Raw Normal View History

<template>
2025-02-18 10:49:05 +08:00
<view class="content">
2025-02-18 16:54:09 +08:00
<u-list @scrolltolower="scrolltolower" v-if="trainList.length > 0">
2025-02-18 10:49:05 +08:00
<u-list-item v-for="(item, index) in trainList" :key="index">
<view class="container_item">
<view class="container_item_name">
<text>{{ item.className }}</text>
</view>
2025-02-18 10:49:05 +08:00
<view class="container_item_content">
<view class="content_text">
<view>
<text class="content_label">所属单位: </text>
2025-02-18 16:18:07 +08:00
<text class="content_value">{{ item.corpinfoName }}</text>
2025-02-18 10:49:05 +08:00
</view>
</view>
<view class="content_text">
<view>
<text class="content_label">培训开始时间: </text>
2025-02-18 16:18:07 +08:00
<text class="content_value">{{ item.startTime }}</text>
2025-02-18 10:49:05 +08:00
</view>
</view>
<view class="content_text">
<view>
<text class="content_label">培训结束时间: </text>
2025-02-18 16:18:07 +08:00
<text class="content_value">{{ item.endTime }}</text>
2025-02-18 10:49:05 +08:00
</view>
</view>
<view class="content_text">
<view class="content_bottom">
<view> <text class="content_label">任务状态: </text>{{ handleCalcTaskStatus(item.state) }} </view>
2025-02-18 10:49:05 +08:00
<view class="action-row">
<u-button size="mini" type="primary" text="签到信息" :disabled="item.userSignPath === '0'" @click="signInInformation(item.classId)" />
2025-02-19 18:13:40 +08:00
<u-button size="mini" type="primary" text="考试记录" :disabled="item.stageexamstate === '1' || item.stageexamstate === '4'" @click="ExamRecord(item)" />
2025-02-18 10:49:05 +08:00
</view>
</view>
</view>
</view>
</view>
</u-list-item>
</u-list>
2025-02-18 16:54:09 +08:00
<empty v-else></empty>
2025-02-18 10:49:05 +08:00
</view>
</template>
<script>
import { getClassList, getIsUploadFace } from '@/api';
import store from '@/store/index';
2025-02-18 16:54:09 +08:00
export default {
data() {
return {
verification: store.state.verification, // 本地读取人脸检测验证状态
2025-02-18 16:54:09 +08:00
pageSize: 10,
currentPage: 1,
totalPage: 0,
trainList: [],
taskStatusMap: {
1: '待完善',
4: '待开班',
5: '培训中',
6: '培训结束'
2025-02-18 10:49:05 +08:00
}
2025-02-18 16:54:09 +08:00
}
},
2025-02-18 16:54:09 +08:00
/* 监听页面显示,页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面 */
2025-02-22 17:21:46 +08:00
async onShow() {
await this.getUserFaceCompleted()
await this.resetList()
2025-02-18 16:54:09 +08:00
},
async onLoad(query) {
2025-02-22 17:21:46 +08:00
// await this.getUserFaceCompleted()
// await this.resetList()
},
2025-02-18 16:54:09 +08:00
methods: {
async resetList() {
2025-02-18 16:54:09 +08:00
this.pageSize = 10
this.currentPage = 1
this.trainList = []
await this.getData()
},
async getData() {
// verification --> 0: 未完成人脸认证
// verification --> 1: 已完成人脸认证
if (this.verification === '1') {
let resData = await getClassList({
showCount: this.pageSize,
currentPage: this.currentPage
})
this.trainList = [...this.trainList, ...resData.page.list]
this.totalPage = resData.page.totalPage
}
2025-02-18 16:54:09 +08:00
},
scrolltolower() {
this.currentPage++
if (this.totalPage >= this.currentPage) this.getData()
},
/**
* 右上角自定义扫码图标触发事件
*/
onNavigationBarButtonTap(e) {
// 只允许通过手机相机扫码
uni.scanCode({
// scanType: ['qrCode'], // 仅支持二维码扫码
2025-02-19 18:13:40 +08:00
onlyFromCamera: false, // 是否只能从相机扫码,允许从相册选择图片
hideAlbum: false, // 显示相册,允许从相册选择图片
success: (response) => {
2025-02-22 17:21:46 +08:00
const { stageexampaperinputId, classId, type, } = JSON.parse(response.result)
const findClassId = this.trainList.some((item) => item.classId === classId)
if (type === '0') {
2025-02-18 16:54:09 +08:00
// 签到二维码方式进入
if (findClassId) {
uni.$u.route({
url: '/pages/train_management/realname_info_auth',
params: {
type: 'scan_face',
classId
}
})
} else {
uni.$u.toast('您未在培训计划内,无法入班签到,请联系教师')
}
} else if (type === '1') {
2025-02-18 16:54:09 +08:00
// 考试二维码方式进入
if (findClassId) {
uni.$u.route({
url: '/pages/train_management/face_authentication',
params: {
type: 'learning_certification',
stageexampaperinputId,
classId,
}
})
} else {
uni.$u.toast('您未在培训计划内,无法进行考试,请联系教师')
}
2025-02-18 10:49:05 +08:00
}
2025-02-18 16:54:09 +08:00
},
fail: function (error) {
console.log('error :>> ', error)
},
complete: function (result) {
console.log('扫码完成,正在跳转功能页!')
}
})
},
/**
* 获取是否已经完成上传人脸信息
*/
2025-02-19 18:13:40 +08:00
async getUserFaceCompleted() {
// const userFaceData = await getIsUploadFace()
// verification --> 0: 未完成人脸认证
// verification --> 1: 已完成人脸认证
if (this.verification === '0') {
2025-02-19 18:13:40 +08:00
uni.showModal({
title: '温馨提示',
content: '检测到您还未完成人脸信息读取,请先完成人脸信息认证!',
success: function (res) {
if (res.confirm) {
uni.$u.route({
url: '/pages/train_management/face_authentication',
params: {
type: 'facial_input'
}
})
}
if (res.cancel) {
uni.navigateBack({ delta: 1 })
}
}
})
}
},
2025-02-18 16:54:09 +08:00
handleCalcTaskStatus(type) {
return this.taskStatusMap[type]
},
/**
* 签到信息
*/
signInInformation(classId) {
uni.$u.route({
url: '/pages/train_management/sign_information',
params: {
classId
}
})
},
/**
* 考试记录
*/
2025-02-19 18:13:40 +08:00
ExamRecord(record) {
const { stagestudentrelationId, classId } = record
2025-02-18 16:54:09 +08:00
uni.$u.route({
url: '/pages/train_management/exam_record',
params: {
2025-02-19 18:13:40 +08:00
classId,
2025-02-22 17:21:46 +08:00
stagestudentrelationId
2025-02-18 16:54:09 +08:00
}
})
2025-02-18 10:49:05 +08:00
}
}
2025-02-18 16:54:09 +08:00
}
</script>
<style scoped lang="scss">
2025-02-18 16:54:09 +08:00
.container_item {
padding-left: 16rpx;
2025-02-18 16:54:09 +08:00
.container_item_name {
font-size: 32rpx;
font-weight: 500;
margin-bottom: 20rpx;
}
2025-02-18 16:54:09 +08:00
.container_item_content {
display: flex;
flex-direction: column;
gap: 8rpx;
2025-02-18 16:54:09 +08:00
.content_text {
color: #acafb3;
font-size: 30rpx;
2025-02-18 16:54:09 +08:00
.content_label {
display: inline-block;
width: 220rpx;
}
2025-02-18 16:54:09 +08:00
.content_value {
display: inline-block;
transform: translateY(8rpx);
padding: 0;
width: 452rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
2025-02-18 16:54:09 +08:00
.content_bottom {
display: flex;
align-items: center;
justify-content: space-between;
}
2025-02-18 16:54:09 +08:00
.action-row {
display: flex;
align-items: center;
justify-content: center;
gap: 16rpx;
2025-02-18 10:49:05 +08:00
}
}
}
2025-02-18 16:54:09 +08:00
}
</style>