|
@@ -16,11 +16,11 @@
|
|
|
</view>
|
|
|
<view class="select-info" v-else-if="activeTab == 'class'">
|
|
|
<view v-for="(item, index) in classList" class="info-item" @click="changeClass(item)"
|
|
|
- :class="item.active == true ? `info-active-item1` : `info-item1`">{{ item.name }}</view>
|
|
|
+ :class="item.active == true ? `info-active-item1` : `info-item1`">{{ item.class_name }}</view>
|
|
|
</view>
|
|
|
<view class="select-info" v-else-if="activeTab == 'student'">
|
|
|
<view v-for="(item, index) in studentList" class="info-item" @click="changeStudent(item)"
|
|
|
- :class="item.active == true ? `info-active-item2` : `info-item2`">{{ item.name }}</view>
|
|
|
+ :class="item.active == true ? `info-active-item2` : `info-item2`">{{ item.jname }}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="selected-box">
|
|
@@ -37,16 +37,18 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { onActivated, onMounted, reactive, ref, computed } from "vue";
|
|
|
-import { onLoad } from '@dcloudio/uni-app';
|
|
|
+import { onActivated, onUnmounted, watch, ref, computed } from "vue";
|
|
|
+import { onLoad, onUnload, onHide } from '@dcloudio/uni-app';
|
|
|
import { navTo, showToast } from "@/utils/app";
|
|
|
+import { getTaskClassList, getTaskStudentList } from "@/api/student";
|
|
|
|
|
|
const title = ref('学生未激活')
|
|
|
const select = ref(0)
|
|
|
const selectMax = ref(1)
|
|
|
const totalList = ref([])
|
|
|
const activeTab = ref('grade')
|
|
|
-const countdown = ref(60)
|
|
|
+const countdown = ref(5)
|
|
|
+const interval = ref()
|
|
|
const queryForm = ref({
|
|
|
student_id: 0,
|
|
|
})
|
|
@@ -61,6 +63,23 @@ const selectedArr = ref([
|
|
|
{ name: '11', id: 3 },
|
|
|
])
|
|
|
|
|
|
+const setCountdown = ()=>{
|
|
|
+ interval.value = setInterval(()=>{
|
|
|
+ countdown.value -=1
|
|
|
+ } , 1000);
|
|
|
+ if(countdown.value == 0){
|
|
|
+ clearInterval(interval)
|
|
|
+ goBcak()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+watch(countdown, (newVal, oldVal)=>{
|
|
|
+ if(newVal <= 0){
|
|
|
+ clearInterval(interval.value)
|
|
|
+ goBcak()
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
const classList = computed(() => {
|
|
|
let activeGrade = totalList.value.find(item => item.active == true)
|
|
|
return activeGrade ? activeGrade.class : null
|
|
@@ -83,46 +102,63 @@ const curSelected = computed(() => {
|
|
|
let activeClass = classList.value.find(item => item.active == true)
|
|
|
if (activeClass) {
|
|
|
arr.push(activeClass)
|
|
|
- let activeStudent = studentList.value.find(item => item.active == true)
|
|
|
- if (activeStudent) arr.push(activeStudent)
|
|
|
+ if(studentList.value && studentList.value.length > 0){
|
|
|
+ let activeStudent = studentList.value.find(item => item.active == true)
|
|
|
+ if (activeStudent) arr.push(activeStudent)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return arr
|
|
|
})
|
|
|
|
|
|
-const getGradeList = () => {
|
|
|
- totalList.value = [
|
|
|
- { name: '一年级', id: 1 },
|
|
|
- { name: '二年级', id: 2 },
|
|
|
- { name: '二年级', id: 3 },
|
|
|
- { name: '二年级', id: 4 },
|
|
|
- { name: '二年级', id: 5 },
|
|
|
- { name: '二年级', id: 6 },
|
|
|
- { name: '二年级', id: 7 },
|
|
|
- ]
|
|
|
-}
|
|
|
-
|
|
|
-const getClassList = () => {
|
|
|
- totalList.value.find(item => item.active == true).class = [
|
|
|
- { name: '一班', id: 1 },
|
|
|
- { name: '二班', id: 3 },
|
|
|
- { name: '三班', id: 4 },
|
|
|
- { name: '四班', id: 5 },
|
|
|
- { name: '五班', id: 6 },
|
|
|
- { name: '六班', id: 7 },
|
|
|
- ]
|
|
|
-}
|
|
|
-
|
|
|
-const getStudent = () => {
|
|
|
- totalList.value.find(item => item.active == true).class
|
|
|
- .find(item => item.active == true).student = [
|
|
|
- { name: '11', id: 1 },
|
|
|
- { name: '22', id: 3 },
|
|
|
- { name: '33', id: 4 },
|
|
|
- { name: '44', id: 5 },
|
|
|
- { name: '55', id: 6 },
|
|
|
- { name: '66', id: 7 },
|
|
|
- ]
|
|
|
+const getGradeList = async () => {
|
|
|
+ const res = await getTaskClassList()
|
|
|
+ const list = []
|
|
|
+ if(res.code == 1){
|
|
|
+ res.data.grades.forEach(el => {
|
|
|
+ if (!list.some(e => e.id == el.id)) {
|
|
|
+ list.push(el);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ totalList.value = list
|
|
|
+
|
|
|
+ const classList = []
|
|
|
+ for(let item of res.data.list){
|
|
|
+ for(let task of item.task){
|
|
|
+ classList.push({
|
|
|
+ ...item,
|
|
|
+ ...task,
|
|
|
+ name: item.class_name
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for(let gradeItem of totalList.value){
|
|
|
+
|
|
|
+ let arr = []
|
|
|
+ for(let classItem of classList){
|
|
|
+ if(gradeItem.id == classItem.grade){
|
|
|
+ arr.push(classItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(arr.length > 0)gradeItem.class = arr
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const getStudent = async (item) => {
|
|
|
+ const res = await getTaskStudentList({
|
|
|
+ task_id: item.task_id
|
|
|
+ })
|
|
|
+ if(res.code == 1){
|
|
|
+ let list = res.data.list.map(i=>{
|
|
|
+ return {...i,name: i.jname}
|
|
|
+ })
|
|
|
+ totalList.value.find(item => item.active == true).class
|
|
|
+ .find(item => item.active == true).student = list
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
const changeTab = (item) => {
|
|
@@ -133,7 +169,9 @@ const changeGrade = (item) => {
|
|
|
activeTab.value = 'class'
|
|
|
for (let i of totalList.value) { i.active = false }
|
|
|
item.active = true
|
|
|
- getClassList()
|
|
|
+ let classList = totalList.value.find(i => i.active == true).class
|
|
|
+ for (let i of classList) { i.active = false }
|
|
|
+ // getClassList()
|
|
|
}
|
|
|
|
|
|
const changeClass = (item) => {
|
|
@@ -141,7 +179,7 @@ const changeClass = (item) => {
|
|
|
let classList = totalList.value.find(i => i.active == true).class
|
|
|
for (let i of classList) { i.active = false }
|
|
|
item.active = true
|
|
|
- getStudent()
|
|
|
+ getStudent(item)
|
|
|
}
|
|
|
|
|
|
const changeStudent = (item) => {
|
|
@@ -160,7 +198,8 @@ const goBcak = () => {
|
|
|
const navToTest = () => {
|
|
|
if (curSelected.value.length == 3) {
|
|
|
navTo('pages/test/bmi', {
|
|
|
-
|
|
|
+ student_id: curSelected.value[2].id,
|
|
|
+ task_id: curSelected.value[1].task_id,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -168,10 +207,14 @@ const navToTest = () => {
|
|
|
|
|
|
onLoad(() => {
|
|
|
getGradeList()
|
|
|
+ setCountdown()
|
|
|
})
|
|
|
|
|
|
-// 挂载完成之后
|
|
|
-onMounted(() => {
|
|
|
+onHide(()=>{
|
|
|
+ clearInterval(interval.value)
|
|
|
+})
|
|
|
+onUnload(()=>{
|
|
|
+ clearInterval(interval.value)
|
|
|
})
|
|
|
</script>
|
|
|
|
|
@@ -280,7 +323,7 @@ onMounted(() => {
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
text-align: center;
|
|
|
- height: 110upx;
|
|
|
+ height: 10vh;
|
|
|
line-height: 110upx;
|
|
|
font-weight: bold;
|
|
|
font-size: 28rpx;
|
|
@@ -319,9 +362,11 @@ onMounted(() => {
|
|
|
}
|
|
|
|
|
|
.select-info {
|
|
|
- padding: 20upx;
|
|
|
+ padding: 20upx 10upx 20upx 20upx;
|
|
|
display: flex;
|
|
|
flex-wrap: wrap;
|
|
|
+ height: 40vh;
|
|
|
+ overflow: auto;
|
|
|
}
|
|
|
|
|
|
.info-item {
|