<template>
  <view>
    <view class='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: function(res) {
          this.studentXh = res.data
        }
      })
      this.getYears()
      this.onClickItem({ currentIndex: 0 }) // 添加默认事件对象
    },
    methods: {
      change(e) {
        this.gradeyear = e
      },
      getYears() {
        getGradeYears({
          xh: this.studentXh
        }).then(res => {
          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()
            }
          }
        })
      },
      queryscires() {
        getDeatil({
          studentId: this.studentXh,
          gradeYear: this.gradeyear
        }).then(res => {
          if (res.msg == '成功') {
            this.score = res.data.score
            this.tableData = res.data.list
            // this.onClickItem()
            this.selectdata()
          }
        })
      },
      selectdata() {
        let index = Number.parseInt(this.current)
        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.selectdata()
        } else {
          // this.selectdata()
        }
      }
    }
  }
</scrip
学生评价体系-综合评价

原文地址: https://www.cveoy.top/t/topic/o2ph 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录