定制软件开发Vue项目:学生管理系统


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

查询学生

步骤1:设置导航

 步骤2:添加路由

步骤3:创建页面

  • 步骤:

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

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

    • 步骤3:定制软件开发页面加载成功时,查询第一页

    • 步骤4:遍历结果

  1. <template>
  2. <div>
  3. 班级: <select v-model = "studentVo.cid">
  4. <option value="" disabled>--请选择--</option>
  5. <option :value="classes.cid" v-for = "(classes,index) in classesList" :key = "index">{{classes.cname}}</option>
  6. </select>
  7. 姓名:<input type="text" v-model = "studentVo.studentName">
  8. 年龄:<input type="text" v-model = "studentVo.startAge">——<input type="text" v-model = "studentVo.endAge">
  9. <input type="button" value = "查询" @click = "conditionStudent()">
  10. <table border="1">
  11. <tr>
  12. <td>ID</td>
  13. <td>班级</td>
  14. <td>姓名</td>
  15. <td>年龄</td>
  16. <td>生日</td>
  17. <td>性别</td>
  18. <td>操作</td>
  19. </tr>
  20. <tr v-for = "(student,index) in pageInfo.list" :key="index">
  21. <td>{{student.sid}}</td>
  22. <td>{{student.classes == null ? student.cname : student.classes.cname}}</td>
  23. <td>{{student.sname}}</td>
  24. <td>{{student.age}}</td>
  25. <td>{{student.birthday}}</td>
  26. <td>{{student.gender == 1 ? '男' : '女'}}</td>
  27. <td>
  28. <router-link :to="{path:'/studentEdit',query:{sid : student.sid}}">修改</router-link>
  29. <router-link to="" @click.native.prevent = "deleteStudent(student.sid)">删除</router-link>
  30. </td>
  31. </tr>
  32. </table>
  33. <!-- 分页 start -->
  34. 当前第 {{pageInfo.pageNum}}页,共{{pageInfo.pages}}页, 总计数{{pageInfo.total}}条,
  35. 每页 <select v-model = "pageInfo.pageSize" @change = "conditionStudent(1)">
  36. <option value="1">1</option>
  37. <option value="2">2</option>
  38. <option value="3">3</option>
  39. <option value="5">5</option>
  40. <option value="10">10</option>
  41. </select>
  42. <a href="" v-if = "!pageInfo.isFirstPage" @click.prevent = "conditionStudent(1)">首页</a>
  43. <a href="" v-if = "pageInfo.hasPreviousPage" @click.prevent = "conditionStudent(pageInfo.pageNum - 1)">上一页</a>
  44. <a href="" v-for = "(num,index) in pageInfo.pages" @click.prevent = "conditionStudent(num)" :key="index">{{num}}</a>
  45. <a href="" v-if = "pageInfo.hasNextPage" @click.prevent = "conditionStudent(pageInfo.pageNum - 1)">下一页</a>
  46. <a href="" v-if = "!pageInfo.isLastPage" @click.prevent = "conditionStudent(pageInfo.pages)">尾页</a>
  47. 跳转到 <input v-model = "pageInfo.pageNum" placeholder="enter跳转" @keyup.enter = "conditionStudent()">
  48. <!-- 分页 end -->
  49. </div>
  50. </template>
  51. <script>
  52. import axios from 'axios'
  53. export default {
  54. data() {
  55. return {
  56. classesList:[],
  57. studentVo: {
  58. cid:''
  59. },
  60. pageInfo:{
  61. pageNum:1,
  62. pageSize:2
  63. }
  64. }
  65. },
  66. methods:{
  67. async selectClasses(){
  68. let { data: baseResult } = await axios.get("http://localhost:8888/classes");
  69. this.classesList = baseResult.data
  70. },
  71. async conditionStudent(num){
  72. if(num){
  73. this.pageInfo.pageNum = num
  74. }
  75. var url = `http://localhost:8888/student/condition/${this.pageInfo.pageSize}/${this.pageInfo.pageNum}`;
  76. let {data: baseResult} = await axios.post(url,this.studentVo);
  77. this.pageInfo = baseResult.data
  78. },
  79. },
  80. mounted(){
  81. //查询所有班级
  82. this.selectClasses();
  83. //查询所有学生
  84. this.conditionStudent();
  85. }
  86. }
  87. </script>
  88. <style>
  89. </style>

