vue实现管理系统_学生管理系统实验报告

vue实现管理系统_学生管理系统实验报告Vue项目:学生管理系统增删改查一套免费获取

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺


  • ? 个人主页: 陶然同学
  • ? 版权: 本文由【陶然同学】原创、在CSDN首发、需要转载请联系博主
  • ? 如果文章对你有帮助、欢迎关注、点赞、收藏(一键三连)和订阅专栏哦
  • 想寻找共同成长的小伙伴,请点击【Java全栈开发社区

查询学生

步骤1:设置导航

vue实现管理系统_学生管理系统实验报告

 步骤2:添加路由

vue实现管理系统_学生管理系统实验报告

步骤3:创建页面

vue实现管理系统_学生管理系统实验报告

  • 步骤:

    • 步骤1:准备2个变量(pageInfo、studentVo)

    • 步骤2:编写查询condition函数,接收参数num

    • 步骤3:页面加载成功时,查询第一页

    • 步骤4:遍历结果

<template>
    <div>
        班级: <select v-model = "studentVo.cid">
            <option value="" disabled>--请选择--</option>
            <option :value="classes.cid" v-for = "(classes,index) in classesList" :key = "index">{
  
  {classes.cname}}</option>
        </select>
        姓名:<input type="text" v-model = "studentVo.studentName">
        年龄:<input type="text" v-model = "studentVo.startAge">——<input type="text" v-model = "studentVo.endAge">
        <input type="button" value = "查询" @click = "conditionStudent()">
        <table border="1">
            <tr>
                <td>ID</td>
                <td>班级</td>
                <td>姓名</td>
                <td>年龄</td>
                <td>生日</td>
                <td>性别</td>
                <td>操作</td>
            </tr>
            <tr v-for = "(student,index) in pageInfo.list" :key="index">
                <td>{
  
  {student.sid}}</td>
                <td>{
  
  {student.classes == null ? student.cname : student.classes.cname}}</td>
                <td>{
  
  {student.sname}}</td>
                <td>{
  
  {student.age}}</td>
                <td>{
  
  {student.birthday}}</td>
                <td>{
  
  {student.gender == 1 ? '男' : '女'}}</td>
                <td>
                    <router-link :to="{path:'/studentEdit',query:{sid : student.sid}}">修改</router-link>
                    <router-link to="" @click.native.prevent = "deleteStudent(student.sid)">删除</router-link>
                </td>
            </tr>
        </table>

        <!-- 分页 start -->
        当前第 {
  
  {pageInfo.pageNum}}页,共{
  
  {pageInfo.pages}}页, 总计数{
  
  {pageInfo.total}}条,
        每页 <select v-model = "pageInfo.pageSize" @change = "conditionStudent(1)">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="5">5</option>
            <option value="10">10</option>
        </select>条

        <a href="" v-if = "!pageInfo.isFirstPage" @click.prevent = "conditionStudent(1)">首页</a>
        <a href="" v-if = "pageInfo.hasPreviousPage" @click.prevent = "conditionStudent(pageInfo.pageNum - 1)">上一页</a>
        <a href="" v-for = "(num,index) in pageInfo.pages" @click.prevent = "conditionStudent(num)" :key="index">{
  
  {num}}</a>
        <a href="" v-if = "pageInfo.hasNextPage" @click.prevent = "conditionStudent(pageInfo.pageNum - 1)">下一页</a>
        <a href="" v-if = "!pageInfo.isLastPage" @click.prevent = "conditionStudent(pageInfo.pages)">尾页</a>
        跳转到 <input v-model = "pageInfo.pageNum" placeholder="enter跳转" @keyup.enter = "conditionStudent()"> 页
        <!-- 分页 end -->
    </div>
</template>

<script>
import axios from 'axios'

export default {
    data() {
        return {
            classesList:[],
            studentVo: {
                cid:''
            },
            pageInfo:{
                pageNum:1,
                pageSize:2
            }
        }
    },
    methods:{
        async selectClasses(){
            let { data: baseResult } = await axios.get("http://localhost:8888/classes");  
            this.classesList = baseResult.data
        },

        async conditionStudent(num){
            if(num){
                this.pageInfo.pageNum = num
            }
            var url = `http://localhost:8888/student/condition/${this.pageInfo.pageSize}/${this.pageInfo.pageNum}`;
            let {data: baseResult} = await axios.post(url,this.studentVo);
            this.pageInfo = baseResult.data
        },
    },
    mounted(){
        //查询所有班级
        this.selectClasses();
        //查询所有学生
        this.conditionStudent();
    }
}
</script>

