记录一个vue编辑的移动端页面

news2024/10/7 19:19:21

<template>
  <div class="wrap">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="120px">

      <el-form-item label="班级" prop="classId" required style="width: 100%;">
        <template v-if="oroles == 'teacher_director'">
          <el-select v-model="queryParams.classId" placeholder="请选择班级" @change="seletChange">
            <el-option v-for="item in classList" :key="item.deptId" :label="item.deptName" :value="item.deptId">
            </el-option>
          </el-select>
        </template>
        <template v-else>
          <div>{{ classList[0] ? classList[0].deptName : '' }}</div>
        </template>
      </el-form-item> 

      <el-form-item label="选择学生" prop="student" required>
        <el-button size="mini" @click="openStudent">点击选择</el-button>
        <div class="checked-student" v-if="checkedStudent">
          <!-- <el-image style="width: 60px; height: 60px; border-radius: 50%;" :src="checkedStudent.headUrl" fit="cover"></el-image> -->
          <div class="student-mes">
            <div class="d1">{{ checkedStudent.number }}号</div>
            <!-- <div class="d2">{{ checkedStudent.name }}</div> -->
          </div>
        </div>
      </el-form-item>

      <el-form-item label="性别" prop="sex">
        <el-radio v-model="queryParams.sex" label="0">男</el-radio>
        <el-radio v-model="queryParams.sex" label="1">女</el-radio>
      </el-form-item>

      <el-form-item label="生日" prop="birthday">
        <el-date-picker clearable v-model="queryParams.birthday" type="date" value-format="yyyy-MM-dd" placeholder="请选择生日">
        </el-date-picker>
      </el-form-item>      
                
      <el-form-item label="身高" prop="height">
        <div class="input-wrap">
          <el-input type="number" oninput="if(value.length>5)value=value.slice(0,5)" v-model="queryParams.height" placeholder="请输入身高" />
          <div class="d1">(cm)</div>
        </div>
      </el-form-item>
      <el-form-item label="体重" prop="weight">
        <div class="input-wrap">
          <el-input type="number" oninput="if(value.length>5)value=value.slice(0,5)" v-model="queryParams.weight" placeholder="请输入体重" />
          <div class="d1">(kg)</div>
        </div>    
      </el-form-item>
      
      <el-form-item label="坐位体前屈" prop="flexibility">
        <div class="input-wrap">
          <el-input type="number" oninput="if(value.length>5)value=value.slice(0,5)" v-model="queryParams.flexibility" placeholder="请输入" />
          <div class="d1">(cm)</div>
        </div>          
      </el-form-item>

      <el-form-item label="立定跳远" prop="downStrength">
        <div class="input-wrap">
          <el-input type="number" oninput="if(value.length>5)value=value.slice(0,5)" v-model="queryParams.downStrength" placeholder="请输入" />
          <div class="d1">(cm)</div>
        </div>        
      </el-form-item>
      <el-form-item :label="physicalVersion == '2' ? '握力' : '网球掷远'" prop="upStrength">
        <div class="input-wrap">
          <el-input type="number" oninput="if(value.length>5)value=value.slice(0,5)" v-model="queryParams.upStrength" placeholder="请输入" />
          <div class="d1">{{ physicalVersion == '2' ? '(kg)' : '(m)' }}</div>
        </div>          
      </el-form-item>
      
      <el-form-item label="平衡木" prop="balance"> 
        <div class="input-wrap">
          <el-input type="number" oninput="if(value.length>5)value=value.slice(0,5)" v-model="queryParams.balance" placeholder="请输入" /> 
          <div class="d1">(s)</div>
        </div>         
      </el-form-item>

      <el-form-item label="双脚连跳" prop="coordination"> 
        <div class="input-wrap">
          <el-input type="number" oninput="if(value.length>5)value=value.slice(0,5)" v-model="queryParams.coordination" placeholder="请输入" /> 
          <div class="d1">(s)</div>
        </div>        
      </el-form-item>

      <el-form-item :label="physicalVersion == '2' ? '15米绕障碍跑' : '10米折返跑'" prop="sensitivity"> 
        <div class="input-wrap">
          <el-input type="number" oninput="if(value.length>5)value=value.slice(0,5)" v-model="queryParams.sensitivity" placeholder="请输入" /> 
          <div class="d1">{{ physicalVersion == '2' ? '(s)' : '(s)' }}</div>
        </div>         
      </el-form-item>
      
      <el-form-item label=" " prop="" size="medium">
        <div class="pop-footer">
          <div class="b1" @click="prev">返回</div>
          <div class="b2" @click="save">保存</div>
        </div>
      </el-form-item>   
    </el-form>
            
    <div class="mask" v-if="open"></div>
    <!-- 选择学生 -->
    <div class="pop-box" v-if="open">
      <div class="student-header">
        <div class="d1">请选择学生</div>
        <div class="close-wrap" @click="cancel">
          <i class="el-icon-close"></i>
        </div>
      </div>
      <div class="student-main">

        <div class="student-list" v-for="(item,index) in reportRecordDetailList" :key="item.id" @click="studentHandle(index)">          
          <div class="img-wrap">
            <img src="@/assets/images/complet.png" class="icon-complet" v-if="item.status == 1" />
            <!-- <i class="el-icon-success" v-if="item.checked"></i> -->
          </div>
          <div class="student-mes" :class="{ active: item.checked }">
            <div class="d1">{{ item.number }}号</div>
          </div>
        </div>        

      </div>
    </div>

  </div>