添加学生

步骤1:设置导航

步骤2:添加路由

步骤3:创建页面

步骤:

  • 创建数据 班级数组 和 学生对象
  • 班级数据跟select绑定 table绑定学生对象
  • 发送post请求添加学生
  1. <template>
  2. <div>
  3. <table border="1">
  4. <tr>
  5. <td>ID</td>
  6. <td>
  7. <input type="text" v-model = "student.sid">
  8. </td>
  9. </tr>
  10. <tr>
  11. <td>班级</td>
  12. <td>
  13. <select v-model = "student.cid">
  14. <option value="">--请选择--</option>
  15. <option :value="classes.cid" v-for = "(classes,index) in classesList" :key="index">{{classes.cname}}</option>
  16. </select>
  17. </td>
  18. </tr>
  19. <tr>
  20. <td>姓名</td>
  21. <td>
  22. <input type="text" v-model = "student.sname">
  23. </td>
  24. </tr>
  25. <tr>
  26. <td>年龄</td>
  27. <td>
  28. <input type="text" v-model = "student.age">
  29. </td>
  30. </tr>
  31. <tr>
  32. <td>生日</td>
  33. <td>
  34. <input type="date" v-model = "student.birthday">
  35. </td>
  36. </tr>
  37. <tr>
  38. <td>性别</td>
  39. <td>
  40. <input type="radio" v-model = "student.gender" value = "1">
  41. <input type="radio" v-model = "student.gender" value = "0">
  42. </td>
  43. </tr>
  44. <tr>
  45. <td colspan="2">
  46. <input type="button" value = "添加学生" @click = "addStudent()">
  47. </td>
  48. </tr>
  49. </table>
  50. </div>
  51. </template>
  52. <script>
  53. import axios from 'axios'
  54. export default {
  55. data() {
  56. return {
  57. classesList:[],
  58. student:{}
  59. }
  60. },
  61. methods:{
  62. async selectClasses(){
  63. let {data:baseResult} = await axios.get(`http://localhost:8888/classes`);
  64. this.classesList = baseResult.data
  65. },
  66. async addStudent(){
  67. var url = "http://localhost:8888/student";
  68. let { data: baseResult } = await axios.post(url,this.student);
  69. if(baseResult.code == 20000){
  70. this.$router.push('/studentList')
  71. }else{
  72. alert(baseResult.message)
  73. }
  74. }
  75. },
  76. mounted(){
  77. //查询所有班级
  78. this.classesList = this.selectClasses();
  79. }
  80. }
  81. </script>
  82. <style>
  83. </style>

修改学生

步骤1:设置导航

步骤2:添加路由

  

步骤3:创建页面

步骤:

  • 先获得路由传参传过来的参数 存储到data数据区域 cid
  • 根据cid查询到学生 存储到student table对student进行数据双向关联
  • 修改学生信息 发送ajax请求
  1. <template>
  2. <div>
  3. <table border = "1">
  4. <tr>
  5. <td>编号</td>
  6. <td>
  7. {{ classes.cid }}
  8. </td>
  9. </tr>
  10. <tr>
  11. <td>班级名称</td>
  12. <td>
  13. <input type="text" v-model = "classes.cname">
  14. </td>
  15. </tr>
  16. <tr>
  17. <td>班级描述</td>
  18. <td>
  19. <textarea name="" id="" cols="30" rows="10" v-model = "classes.desc"></textarea>
  20. </td>
  21. </tr>
  22. <tr>
  23. <td colspan="2">
  24. <input type="text" value = "修改" @click = "editClasses()">
  25. </td>
  26. </tr>
  27. </table>
  28. </div>
  29. </template>
  30. <script>
  31. import axios from 'axios';
  32. export default {
  33. data() {
  34. return {
  35. classes:{},
  36. cid:'',
  37. };
  38. },
  39. methods:{
  40. async selectClassesById(){
  41. let url = `http://localhost:8888/classes/${this.cid}`;
  42. let { data: baseResult } = await axios.get(url);
  43. this.classes = baseResult.data
  44. },
  45. async editClasses(){
  46. var url = `http://localhost:8888/classes`;
  47. let { data: baseResult } = await axios.put(url,this.classes);
  48. if(baseResult.code == 20000){
  49. this.$router.push("/classesList");
  50. }else{
  51. alert(baseResult.message);
  52. }
  53. }
  54. },
  55. mounted(){
  56. //获得cid
  57. this.cid = this.$route.params.cid;
  58. //根据id查询班级信息
  59. this.selectClassesById();
  60. }
  61. }
  62. </script>
  63. <style>
  64. </style>

