学生评价信息展示-思想、职业、身心、文化、劳动
<template>
<view>
<view class='page-container'>
<uni-segmented-control :current='current' :values='items' @clickItem='onClickItem' styleType='button' activeColor='#4cd964'></uni-segmented-control>
<view class='content'>
<view v-show='current === 0'>
选项卡1的内容
</view>
<view v-show='current === 1'>
选项卡2的内容
</view>
<view v-show='current === 2'>
选项卡3的内容
</view>
</view>
</view>
</view>
</template>
<script>
import {
getGradeYears,
getDeatil
} from '@/utils/student.js'
export default {
data() {
return {
gradeyear: 0,
options: [],
studentXh: '',
items: ['思想', '职业', '身心', '文化', '劳动'],
current: 0,
score: '',
tableData: [],
currentableData: [],
vModelValue: 3,
value: '',
}
},
mounted() {
uni.getStorage({
key: 'studentxh',
success: (res) => {
this.studentXh = res.data
}
})
this.getYears()
this.onClickItem({currentIndex: 0})
},
methods: {
change(e) {
this.gradeyear = e
},
async getYears() {
const res = await getGradeYears({
xh: this.studentXh
})
if (res.msg == '成功') {
const All = res.data
let myrange = []
All.forEach((val, index) => {
myrange.push({
value: val.gradeYear, // 选项id
text: val.gradeYear // 选项名称
})
})
this.options = myrange
if (this.options.length > 0) {
this.gradeyear = this.options[0].value
this.queryscires()
}
}
},
async queryscires() {
const res = await getDeatil({
studentId: this.studentXh,
gradeYear: this.gradeyear
})
if (res.msg == '成功') {
this.score = res.data.score
this.tableData = res.data.list
// console.log(this.tableData)
// this.onClickItem()
this.selectdata()
}
},
selectdata() {
let index = Number.parseInt(this.current) + 1
console.log(index)
let start, end;
start = this.tableData.findIndex(item => item.itemName.startsWith(index))
end = this.tableData.findIndex(item => item.itemName.startsWith(index + 1))
if (end == -1) {
console.log(start)
this.currentableData = this.tableData.slice(start)
} else {
console.log(start, end)
this.currentableData = this.tableData.slice(start, end)
if (this.currentableData.length > 0) {
console.log(this.currentableData)
}
}
},
onClickItem(e) {
if (this.current !== e.currentIndex) {
this.current = e.currentIndex;
this.queryscires()
}
}
}
}
</scrip
原文地址: https://www.cveoy.top/t/topic/o2qC 著作权归作者所有。请勿转载和采集!