</template>

<script>
import { listDeptAll,listReportRecordDetail, getReportRecordDetail, delReportRecordDetail, addReportRecordDetail, updateReportRecordDetail } from "@/api/school/reportRecordDetail";
import { listDept } from "@/api/system/dept";

export default {
  metaInfo() {
    return {
      title: this.PageTitle,
      titleTemplate: null,//不加这个会有个默认的后缀
      meta: [
        {
          name: "viewport",
          content: 'width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no',
        },
      ],
    };
  },

  // metaInfo: {
  //   //title: '详情页',
  //   meta: [
  //     { charset: 'utf-8' },
  //     { name: 'viewport', content: 'width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no' }
  //   ]
  // },
  name: "ReportRecordDetail",
  data() {
    return {
      // 班级数据
      classList: [],
      queryParams: {
        classId: null,        
        recordId: null,//上级目录id
        id: null,//学生列表里的id(修改则必填 新增的时候没有id)
        sid: null,//选中的学生id
        sex: null,//性别 2是未知 0男 1女
        birthday: null,   
        height: null,
        weight: null,
        flexibility: null,
        downStrength: null,
        upStrength: null,   

        balance: null,  
        coordination: null,
        sensitivity: null,
      },
      ouser: null,//用户信息
      checkedStudent: null,//选中的学生信息    
      reportRecordDetailList: [],// 体测数据,录入学生数据表格数据
      oroles: null,//角色
      studentIndex: null,
      physicalVersion: null,//版本

      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      // 总条数
      total: 0,      
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数      
      // 表单参数
      form: {},    
      name: null,
      PageTitle: null, 
      isclock: false, 
    };
  },
  watch: {
    selectedValue(newValue, oldValue) {
      // 当selectedValue变化时,这个函数会被调用
      // newValue是新选中的值,oldValue是之前的值
      console.log('选中的值变化了', newValue, oldValue);
      // 在这里可以执行其他逻辑
    }
  },
  created() {    
    this.ouser = this.$store.state.user;
    this.reportRecordDetailList = [];//重置学生列表
    this.queryParams.recordId = this.$route.params.id
    this.physicalVersion = this.$route.params.physicalVersion
    this.name = this.$route.params.name

    //如果用户直接访问这个页面 给它跳转到列表页
    if(!this.queryParams.recordId){
      this.$router.push({ path: '/reportRecord' })
    }
    //判断当前老师是不是混龄班级的老师teacher_director
    this.oroles = this.ouser.roles[0]
    if(this.oroles == 'teacher_director'){
      this.getClassListAll();
    }else{
      this.getClassList();
    }    
  },
  mounted() {    
    this.PageTitle = this.name
  },
  methods: {
    seletChange(val){
      if(val){
        this.checkedStudent = null
        this.resetInput()
      }
    },
    prev(){
      this.$router.go(-1); // 返回上一页
    },
    /** 查询班级列表 */
    getClassListAll() {
      listDeptAll({ deptType: 3, parentId: this.ouser.schoolId, status :0 }).then(response => {
        this.classList = response.data;
      });
    },
    save(){
      if(this.isclock) return
      this.isclock = true
      if(!this.checkedStudent){
        this.$modal.msgError("请先选择学生");
        this.isclock = true
        return
      }
      this.queryParams.sid = this.checkedStudent.sid
      if(this.checkedStudent.id){
        this.queryParams.id = this.checkedStudent.id        
      }else{
        this.queryParams.id = null
      }
      //新增/编辑
      addReportRecordDetail(this.queryParams).then(res => {
        //this.$modal.msgSuccess("新增成功");
        this.checkedStudent.id = res.data.id //ly-add
        this.$modal.confirm(this.checkedStudent.number + '号学生数据保存成功,继续提交下一位同学?').then(() => {          
          this.isclock = false
          this.queryParams.id = null
          this.queryParams.sid = null
          this.resetInput()  
          //studentIndex 学生下标 如果学生下标+1 有sid 那么就是有学生 如果没有sid 则最后一个学生了
          //学生列表 this.reportRecordDetailList
          let olist = this.reportRecordDetailList
          if(olist[this.studentIndex + 1].sid){
            this.checkedStudent = olist[this.studentIndex + 1]
            if(olist[this.studentIndex + 1].id){
              let slist = olist[this.studentIndex + 1]              
              //有id代表编辑状态
              this.fillValue(slist)              
            }
            this.studentIndex++            
          }
        }).catch(() => { 
          this.isclock = false
        });
      }).catch(() => { 
        this.isclock = false
      });;        
    },
    studentHandle(idx){
      this.studentIndex = idx; //给选中的下标赋值
      let olist = this.reportRecordDetailList
      this.reportRecordDetailList.forEach(item => {
        item.checked = false; // 重置所有的checked状态为false
      })
      olist[idx].checked = true
      this.reportRecordDetailList = olist
      this.checkedStudent = olist[idx]
      if(olist[idx].id){
        //有id代表编辑状态
        this.fillValue(olist[idx])
      }else{
        this.resetInput()
      }      
      this.open = false
    },

    fillValue(list){
      this.queryParams.sex = list.sex
      this.queryParams.birthday = list.birthday
      this.queryParams.height = list.height
      this.queryParams.weight = list.weight
      this.queryParams.flexibility = list.flexibility
      this.queryParams.downStrength = list.downStrength
      this.queryParams.upStrength = list.upStrength
      this.queryParams.balance = list.balance 
      this.queryParams.coordination = list.coordination
      this.queryParams.sensitivity = list.sensitivity 
    },

    resetInput(){
      this.queryParams.sex = null
      this.queryParams.birthday = null
      this.queryParams.height = null
      this.queryParams.weight = null
      this.queryParams.flexibility = null
      this.queryParams.downStrength = null
      this.queryParams.upStrength = null  
      this.queryParams.balance = null 
      this.queryParams.coordination = null
      this.queryParams.sensitivity = null 
    },

    //打开学生列表
    openStudent(){
      if(!this.queryParams.classId){
        this.$modal.msgError("请先选择班级");
        return
      }
      this.getList()
      this.open = true
    },
    /** 查询班级列表 */
    getClassList() {
      listDept({ deptType: 3, parentId: this.ouser.schoolId }).then(response => {
        this.classList = response.data;
        this.queryParams.classId = this.classList[0].deptId
      });
    },

    /** 查询体测数据,录入学生数据列表 */
    getList() {
      //如果班级id为空 则不请求接口      
      this.loading = true;      
      let params = {
        classId: this.queryParams.classId,
        recordId: this.queryParams.recordId
      }
      listReportRecordDetail(params).then(response => {
        response.rows.forEach(item => {
          item.checked = false; // 添加checked属性并赋值为false 作为判断是否选中的标识
        });
        this.reportRecordDetailList = response.rows
        //如果已有选中的学生 给选中的学生加个选中状态
        if(this.checkedStudent && this.checkedStudent.number){
          let oindex = this.reportRecordDetailList.findIndex(item => item.number == this.checkedStudent.number)          
          this.reportRecordDetailList[oindex].checked = true
        }
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      //this.reset();
    },
    // 表单重置
    reset() {
      this.queryParams = {
        id: null,
        sid: null,
        classId: null,
        recordId: null,
        sex: null,//性别 2是未知 0男 1女
        birthday: null, 
        height: null,
        weight: null,
        flexibility: null,
        downStrength: null,
        upStrength: null,
      };
      this.resetForm("queryParams");//queryForm / form
    },

  }
};
</script>
<style scoped>
.close-wrap{ width: 40px; height: 40px; display: flex; justify-content: center; align-items: center;}
.close-wrap .el-icon-close{ color: #fff;}
.student-list{ display: flex; flex-direction: column; align-items: center;}
.img-wrap{ position: relative; width: 40px;}
.img-wrap .el-icon-success{ position: absolute; top: -5px; right: -5px; color: #33a9ff;}
.wrap /deep/ .el-scrollbar .el-scrollbar__bar {
  opacity: 1 !important;
}
.wrap{ padding: 30px 15px 15px 15px;}
.checked-student{ margin-top: 5px; display: flex; flex-direction: column;}
.student-mes{ width: 40px; height: 40px; text-align: center; line-height: 40px; font-size: 12px; color: #33a9ff; border: 1px solid #33a9ff; border-radius: 50%;}
.student-mes .d2{ margin-left: 5px; max-width: 50px;}
.student-mes.active{ background: #33a9ff; color: #fff;}
.mask{ position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 998; background: rgba(0,0,0,0.3);}
.pop-box{ position: fixed; top: 5%; left: 5%; z-index: 999; box-sizing: border-box; display: flex; flex-direction: column; width: 90%; height: 90%; background: #fff; border-radius: 10px;}
.student-header{ padding-left: 15px; display: flex; justify-content: space-between; align-items: center; height: 40px; background: #33a9ff; font-size: 14px;
   color: #fff; border-radius: 10px 10px 0 0;}
.student-main{ align-content:flex-start; padding: 15px 0 10px 0; display: grid; grid-template-columns: repeat(5, 1fr); grid-gap: 10px; flex: 1; overflow-y: scroll;}
.student-img{ display: block; width: 40px; height: 40px; object-fit: cover; border-radius: 50%;}
.icon-complet{ position: absolute; top: -5px; left: -5px; width: 20px;}
.wrap /deep/ .el-form-item__label{ font-weight: 400;}
</style>
<style>
@media (max-width: 720px) {
  .el-message-box {
    width: 350px !important;
  }
}

.pop-footer{ display: flex; justify-content: center; align-items: center; height: 60px;}
.pop-footer .b1,.pop-footer .b2{ width: 80px; height: 36px; text-align: center; line-height: 36px; font-size: 14px; color: #fff; border-radius: 18px;}
.pop-footer .b1{ background: #ffa400;}
.pop-footer .b2{ margin-left: 30px; background: #33a9ff;}
.input-wrap{ position: relative;}
.input-wrap .d1{ position: absolute; top: 0; right: 10px; line-height: 32px; font-size: 12px; color: #33a9ff;}
</style>

起作用的是

main.js
// 头部标签组件 在PC端里使用移动端布局的方法
import VueMeta from 'vue-meta'
Vue.use(VueMeta)

页面里:
metaInfo() {
    return {
      title: this.PageTitle,
      titleTemplate: null,//不加这个会有个默认的后缀
      meta: [
        {
          name: "viewport",
          content: 'width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no',
        },
      ],
    };
  },


@media (max-width: 720px) {
  .el-message-box {
    width: 350px !important;
  }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1509281.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

K8s — PVC|PV Terminating State

在本文中&#xff0c;我们将讨论PV和PVC一直Terminating的状态。 何时会Terminting? 在以下情况下&#xff0c;资源将处于Terminating状态。 在删除Bounded 状态的PVC之前&#xff0c;删除了对应的PV&#xff0c;PV在删除后是Terminting状态。删除PVC时&#xff0c;仍有引用…

使用飞书机器人发送消息与文件

本文默认你已拥有一个机器人&#xff0c;如果没有请点击以下链接创建机器人 检查机器人权限 如果需要跨部门发送消息&#xff0c;检查是否开通跨部门权限 在发布版本时选择作用范围为所有员工 机器人发送消息需要获取以下权限&#xff1a; 通过手机号或邮箱获取用户 ID查看…

ETL的数据挖掘方式

ETL的基本概念 数据抽取&#xff08;Extraction&#xff09;&#xff1a;从不同源头系统中获取所需数据的步骤。比如从mysql中拿取数据就是一种简单的抽取动作&#xff0c;从API接口拿取数据也是。 数据转换&#xff08;Transformation&#xff09;&#xff1a;清洗、整合和转…

Flutter可重排的列表控件ReorderableListView详解

文章目录 ReorderableListView 介绍主要属性使用示例注意事项 ReorderableListView 介绍 ReorderableListView 是 Flutter 中一个可重排的列表控件&#xff0c;允许用户通过拖动来改变列表项的顺序。它继承自 ListView&#xff0c;并提供了一些额外的功能来实现重排功能。 主…

应用方案 | DCDC电源管理芯片MC34063A

DCDC电源管理芯片 MC34063A MC34063A 为一单片 DC-DC 变换集成电路&#xff0c;内含温度补偿的参考电压源&#xff08;1.25V&#xff09;、比较器、能有效限制电流及控制工作周期的振荡器&#xff0c;驱动器及大电流输出开关管等。外配少量元件&#xff0c;就能组成升压、…

Mysql 学习(十五)redo 日志

redo 日志 什么是redo日志&#xff1f;在说这个之前我们先来想一个场景&#xff0c;在访问磁盘的页面之前&#xff0c;我们会先把页面缓存到Buffer Pool之后&#xff0c;才会访问。写页面的时候也会先将buffer pool中的页面修改之后&#xff0c;然后在某个时机才会刷新到磁盘中…

Centos7 安装mongodb 7.0

官方手册参考&#xff1a; https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-red-hat/ Mongodb支持的版本 安装 MongoDB 社区版 按照以下步骤使用包管理器安装 MongoDB Community Edition yum。 配置包管理系统 ( yum) 创建一个/etc/yum.repos.d/mongodb-o…

uni-app微信小程序上拉加载,下拉刷新

pages.json配置官网链接 onPullDownRefresh、onReachBottom函数跟生命周期同级 data() {return {orderList:[],total: null, //总共多少条数据page: 1,pageSize: 10,} }, onLoad() {}, mounted(){this.getInfo() }, methods:{getInfo(){API.getListxxx().then(res > {const…

sensitive-word 敏感词 违规文字检测

1、快速开始 - JDK1.7- Maven 3.x 2、Maven 引入 <!-- https://mvnrepository.com/artifact/com.github.houbb/sensitive-word --><dependency><groupId>com.github.houbb</groupId><artifactId>sensitive-word</artifactId><version…

【CSS3】CSS3 3D 转换示例 - 3D 旋转木马 ( @keyframes 规则 定义动画 | 为 盒子模型 应用动画 | 开启透视视图 | 设置 3D 呈现样式 )

文章目录 一、3D 导航栏示例 - 核心要点1、需求分析2、HTML 结构section 标签 3、CSS 样式keyframes 规则 定义动画为 盒子模型 应用动画开启透视视图设置 3D 呈现样式鼠标移动到控件上方效果设置 6 个子盒子模型的效果 二、完整代码示例1、代码示例2、展示效果 一、3D 导航栏示…

安全防御第七次作业

拓扑图如图所示&#xff1a; 问题&#xff1a;在FW7和FW8之间建立一条IPSEC通道保证10.0.2.0/24网段 可以正常访问到192.168.1.0/24 注&#xff1a;基础配置我在此省略了 一、NAT配置 FW4&#xff1a; FW6&#xff1a; 二、在FW4上做服务器映射 三、配置IPSEC FW5&#xff…

最大的单入口空闲区域

最大的单入口空闲区域 问题描述输入输出代码实现 问题描述 找到最大的单入口空闲区域。 空闲区域是由连通的’O’组成的区域&#xff0c;位于边界的’O’可以是入口&#xff0c; 单入口空闲区域即有且只有一个位于边界的’O’作为入口的由连通的’O’组成的区域。 如果两个元素…

SpringBoot中定时任务、corn表达式

SpringBoot中定时任务、corn表达式 corn表达式网站&#xff1a;https://cron.qqe2.com/ 方法上加上Scheduled(cron表达式) 启动类上加上EnableScheduling 示例 启动类上 启动类加上EnableScheduling开启定时任务。 SpringBootApplication EnableScheduling public class…

应用方案 | D54123B低功耗漏电保护电路

概 述 A&#xff09;、D54123B是一款高性能 CMOS 漏电保护器专用电路。芯片内部包含稳压电源、放大电路、比较器电路、延时电路、计数器电路、跳闸控制电路及跳闸驱动电路。芯片外围应用有脱扣线圈、压敏电阻、稳压二级管、二级管、电阻、电容等元器件。 B&#xff09;、内部…

Day35:安全开发-JavaEE应用原生反序列化重写方法链条分析触发类类加载

目录 Java-原生使用-序列化&反序列化 Java-安全问题-重写方法&触发方法 Java-安全问题-可控其他类重写方法 思维导图 Java知识点&#xff1a; 功能&#xff1a;数据库操作&#xff0c;文件操作&#xff0c;序列化数据&#xff0c;身份验证&#xff0c;框架开发&…

数据结构顺序表的操作,窗口界面(c语言版)

// 准备头文件 #include <stdio.h> #include <stdlib.h>#define InitSize 10 // 动态顺序表的初始默认长度// 定义C语言的bool变量 #define bool char #define true 1 #define false 0/* 定义数据元素的数据类型 */ typedef int ElemType; // 方便更改// 动态顺…

职场逆袭!如何打造‘黄金简历’

现在的职场&#xff0c;无论是哪个行业都特别卷&#xff0c;想要找到一份满意&#xff0c;不仅要求你要拥有丰富的工作经验&#xff0c;而且还要求你的简历足够精彩&#xff0c;这样才能在一众求职者中脱颖而出&#xff01; 一、希赛老师在线指导 之前&#xff0c;小赛分享了…

从0到1了解工业物联网,只需掌握这七点!

目录 1、什么是工业物联网&#xff1f; 2、为什么需要工业物联网&#xff1f; 3、工业物联网与物联网的区别&#xff1f; 4、工业物联网与工业互联网的区别&#xff1f; 5、工业物联网有哪些典型特征&#xff1f; 6、工业物联网方案架构&#xff1f; 7、工业物联网有哪些…

用了一个select框出现的问题许多问题差不多搞了一个多小时最后还是百度解决了,百度伟大

问题出现 问题描述 select 多选框里的数据问题&#xff0c;我讲获取的数据信息放入框ref(null) 中&#xff0c;将数据返回到返回框里&#xff0c;一直发现存在问题&#xff0c;不能正常显示&#xff0c;百度里一下&#xff0c;发现没有百度到其他问题&#xff0c;最后换了一种…

【网络安全】-数字证书

数字证书 数字证书是互联网通讯中用于标志通讯各方身份信息的一串数字或数据&#xff0c;它为网络应用提供了一种验证通信实体身份的方式。具体来说&#xff0c;数字证书是由权威的证书授权&#xff08;CA&#xff09;中心签发的&#xff0c;包含公开密钥拥有者信息以及公开密…