<style>

</style>

添加学生

步骤1:设置导航

vue实现管理系统_学生管理系统实验报告

步骤2:添加路由

vue实现管理系统_学生管理系统实验报告

步骤3:创建页面

vue实现管理系统_学生管理系统实验报告

步骤:

  • 创建数据 班级数组 和 学生对象
  • 班级数据跟select绑定 table绑定学生对象
  • 发送post请求添加学生
<template>
  <div>
    <table border="1">
      <tr>
        <td>ID</td>
        <td>
          <input type="text" v-model = "student.sid">
        </td>
      </tr>
      <tr>
        <td>班级</td>
        <td>
          <select v-model = "student.cid">
            <option value="">--请选择--</option>
            <option :value="classes.cid" v-for = "(classes,index) in classesList" :key="index">{
  
  {classes.cname}}</option>
          </select>
        </td>
      </tr>
      <tr>
        <td>姓名</td>
        <td>
          <input type="text" v-model = "student.sname">
        </td>
      </tr>
      <tr>
        <td>年龄</td>
        <td> 
          <input type="text" v-model = "student.age">
        </td>
      </tr>
      <tr>
        <td>生日</td>
        <td>
          <input type="date" v-model = "student.birthday">
        </td>
      </tr>
      <tr>
        <td>性别</td>
        <td>
          <input type="radio" v-model = "student.gender" value = "1"> 男
          <input type="radio" v-model = "student.gender" value = "0"> 女
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <input type="button" value = "添加学生" @click = "addStudent()">
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
import axios from 'axios'

export default {
  data() {
    return {
      classesList:[],
      student:{}
    }
  },
  methods:{
      async selectClasses(){
        let {data:baseResult} = await axios.get(`http://localhost:8888/classes`);
        this.classesList = baseResult.data
      },
      async addStudent(){
        var url = "http://localhost:8888/student";
        let { data: baseResult } = await axios.post(url,this.student);
        if(baseResult.code == 20000){
            this.$router.push('/studentList')
        }else{
          alert(baseResult.message)
        }
      }
  },
  mounted(){
    //查询所有班级
    this.classesList = this.selectClasses();
  }
}
</script>

<style>

</style>

修改学生

步骤1:设置导航

vue实现管理系统_学生管理系统实验报告

步骤2:添加路由

vue实现管理系统_学生管理系统实验报告  

步骤3:创建页面

vue实现管理系统_学生管理系统实验报告

步骤:

  • 先获得路由传参传过来的参数 存储到data数据区域 cid
  • 根据cid查询到学生 存储到student table对student进行数据双向关联
  • 修改学生信息 发送ajax请求
<template>
    <div>
        <table border = "1">
            <tr>
                <td>编号</td>
                <td>
                    {
  
  { classes.cid }}
                </td>
            </tr>
            <tr>
                <td>班级名称</td>
                <td>
                    <input type="text" v-model = "classes.cname">
                </td>
            </tr>
            <tr>
                <td>班级描述</td>
                <td>
                    <textarea name="" id="" cols="30" rows="10" v-model = "classes.desc"></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="text" value = "修改" @click = "editClasses()">
                </td>
            </tr>
        </table>
    </div>
</template>

<script>
import axios from 'axios';
export default {
    data() {
        return {
            classes:{},
            cid:'',
        };
    },
    methods:{
        async selectClassesById(){
            let url = `http://localhost:8888/classes/${this.cid}`;
            let { data: baseResult } = await axios.get(url);
            this.classes = baseResult.data
        },

        async editClasses(){
            var url = `http://localhost:8888/classes`;
            let { data: baseResult } = await axios.put(url,this.classes);
            if(baseResult.code == 20000){
                this.$router.push("/classesList");
            }else{
                alert(baseResult.message);
            }
        }
    },
    mounted(){
        //获得cid
        this.cid = this.$route.params.cid;
        //根据id查询班级信息
        this.selectClassesById();
    }
}
</script>

<style>

</style>

删除学生

步骤1:设置导航

vue实现管理系统_学生管理系统实验报告

步骤2:添加方法

vue实现管理系统_学生管理系统实验报告

步骤:

  • 根据cid发送ajax删除学生