删除学生

步骤1:设置导航

步骤2:添加方法

步骤:

  • 根据cid发送ajax删除学生
  1. <template>
  2. <div>
  3. 班级: <select v-model = "studentVo.cid">
  4. <option value="" disabled>--请选择--</option>
  5. <option :value="classes.cid" v-for = "(classes,index) in classesList" :key = "index">{{classes.cname}}</option>
  6. </select>
  7. 姓名:<input type="text" v-model = "studentVo.studentName">
  8. 年龄:<input type="text" v-model = "studentVo.startAge">——<input type="text" v-model = "studentVo.endAge">
  9. <input type="button" value = "查询" @click = "conditionStudent()">
  10. <table border="1">
  11. <tr>
  12. <td>ID</td>
  13. <td>班级</td>
  14. <td>姓名</td>
  15. <td>年龄</td>
  16. <td>生日</td>
  17. <td>性别</td>
  18. <td>操作</td>
  19. </tr>
  20. <tr v-for = "(student,index) in pageInfo.list" :key="index">
  21. <td>{{student.sid}}</td>
  22. <td>{{student.classes == null ? student.cname : student.classes.cname}}</td>
  23. <td>{{student.sname}}</td>
  24. <td>{{student.age}}</td>
  25. <td>{{student.birthday}}</td>
  26. <td>{{student.gender == 1 ? '男' : '女'}}</td>
  27. <td>
  28. <router-link :to="{path:'/studentEdit',query:{sid : student.sid}}">修改</router-link>
  29. <router-link to="" @click.native.prevent = "deleteStudent(student.sid)">删除</router-link>
  30. </td>
  31. </tr>
  32. </table>
  33. <!-- 分页 start -->
  34. 当前第 {{pageInfo.pageNum}}页,共{{pageInfo.pages}}页, 总计数{{pageInfo.total}}条,
  35. 每页 <select v-model = "pageInfo.pageSize" @change = "conditionStudent(1)">
  36. <option value="1">1</option>
  37. <option value="2">2</option>
  38. <option value="3">3</option>
  39. <option value="5">5</option>
  40. <option value="10">10</option>
  41. </select>
  42. <a href="" v-if = "!pageInfo.isFirstPage" @click.prevent = "conditionStudent(1)">首页</a>
  43. <a href="" v-if = "pageInfo.hasPreviousPage" @click.prevent = "conditionStudent(pageInfo.pageNum - 1)">上一页</a>
  44. <a href="" v-for = "(num,index) in pageInfo.pages" @click.prevent = "conditionStudent(num)" :key="index">{{num}}</a>
  45. <a href="" v-if = "pageInfo.hasNextPage" @click.prevent = "conditionStudent(pageInfo.pageNum - 1)">下一页</a>
  46. <a href="" v-if = "!pageInfo.isLastPage" @click.prevent = "conditionStudent(pageInfo.pages)">尾页</a>
  47. 跳转到 <input v-model = "pageInfo.pageNum" placeholder="enter跳转" @keyup.enter = "conditionStudent()">
  48. <!-- 分页 end -->
  49. </div>
  50. </template>
  51. <script>
  52. import axios from 'axios'
  53. export default {
  54. data() {
  55. return {
  56. classesList:[],
  57. studentVo: {
  58. cid:''
  59. },
  60. pageInfo:{
  61. pageNum:1,
  62. pageSize:2
  63. }
  64. }
  65. },
  66. methods:{
  67. async selectClasses(){
  68. let { data: baseResult } = await axios.get("http://localhost:8888/classes");
  69. this.classesList = baseResult.data
  70. },
  71. async conditionStudent(num){
  72. if(num){
  73. this.pageInfo.pageNum = num
  74. }
  75. var url = `http://localhost:8888/student/condition/${this.pageInfo.pageSize}/${this.pageInfo.pageNum}`;
  76. let {data: baseResult} = await axios.post(url,this.studentVo);
  77. this.pageInfo = baseResult.data
  78. },
  79. async deleteStudent(sid){
  80. if(!confirm("您确定要删除么?")){
  81. return
  82. }
  83. let {data : baseResult} = await axios.delete(`http://localhost:8888/student/${sid}`)
  84. if(baseResult.code == 20000){
  85. this.conditionStudent(1);
  86. }else {
  87. alert(baseResult.message)
  88. }
  89. }
  90. },
  91. mounted(){
  92. //查询所有班级
  93. this.selectClasses();
  94. //查询所有学生
  95. this.conditionStudent();
  96. }
  97. }
  98. </script>
  99. <style>
  100. </style>

