提交代码

main
姜玉琦 2025-02-18 11:01:53 +08:00
parent 0b6db48732
commit e1a8918435
16 changed files with 1087 additions and 9 deletions

View File

@ -0,0 +1,104 @@
package com.ruoyi.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TestStudents;
import com.ruoyi.system.service.ITestStudentsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* Controller
*
* @author ruoyi
* @date 2025-02-18
*/
@RestController
@RequestMapping("/system/students")
public class TestStudentsController extends BaseController
{
@Autowired
private ITestStudentsService testStudentsService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:students:list')")
@GetMapping("/list")
public TableDataInfo list(TestStudents testStudents)
{
startPage();
List<TestStudents> list = testStudentsService.selectTestStudentsList(testStudents);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:students:export')")
@Log(title = "学生", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, TestStudents testStudents)
{
List<TestStudents> list = testStudentsService.selectTestStudentsList(testStudents);
ExcelUtil<TestStudents> util = new ExcelUtil<TestStudents>(TestStudents.class);
util.exportExcel(response, list, "学生数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:students:query')")
@GetMapping(value = "/{studentId}")
public AjaxResult getInfo(@PathVariable("studentId") Long studentId)
{
return success(testStudentsService.selectTestStudentsByStudentId(studentId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:students:add')")
@Log(title = "学生", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TestStudents testStudents)
{
return toAjax(testStudentsService.insertTestStudents(testStudents));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:students:edit')")
@Log(title = "学生", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TestStudents testStudents)
{
return toAjax(testStudentsService.updateTestStudents(testStudents));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:students:remove')")
@Log(title = "学生", businessType = BusinessType.DELETE)
@DeleteMapping("/{studentIds}")
public AjaxResult remove(@PathVariable Long[] studentIds)
{
return toAjax(testStudentsService.deleteTestStudentsByStudentIds(studentIds));
}
}

View File

@ -0,0 +1,125 @@
package com.ruoyi.system.domain;
import java.util.List;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* test_students
*
* @author ruoyi
* @date 2025-02-18
*/
public class TestStudents extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 学生ID */
private Long studentId;
/** 学生姓名 */
@Excel(name = "学生姓名")
private String name;
/** 学生年龄 */
@Excel(name = "学生年龄")
private Long age;
/** 性别 */
@Excel(name = "性别")
private String gender;
/** 专业 */
@Excel(name = "专业")
private String major;
/** 入学日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "入学日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date enrollmentDate;
/** 学生成绩信息 */
private List<TestStudentsScores> testStudentsScoresList;
public void setStudentId(Long studentId)
{
this.studentId = studentId;
}
public Long getStudentId()
{
return studentId;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setAge(Long age)
{
this.age = age;
}
public Long getAge()
{
return age;
}
public void setGender(String gender)
{
this.gender = gender;
}
public String getGender()
{
return gender;
}
public void setMajor(String major)
{
this.major = major;
}
public String getMajor()
{
return major;
}
public void setEnrollmentDate(Date enrollmentDate)
{
this.enrollmentDate = enrollmentDate;
}
public Date getEnrollmentDate()
{
return enrollmentDate;
}
public List<TestStudentsScores> getTestStudentsScoresList()
{
return testStudentsScoresList;
}
public void setTestStudentsScoresList(List<TestStudentsScores> testStudentsScoresList)
{
this.testStudentsScoresList = testStudentsScoresList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("studentId", getStudentId())
.append("name", getName())
.append("age", getAge())
.append("gender", getGender())
.append("major", getMajor())
.append("enrollmentDate", getEnrollmentDate())
.append("testStudentsScoresList", getTestStudentsScoresList())
.toString();
}
}

View File

@ -0,0 +1,79 @@
package com.ruoyi.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* test_students_scores
*
* @author ruoyi
* @date 2025-02-18
*/
public class TestStudentsScores extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 分数ID */
private Long scoreId;
/** 学生ID */
@Excel(name = "学生ID")
private Long studentId;
/** 课程名称 */
@Excel(name = "课程名称")
private String courseName;
/** 课程分数 */
@Excel(name = "课程分数")
private Long score;
public void setScoreId(Long scoreId)
{
this.scoreId = scoreId;
}
public Long getScoreId()
{
return scoreId;
}
public void setStudentId(Long studentId)
{
this.studentId = studentId;
}
public Long getStudentId()
{
return studentId;
}
public void setCourseName(String courseName)
{
this.courseName = courseName;
}
public String getCourseName()
{
return courseName;
}
public void setScore(Long score)
{
this.score = score;
}
public Long getScore()
{
return score;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("scoreId", getScoreId())
.append("studentId", getStudentId())
.append("courseName", getCourseName())
.append("score", getScore())
.toString();
}
}

View File

@ -0,0 +1,87 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.TestStudents;
import com.ruoyi.system.domain.TestStudentsScores;
/**
* Mapper
*
* @author ruoyi
* @date 2025-02-18
*/
public interface TestStudentsMapper
{
/**
*
*
* @param studentId
* @return
*/
public TestStudents selectTestStudentsByStudentId(Long studentId);
/**
*
*
* @param testStudents
* @return
*/
public List<TestStudents> selectTestStudentsList(TestStudents testStudents);
/**
*
*
* @param testStudents
* @return
*/
public int insertTestStudents(TestStudents testStudents);
/**
*
*
* @param testStudents
* @return
*/
public int updateTestStudents(TestStudents testStudents);
/**
*
*
* @param studentId
* @return
*/
public int deleteTestStudentsByStudentId(Long studentId);
/**
*
*
* @param studentIds
* @return
*/
public int deleteTestStudentsByStudentIds(Long[] studentIds);
/**
*
*
* @param studentIds
* @return
*/
public int deleteTestStudentsScoresByStudentIds(Long[] studentIds);
/**
*
*
* @param testStudentsScoresList
* @return
*/
public int batchTestStudentsScores(List<TestStudentsScores> testStudentsScoresList);
/**
*
*
* @param studentId ID
* @return
*/
public int deleteTestStudentsScoresByStudentId(Long studentId);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.TestStudents;
/**
* Service
*
* @author ruoyi
* @date 2025-02-18
*/
public interface ITestStudentsService
{
/**
*
*
* @param studentId
* @return
*/
public TestStudents selectTestStudentsByStudentId(Long studentId);
/**
*
*
* @param testStudents
* @return
*/
public List<TestStudents> selectTestStudentsList(TestStudents testStudents);
/**
*
*
* @param testStudents
* @return
*/
public int insertTestStudents(TestStudents testStudents);
/**
*
*
* @param testStudents
* @return
*/
public int updateTestStudents(TestStudents testStudents);
/**
*
*
* @param studentIds
* @return
*/
public int deleteTestStudentsByStudentIds(Long[] studentIds);
/**
*
*
* @param studentId
* @return
*/
public int deleteTestStudentsByStudentId(Long studentId);
}

View File

@ -0,0 +1,131 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.system.domain.TestStudentsScores;
import com.ruoyi.system.mapper.TestStudentsMapper;
import com.ruoyi.system.domain.TestStudents;
import com.ruoyi.system.service.ITestStudentsService;
/**
* Service
*
* @author ruoyi
* @date 2025-02-18
*/
@Service
public class TestStudentsServiceImpl implements ITestStudentsService
{
@Autowired
private TestStudentsMapper testStudentsMapper;
/**
*
*
* @param studentId
* @return
*/
@Override
public TestStudents selectTestStudentsByStudentId(Long studentId)
{
return testStudentsMapper.selectTestStudentsByStudentId(studentId);
}
/**
*
*
* @param testStudents
* @return
*/
@Override
public List<TestStudents> selectTestStudentsList(TestStudents testStudents)
{
return testStudentsMapper.selectTestStudentsList(testStudents);
}
/**
*
*
* @param testStudents
* @return
*/
@Transactional
@Override
public int insertTestStudents(TestStudents testStudents)
{
int rows = testStudentsMapper.insertTestStudents(testStudents);
insertTestStudentsScores(testStudents);
return rows;
}
/**
*
*
* @param testStudents
* @return
*/
@Transactional
@Override
public int updateTestStudents(TestStudents testStudents)
{
testStudentsMapper.deleteTestStudentsScoresByStudentId(testStudents.getStudentId());
insertTestStudentsScores(testStudents);
return testStudentsMapper.updateTestStudents(testStudents);
}
/**
*
*
* @param studentIds
* @return
*/
@Transactional
@Override
public int deleteTestStudentsByStudentIds(Long[] studentIds)
{
testStudentsMapper.deleteTestStudentsScoresByStudentIds(studentIds);
return testStudentsMapper.deleteTestStudentsByStudentIds(studentIds);
}
/**
*
*
* @param studentId
* @return
*/
@Transactional
@Override
public int deleteTestStudentsByStudentId(Long studentId)
{
testStudentsMapper.deleteTestStudentsScoresByStudentId(studentId);
return testStudentsMapper.deleteTestStudentsByStudentId(studentId);
}
/**
*
*
* @param testStudents
*/
public void insertTestStudentsScores(TestStudents testStudents)
{
List<TestStudentsScores> testStudentsScoresList = testStudents.getTestStudentsScoresList();
Long studentId = testStudents.getStudentId();
if (StringUtils.isNotNull(testStudentsScoresList))
{
List<TestStudentsScores> list = new ArrayList<TestStudentsScores>();
for (TestStudentsScores testStudentsScores : testStudentsScoresList)
{
testStudentsScores.setStudentId(studentId);
list.add(testStudentsScores);
}
if (list.size() > 0)
{
testStudentsMapper.batchTestStudentsScores(list);
}
}
}
}

View File

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.TestStudentsMapper">
<resultMap type="TestStudents" id="TestStudentsResult">
<result property="studentId" column="student_id" />
<result property="name" column="name" />
<result property="age" column="age" />
<result property="gender" column="gender" />
<result property="major" column="major" />
<result property="enrollmentDate" column="enrollment_date" />
</resultMap>
<resultMap id="TestStudentsTestStudentsScoresResult" type="TestStudents" extends="TestStudentsResult">
<collection property="testStudentsScoresList" ofType="TestStudentsScores" column="student_id" select="selectTestStudentsScoresList" />
</resultMap>
<resultMap type="TestStudentsScores" id="TestStudentsScoresResult">
<result property="scoreId" column="score_id" />
<result property="studentId" column="student_id" />
<result property="courseName" column="course_name" />
<result property="score" column="score" />
</resultMap>
<sql id="selectTestStudentsVo">
select student_id, name, age, gender, major, enrollment_date from test_students
</sql>
<select id="selectTestStudentsList" parameterType="TestStudents" resultMap="TestStudentsResult">
<include refid="selectTestStudentsVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="age != null "> and age = #{age}</if>
<if test="gender != null and gender != ''"> and gender = #{gender}</if>
<if test="major != null and major != ''"> and major = #{major}</if>
<if test="enrollmentDate != null "> and enrollment_date = #{enrollmentDate}</if>
</where>
</select>
<select id="selectTestStudentsByStudentId" parameterType="Long" resultMap="TestStudentsTestStudentsScoresResult">
select student_id, name, age, gender, major, enrollment_date
from test_students
where student_id = #{studentId}
</select>
<select id="selectTestStudentsScoresList" resultMap="TestStudentsScoresResult">
select score_id, student_id, course_name, score
from test_students_scores
where student_id = #{student_id}
</select>
<insert id="insertTestStudents" parameterType="TestStudents" useGeneratedKeys="true" keyProperty="studentId">
insert into test_students
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="age != null">age,</if>
<if test="gender != null">gender,</if>
<if test="major != null">major,</if>
<if test="enrollmentDate != null">enrollment_date,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="age != null">#{age},</if>
<if test="gender != null">#{gender},</if>
<if test="major != null">#{major},</if>
<if test="enrollmentDate != null">#{enrollmentDate},</if>
</trim>
</insert>
<update id="updateTestStudents" parameterType="TestStudents">
update test_students
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="age != null">age = #{age},</if>
<if test="gender != null">gender = #{gender},</if>
<if test="major != null">major = #{major},</if>
<if test="enrollmentDate != null">enrollment_date = #{enrollmentDate},</if>
</trim>
where student_id = #{studentId}
</update>
<delete id="deleteTestStudentsByStudentId" parameterType="Long">
delete from test_students where student_id = #{studentId}
</delete>
<delete id="deleteTestStudentsByStudentIds" parameterType="String">
delete from test_students where student_id in
<foreach item="studentId" collection="array" open="(" separator="," close=")">
#{studentId}
</foreach>
</delete>
<delete id="deleteTestStudentsScoresByStudentIds" parameterType="String">
delete from test_students_scores where student_id in
<foreach item="studentId" collection="array" open="(" separator="," close=")">
#{studentId}
</foreach>
</delete>
<delete id="deleteTestStudentsScoresByStudentId" parameterType="Long">
delete from test_students_scores where student_id = #{studentId}
</delete>
<insert id="batchTestStudentsScores">
insert into test_students_scores( score_id, student_id, course_name, score) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.scoreId}, #{item.studentId}, #{item.courseName}, #{item.score})
</foreach>
</insert>
</mapper>

View File

@ -1,10 +1,10 @@
# 页面标题
VUE_APP_TITLE = 若依管理系统
VUE_APP_TITLE = 研筑机试管理
# 开发环境配置
ENV = 'development'
# 若依管理系统/开发环境
# 研筑机试管理/开发环境
VUE_APP_BASE_API = '/dev-api'
# 路由懒加载

View File

@ -1,8 +1,8 @@
# 页面标题
VUE_APP_TITLE = 若依管理系统
VUE_APP_TITLE = 研筑机试管理
# 生产环境配置
ENV = 'production'
# 若依管理系统/生产环境
# 研筑机试管理/生产环境
VUE_APP_BASE_API = '/prod-api'

View File

@ -1,5 +1,5 @@
# 页面标题
VUE_APP_TITLE = 若依管理系统
VUE_APP_TITLE = 研筑机试管理
BABEL_ENV = production
@ -8,5 +8,5 @@ NODE_ENV = production
# 测试环境配置
ENV = 'staging'
# 若依管理系统/测试环境
# 研筑机试管理/测试环境
VUE_APP_BASE_API = '/stage-api'

View File

@ -1,7 +1,7 @@
{
"name": "ruoyi",
"version": "3.8.9",
"description": "若依管理系统",
"description": "研筑机试管理",
"author": "若依",
"license": "MIT",
"scripts": {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 894 B

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询学生列表
export function listStudents(query) {
return request({
url: '/system/students/list',
method: 'get',
params: query
})
}
// 查询学生详细
export function getStudents(studentId) {
return request({
url: '/system/students/' + studentId,
method: 'get'
})
}
// 新增学生
export function addStudents(data) {
return request({
url: '/system/students',
method: 'post',
data: data
})
}
// 修改学生
export function updateStudents(data) {
return request({
url: '/system/students',
method: 'put',
data: data
})
}
// 删除学生
export function delStudents(studentId) {
return request({
url: '/system/students/' + studentId,
method: 'delete'
})
}

View File

@ -12,7 +12,7 @@
<el-col :sm="24" :lg="12" style="padding-left: 20px">
<h2>若依后台管理框架</h2>
<p>
一直想做一款后台管理系统看了很多优秀的开源项目但是发现没有合适自己的于是利用空闲休息时间开始自己写一套后台系统如此有了若依管理系统她可以用于所有的Web应用程序如网站管理后台网站会员中心CMSCRMOA等等当然您也可以对她进行深度定制以做出更强系统所有前端后台代码封装过后十分精简易上手出错概率低同时支持移动客户端访问系统会陆续更新一些实用功能
一直想做一款后台管理系统看了很多优秀的开源项目但是发现没有合适自己的于是利用空闲休息时间开始自己写一套后台系统如此有了研筑机试管理她可以用于所有的Web应用程序如网站管理后台网站会员中心CMSCRMOA等等当然您也可以对她进行深度定制以做出更强系统所有前端后台代码封装过后十分精简易上手出错概率低同时支持移动客户端访问系统会陆续更新一些实用功能
</p>
<p>
<b>当前版本:</b> <span>v{{ version }}</span>

View File

@ -0,0 +1,335 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="学生姓名" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入学生姓名"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:students:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:students:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:students:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:students:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="studentsList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="学生编号" align="center" prop="studentId" width="88"/>
<el-table-column label="学生姓名" align="center" prop="name" />
<el-table-column label="学生年龄" align="center" prop="age" />
<el-table-column label="性别" align="center" prop="gender" />
<el-table-column label="专业" align="center" prop="major" />
<el-table-column label="入学日期" align="center" prop="enrollmentDate" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.enrollmentDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:students:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:students:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改学生对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="学生姓名" prop="name">
<el-input v-model="form.name" placeholder="请输入学生姓名" />
</el-form-item>
<el-form-item label="学生年龄" prop="age">
<el-input v-model="form.age" placeholder="请输入学生年龄" />
</el-form-item>
<el-form-item label="性别" prop="gender">
<el-input v-model="form.gender" placeholder="请输入性别" />
</el-form-item>
<el-form-item label="专业" prop="major">
<el-input v-model="form.major" placeholder="请输入专业" />
</el-form-item>
<el-form-item label="入学日期" prop="enrollmentDate">
<el-date-picker clearable
v-model="form.enrollmentDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择入学日期">
</el-date-picker>
</el-form-item>
<el-divider content-position="center">学生成绩信息</el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddTestStudentsScores"></el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteTestStudentsScores"></el-button>
</el-col>
</el-row>
<el-table :data="testStudentsScoresList" :row-class-name="rowTestStudentsScoresIndex" @selection-change="handleTestStudentsScoresSelectionChange" ref="testStudentsScores">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="序号" align="center" prop="index" width="50"/>
<el-table-column label="课程名称" prop="courseName" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.courseName" placeholder="请输入课程名称" />
</template>
</el-table-column>
<el-table-column label="课程分数" prop="score" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.score" placeholder="请输入课程分数" />
</template>
</el-table-column>
</el-table>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listStudents, getStudents, delStudents, addStudents, updateStudents } from "@/api/system/students";
export default {
name: "Students",
data() {
return {
//
loading: true,
//
ids: [],
//
checkedTestStudentsScores: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
studentsList: [],
//
testStudentsScoresList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
name: null,
age: null,
gender: null,
major: null,
enrollmentDate: null
},
//
form: {},
//
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询学生列表 */
getList() {
this.loading = true;
listStudents(this.queryParams).then(response => {
this.studentsList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
studentId: null,
name: null,
age: null,
gender: null,
major: null,
enrollmentDate: null
};
this.testStudentsScoresList = [];
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.studentId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加学生";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const studentId = row.studentId || this.ids
getStudents(studentId).then(response => {
this.form = response.data;
this.testStudentsScoresList = response.data.testStudentsScoresList;
this.open = true;
this.title = "修改学生";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.form.testStudentsScoresList = this.testStudentsScoresList;
if (this.form.studentId != null) {
updateStudents(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addStudents(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const studentIds = row.studentId || this.ids;
this.$modal.confirm('是否确认删除学生编号为"' + studentIds + '"的数据项?').then(function() {
return delStudents(studentIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 学生成绩序号 */
rowTestStudentsScoresIndex({ row, rowIndex }) {
row.index = rowIndex + 1;
},
/** 学生成绩添加按钮操作 */
handleAddTestStudentsScores() {
let obj = {};
obj.courseName = "";
obj.score = "";
this.testStudentsScoresList.push(obj);
},
/** 学生成绩删除按钮操作 */
handleDeleteTestStudentsScores() {
if (this.checkedTestStudentsScores.length == 0) {
this.$modal.msgError("请先选择要删除的学生成绩数据");
} else {
const testStudentsScoresList = this.testStudentsScoresList;
const checkedTestStudentsScores = this.checkedTestStudentsScores;
this.testStudentsScoresList = testStudentsScoresList.filter(function(item) {
return checkedTestStudentsScores.indexOf(item.index) == -1
});
}
},
/** 复选框选中数据 */
handleTestStudentsScoresSelectionChange(selection) {
this.checkedTestStudentsScores = selection.map(item => item.index)
},
/** 导出按钮操作 */
handleExport() {
this.download('system/students/export', {
...this.queryParams
}, `students_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@ -7,7 +7,7 @@ function resolve(dir) {
const CompressionPlugin = require('compression-webpack-plugin')
const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题
const name = process.env.VUE_APP_TITLE || '研筑机试管理' // 网页标题
const port = process.env.port || process.env.npm_config_port || 80 // 端口