vue 移动端弹窗带滚动效果 滚动到底的时候弹窗下的页面会跟着滑动

21 篇文章 0 订阅

<template>
  <div class="wrap" :style="dynamicStyle"><!--dynamicStyle主要是介个 通过computed设置postion的值 弹窗的时候设置为fixed 关闭弹窗的时候设置为unset-->
    <div class="banner-wrap">
      <img src="@/assets/images/banner2.png" class="banner" />
      <div class="header">
        <div class="d1">{{ user.name }},您好</div>        
        <img src="@/assets/images/help.png" alt="" class="icon-help" @click="openHelpHandle">
      </div>
    </div>
    <div class="scrollerWrap">
      <!--头部下拉选择-->
      <div class="scroll-head">
        <el-select v-model="classId" style="flex: 1; margin-right: 10px;" @change="seletClassChange">
          <el-option v-for="item in classList" :key="item.deptId" :label="item.deptName" :value="item.deptId">
          </el-option>        
        </el-select>
        <el-select v-model="itemType" style="width: 60%;" @change="seletTaskChange">
          <el-option label="身高/体重" :value="1"></el-option>
          <el-option label="立定跳远" :value="3"></el-option>
          <el-option label="坐位体前屈" :value="4"></el-option>
          <el-option label="双脚连续跳" :value="5"></el-option>
          <el-option label="走平衡木" :value="6"></el-option>
          <el-option label="握力" :value="7" v-if="physicalVersion == 2"></el-option>
          <el-option label="15米绕障碍跑" :value="8" v-if="physicalVersion == 2"></el-option>
          <el-option label="网球掷远" :value="9" v-if="physicalVersion == 1"></el-option>
          <el-option label="10米折返跑" :value="10" v-if="physicalVersion == 1"></el-option>
        </el-select>
      </div>

      <div v-if="!isAll">
        <!--头部tab-->
        <div class="tab">
          <div class="tab-list" :class="{ active: tabIdx == 0 }" @click="changeTab(0)">共{{ total }}个幼儿</div>
          <div class="tab-list" :class="{ active: tabIdx == 1 }" @click="changeTab(1)">{{ totalTested }}个测试完</div>
          <div class="tab-list" :class="{ active: tabIdx == 2 }" @click="changeTab(2)">{{ totalUntested }}个未测试</div>
          <!-- <div class="tab-list tab-list4">3个异常</div> -->
        </div>

        <!--学生列表-->
        <div class="item" v-if="tabIdx == 0">         
          <div v-for="item in phyTaskDetailList" :key="item.sid" class="list" :class="{ entered: item.checked }" @click="openEnter(item)">
            <div class="list-head">
              <div class="physical-wrap">
                <img src="@/assets/images/type8.png" class="icon-physical" alt="">
              </div>

              <div class="physical-data" v-if="itemType == 1">
                <div class="d1">身高<span class="s1">{{ item.heightList == null ? 0 : item.heightList[0].score }}</span>cm</div>
                <div class="d1">体重<span class="s1">{{ item.weightList == null ? 0 : item.weightList[0].score}}</span>kg</div>              
              </div>
              
              <div class="physical-data" v-else>
                <div class="d1">{{ computedTxt }}<span class="s1">{{ computedName(item) }}</span>{{ computedUnit }}</div>              
              </div>            

              <div class="entered-num" v-if="itemType != 1 && computedNavlistLength(item) > 0">{{ computedNavlistLength(item) }}</div>
            </div>
            <div class="list-bot">{{ item.number }}号</div>
          </div>
        </div>

        <div class="item" v-if="tabIdx == 1">         
          <div v-for="item in testedArr" :key="item.sid" class="list" :class="{ entered: item.checked }" @click="openEnter(item)">
            <div class="list-head">
              <div class="physical-wrap">
                <img src="@/assets/images/type8.png" class="icon-physical" alt="">
              </div>

              <div class="physical-data" v-if="itemType == 1">
                <div class="d1">身高<span class="s1">{{ item.heightList == null ? 0 : item.heightList[0].score }}</span>cm</div>
                <div class="d1">体重<span class="s1">{{ item.weightList == null ? 0 : item.weightList[0].score}}</span>kg</div>              
              </div>
              
              <div class="physical-data" v-else>
                <div class="d1">{{ computedTxt }}<span class="s1">{{ computedName(item) }}</span>{{ computedUnit }}</div>              
              </div>            

              <div class="entered-num" v-if="itemType != 1 && computedNavlistLength(item) > 0">{{ computedNavlistLength(item) }}</div>
            </div>
            <div class="list-bot">{{ item.number }}号</div>
          </div>
        </div>

        <div class="item" v-if="tabIdx == 2">         
          <div v-for="item in unTestedArr" :key="item.sid" class="list" :class="{ entered: item.checked }" @click="openEnter(item)">
            <div class="list-head">
              <div class="physical-wrap">
                <img src="@/assets/images/type8.png" class="icon-physical" alt="">
              </div>

              <div class="physical-data" v-if="itemType == 1">
                <div class="d1">身高<span class="s1">{{ item.heightList == null ? 0 : item.heightList[0].score }}</span>cm</div>
                <div class="d1">体重<span class="s1">{{ item.weightList == null ? 0 : item.weightList[0].score}}</span>kg</div>              
              </div>
              
              <div class="physical-data" v-else>
                <div class="d1">{{ computedTxt }}<span class="s1">{{ computedName(item) }}</span>{{ computedUnit }}</div>              
              </div>            

              <div class="entered-num" v-if="itemType != 1 && computedNavlistLength(item) > 0">{{ computedNavlistLength }}</div>
            </div>
            <div class="list-bot">{{ item.number }}号</div>
          </div>
        </div>
      </div>  
      <div v-else>
        <div class="class-list">
          <div class="class-list-head">共{{ allTotal }}个班级,8个项目</div>          
          <div class="class-box" v-for="item in allInfo" :key="item.id">
            <div class="class-name">{{ item.className }}</div>
            <div class="d1" v-for="navitem in item.itemList" :key="navitem.id">
              <span>{{ navitem.itemTypeName }}</span> 
              <span>已测试完成{{ navitem.completeNum }}个幼儿({{ navitem.completePercent }}%)</span>
              <span>未测试{{ navitem.incompleteNum }}个({{ navitem.incompletePercent }}%)</span>
            </div>
          </div>
        </div>
      </div>
    </div>    

    <div class="mask" v-if="openMask"></div>
    <!-- 新增/编辑列表数据 -->
    <div class="pop-box" v-if="open">
      <img src="@/assets/images/logo_head2.png" class="logo-head" alt="">
      <div class="pop-header">{{ typeName }}</div>  
      <div class="student-mes-wrap">
        <div class="student-mes">{{ deptName }} {{studentNumber}}号</div>
      </div>
      <div class="group-wrap">
        <div class="group-item" v-if="itemType != 1">
          <div class="group-list">
            <div class="d1">第1组记录</div>
            <el-input type="number" v-model="teamgroup.team1" placeholder="请输入内容" class="i1"></el-input>
            <div class="d2" @click="saveTeam(1)">保存</div>
          </div>

          <div class="group-list">
            <div class="d1">第2组记录</div>
            <el-input type="number" v-model="teamgroup.team2" placeholder="请输入内容" class="i1"></el-input>
            <div class="d2" @click="saveTeam(2)">保存</div>
          </div>

          <div class="group-list">
            <div class="d1">第3组记录</div>
            <el-input type="number" v-model="teamgroup.team3" placeholder="请输入内容" class="i1"></el-input>
            <div class="d2" @click="saveTeam(3)">保存</div>
          </div>
        </div>
        <div class="group-item" v-else>
          <div class="group-list">
            <div class="d1">身高</div>
            <el-input type="number" v-model="teamgroup.teamHeight" placeholder="请输入内容" class="i1"></el-input>
            <div class="d2" @click="saveTeamHeight">保存</div>
          </div>

          <div class="group-list">
            <div class="d1">体重</div>
            <el-input type="number" v-model="teamgroup.teamWeight" placeholder="请输入内容" class="i1"></el-input>
            <div class="d2" @click="saveTeamWeight">保存</div>
          </div>
        </div>

        <div class="group-warn">
          <span>*保留小数点后一位</span>
          <span>*正常值在{{ sectionValue }}</span>
        </div>

      </div>
      <div class="pop-footer">
        <div class="b1" @click="cancel">取消</div>
      </div>
    </div>    

    <!--提示弹窗-->
    <div class="alert-mask" v-if="alertmask"></div>
    <transition name="fade" v-if="alertOpen">      
      <div class="alert-box">
        <i class="el-icon-circle-check icon-success" v-if="alertIcon == 1"></i>
        <i class="el-icon-circle-close icon-danger" v-if="alertIcon == 2"></i>
        <i class="el-icon-warning-outline icon-warning" v-if="alertIcon == 3"></i>        
        <p class="p1">{{ alertMes }}</p>
      </div>
    </transition>

    <!--帮助弹窗-->
    <div class="pop-box" v-if="openHelp">
      <img src="@/assets/images/logo_head2.png" class="logo-head" alt="">
      <div class="pop-header">帮助</div>  
      <div class="help-cont" v-html="helpCont" @click="judgeImg($event)"></div>
      <div class="pop-footer">
        <div class="b1" @click="closeHelp">关闭</div>
      </div>
    </div>
  </div> 