后端

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

密码:2002        

后端部分代码:

  1. package com.czxy.controller;
  2. import com.czxy.domain.Student;
  3. import com.czxy.service.StudentService;
  4. import com.czxy.vo.BaseResult;
  5. import com.czxy.vo.StudentVo;
  6. import com.github.pagehelper.PageInfo;
  7. import org.springframework.web.bind.annotation.*;
  8. import javax.annotation.Resource;
  9. /**
  10. * @Author 刘嘉俊
  11. * @Date 2022/2/21
  12. */
  13. @RestController
  14. @RequestMapping("/student")
  15. @CrossOrigin
  16. public class StudentController {
  17. @Resource
  18. private StudentService studentService;
  19. @PostMapping("/condition/{pageSize}/{pageNum}")
  20. public BaseResult condition(
  21. @PathVariable("pageSize") Integer pageSize,
  22. @PathVariable("pageNum") Integer pageNum,
  23. @RequestBody StudentVo studentVo) {
  24. // 查询
  25. PageInfo<Student> pageInfo = studentService.condition(pageSize,pageNum,studentVo);
  26. // 返回结果
  27. return BaseResult.ok("查询成功", pageInfo);
  28. }
  29. @GetMapping("/{sid}")
  30. public BaseResult selectById(@PathVariable("sid") String sid){
  31. Student student = studentService.selectById(sid);
  32. return BaseResult.ok("查询成功",student);
  33. }
  34. @PutMapping
  35. public BaseResult update(@RequestBody Student student){
  36. System.out.println(student);
  37. try {
  38. boolean result = studentService.update(student);
  39. if(result){
  40. return BaseResult.ok("更新成功");
  41. }else{
  42. return BaseResult.error("更新失败");
  43. }
  44. } catch (Exception e) {
  45. e.printStackTrace();
  46. return BaseResult.error(e.getMessage());
  47. }
  48. }
  49. @DeleteMapping("/{sid}")
  50. public BaseResult delete(@PathVariable("sid")String sid){
  51. System.out.println("sid" + sid);
  52. try {
  53. boolean result = studentService.delete(sid);
  54. if(result){
  55. return BaseResult.ok("删除成功");
  56. }
  57. return BaseResult.error("删除失败");
  58. } catch (Exception e) {
  59. e.printStackTrace();
  60. return BaseResult.error(e.getMessage());
  61. }
  62. }
  63. @PostMapping
  64. public BaseResult addStudent(@RequestBody Student student){
  65. try {
  66. boolean result = studentService.addStudent(student);
  67. if(result){
  68. return BaseResult.ok("添加成功");
  69. }
  70. return BaseResult.error("添加失败");
  71. } catch (Exception e) {
  72. e.printStackTrace();
  73. return BaseResult.error(e.getMessage());
  74. }
  75. }
  76. }

源码获取

 

网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发