<template>
    <div>
        班级: <select v-model = "studentVo.cid">
            <option value="" disabled>--请选择--</option>
            <option :value="classes.cid" v-for = "(classes,index) in classesList" :key = "index">{
  
  {classes.cname}}</option>
        </select>
        姓名:<input type="text" v-model = "studentVo.studentName">
        年龄:<input type="text" v-model = "studentVo.startAge">——<input type="text" v-model = "studentVo.endAge">
        <input type="button" value = "查询" @click = "conditionStudent()">
        <table border="1">
            <tr>
                <td>ID</td>
                <td>班级</td>
                <td>姓名</td>
                <td>年龄</td>
                <td>生日</td>
                <td>性别</td>
                <td>操作</td>
            </tr>
            <tr v-for = "(student,index) in pageInfo.list" :key="index">
                <td>{
  
  {student.sid}}</td>
                <td>{
  
  {student.classes == null ? student.cname : student.classes.cname}}</td>
                <td>{
  
  {student.sname}}</td>
                <td>{
  
  {student.age}}</td>
                <td>{
  
  {student.birthday}}</td>
                <td>{
  
  {student.gender == 1 ? '男' : '女'}}</td>
                <td>
                    <router-link :to="{path:'/studentEdit',query:{sid : student.sid}}">修改</router-link>
                    <router-link to="" @click.native.prevent = "deleteStudent(student.sid)">删除</router-link>
                </td>
            </tr>
        </table>

        <!-- 分页 start -->
        当前第 {
  
  {pageInfo.pageNum}}页,共{
  
  {pageInfo.pages}}页, 总计数{
  
  {pageInfo.total}}条,
        每页 <select v-model = "pageInfo.pageSize" @change = "conditionStudent(1)">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="5">5</option>
            <option value="10">10</option>
        </select>条

        <a href="" v-if = "!pageInfo.isFirstPage" @click.prevent = "conditionStudent(1)">首页</a>
        <a href="" v-if = "pageInfo.hasPreviousPage" @click.prevent = "conditionStudent(pageInfo.pageNum - 1)">上一页</a>
        <a href="" v-for = "(num,index) in pageInfo.pages" @click.prevent = "conditionStudent(num)" :key="index">{
  
  {num}}</a>
        <a href="" v-if = "pageInfo.hasNextPage" @click.prevent = "conditionStudent(pageInfo.pageNum - 1)">下一页</a>
        <a href="" v-if = "!pageInfo.isLastPage" @click.prevent = "conditionStudent(pageInfo.pages)">尾页</a>
        跳转到 <input v-model = "pageInfo.pageNum" placeholder="enter跳转" @keyup.enter = "conditionStudent()"> 页
        <!-- 分页 end -->
    </div>
</template>

<script>
import axios from 'axios'

export default {
    data() {
        return {
            classesList:[],
            studentVo: {
                cid:''
            },
            pageInfo:{
                pageNum:1,
                pageSize:2
            }
        }
    },
    methods:{
        async selectClasses(){
            let { data: baseResult } = await axios.get("http://localhost:8888/classes");  
            this.classesList = baseResult.data
        },

        async conditionStudent(num){
            if(num){
                this.pageInfo.pageNum = num
            }
            var url = `http://localhost:8888/student/condition/${this.pageInfo.pageSize}/${this.pageInfo.pageNum}`;
            let {data: baseResult} = await axios.post(url,this.studentVo);
            this.pageInfo = baseResult.data
        },

        async deleteStudent(sid){
            if(!confirm("您确定要删除么?")){
                return
            }

            let {data : baseResult} = await axios.delete(`http://localhost:8888/student/${sid}`)
            if(baseResult.code == 20000){
                this.conditionStudent(1);
            }else {
                    alert(baseResult.message)
            }
        }
    },
    mounted(){
        //查询所有班级
        this.selectClasses();
        //查询所有学生
        this.conditionStudent();
    }
}
</script>

<style>

</style>

后端

链接:https://pan.baidu.com/s/1032Wkr58iZfPJ7baJSsqiw 

密码:2002        

后端部分代码:

package com.czxy.controller;

import com.czxy.domain.Student;
import com.czxy.service.StudentService;
import com.czxy.vo.BaseResult;
import com.czxy.vo.StudentVo;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author 刘嘉俊
 * @Date 2022/2/21
 */
@RestController
@RequestMapping("/student")
@CrossOrigin
public class StudentController {

    @Resource
    private StudentService studentService;