</template>

<script>
import { listPhyTaskDetail, getClassList, getStatisticsTotal, getPhyTaskDetail, addPhyTaskDetail, updatePhyTaskDetail, getDetectMissionHelp } from "@/api/school/phyTaskDetail";
import {ImagePreview} from "vant"  //引入vant预览图片组件

export default {
  metaInfo: {
    title: '测试页',
    titleTemplate: null,//不加这个会有个默认的后缀
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no' }
    ]
  },
  name: "PhyTaskDetail",
  data() {
    return {     
      position: 'unset',
      helpCont: null,
      openHelp: false,
      allInfo: null,//全部统计的信息
      allTotal: 0,
      isAll: false,//判断是不是全部统计
      studentNumber: null,//选中的学生班号      
      testedArr: [],//已测试的数组
      unTestedArr: [],//未测试的数组
      sid: null,//学生id
      tabIdx: 0,//顶部tab的下标 
      classId:null,//选中的班级id
      deptName: null,//选中的班级名称
      taskId:null,//上一个页面传过来的id
      physicalVersion: null,//体测版本
      classList: [],//班级下拉列表的值 也就是左上角第一个下拉列表
      //弹窗-start
      alertMes: null,
      alertIcon: null,//success1 error2 warning3
      alertOpen: false,
      alertmask: false,
      //弹窗-end

      teamgroup : {
        teamHeight: null,
        teamHeightId: null,
        teamWeight: null,
        teamWeightId: null,
        team1: null,
        teamId1: null,
        team2: null,
        teamId2: null,
        team3: null,
        teamId3: null,
      },
      
      openMask: false,
      // 是否显示弹出层
      open: false,
      typeName: '身高/体重',
      sectionValue: '50cm~200cm, 5kg~50kg',//区间值
      itemType: 1,
      user: null,
      total: 0,
      totalTested: 0,//统计已测试
      totalUntested: 0,//统计未测试
      // 遮罩层
      loading: true,
      // 体测数据表格数据
      phyTaskDetailList: [],

      // 表单参数
      form: {},
    };
  },
  computed: {
    computedTxt() {
      if (this.itemType == '3' || this.itemType == '4' || this.itemType == '9') {
        return '距离';
      } else if(this.itemType == '5' || this.itemType == '6' || this.itemType == '8' || this.itemType == '10') {
        return '用时';
      } else if(this.itemType == '7'){
        return '力度'
      }
    },
    computedUnit() {
      if (this.itemType == '3' || this.itemType == '4') {
        return 'cm';
      } else if(this.itemType == '9'){
        return 'm';
      } else if(this.itemType == '5' || this.itemType == '6' || this.itemType == '8' || this.itemType == '10') {
        return 's';
      } else if(this.itemType == '7'){
        return 'kg'
      }
    },
    computedName(){
      return function(item) { //通过itemType判断要显示那个字段
        return this.itemType == 3 ? item.downStrength : this.itemType == 4 ? item.flexibility : this.itemType == 5 ? item.coordination : this.itemType == 6 ? item.balance : this.itemType == 7 ? item.upStrength : this.itemType == 8 ? item.sensitivity : this.itemType == 9 ? item.upStrength : this.itemType == 10 ? item.sensitivity : ''
      };
    },
    computedNavlistLength(){
      return function(item) { //通过itemType判断要显示那个字段的子集长度
        return this.itemType == 3 ? (Array.isArray(item.downStrengthList) ? item.downStrengthList.length : 0) : 
               this.itemType == 4 ? (Array.isArray(item.flexibilityList) ? item.flexibilityList.length : 0) : 
               this.itemType == 5 ? (Array.isArray(item.coordinationList) ? item.coordinationList.length : 0) : 
               this.itemType == 6 ? (Array.isArray(item.balanceList) ? item.balanceList.length : 0) : 
               this.itemType == 7 ? (Array.isArray(item.upStrengthList) ? item.upStrengthList.length : 0) : 
               this.itemType == 8 ? (Array.isArray(item.sensitivityList) ? item.sensitivityList.length : 0) : 
               this.itemType == 9 ? (Array.isArray(item.upStrengthList) ? item.upStrengthList.length : 0) : 
               this.itemType == 10 ? (Array.isArray(item.sensitivityList) ? item.sensitivityList.length : 0) : ''
      };
    },
    dynamicStyle() {
      return {
        position: this.position, // 使用计算属性返回样式对象
        // 其他样式属性...
      };
    },
  },
  created() {
    //console.log(this.$route.params.id)
    this.taskId = this.$route.params.id;  //'27836848421849e997cf48b672646d0ed4ec38d4abeb44aba78ea333bb0001b2'; //'8e86e2f4f06d4021bf548239b1937db4eb130fd0376141fdaaa175822f08b106'; // this.$route.params.id
    this.physicalVersion = this.$route.params.physicalVersion; // '1'; // this.$route.params.physicalVersion
    this.user = this.$store.state.user;
    //console.log(this.user)
    this.form.userId = this.user.userId;
    this.form.schoolId = this.user.schoolId;    
    //this.seletTaskChange(this.itemType) //选择体测的项目 获取对应的项目名称 对应的区间 默认身高/体重

    //如果用户直接访问这个页面 给它跳转到列表页
    if(!this.$route.params.id){
      this.$router.push({ path: '/phyTask' })
    }
    this.getClassListData() //获取班级列表
    //this.getList();
  },
  methods: {
    //判断是否为图片并提取当前图片地址
    judgeImg(e){
        if(e.target.tagName=="IMG" && e.target.currentSrc){
            this.previewSingleImg(e.target.currentSrc)
        }
    },
    //查看单个大图
    previewSingleImg(url) {
        ImagePreview({
            images: Array.of(url),
            startPosition: 0,
        });
    },
    closeHelp(){
      this.openHelp = false
      this.openMask = false
      this.position = 'unset'
    },
    openHelpHandle(){
      const that = this
      let params = {
        type: 6,
        userId: this.user.userId
      }
      getDetectMissionHelp(params).then(res => {        
        if(res.rows.length == 0 || res.rows[0].length == 0){
          this.handleAlert('暂无帮助信息', 3)
          setTimeout(function(){
            that.closeAlert()
          },1000)
          return
        }
        //console.log(res.rows[0].brief)
        this.helpCont = res.rows[0].brief
        this.openHelp = true
        this.openMask = true
        this.position = 'fixed'
      });
    },
    //通过itemType判断当前获取到的是哪个体测项目
    getCurrentItem(item){
      return this.itemType == 3 ? item.downStrengthList : this.itemType == 4 ? item.flexibilityList : this.itemType == 5 ? item.coordinationList : this.itemType == 6 ? item.balanceList : this.itemType == 7 ? item.upStrengthList : this.itemType == 8 ? item.sensitivityList : this.itemType == 9 ? item.upStrengthList : this.itemType == 10 ? item.sensitivityList : []
    },
    openEnter(item){
      this.studentNumber = item.number
      /*
        点击的时候获取到item
        通过itemType判断当前获取到的是哪个体测项目
        拿到该体测项目的数组
        回显到对应的组里面去
      */
      //console.log(item)
      let oitemArr = this.getCurrentItem(item)
      //console.log(item)
      if(oitemArr && oitemArr.length > 0){
        //编辑
        if(this.itemType != 1){
          for(let i in oitemArr){
            if(oitemArr[i].sort == 1){
              this.teamgroup.teamId1 = oitemArr[i].id
              this.teamgroup.team1 = oitemArr[i].score
            }
            if(oitemArr[i].sort == 2){
              this.teamgroup.teamId2 = oitemArr[i].id
              this.teamgroup.team2 = oitemArr[i].score
            }
            if(oitemArr[i].sort == 3){
              this.teamgroup.teamId3 = oitemArr[i].id
              this.teamgroup.team3 = oitemArr[i].score
            }
          }
        }
      }
      //身高体重 回显
      if(this.itemType == 1){
        if(item.heightList != null && item.heightList && item.heightList.length > 0){
          this.teamgroup.teamHeight = item.heightList[0].score
          this.teamgroup.teamHeightId = item.heightList[0].id
        }
        if(item.weightList != null && item.weightList && item.weightList.length > 0){
          this.teamgroup.teamWeight = item.weightList[0].score
          this.teamgroup.teamWeightId = item.weightList[0].id
        }
      }
      this.sid = item.sid
      //console.log(sid)
      this.open = true
      this.openMask = true
    },
    changeTab(idx){
      this.tabIdx = idx
    },
    //查询班级列表
    getClassListData(){
      getClassList(this.taskId).then(response => {
        if(response.code == 200){
          this.classList = response.rows
          let allOption = {
            deptId: 0,
            deptName: '全部'
          }
          this.classList.unshift(allOption)        
          if(this.classList.length > 1){
            this.classId = this.classList[1].deptId
            this.deptName = this.classList[1].deptName
            this.getList()
          }   
        }
      });
    },
    /** 查询体测数据列表 */
    getList() {
      this.loading = true;
      let params = {
        classId: this.classId,
        taskId: this.taskId,
        itemType: this.itemType == 1 ? '1,2' : this.itemType 
      }
      listPhyTaskDetail(params).then(response => {
        this.phyTaskDetailList = response.rows;
        this.total = response.total;
        this.loading = false;

        //选择不同的体测项目的时候 要重新刷新数据 通过itemType获取不同项目的列表以及状态
        this.getTotalTested()//统计已测试和未测试
      });
    },

    //统计已测试和未测试
    getTotalTested(){
      let totalTested = 0//统计已测试      
      let testedArr = []//已测试的数组
      let unTestedArr =[]//未测试的数组
      this.phyTaskDetailList.forEach(item => {
        //判断 itemType 为1的时候为身高体重
        if(this.itemType == 1){
          if(item.heightList != null && item.heightList.length > 0 || item.weightList != null && item.weightList.length > 0){
            totalTested++
            item.checked = true;//新增checked属性并赋值   
            testedArr.push(item) 
          }else{
            item.checked = false;//新增checked属性并赋值    
            unTestedArr.push(item)
          }
        } else if(this.itemType == 3){ //立定跳远
          if(item.downStrengthList != null && item.downStrengthList.length > 0){
            totalTested++
            item.checked = true;//新增checked属性并赋值   
            testedArr.push(item) 
          }else{
            item.checked = false;//新增checked属性并赋值    
            unTestedArr.push(item)
          }
        } else if(this.itemType == 4){ //坐位体前屈
          if(item.flexibilityList != null && item.flexibilityList.length > 0){
            totalTested++
            item.checked = true;//新增checked属性并赋值   
            testedArr.push(item) 
          }else{
            item.checked = false;//新增checked属性并赋值    
            unTestedArr.push(item)
          }
        } else if(this.itemType == 5){ //双脚连续跳
          if(item.coordinationList != null && item.coordinationList.length > 0){
            totalTested++
            item.checked = true;//新增checked属性并赋值   
            testedArr.push(item) 
          }else{
            item.checked = false;//新增checked属性并赋值    
            unTestedArr.push(item)
          }
        } else if(this.itemType == 6){ //平衡木
          if(item.balanceList != null && item.balanceList.length > 0){
            totalTested++
            item.checked = true;//新增checked属性并赋值   
            testedArr.push(item) 
          }else{
            item.checked = false;//新增checked属性并赋值    
            unTestedArr.push(item)
          }
        } else if(this.itemType == 7){ //握力
          if(item.upStrengthList != null && item.upStrengthList.length > 0){
            totalTested++
            item.checked = true;//新增checked属性并赋值   
            testedArr.push(item) 
          }else{
            item.checked = false;//新增checked属性并赋值    
            unTestedArr.push(item)
          }
        } else if(this.itemType == 8){ //15米绕障碍跑
          if(item.sensitivityList != null && item.sensitivityList.length > 0){
            totalTested++
            item.checked = true;//新增checked属性并赋值   
            testedArr.push(item) 
          }else{
            item.checked = false;//新增checked属性并赋值    
            unTestedArr.push(item)
          }
        } else if(this.itemType == 9){ //网球掷远
          if(item.upStrengthList != null && item.upStrengthList.length > 0){
            totalTested++
            item.checked = true;//新增checked属性并赋值   
            testedArr.push(item) 
          }else{
            item.checked = false;//新增checked属性并赋值    
            unTestedArr.push(item)
          }
        } else if(this.itemType == 10){ //10米折返跑跑
          if(item.sensitivityList != null && item.sensitivityList.length > 0){
            totalTested++
            item.checked = true;//新增checked属性并赋值   
            testedArr.push(item) 
          }else{
            item.checked = false;//新增checked属性并赋值    
            unTestedArr.push(item)
          }
        }        
      });
      this.totalTested = totalTested;//统计已测试
      this.totalUntested = this.total - totalTested;//统计未测试
      this.testedArr = testedArr
      this.unTestedArr = unTestedArr
    },

    //判断输入的值是否在区间内
    detectionSection(val){
      //this.itemType
      if(this.itemType == 3){//立定跳远
        return val > 1 && val < 200 ? true : false
      }else if(this.itemType == 4){//坐位体前屈
        return (val > -10 && val < 30) && val != '' && val != null ? true : false
      }else if(this.itemType == 5){//双脚连续跳
        return val > 2.4 && val < 25 ? true : false
      }else if(this.itemType == 6){//平衡木
        return val > 1.5 && val < 50 ? true : false
      }else if(this.itemType == 7){//握力
        return val > 0 && val < 16 ? true : false
      }else if(this.itemType == 8){//15米绕障碍跑
        return val > 3 && val < 25 ? true : false
      }else if(this.itemType == 9){//网球掷远
        return val > 0 && val < 20 ? true : false
      }else if(this.itemType == 10){//10米折返跑跑
        return val > 3.7 && val < 25 ? true : false
      }
    },

    handleAlert(txt, type){
      this.alertMes = txt
      this.alertIcon = type
      this.alertOpen = true
      this.alertmask = true
    },
    closeAlert(){
      this.alertMes = null
      this.alertIcon = null
      this.alertOpen = false
      this.alertmask = false
    },

    saveTeam(num){
      const that = this
      let oteam = null
      let isEdit = false //判断是新增还是编辑
      if(num == 1){
        oteam = this.teamgroup.team1
        isEdit = this.teamgroup.teamId1 != null && this.teamgroup.teamId1 ? true : false
      } else if(num == 2){
        oteam = this.teamgroup.team2
        isEdit = this.teamgroup.teamId2 != null && this.teamgroup.teamId2 ? true : false
      } else if(num == 3){
        oteam = this.teamgroup.team3
        isEdit = this.teamgroup.teamId3 != null && this.teamgroup.teamId3 ? true : false
      }
      if(!this.detectionSection(oteam)){                
        this.handleAlert('输入有误请重新输入', 3)
        setTimeout(function(){
          that.closeAlert()
        },1000)
        return
      }
                  
      if(isEdit){        
        //编辑
        let params = {
          id: num == 1 ? this.teamgroup.teamId1 : num == 2 ? this.teamgroup.teamId2 : num == 3 ? this.teamgroup.teamId3 : '',
          score: Number(oteam).toFixed(1)
        }
        updatePhyTaskDetail(params).then(res => {
          this.handleAlert('编辑成功', 1)
          setTimeout(function(){
            that.closeAlert()
          },1000)
          this.getList();
        });
      }else{
        //新增
        let params = {
          itemType: this.itemType,
          score: Number(oteam).toFixed(1),
          sid: this.sid,
          sort: num, //身高体重默认1组
          taskId: this.taskId
        }
        addPhyTaskDetail(params).then(res => {
          if(num == 1){
            this.teamgroup.teamId1 = res.data.id
          } else if(num == 2){
            this.teamgroup.teamId2 = res.data.id
          } else if(num == 3){
            this.teamgroup.teamId3 = res.data.id
          }
          this.handleAlert('新增成功', 1)
          setTimeout(function(){
            that.closeAlert()
          },1000)
          this.getList();
        });
      }      
    },    
    saveTeamHeight(){   
      const that = this   
      let heightEstimate = this.teamgroup.teamHeight > 50 && this.teamgroup.teamHeight < 200 ? true : false
      if(!heightEstimate){        
        this.handleAlert('输入有误请重新输入', 3)
        setTimeout(function(){
          that.closeAlert()
        },1000)
        return
      }
      if(this.teamgroup.teamHeightId != null && this.teamgroup.teamHeightId){
        //编辑
        let params = {
          id: this.teamgroup.teamHeightId,
          score: Number(this.teamgroup.teamHeight).toFixed(1)
        }
        updatePhyTaskDetail(params).then(res => {
          this.handleAlert('编辑成功', 1)
          setTimeout(function(){
            that.closeAlert()
          },1000)
          this.getList();
        });
      }else{
        //新增
        let params = {
          itemType: 1,
          score: Number(this.teamgroup.teamHeight).toFixed(1),
          sid: this.sid,
          sort: 1, //身高体重默认1组
          taskId: this.taskId
        }
        addPhyTaskDetail(params).then(res => {
          this.teamgroup.teamHeightId = res.data.id
          this.handleAlert('新增成功', 1)
          setTimeout(function(){
            that.closeAlert()
          },1000)
          this.getList();
        });
      }      
    },
    saveTeamWeight(){
      const that = this
      let weightEstimate = this.teamgroup.teamWeight > 5 && this.teamgroup.teamWeight < 50 ? true : false
      if(!weightEstimate){        
        this.handleAlert('输入有误请重新输入', 3)
        setTimeout(function(){
          that.closeAlert()
        },1000)
        return
      }

      if(this.teamgroup.teamWeightId != null && this.teamgroup.teamWeightId){
        //编辑
        let params = {
          id: this.teamgroup.teamWeightId,
          score: Number(this.teamgroup.teamWeight).toFixed(1)
        }
        updatePhyTaskDetail(params).then(res => {
          this.handleAlert('编辑成功', 1)
          setTimeout(function(){
            that.closeAlert()
          },1000)
          this.getList();
        });
      }else{
        let params = {
          itemType: 2,
          score: Number(this.teamgroup.teamWeight).toFixed(1),
          sid: this.sid,
          sort: 1, //身高体重默认1组
          taskId: this.taskId
        }
        addPhyTaskDetail(params).then(res => {
          this.teamgroup.teamWeightId = res.data.id
          this.handleAlert('新增成功', 1)
          setTimeout(function(){
            that.closeAlert()
          },1000)
          this.getList();
        });
      }      
    },    
    //选择班级
    seletClassChange(val){
      if(val != 0){
        this.isAll = false
        this.classId = val
        let selectedItem = this.classList.find(item => item.deptId === this.classId);
        this.deptName = selectedItem.deptName
        this.getList()
      }else{
        this.isAll = true
        //获取全部的统计信息
        getStatisticsTotal(this.taskId).then(res => {
          if(res.code == 200){            
            this.allInfo = res.rows
            this.allTotal = res.total
          }
        });
      }           
    },
    //选择体测项目
    seletTaskChange(val){
      this.getList()
      switch (val) {
        case 1:
          this.typeName = '身高/体重'
          this.sectionValue = '50cm~200cm, 5kg~50kg'
          break;
        case 3:
          this.typeName = '立定跳远'
          this.sectionValue = '1cm ~ 200cm'
          break;           
        case 4:
          this.typeName = '坐位体前屈'
          this.sectionValue = '-10cm ~ 30cm'
          break;        
        case 5:
          this.typeName = '双脚连续跳'          
          this.sectionValue = '2.4s ~ 25s'
          break;        
        case 6:
          this.typeName = '走平衡木'
          this.sectionValue = '1.5s ~ 50s'
          break;        
        case 7:
          this.typeName = '握力'          
          this.sectionValue = '0kg ~ 16kg'
          break;        
        case 8:
          this.typeName = '15米绕障碍跑'
          this.sectionValue = '3s ~ 25s'
          break;        
        case 9:
          this.typeName = '网球掷远'
          this.sectionValue = '0m ~ 20m'
          break;        
        case 10:
          this.typeName = '10米折返跑'
          this.sectionValue = '3.7s ~ 25s'
          break;        
        default:
          break;
      }
    },   
    // 取消按钮
    cancel() {
      this.teamgroup = {
        teamHeight: null,
        teamHeightId: null,
        teamWeight: null,
        teamWeightId: null,
        team1: null,
        teamId1: null,
        team2: null,
        teamId2: null,
        team3: null,
        teamId3: null,
      }

      this.open = false;
      this.openMask = false;
      //this.reset();
    },

  }
};
</script>

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值