    @PostMapping("/condition/{pageSize}/{pageNum}")
    public BaseResult condition(
            @PathVariable("pageSize") Integer pageSize,
            @PathVariable("pageNum") Integer pageNum,
            @RequestBody StudentVo studentVo) {

        // 查询
        PageInfo<Student> pageInfo = studentService.condition(pageSize,pageNum,studentVo);

        // 返回结果
        return BaseResult.ok("查询成功", pageInfo);
    }

    @GetMapping("/{sid}")
    public BaseResult selectById(@PathVariable("sid") String sid){
        Student student = studentService.selectById(sid);

        return BaseResult.ok("查询成功",student);
    }

    @PutMapping
    public BaseResult update(@RequestBody Student student){
        System.out.println(student);
        try {
            boolean result = studentService.update(student);
            if(result){
                return BaseResult.ok("更新成功");
            }else{
                return BaseResult.error("更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return BaseResult.error(e.getMessage());
        }
    }

    @DeleteMapping("/{sid}")
    public BaseResult delete(@PathVariable("sid")String sid){
        System.out.println("sid" + sid);
        try {
            boolean result = studentService.delete(sid);
            if(result){
                return BaseResult.ok("删除成功");
            }
            return BaseResult.error("删除失败");
        } catch (Exception e) {
            e.printStackTrace();
            return BaseResult.error(e.getMessage());
        }
    }

    @PostMapping
    public BaseResult addStudent(@RequestBody Student student){
        try {
            boolean result = studentService.addStudent(student);
            if(result){
                return BaseResult.ok("添加成功");
            }
            return BaseResult.error("添加失败");
        } catch (Exception e) {
            e.printStackTrace();
            return BaseResult.error(e.getMessage());
        }
    }
}

源码获取

vue实现管理系统_学生管理系统实验报告

 vue实现管理系统_学生管理系统实验报告

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/191612.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 脱壳——UPX脱壳原理(脱壳helloworld)

    脱壳——UPX脱壳原理(脱壳helloworld)脱壳——UPX脱壳原理脱壳步骤1找到OEP2dump(导出)内存文件3修复1找到OEP1程序运行先从壳代码运行,壳代码执行完之后会跳转到真正的OEP,也就是是说第一步,首先要找到

    2022年7月1日
    33
  • 如何组装配置属于自己的台式机电脑_台式电脑怎么组装的

    如何组装配置属于自己的台式机电脑_台式电脑怎么组装的如何组装配置属于自己的台式机现在电脑这么普及,大部分人都有自己的电脑,有的是台式机,有的是笔记本。很多朋友配台式机时都是直接去电脑城然后商家给配置方案或者找认识的朋友推荐一套配置方案,但是有些时候会

    2022年8月4日
    4
  • vs 错误LNK2019 无法解析的外部符号 __imp__PathFileExistsA@

    vs 错误LNK2019 无法解析的外部符号 __imp__PathFileExistsA@尝试:在main函数前添加:#pragmacomment(lib,”Shlwapi.lib”)

    2022年7月14日
    14
  • initramfs是什么_hdfs工作原理

    initramfs是什么_hdfs工作原理initramfs概述initramfs与initrd类似,也是初始化好了且存在于ram中的,可以压缩也可以不压缩。但是目前initramfs只支持cpio包格式,它会被populate_rootfs->unpack_to_rootfs(&__initramfs_start,&__initramfs_end-&__initramfs_start,0)函数(解压缩、)解析、安装。

    2022年8月11日
    7
  • idea 运行单个main方法_idea如何运行main方法[通俗易懂]

    idea 运行单个main方法_idea如何运行main方法[通俗易懂]使用IntelliJIdea打包可执行JAR1、Model结构如下:…IDEA发布1.8.1配置编译class的环境1.8.2配置web环境1.8.3发布到tomcat运行环境中1.8.4启动运行1.8.5发布到war文件操作完成后进入下一……Main-Class:Main这边Main既是运行类,含有main()方法的一个类文…

    2022年5月31日
    376
  • 用python做学生信息管理系统_python管理系统实例

    用python做学生信息管理系统_python管理系统实例Python面向对象版学员管理系统文章目录Python面向对象版学员管理系统目标一.系统需求二.准备程序文件2.1分析2.2创建程序文件三.书写程序3.1student.py3.1.2程序代码3.2managerSystem.py3.2.1定义类3.2.2管理系统框架3.3main.py3.4定义系统功能函数3.4.1添加功能3.4.2删除学员3.4.3修改学员信息3.4.5查询学员信息3.4.6显示所有学员信息3.4.7保存学员信息3.4.8加载学员信息四.总结

    2022年9月20日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号