2023.6.23
1. 完结撒花~~
This commit is contained in:
parent
e9c9e284fe
commit
c28867e3e4
@ -1,7 +1,7 @@
|
|||||||
package com.sdut.labex.Factory;
|
package com.sdut.labex.Factory;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.sdut.labex.entity.SubmitRecords;
|
import com.sdut.labex.entity.SubmitRecord;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,13 +12,13 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SubmitRecordsFactory {
|
public class SubmitRecordsFactory {
|
||||||
public static SubmitRecords create(JSONObject jsonObject) {
|
public static SubmitRecord create(JSONObject jsonObject) {
|
||||||
SubmitRecords submitRecords = new SubmitRecords();
|
SubmitRecord submitRecord = new SubmitRecord();
|
||||||
submitRecords.setExperimentId(jsonObject.getInteger("experimentId"));
|
submitRecord.setId(jsonObject.getInteger("id"));
|
||||||
submitRecords.setStudentId(jsonObject.getInteger("studentId"));
|
submitRecord.setExperimentId(jsonObject.getInteger("experimentId"));
|
||||||
submitRecords.setFilePath(jsonObject.getString("filePath"));
|
submitRecord.setStudentId(jsonObject.getString("studentId"));
|
||||||
submitRecords.setScore(jsonObject.getInteger("score"));
|
submitRecord.setFilePath(jsonObject.getString("filePath"));
|
||||||
log.info("SubMitRecords: " + submitRecords.toString());
|
submitRecord.setScore(jsonObject.getInteger("score"));
|
||||||
return submitRecords;
|
return submitRecord;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.sdut.labex.Factory.ExperimentFactory;
|
|||||||
import com.sdut.labex.entity.Experiment;
|
import com.sdut.labex.entity.Experiment;
|
||||||
import com.sdut.labex.service.ExperimentsService;
|
import com.sdut.labex.service.ExperimentsService;
|
||||||
import com.sdut.labex.utils.ResVo;
|
import com.sdut.labex.utils.ResVo;
|
||||||
|
import com.sdut.labex.utils.UserHolder;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -31,9 +32,7 @@ public class ExperimentsController {
|
|||||||
public ResVo applyExperiment(@RequestBody JSONObject jsonObject) {
|
public ResVo applyExperiment(@RequestBody JSONObject jsonObject) {
|
||||||
Experiment experiment = ExperimentFactory.createExperiment(jsonObject);
|
Experiment experiment = ExperimentFactory.createExperiment(jsonObject);
|
||||||
//设置申请人
|
//设置申请人
|
||||||
//experiment.setApplyUser(UserHolder.getUser().getId());
|
experiment.setApplyUser(UserHolder.getUser().getUsername());
|
||||||
//todo:上线删除
|
|
||||||
experiment.setApplyUser("测试");
|
|
||||||
//获取当前时间
|
//获取当前时间
|
||||||
LocalDateTime currentDateTime = LocalDateTime.now();
|
LocalDateTime currentDateTime = LocalDateTime.now();
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
@ -78,8 +77,10 @@ public class ExperimentsController {
|
|||||||
//获取实验列表
|
//获取实验列表
|
||||||
@PostMapping("/experiments/{pageNum}/{pageSize}")
|
@PostMapping("/experiments/{pageNum}/{pageSize}")
|
||||||
public ResVo getExperiments(@RequestBody JSONObject jsonObject, @PathVariable int pageNum, @PathVariable int pageSize) {
|
public ResVo getExperiments(@RequestBody JSONObject jsonObject, @PathVariable int pageNum, @PathVariable int pageSize) {
|
||||||
//todo: 如果用户为老师则只能看到自己的实验
|
|
||||||
Experiment experiment = ExperimentFactory.createExperiment(jsonObject);
|
Experiment experiment = ExperimentFactory.createExperiment(jsonObject);
|
||||||
|
if (UserHolder.getUser().getRole().equals("teacher")) {
|
||||||
|
experiment.setApplyUser(UserHolder.getUser().getUsername());
|
||||||
|
}
|
||||||
return experimentsService.getExperiments(experiment, pageNum, pageSize);
|
return experimentsService.getExperiments(experiment, pageNum, pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,4 +89,7 @@ public class ExperimentsController {
|
|||||||
public ResVo getExperiment(@PathVariable String id) {
|
public ResVo getExperiment(@PathVariable String id) {
|
||||||
return experimentsService.getExperiment(id);
|
return experimentsService.getExperiment(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//删除
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,29 +15,43 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
public class FileController {
|
public class FileController {
|
||||||
private final Path fileStorageLocation = Paths.get("/Users/springforest/");
|
private final Path fileStorageLocation = Paths.get("/Users/springforest/Downloads/软件实训/");
|
||||||
|
|
||||||
@PostMapping("/upload")
|
@PostMapping("/upload")
|
||||||
public ResVo uploadFile(@RequestParam("file") MultipartFile file) {
|
public ResVo uploadFile(@RequestParam("file") MultipartFile file) {
|
||||||
try {
|
try {
|
||||||
// Copy file to the target location (Replacing existing file with the same name)
|
|
||||||
if (file.isEmpty()) {
|
if (file.isEmpty()) {
|
||||||
return ResVo.error("您传了个寂寞");
|
return ResVo.error("上传文件为空");
|
||||||
}
|
}
|
||||||
Path filePath = this.fileStorageLocation.resolve(file.getOriginalFilename());
|
|
||||||
log.info(filePath.toString());
|
// 获取原始文件名的后缀
|
||||||
|
String originalFileName = file.getOriginalFilename();
|
||||||
|
String extension = originalFileName.substring(originalFileName.lastIndexOf("."));
|
||||||
|
|
||||||
|
// 生成新的文件名
|
||||||
|
String newFileName = UUID.randomUUID().toString() + extension;
|
||||||
|
|
||||||
|
// 将文件保存到指定的路径
|
||||||
|
Path filePath = this.fileStorageLocation.resolve(newFileName);
|
||||||
Files.copy(file.getInputStream(), filePath, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(file.getInputStream(), filePath, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
return ResVo.ok();
|
// 返回新的文件名
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("fileName", newFileName);
|
||||||
|
return ResVo.ok(map);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResVo.error("文件上传失败");
|
return ResVo.error("文件上传失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/download/{fileName}")
|
@GetMapping("/download/{fileName}")
|
||||||
@ -45,6 +59,7 @@ public class FileController {
|
|||||||
log.info(fileName);
|
log.info(fileName);
|
||||||
try {
|
try {
|
||||||
Path filePath = this.fileStorageLocation.resolve(fileName).normalize();
|
Path filePath = this.fileStorageLocation.resolve(fileName).normalize();
|
||||||
|
System.out.println(filePath.toUri());
|
||||||
Resource resource = new UrlResource(filePath.toUri());
|
Resource resource = new UrlResource(filePath.toUri());
|
||||||
|
|
||||||
if (resource.exists()) {
|
if (resource.exists()) {
|
||||||
@ -52,7 +67,8 @@ public class FileController {
|
|||||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getFilename() + "\"")
|
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getFilename() + "\"")
|
||||||
.body(resource);
|
.body(resource);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("File not found " + fileName);
|
log.error("File not found " + fileName);
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (MalformedURLException ex) {
|
} catch (MalformedURLException ex) {
|
||||||
|
@ -2,10 +2,11 @@ package com.sdut.labex.controller;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.sdut.labex.Factory.SubmitRecordsFactory;
|
import com.sdut.labex.Factory.SubmitRecordsFactory;
|
||||||
import com.sdut.labex.entity.SubmitRecords;
|
import com.sdut.labex.entity.SubmitRecord;
|
||||||
import com.sdut.labex.service.SubmitRecordsService;
|
import com.sdut.labex.service.SubmitRecordsService;
|
||||||
import com.sdut.labex.utils.ResVo;
|
import com.sdut.labex.utils.ResVo;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import com.sdut.labex.utils.UserHolder;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -17,21 +18,31 @@ import javax.annotation.Resource;
|
|||||||
* Description:
|
* Description:
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@Configuration
|
@CrossOrigin
|
||||||
|
@Slf4j
|
||||||
public class SubmitRecordsController {
|
public class SubmitRecordsController {
|
||||||
@Resource
|
@Resource
|
||||||
private SubmitRecordsService submitRecordsService;
|
private SubmitRecordsService submitRecordsService;
|
||||||
|
|
||||||
@PostMapping("/records")
|
@PostMapping("/records")
|
||||||
public ResVo record(@RequestBody JSONObject jsonObject) {
|
public ResVo addRecord(@RequestBody JSONObject jsonObject) {
|
||||||
SubmitRecords submitRecords = SubmitRecordsFactory.create(jsonObject);
|
SubmitRecord submitRecord = SubmitRecordsFactory.create(jsonObject);
|
||||||
return submitRecordsService.addRecords(submitRecords);
|
return submitRecordsService.addRecords(submitRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/getRecord/{pageNum}/{pageSize}")
|
@PostMapping("/getRecordST/{pageNum}/{pageSize}")
|
||||||
public ResVo getRecord(@PathVariable int pageNum, @PathVariable int pageSize, @RequestBody JSONObject jsonObject) {
|
public ResVo getRecordST(@PathVariable int pageNum, @PathVariable int pageSize, @RequestBody JSONObject jsonObject) {
|
||||||
SubmitRecords submitRecords = SubmitRecordsFactory.create(jsonObject);
|
String className = jsonObject.getString("className");
|
||||||
return submitRecordsService.selectRecords(pageNum, pageSize, submitRecords);
|
String stId = jsonObject.getString("studentId");
|
||||||
|
String applyUser = jsonObject.getString("applyUser");
|
||||||
|
if (UserHolder.getUser().getRole().equals("student")) {
|
||||||
|
className = UserHolder.getUser().getClassName();
|
||||||
|
stId = UserHolder.getUser().getId();
|
||||||
|
} else if (UserHolder.getUser().getRole().equals("teacher")) {
|
||||||
|
applyUser = UserHolder.getUser().getUsername();
|
||||||
|
}
|
||||||
|
|
||||||
|
return submitRecordsService.selectRecords(pageNum, pageSize, className, stId, applyUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/records/{id}")
|
@DeleteMapping("/records/{id}")
|
||||||
@ -41,8 +52,9 @@ public class SubmitRecordsController {
|
|||||||
|
|
||||||
@PutMapping("/records")
|
@PutMapping("/records")
|
||||||
public ResVo updateRecord(@RequestBody JSONObject jsonObject) {
|
public ResVo updateRecord(@RequestBody JSONObject jsonObject) {
|
||||||
SubmitRecords submitRecords = SubmitRecordsFactory.create(jsonObject);
|
log.info("updateRecords:{}", jsonObject);
|
||||||
return submitRecordsService.updateRecords(submitRecords);
|
SubmitRecord submitRecord = SubmitRecordsFactory.create(jsonObject);
|
||||||
|
return submitRecordsService.updateRecords(submitRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,14 @@ public class TableController {
|
|||||||
public ResVo uploadTable(MultipartFile file, @RequestPart("date") String date, @RequestPart("room") String room) {
|
public ResVo uploadTable(MultipartFile file, @RequestPart("date") String date, @RequestPart("room") String room) {
|
||||||
return tableService.uploadTable(file, date, room);
|
return tableService.uploadTable(file, date, room);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getUsedTable")
|
||||||
|
public ResVo getUsedTable(@RequestBody JSONObject jsonObject) {
|
||||||
|
String roomName = jsonObject.getString("roomName");
|
||||||
|
String date = jsonObject.getString("date");
|
||||||
|
if (roomName.equals("")) {
|
||||||
|
roomName = "9教207";
|
||||||
|
}
|
||||||
|
return tableService.getUsedTable(roomName, date);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
31
src/main/java/com/sdut/labex/dto/ExperimentDTO.java
Normal file
31
src/main/java/com/sdut/labex/dto/ExperimentDTO.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package com.sdut.labex.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File: ExperimentDTO
|
||||||
|
* Created: 2023/6/22
|
||||||
|
* Author: springforest
|
||||||
|
* Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ExperimentDTO {
|
||||||
|
private Integer recordId;
|
||||||
|
private Integer experimentId;
|
||||||
|
private String studentId;
|
||||||
|
private String filePath;
|
||||||
|
private Integer score;
|
||||||
|
private String username;
|
||||||
|
private String className;
|
||||||
|
private String department;
|
||||||
|
private String role;
|
||||||
|
private String experimentName;
|
||||||
|
private Integer status;
|
||||||
|
private String experimentClass;
|
||||||
|
private Date applyTime;
|
||||||
|
private String applyUser;
|
||||||
|
private String annex;
|
||||||
|
}
|
||||||
|
|
@ -28,7 +28,7 @@ public class TimeTable {
|
|||||||
this.time = new String[2];
|
this.time = new String[2];
|
||||||
this.reason = temp[0];
|
this.reason = temp[0];
|
||||||
|
|
||||||
String tt = new String(temp[1].substring(1, 5));
|
String tt = temp[1].substring(1, 5);
|
||||||
switch (tt) {
|
switch (tt) {
|
||||||
case "1-2节":
|
case "1-2节":
|
||||||
this.time[0] = "第一节";
|
this.time[0] = "第一节";
|
||||||
|
@ -15,7 +15,7 @@ import java.io.Serializable;
|
|||||||
*/
|
*/
|
||||||
@TableName(value = "submit_records")
|
@TableName(value = "submit_records")
|
||||||
@Data
|
@Data
|
||||||
public class SubmitRecords implements Serializable {
|
public class SubmitRecord implements Serializable {
|
||||||
/**
|
/**
|
||||||
* ID
|
* ID
|
||||||
*/
|
*/
|
||||||
@ -30,7 +30,7 @@ public class SubmitRecords implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 学生ID
|
* 学生ID
|
||||||
*/
|
*/
|
||||||
private Integer studentId;
|
private String studentId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件路径
|
* 文件路径
|
@ -2,9 +2,12 @@ package com.sdut.labex.mapper;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.sdut.labex.entity.SubmitRecords;
|
import com.sdut.labex.dto.ExperimentDTO;
|
||||||
|
import com.sdut.labex.entity.SubmitRecord;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author springforest
|
* @author springforest
|
||||||
* @description 针对表【submit_records(实验提交记录)】的数据库操作Mapper
|
* @description 针对表【submit_records(实验提交记录)】的数据库操作Mapper
|
||||||
@ -12,8 +15,12 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
* @Entity com.sdut.labex.entity.SubmitRecords
|
* @Entity com.sdut.labex.entity.SubmitRecords
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SubmitRecordsMapper extends BaseMapper<SubmitRecords> {
|
public interface SubmitRecordsMapper extends BaseMapper<SubmitRecord> {
|
||||||
Page<SubmitRecords> selectPage(Page<SubmitRecords> page, SubmitRecords submitRecords);
|
Page<SubmitRecord> selectPageForCheck(Page<SubmitRecord> page, SubmitRecord submitRecord);
|
||||||
|
|
||||||
|
Page<ExperimentDTO> selectPageST(Page<ExperimentDTO> page, String className, String studentId, String applyUser);
|
||||||
|
|
||||||
|
void insertBatch(List<SubmitRecord> submitRecordList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.sdut.labex.service;
|
package com.sdut.labex.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.sdut.labex.entity.SubmitRecords;
|
import com.sdut.labex.entity.SubmitRecord;
|
||||||
import com.sdut.labex.utils.ResVo;
|
import com.sdut.labex.utils.ResVo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -9,13 +9,16 @@ import com.sdut.labex.utils.ResVo;
|
|||||||
* @description 针对表【submit_records(实验提交记录)】的数据库操作Service
|
* @description 针对表【submit_records(实验提交记录)】的数据库操作Service
|
||||||
* @createDate 2023-06-21 11:01:21
|
* @createDate 2023-06-21 11:01:21
|
||||||
*/
|
*/
|
||||||
public interface SubmitRecordsService extends IService<SubmitRecords> {
|
public interface SubmitRecordsService extends IService<SubmitRecord> {
|
||||||
public ResVo addRecords(SubmitRecords submitRecords);
|
public ResVo addRecords(SubmitRecord submitRecord);
|
||||||
|
|
||||||
public ResVo deleteRecord(Integer id);
|
public ResVo deleteRecord(Integer id);
|
||||||
|
|
||||||
public ResVo updateRecords(SubmitRecords submitRecords);
|
public ResVo updateRecords(SubmitRecord submitRecord);
|
||||||
|
|
||||||
public ResVo selectRecords(int pageNum, int pageSize, SubmitRecords submitRecords);
|
public ResVo selectRecords(int pageNum, int pageSize, SubmitRecord submitRecord);
|
||||||
|
|
||||||
|
//正式
|
||||||
|
public ResVo selectRecords(int pageNum, int pageSize, String className, String studentId, String applyUser);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,4 +15,6 @@ public interface TableService {
|
|||||||
public ResVo getUnUsedTable(String room, String date);
|
public ResVo getUnUsedTable(String room, String date);
|
||||||
|
|
||||||
public ResVo uploadTable(MultipartFile file, String startDate, String roomName);
|
public ResVo uploadTable(MultipartFile file, String startDate, String roomName);
|
||||||
|
|
||||||
|
public ResVo getUsedTable(String room, String date);
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,20 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.sdut.labex.entity.Experiment;
|
import com.sdut.labex.entity.Experiment;
|
||||||
|
import com.sdut.labex.entity.SubmitRecord;
|
||||||
|
import com.sdut.labex.entity.User;
|
||||||
import com.sdut.labex.mapper.ExperimentsMapper;
|
import com.sdut.labex.mapper.ExperimentsMapper;
|
||||||
|
import com.sdut.labex.mapper.SubmitRecordsMapper;
|
||||||
|
import com.sdut.labex.mapper.UserMapper;
|
||||||
import com.sdut.labex.service.ExperimentsService;
|
import com.sdut.labex.service.ExperimentsService;
|
||||||
import com.sdut.labex.utils.FormatDate;
|
import com.sdut.labex.utils.FormatDate;
|
||||||
import com.sdut.labex.utils.ResVo;
|
import com.sdut.labex.utils.ResVo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -27,6 +33,11 @@ public class ExperimentsServiceImpl extends ServiceImpl<ExperimentsMapper, Exper
|
|||||||
implements ExperimentsService {
|
implements ExperimentsService {
|
||||||
@Resource
|
@Resource
|
||||||
private ExperimentsMapper experimentsMapper;
|
private ExperimentsMapper experimentsMapper;
|
||||||
|
@Resource
|
||||||
|
private UserMapper usersMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SubmitRecordsMapper submitRecordsMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResVo applyExperiment(Experiment experiment) {
|
public ResVo applyExperiment(Experiment experiment) {
|
||||||
@ -110,17 +121,46 @@ public class ExperimentsServiceImpl extends ServiceImpl<ExperimentsMapper, Exper
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public ResVo isAdmitted(int id, int status) {
|
public ResVo isAdmitted(int id, int status) {
|
||||||
Experiment experiment = experimentsMapper.selectById(id);
|
Experiment experiment = experimentsMapper.selectById(id);
|
||||||
if (experiment == null)
|
if (experiment == null)
|
||||||
return ResVo.error("该实验不存在");
|
return ResVo.error("该实验不存在");
|
||||||
experiment.setStatus(status);
|
experiment.setStatus(status);
|
||||||
|
|
||||||
|
if (status == 1) {
|
||||||
|
//为实验中包含的班级添加实验记录
|
||||||
|
String[] classList = experiment.getClassName().split(";");
|
||||||
|
List<User> users;
|
||||||
|
List<SubmitRecord> submitRecordList = new ArrayList<>();
|
||||||
|
for (String className : classList) {
|
||||||
|
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("class_name", className);
|
||||||
|
users = usersMapper.selectList(queryWrapper);
|
||||||
|
for (User user : users) {
|
||||||
|
|
||||||
|
SubmitRecord submitRecord = new SubmitRecord();
|
||||||
|
submitRecord.setExperimentId(experiment.getId());
|
||||||
|
submitRecord.setStudentId(user.getId());
|
||||||
|
submitRecordList.add(submitRecord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(submitRecordList);
|
||||||
|
try {
|
||||||
|
submitRecordsMapper.insertBatch(submitRecordList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return ResVo.error("添加实验记录失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
experimentsMapper.updateById(experiment);
|
experimentsMapper.updateById(experiment);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return ResVo.error();
|
return ResVo.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResVo.ok();
|
return ResVo.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,12 @@ package com.sdut.labex.service.impl;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.sdut.labex.entity.SubmitRecords;
|
import com.sdut.labex.dto.ExperimentDTO;
|
||||||
|
import com.sdut.labex.entity.SubmitRecord;
|
||||||
import com.sdut.labex.mapper.SubmitRecordsMapper;
|
import com.sdut.labex.mapper.SubmitRecordsMapper;
|
||||||
import com.sdut.labex.service.SubmitRecordsService;
|
import com.sdut.labex.service.SubmitRecordsService;
|
||||||
import com.sdut.labex.utils.ResVo;
|
import com.sdut.labex.utils.ResVo;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -18,15 +20,16 @@ import java.util.Map;
|
|||||||
* @createDate 2023-06-21 11:01:21
|
* @createDate 2023-06-21 11:01:21
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SubmitRecordsServiceImpl extends ServiceImpl<SubmitRecordsMapper, SubmitRecords>
|
@Slf4j
|
||||||
|
public class SubmitRecordsServiceImpl extends ServiceImpl<SubmitRecordsMapper, SubmitRecord>
|
||||||
implements SubmitRecordsService {
|
implements SubmitRecordsService {
|
||||||
@Resource
|
@Resource
|
||||||
private SubmitRecordsMapper submitRecordsMapper;
|
private SubmitRecordsMapper submitRecordsMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResVo addRecords(SubmitRecords submitRecords) {
|
public ResVo addRecords(SubmitRecord submitRecord) {
|
||||||
try {
|
try {
|
||||||
submitRecordsMapper.insert(submitRecords);
|
submitRecordsMapper.insert(submitRecord);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return ResVo.error("保存失败");
|
return ResVo.error("保存失败");
|
||||||
@ -46,9 +49,10 @@ public class SubmitRecordsServiceImpl extends ServiceImpl<SubmitRecordsMapper, S
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResVo updateRecords(SubmitRecords submitRecords) {
|
public ResVo updateRecords(SubmitRecord submitRecord) {
|
||||||
|
log.info("updateRecords:{}", submitRecord);
|
||||||
try {
|
try {
|
||||||
submitRecordsMapper.updateById(submitRecords);
|
submitRecordsMapper.updateById(submitRecord);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return ResVo.error("更新失败");
|
return ResVo.error("更新失败");
|
||||||
@ -57,9 +61,10 @@ public class SubmitRecordsServiceImpl extends ServiceImpl<SubmitRecordsMapper, S
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResVo selectRecords(int pageNum, int pageSize, SubmitRecords submitRecords) {
|
public ResVo selectRecords(int pageNum, int pageSize, SubmitRecord submitRecord) {
|
||||||
Page<SubmitRecords> page = new Page<>(pageNum, pageSize);
|
log.info("selectRecords:{}", submitRecord);
|
||||||
submitRecordsMapper.selectPage(page, submitRecords);
|
Page<SubmitRecord> page = new Page<>(pageNum, pageSize);
|
||||||
|
submitRecordsMapper.selectPageForCheck(page, submitRecord);
|
||||||
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("current", page.getCurrent());
|
map.put("current", page.getCurrent());
|
||||||
@ -67,6 +72,17 @@ public class SubmitRecordsServiceImpl extends ServiceImpl<SubmitRecordsMapper, S
|
|||||||
map.put("list", page.getRecords());
|
map.put("list", page.getRecords());
|
||||||
return ResVo.ok(map);
|
return ResVo.ok(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResVo selectRecords(int pageNum, int pageSize, String className, String studentId, String applyUser) {
|
||||||
|
Page<ExperimentDTO> page = new Page<>(pageNum, pageSize);
|
||||||
|
submitRecordsMapper.selectPageST(page, className, studentId, applyUser);
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("current", page.getCurrent());
|
||||||
|
map.put("total", page.getTotal());
|
||||||
|
map.put("list", page.getRecords());
|
||||||
|
return ResVo.ok(map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -164,4 +164,49 @@ public class TableServiceImpl implements TableService {
|
|||||||
return ResVo.error("文件读取失败");
|
return ResVo.error("文件读取失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResVo getUsedTable(String room, String date) {
|
||||||
|
QueryWrapper<BorrowInfo> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("date", date)
|
||||||
|
.eq("room_name", room);
|
||||||
|
List<BorrowInfo> borrowedList = borrowInfoMapper.selectList(queryWrapper);
|
||||||
|
Map<String, List<String>> tempMap = new HashMap<>();
|
||||||
|
// 获取所有教室
|
||||||
|
List<Room> roomList = roomMapper.selectList(null);
|
||||||
|
// 获取所有时间(按顺序)
|
||||||
|
List<TimeOption> timeOptionList = timeOptionMapper.selectList(null);
|
||||||
|
|
||||||
|
for (TimeOption time : timeOptionList) {
|
||||||
|
List<String> rooms = new ArrayList<>();
|
||||||
|
tempMap.put(time.getName(), rooms);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BorrowInfo item : borrowedList) {
|
||||||
|
tempMap.get(item.getTime()).add(item.getRoomName());
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
List<List<String>> res = new ArrayList<>();
|
||||||
|
|
||||||
|
// 获取不在borrowedList中的教室
|
||||||
|
for (TimeOption key : timeOptionList) {
|
||||||
|
List<String> rooms = new ArrayList<>();
|
||||||
|
for (Room item : roomList) {
|
||||||
|
if (tempMap.get(key.getName()).contains(item.getName())) {
|
||||||
|
rooms.add(item.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res.add(rooms);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (room != null && !room.isEmpty()) {
|
||||||
|
for (List<String> rooms : res) {
|
||||||
|
rooms.removeIf(r -> !r.equals(room));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
map.put("list", res);
|
||||||
|
return ResVo.ok(map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,8 +152,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
|||||||
}
|
}
|
||||||
//默认密码为123456
|
//默认密码为123456
|
||||||
user.setPassword(DigestUtils.md5DigestAsHex("123456".getBytes()));
|
user.setPassword(DigestUtils.md5DigestAsHex("123456".getBytes()));
|
||||||
//身份
|
|
||||||
user.setRole("student");
|
|
||||||
//班级
|
//班级
|
||||||
try {
|
try {
|
||||||
if (excel.readCell(i, 2) == null) {
|
if (excel.readCell(i, 2) == null) {
|
||||||
@ -174,7 +172,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return ResVo.error("Excel格式错误:第" + (i + 1) + "行第4列");
|
return ResVo.error("Excel格式错误:第" + (i + 1) + "行第4列");
|
||||||
}
|
}
|
||||||
|
//身份
|
||||||
|
try {
|
||||||
|
if (excel.readCell(i, 4) == null) {
|
||||||
|
return ResVo.error("Excel格式错误:第" + (i + 1) + "行第5列");
|
||||||
|
}
|
||||||
|
user.setRole(excel.readCell(i, 3));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return ResVo.error("Excel格式错误:第" + (i + 1) + "行第5列");
|
||||||
|
}
|
||||||
list.add(user);
|
list.add(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,5 +27,8 @@ logging:
|
|||||||
level:
|
level:
|
||||||
root: info
|
root: info
|
||||||
|
|
||||||
file:
|
# 启用MyBatis Plus的SQL语句打印功能
|
||||||
filePath:"/uploadPath/"
|
#mybatis-plus:
|
||||||
|
# configuration:
|
||||||
|
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
<?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.sdut.labex.mapper.FileMapper">
|
|
||||||
|
|
||||||
<resultMap id="BaseResultMap" type="com.sdut.labex.entity.FileEntity">
|
|
||||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
|
||||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
|
||||||
<result property="path" column="path" jdbcType="VARCHAR"/>
|
|
||||||
<result property="experimentId" column="experiment_id" jdbcType="INTEGER"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
|
||||||
id,name,path,
|
|
||||||
experiment_id
|
|
||||||
</sql>
|
|
||||||
</mapper>
|
|
@ -4,10 +4,10 @@
|
|||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.sdut.labex.mapper.SubmitRecordsMapper">
|
<mapper namespace="com.sdut.labex.mapper.SubmitRecordsMapper">
|
||||||
|
|
||||||
<resultMap id="BaseResultMap" type="com.sdut.labex.entity.SubmitRecords">
|
<resultMap id="BaseResultMap" type="com.sdut.labex.entity.SubmitRecord">
|
||||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||||
<result property="experimentId" column="experiment_id" jdbcType="INTEGER"/>
|
<result property="experimentId" column="experiment_id" jdbcType="INTEGER"/>
|
||||||
<result property="studentId" column="student_id" jdbcType="INTEGER"/>
|
<result property="studentId" column="student_id" jdbcType="VARCHAR"/>
|
||||||
<result property="filePath" column="file_path" jdbcType="VARCHAR"/>
|
<result property="filePath" column="file_path" jdbcType="VARCHAR"/>
|
||||||
<result property="score" column="score" jdbcType="INTEGER"/>
|
<result property="score" column="score" jdbcType="INTEGER"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
@ -16,18 +16,47 @@
|
|||||||
id,experiment_id,student_id,
|
id,experiment_id,student_id,
|
||||||
file_path,score
|
file_path,score
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectPage" resultType="com.sdut.labex.entity.SubmitRecords">
|
|
||||||
|
<select id="selectPageForCheck" resultType="com.sdut.labex.entity.SubmitRecord">
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List"/>
|
<include refid="Base_Column_List"/>
|
||||||
from submit_records
|
from submit_records
|
||||||
<where>
|
<where>
|
||||||
<if test="submitRecords.experimentId != null">
|
<if test="submitRecord.experimentId != null and submitRecord.experimentId != ''">
|
||||||
experiment_id = #{submitRecords.experimentId}
|
and experiment_id = #{submitRecord.experimentId}
|
||||||
</if>
|
</if>
|
||||||
<if test="submitRecords.studentId != null">
|
<if test="submitRecord.studentId != null and submitRecord.studentId != ''">
|
||||||
and student_id = #{submitRecords.studentId}
|
and student_id = #{submitRecord.studentId}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectPageST" resultType="com.sdut.labex.dto.ExperimentDTO">
|
||||||
|
SELECT s.id AS record_id, s.experiment_id, s.student_id, s.file_path, s.score,
|
||||||
|
u.username, u.class_name, u.department, u.role,
|
||||||
|
e.name AS experiment_name, e.status, e.class_name AS experiment_class, e.apply_time, e.apply_user, e.annex
|
||||||
|
FROM submit_records s
|
||||||
|
INNER JOIN user u ON s.student_id = u.id
|
||||||
|
INNER JOIN experiments e ON s.experiment_id = e.id
|
||||||
|
<where>
|
||||||
|
<if test="studentId != null and studentId != ''">
|
||||||
|
AND u.id = #{studentId}
|
||||||
|
</if>
|
||||||
|
<if test="className != null and className != ''">
|
||||||
|
AND u.class_name = #{className}
|
||||||
|
</if>
|
||||||
|
<if test="applyUser != null and applyUser != ''">
|
||||||
|
AND e.apply_user = #{applyUser}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertBatch" parameterType="java.util.List">
|
||||||
|
insert into submit_records (experiment_id, student_id, file_path, score)
|
||||||
|
values
|
||||||
|
<foreach collection="list" item="submitRecord" separator="," index="index">
|
||||||
|
(#{submitRecord.experimentId}, #{submitRecord.studentId}, #{submitRecord.filePath}, #{submitRecord.score})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<!--教室使用情况表-->
|
<!--教室使用情况表-->
|
||||||
<h4>可用教室</h4>
|
<h4 v-if="userInfo.role==='teacher'">可用教室</h4>
|
||||||
|
<h4 v-if="userInfo.role==='student'">课表查看</h4>
|
||||||
<el-table :data="tableData" border>
|
<el-table :data="tableData" border>
|
||||||
<el-table-column prop="date"/>
|
<el-table-column prop="date"/>
|
||||||
<el-table-column v-for="(val,index) in timeSet" :key="index" :label="val" align="center">
|
<el-table-column v-for="(val,index) in timeSet" :key="index" :label="val" align="center">
|
||||||
@ -14,7 +15,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<el-form label-width="120px" :inline="true" style="margin-top: 20px;margin-bottom: -20px">
|
<el-form label-width="120px" :inline="true" style="margin-top: 20px;margin-bottom: -20px">
|
||||||
<el-form-item label="教室筛选">
|
<el-form-item label="教室选择">
|
||||||
<div v-for="(item,i) in rooms">
|
<div v-for="(item,i) in rooms">
|
||||||
<el-tag type="warning" @click="subForm.roomName = item.name" style="cursor: pointer;margin-right: 20px;">
|
<el-tag type="warning" @click="subForm.roomName = item.name" style="cursor: pointer;margin-right: 20px;">
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
@ -37,6 +38,15 @@ export default {
|
|||||||
},
|
},
|
||||||
timeSet: ['第一节', '第二节', '第三节', '第四节', '第五节', '第六节', '第七节', '第八节', '第九节', '第十节'],
|
timeSet: ['第一节', '第二节', '第三节', '第四节', '第五节', '第六节', '第七节', '第八节', '第九节', '第十节'],
|
||||||
tableData: [],
|
tableData: [],
|
||||||
|
|
||||||
|
userInfo: {
|
||||||
|
userId: '',
|
||||||
|
role: '',
|
||||||
|
username: '',
|
||||||
|
userDepart: '',
|
||||||
|
newPwd: '',
|
||||||
|
oldPwd: ''
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -51,6 +61,9 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.userInfo.role = window.sessionStorage.getItem('role');
|
||||||
|
this.userInfo.username = window.sessionStorage.getItem("username");
|
||||||
|
this.userInfo.userId = window.sessionStorage.getItem("userId");
|
||||||
//此处传递的是引用
|
//此处传递的是引用
|
||||||
this.subForm.date = this.$props.msg.date;
|
this.subForm.date = this.$props.msg.date;
|
||||||
this.subForm.roomName = this.$props.msg.roomName;
|
this.subForm.roomName = this.$props.msg.roomName;
|
||||||
@ -83,9 +96,17 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
getTableData(offset, subForm) {
|
getTableData(offset, subForm) {
|
||||||
console.log(subForm); // 打印新的 subForm 对象
|
|
||||||
|
let url = '';
|
||||||
|
if (this.userInfo.role !== 'student') {
|
||||||
|
url = '/getUnusedTable';
|
||||||
|
} else {
|
||||||
|
url = '/getUsedTable';
|
||||||
|
}
|
||||||
|
url = '/getUsedTable';
|
||||||
|
|
||||||
this.$http({
|
this.$http({
|
||||||
url: '/getUnusedTable',
|
url: url,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: subForm
|
data: subForm
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { createApp } from 'vue'
|
import {createApp} from 'vue'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
import store from './store'
|
import store from './store'
|
||||||
@ -12,7 +12,7 @@ app.use(store).use(router).mount('#app')
|
|||||||
|
|
||||||
app.config.globalProperties.$http = axios;
|
app.config.globalProperties.$http = axios;
|
||||||
//接口请求的基准路径
|
//接口请求的基准路径
|
||||||
axios.defaults.baseURL = 'http://localhost:8080/';
|
axios.defaults.baseURL = 'http://10.0.0.157:8080/';
|
||||||
// axios.defaults.baseURL = 'http://211.64.28.110:8080/';
|
// axios.defaults.baseURL = 'http://211.64.28.110:8080/';
|
||||||
|
|
||||||
// 添加请求拦截器
|
// 添加请求拦截器
|
||||||
|
@ -53,12 +53,10 @@ const routes = [
|
|||||||
name: 'ExperimentCheck',
|
name: 'ExperimentCheck',
|
||||||
component: () => import('../views/ApplyExperiment/ExperimentCheck.vue')
|
component: () => import('../views/ApplyExperiment/ExperimentCheck.vue')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
path: '/Upload',
|
path: '/Sub',
|
||||||
name: 'Upload',
|
name: 'Sub',
|
||||||
component: () => import('../views/Admin/Upload.vue')
|
component: () => import('../views/Student/Sub.vue')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-space>
|
|
||||||
|
|
||||||
<el-upload :on-change="fileChange" :show-file-list="false" :auto-upload="false">
|
|
||||||
<el-button type="warning">上传</el-button>
|
|
||||||
</el-upload>
|
|
||||||
|
|
||||||
<el-button type="warning" @click="download()">下载</el-button>
|
|
||||||
</el-space>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
let formData = new FormData;
|
|
||||||
export default {
|
|
||||||
name: 'Upload',
|
|
||||||
methods: {
|
|
||||||
fileChange(files, fileList) {
|
|
||||||
formData.append('file', files.raw)
|
|
||||||
files = null;
|
|
||||||
this.loading = true;
|
|
||||||
this.$http({
|
|
||||||
method: 'post',
|
|
||||||
url: '/upload',
|
|
||||||
data: formData,
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'multipart/form-data'
|
|
||||||
}
|
|
||||||
}).then(res => {
|
|
||||||
if (res.data.code === 200) {
|
|
||||||
this.$notify({
|
|
||||||
title: '上传成功',
|
|
||||||
message: res.data.msg,
|
|
||||||
type: 'success'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.$notify({
|
|
||||||
title: '文件解析失败',
|
|
||||||
message: res.data.msg,
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
formData = null;
|
|
||||||
formData = new FormData();
|
|
||||||
this.loading = false;
|
|
||||||
})
|
|
||||||
},
|
|
||||||
download() {
|
|
||||||
// const fileName = this.selectedFile.name;
|
|
||||||
const fileName = '22级新生信息.xlsx';
|
|
||||||
|
|
||||||
this.$http({
|
|
||||||
url: '/download/' + fileName,
|
|
||||||
method: 'GET',
|
|
||||||
responseType: 'blob', // important
|
|
||||||
}).then((response) => {
|
|
||||||
const url = window.URL.createObjectURL(new Blob([response.data]));
|
|
||||||
const link = document.createElement('a');
|
|
||||||
link.href = url;
|
|
||||||
link.setAttribute('download', fileName);
|
|
||||||
document.body.appendChild(link);
|
|
||||||
link.click();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
@ -8,13 +8,15 @@
|
|||||||
<el-upload :on-change="fileChange" :show-file-list="false" :auto-upload="false">
|
<el-upload :on-change="fileChange" :show-file-list="false" :auto-upload="false">
|
||||||
<el-button type="warning" :loading="loading">上传</el-button>
|
<el-button type="warning" :loading="loading">上传</el-button>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</el-space>>
|
<el-button type="success" :loading="loading" @click="download">下载模版</el-button>
|
||||||
|
</el-space>
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<!--表格展示-->
|
<!--表格展示-->
|
||||||
<div style="margin-top: 20px">
|
<div style="margin-top: 20px">
|
||||||
<el-table :data="userList" border stripe v-loading="loading">
|
<el-table :data="userList" border stripe v-loading="loading">
|
||||||
<el-table-column align="center" prop="id" label="ID"/>
|
<el-table-column align="center" prop="id" label="ID"/>
|
||||||
<el-table-column align="center" prop="username" label="姓名" />
|
<el-table-column align="center" prop="username" label="姓名"/>
|
||||||
<el-table-column align="center" prop="className" label="班级"/>
|
<el-table-column align="center" prop="className" label="班级"/>
|
||||||
<el-table-column align="center" prop="department" label="学院"/>
|
<el-table-column align="center" prop="department" label="学院"/>
|
||||||
<el-table-column align="center" prop="role" label="身份"/>
|
<el-table-column align="center" prop="role" label="身份"/>
|
||||||
@ -73,27 +75,28 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {ElMessage, ElMessageBox} from "element-plus";
|
import {ElMessage, ElMessageBox} from "element-plus";
|
||||||
|
|
||||||
let formData = new FormData;
|
let formData = new FormData;
|
||||||
export default {
|
export default {
|
||||||
name: "UserManage",
|
name: "UserManage",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loading:true,
|
loading: true,
|
||||||
isEdit:false,
|
isEdit: false,
|
||||||
|
|
||||||
pageSize:30,
|
pageSize: 30,
|
||||||
pageNum:1,
|
pageNum: 1,
|
||||||
total:0,
|
total: 0,
|
||||||
|
|
||||||
addForm:{
|
addForm: {
|
||||||
id:'',
|
id: '',
|
||||||
username:'',
|
username: '',
|
||||||
role:'teacher',
|
role: 'teacher',
|
||||||
password:'123456',
|
password: '123456',
|
||||||
className:'',
|
className: '',
|
||||||
department:''
|
department: ''
|
||||||
},
|
},
|
||||||
userList:[],
|
userList: [],
|
||||||
dialogVisibleForAdd: false,
|
dialogVisibleForAdd: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -107,9 +110,9 @@ export default {
|
|||||||
this.$http({
|
this.$http({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url: '/user/' + this.pageNum + '/' + this.pageSize,
|
url: '/user/' + this.pageNum + '/' + this.pageSize,
|
||||||
data:{
|
data: {
|
||||||
id:'',
|
id: '',
|
||||||
username:''
|
username: ''
|
||||||
}
|
}
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
this.userList = data.list;
|
this.userList = data.list;
|
||||||
@ -119,14 +122,14 @@ export default {
|
|||||||
},
|
},
|
||||||
addUser() {
|
addUser() {
|
||||||
let method = '';
|
let method = '';
|
||||||
if(this.isEdit){
|
if (this.isEdit) {
|
||||||
method = 'put';
|
method = 'put';
|
||||||
}else {
|
} else {
|
||||||
method = 'post';
|
method = 'post';
|
||||||
}
|
}
|
||||||
this.$http({
|
this.$http({
|
||||||
method: method,
|
method: method,
|
||||||
url: '/user' ,
|
url: '/user',
|
||||||
data: this.addForm
|
data: this.addForm
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
if (data.code === 200) {
|
if (data.code === 200) {
|
||||||
@ -140,7 +143,7 @@ export default {
|
|||||||
this.addForm.id = '';
|
this.addForm.id = '';
|
||||||
this.addForm.password = '123456';
|
this.addForm.password = '123456';
|
||||||
this.getUser();
|
this.getUser();
|
||||||
}else {
|
} else {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: data.msg,
|
message: data.msg,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
@ -148,7 +151,7 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
update(row){
|
update(row) {
|
||||||
this.addForm = JSON.parse(JSON.stringify(row));
|
this.addForm = JSON.parse(JSON.stringify(row));
|
||||||
this.isEdit = true;
|
this.isEdit = true;
|
||||||
|
|
||||||
@ -213,6 +216,28 @@ export default {
|
|||||||
this.loading = false;
|
this.loading = false;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
download() {
|
||||||
|
let fileName = 'userTemplate.xlsx';
|
||||||
|
this.$http({
|
||||||
|
url: '/download/' + fileName,
|
||||||
|
method: 'GET',
|
||||||
|
responseType: 'blob',
|
||||||
|
}).then((response) => {
|
||||||
|
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.setAttribute('download', fileName);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
}).catch((error) => {
|
||||||
|
if (error.response && error.response.status === 404) {
|
||||||
|
this.$message.error('文件不存在!');
|
||||||
|
} else {
|
||||||
|
// 对于其他错误,可以选择不同的处理方式
|
||||||
|
this.$message.error('下载文件时发生错误!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column fixed="right" label="操作">
|
<el-table-column fixed="right" label="操作">
|
||||||
<template #default>
|
<template #default="scope">
|
||||||
<el-button link type="primary" size="small">删除</el-button>
|
<el-button link type="primary" size="small" @click="remove(scope.row.id)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -111,6 +111,25 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
remove(id) {
|
||||||
|
this.$http({
|
||||||
|
url: '/experiment/' + id,
|
||||||
|
method: 'delete',
|
||||||
|
}).then(({data}) => {
|
||||||
|
if (data.code !== 200) {
|
||||||
|
ElMessage({
|
||||||
|
message: data.msg,
|
||||||
|
type: 'error',
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
ElMessage({
|
||||||
|
message: "删除成功",
|
||||||
|
type: 'success',
|
||||||
|
})
|
||||||
|
this.getList()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -2,38 +2,29 @@
|
|||||||
|
|
||||||
<el-page-header content="实验批阅" style="margin-bottom: 30px" @back="this.$router.push('/Login')"/>
|
<el-page-header content="实验批阅" style="margin-bottom: 30px" @back="this.$router.push('/Login')"/>
|
||||||
<el-card style="max-width: 1200px;margin:0 auto;background-color: #f9fafb">
|
<el-card style="max-width: 1200px;margin:0 auto;background-color: #f9fafb">
|
||||||
<div style="display: flex;justify-content: space-between;align-items: center">
|
|
||||||
<el-space>
|
|
||||||
<el-button type="primary" style="margin-right: 10px;" @click="dialogVisibleForAdd = true">添加成员</el-button>
|
|
||||||
<el-upload :on-change="fileChange" :show-file-list="false" :auto-upload="false">
|
|
||||||
<el-button type="warning" :loading="loading">上传</el-button>
|
|
||||||
</el-upload>
|
|
||||||
</el-space>
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<!--表格展示-->
|
<!--表格展示-->
|
||||||
<div style="margin-top: 20px">
|
<div style="margin-top: 20px">
|
||||||
<el-table :data="userList" border stripe v-loading="loading">
|
<el-table :data="list" border stripe v-loading="loading">
|
||||||
<el-table-column align="center" prop="id" label="ID"/>
|
<el-table-column align="center" prop="experimentName" label="实验名称"/>
|
||||||
<el-table-column align="center" prop="username" label="姓名"/>
|
<el-table-column align="center" prop="studentId" label="学号"/>
|
||||||
<el-table-column align="center" prop="className" label="班级"/>
|
<el-table-column align="center" prop="className" label="班级"/>
|
||||||
<el-table-column align="center" prop="department" label="学院"/>
|
<el-table-column align="center" prop="username" label="学生姓名"/>
|
||||||
<el-table-column align="center" prop="role" label="身份"/>
|
<el-table-column align="center" prop="score" label="得分"/>
|
||||||
<el-table-column align="center" label="操作">
|
<el-table-column align="center" label="操作" width="250px">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button type="primary" @click="update(scope.row)">
|
<el-button type="primary" @click="openDialog(scope.row)">
|
||||||
<span style="margin-left: 3px">更新</span>
|
<span style="margin-left: 3px">评分</span>
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="danger" @click="remove(scope.row.id)">
|
<el-button type="info" v-if="scope.row.filePath===null" disabled>未上传</el-button>
|
||||||
<span style="margin-left: 3px">删除</span>
|
<el-button type="success" v-if="scope.row.filePath!==null" @click="download(scope.row.filePath)">下载文件
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
<el-pagination
|
<el-pagination
|
||||||
@size-change="getUser"
|
@size-change="getList"
|
||||||
@current-change="getUser"
|
@current-change="getList"
|
||||||
v-model:current-page="pageNum"
|
v-model:current-page="pageNum"
|
||||||
|
|
||||||
v-model:page-size="pageSize"
|
v-model:page-size="pageSize"
|
||||||
@ -41,31 +32,31 @@
|
|||||||
:total="total">
|
:total="total">
|
||||||
</el-pagination>
|
</el-pagination>
|
||||||
<!--添加用户的对话框-->
|
<!--添加用户的对话框-->
|
||||||
<el-dialog title="添加用户" v-model="dialogVisibleForAdd" width="30%" style="padding-top: 30px">
|
<el-dialog title="添加用户" v-model="dialogVisible" width="30%" style="padding-top: 30px">
|
||||||
<el-form ref="addForm" :model="addForm" label-width="100px">
|
<el-form ref="addForm" :model="form" label-width="100px">
|
||||||
<el-form-item label="工号">
|
<el-form-item label="ID">
|
||||||
<el-input :disabled="isEdit" v-model="addForm.id" placeholder="请输入工号..."></el-input>
|
<el-input disabled v-model="form.id"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="姓名">
|
<el-form-item label="实验ID">
|
||||||
<el-input v-model="addForm.username" placeholder="请输入姓名..."></el-input>
|
<el-input disabled v-model="form.experimentId"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="班级">
|
<el-form-item label="实验名称">
|
||||||
<el-input v-model="addForm.className" placeholder="请输入班级..."></el-input>
|
<el-input disabled v-model="form.experimentName"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="学院">
|
<el-form-item label="学生ID">
|
||||||
<el-input v-model="addForm.department" placeholder="请输入班级..."></el-input>
|
<el-input disabled v-model="form.studentId"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="密码">
|
<el-form-item label="文件">
|
||||||
<el-input v-model="addForm.password" placeholder="请输入密码..."></el-input>
|
<el-button v-if="form.filePath === null" disabled>未上传文件</el-button>
|
||||||
|
<el-button v-if="form.filePath !== null" @click="download(form.filePath)">下载</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="身份">
|
<el-form-item label="得分">
|
||||||
<el-input v-model="addForm.role" placeholder="请输入密码..."></el-input>
|
<el-input v-model="form.score" placeholder="请输入得分..."></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
<span slot="footer" class="dialog-footer">
|
<span slot="footer" class="dialog-footer">
|
||||||
<el-button type="primary" @click="addUser">确 定</el-button>
|
<el-button type="primary" @click="update">确 定</el-button>
|
||||||
<el-button @click="dialogVisibleForAdd = false">取 消</el-button>
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
</span>
|
</span>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</el-card>
|
</el-card>
|
||||||
@ -73,146 +64,85 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {ElMessage, ElMessageBox} from "element-plus";
|
|
||||||
|
|
||||||
let formData = new FormData;
|
let formData = new FormData;
|
||||||
export default {
|
export default {
|
||||||
name: "UserManage",
|
naname: "ExperimentReview",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loading: true,
|
list: [],
|
||||||
isEdit: false,
|
loading: false,
|
||||||
|
form: {
|
||||||
pageSize: 30,
|
|
||||||
pageNum: 1,
|
|
||||||
total: 0,
|
|
||||||
|
|
||||||
addForm: {
|
|
||||||
id: '',
|
id: '',
|
||||||
username: '',
|
experimentId: '',
|
||||||
role: 'teacher',
|
studentId: '',
|
||||||
password: '123456',
|
filePath: '',
|
||||||
className: '',
|
score: ''
|
||||||
department: ''
|
|
||||||
},
|
},
|
||||||
userList: [],
|
dialogVisible: false,
|
||||||
dialogVisibleForAdd: false,
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
total: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getUser();
|
this.getList()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getUser() {
|
getList() {
|
||||||
this.loading = true;
|
|
||||||
this.userList = [];
|
|
||||||
this.$http({
|
|
||||||
method: 'post',
|
|
||||||
url: '/user/' + this.pageNum + '/' + this.pageSize,
|
|
||||||
data: {
|
|
||||||
id: '',
|
|
||||||
username: ''
|
|
||||||
}
|
|
||||||
}).then(({data}) => {
|
|
||||||
this.userList = data.list;
|
|
||||||
this.total = data.total;
|
|
||||||
this.loading = false;
|
|
||||||
})
|
|
||||||
},
|
|
||||||
addUser() {
|
|
||||||
let method = '';
|
|
||||||
if (this.isEdit) {
|
|
||||||
method = 'put';
|
|
||||||
} else {
|
|
||||||
method = 'post';
|
|
||||||
}
|
|
||||||
this.$http({
|
|
||||||
method: method,
|
|
||||||
url: '/user',
|
|
||||||
data: this.addForm
|
|
||||||
}).then(({data}) => {
|
|
||||||
if (data.code === 200) {
|
|
||||||
ElMessage({
|
|
||||||
message: '操作成功',
|
|
||||||
type: 'success'
|
|
||||||
})
|
|
||||||
this.isEdit = false;
|
|
||||||
this.dialogVisibleForAdd = false;
|
|
||||||
this.addForm.username = '';
|
|
||||||
this.addForm.id = '';
|
|
||||||
this.addForm.password = '123456';
|
|
||||||
this.getUser();
|
|
||||||
} else {
|
|
||||||
ElMessage({
|
|
||||||
message: data.msg,
|
|
||||||
type: 'error'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
update(row) {
|
|
||||||
this.addForm = JSON.parse(JSON.stringify(row));
|
|
||||||
this.isEdit = true;
|
|
||||||
|
|
||||||
this.dialogVisibleForAdd = true;
|
|
||||||
},
|
|
||||||
remove(id) {
|
|
||||||
ElMessageBox.confirm(
|
|
||||||
'该操作不可撤销',
|
|
||||||
'警告',
|
|
||||||
{
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning',
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
this.$http({
|
|
||||||
method: 'delete',
|
|
||||||
url: '/user/' + id,
|
|
||||||
}).then(res => {
|
|
||||||
this.getUser();
|
|
||||||
ElMessage({
|
|
||||||
type: 'success',
|
|
||||||
message: '删除成功',
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
ElMessage({
|
|
||||||
type: 'info',
|
|
||||||
message: '删除已取消',
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
fileChange(files, fileList) {
|
|
||||||
formData.append('file', files.raw)
|
|
||||||
files = null;
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.$http({
|
this.$http({
|
||||||
method: 'post',
|
url: '/getRecordST/' + this.pageNum + '/' + this.pageSize,
|
||||||
url: '/addUserBatch',
|
method: 'POST',
|
||||||
data: formData,
|
data: this.form
|
||||||
headers: {
|
|
||||||
'Content-Type': 'multipart/form-data'
|
|
||||||
}
|
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.data.code === 200) {
|
|
||||||
this.$notify({
|
this.list = res.data.list;
|
||||||
title: '上传成功',
|
this.total = res.data.total;
|
||||||
message: res.data.msg,
|
|
||||||
type: 'success'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.$notify({
|
|
||||||
title: '文件解析失败',
|
|
||||||
message: res.data.msg,
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
formData = null;
|
|
||||||
formData = new FormData();
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
download(fileName) {
|
||||||
|
this.$http({
|
||||||
|
url: '/download/' + fileName,
|
||||||
|
method: 'GET',
|
||||||
|
responseType: 'blob', // important
|
||||||
|
}).then((response) => {
|
||||||
|
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.setAttribute('download', fileName);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
openDialog(row) {
|
||||||
|
//给form赋值
|
||||||
|
this.form.id = row.recordId;
|
||||||
|
this.form.experimentId = row.experimentId;
|
||||||
|
this.form.studentId = row.studentId;
|
||||||
|
this.form.filePath = row.filePath;
|
||||||
|
this.form.score = row.score;
|
||||||
|
this.form.experimentName = row.experimentName;
|
||||||
|
this.dialogVisible = true;
|
||||||
|
},
|
||||||
|
update() {
|
||||||
|
this.$http({
|
||||||
|
url: '/records',
|
||||||
|
method: 'put',
|
||||||
|
data: this.form
|
||||||
|
}).then(res => {
|
||||||
|
this.dialogVisible = false;
|
||||||
|
this.form = {
|
||||||
|
id: '',
|
||||||
|
experimentId: '',
|
||||||
|
studentId: '',
|
||||||
|
filePath: '',
|
||||||
|
score: ''
|
||||||
|
};
|
||||||
|
this.getList();
|
||||||
|
}).catch(res => {
|
||||||
|
this.$message.error("请注意评分为数字");
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-page-header content="教室申请" style="margin-bottom: 30px" @back="this.$router.push('/Login')"/>
|
<el-page-header v-if="userInfo.role==='teacher'" content="教室申请" style="margin-bottom: 30px"
|
||||||
|
@back="this.$router.push('/Login')"/>
|
||||||
|
<el-page-header v-if="userInfo.role==='student'" content="课表查看" style="margin-bottom: 30px"
|
||||||
|
@back="this.$router.push('/Login')"/>
|
||||||
<el-card>
|
<el-card>
|
||||||
<Table :msg="borrowForm"/>
|
<Table :msg="borrowForm"/>
|
||||||
<el-divider/>
|
<el-divider/>
|
||||||
@ -16,7 +19,7 @@
|
|||||||
style="width: 200px"
|
style="width: 200px"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="时间">
|
<el-form-item label="时间" v-if="userInfo.role!=='student'">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="borrowForm.time"
|
v-model="borrowForm.time"
|
||||||
placeholder="请选择借用时间"
|
placeholder="请选择借用时间"
|
||||||
@ -37,11 +40,11 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
<el-divider/>
|
<el-divider/>
|
||||||
<div style="margin-left:20px;margin-right:20px;padding-left: 70px;padding-top: 40px;padding-bottom: 30px">
|
<div v-if="this.userInfo.role!=='student'"
|
||||||
|
style="margin-left:20px;margin-right:20px;padding-left: 70px;padding-top: 40px;padding-bottom: 30px">
|
||||||
<el-space :size="45" wrap>
|
<el-space :size="45" wrap>
|
||||||
<div v-for="(item,i) in Rooms">
|
<div v-for="(item,i) in Rooms">
|
||||||
<el-card :body-style="{ padding: '0px' }" style="width: 200px;">
|
<el-card :body-style="{ padding: '0px' }" style="width: 200px;">
|
||||||
|
|
||||||
<div style="padding: 14px">
|
<div style="padding: 14px">
|
||||||
<div style="margin-bottom: 10px">{{ item.name }}</div>
|
<div style="margin-bottom: 10px">{{ item.name }}</div>
|
||||||
<div style="width: 100%;padding-left: 10px;padding-right: 10px">
|
<div style="width: 100%;padding-left: 10px;padding-right: 10px">
|
||||||
|
@ -14,26 +14,19 @@
|
|||||||
<img src="../assets/img/logoW.png" style="height: 60%;width: 80%; margin-left: 20px;margin-top: 5px"
|
<img src="../assets/img/logoW.png" style="height: 60%;width: 80%; margin-left: 20px;margin-top: 5px"
|
||||||
alt="">
|
alt="">
|
||||||
</div>
|
</div>
|
||||||
<el-sub-menu index="1">
|
<el-menu-item index="/ApplyExperiment" v-if="userInfo.role!=='student'">实验项目申请</el-menu-item>
|
||||||
<template #title>
|
<el-menu-item index="/Admit" v-if="userInfo.role!=='student'">实验项目审核</el-menu-item>
|
||||||
<span>实验管理</span>
|
<el-menu-item index="/ExperimentCheck" v-if="userInfo.role!=='student'">实验项目批阅</el-menu-item>
|
||||||
</template>
|
|
||||||
<el-menu-item index="/ApplyExperiment">实验项目申请</el-menu-item>
|
<el-menu-item index="/BorrowRoom" v-if="userInfo.role!=='student'">教室申请</el-menu-item>
|
||||||
<el-menu-item index="/ExperimentCheck">实验项目批阅</el-menu-item>
|
<el-menu-item index="/BorrowRoom" v-if="userInfo.role==='student'">课表查看</el-menu-item>
|
||||||
<el-menu-item index="/Admit">实验项目审核</el-menu-item>
|
<el-menu-item index="/RecordList" v-if="userInfo.role!=='student'">教室申请记录查询</el-menu-item>
|
||||||
<el-menu-item index="/BorrowRoom">教室申请</el-menu-item>
|
<el-menu-item index="/Sub">我的实验</el-menu-item>
|
||||||
<el-menu-item index="/RecordList">教室申请记录查询</el-menu-item>
|
|
||||||
</el-sub-menu>
|
<el-menu-item index="/UserManage" v-if="userInfo.role!=='student'">用户管理</el-menu-item>
|
||||||
<el-sub-menu index="2">
|
<el-menu-item index="/Personal">个人信息</el-menu-item>
|
||||||
<template #title>
|
|
||||||
<i class="el-icon-user-solid"></i>
|
<el-menu-item index="/RoomTimeAndReasonManage" v-if="userInfo.role!=='student'">系统管理</el-menu-item>
|
||||||
<span>用户管理</span>
|
|
||||||
</template>
|
|
||||||
<el-menu-item index="/UserManage">用户管理</el-menu-item>
|
|
||||||
<el-menu-item index="/Personal">个人信息</el-menu-item>
|
|
||||||
</el-sub-menu>
|
|
||||||
<el-menu-item index="/RoomTimeAndReasonManage">系统管理</el-menu-item>
|
|
||||||
<el-menu-item index="/Upload">上传</el-menu-item>
|
|
||||||
</el-menu>
|
</el-menu>
|
||||||
</div>
|
</div>
|
||||||
</el-aside>
|
</el-aside>
|
||||||
|
@ -9,12 +9,22 @@
|
|||||||
</el-card>
|
</el-card>
|
||||||
<el-card style="margin-top: 10px">
|
<el-card style="margin-top: 10px">
|
||||||
<el-table :data="itemList" style="width: 100%">
|
<el-table :data="itemList" style="width: 100%">
|
||||||
<el-table-column fixed prop="name" label="项目名称"/>
|
<el-table-column fixed prop="experimentName" label="项目名称"/>
|
||||||
<el-table-column prop="className" label="上课班级"/>
|
<el-table-column prop="className" label="上课班级"/>
|
||||||
<el-table-column prop="time" label="上课时间"/>
|
<el-table-column label="附件">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button link type="primary" size="small" @click="download(scope.row.annex)">下载</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column fixed="right" label="操作">
|
<el-table-column fixed="right" label="操作">
|
||||||
<template #default>
|
<template #default="scope">
|
||||||
<el-button link type="primary" size="small" @click="upLoad">上传</el-button>
|
<el-upload :on-change="fileChange" v-if="scope.row.filePath === ''" :show-file-list="false"
|
||||||
|
:auto-upload="false">
|
||||||
|
<el-button link type="primary" size="small" @click="change(scope.row)">上传</el-button>
|
||||||
|
</el-upload>
|
||||||
|
<el-button link type="primary" size="small" v-if="scope.row.filePath !== ''"
|
||||||
|
@click="download(scope.row.filePath)">下载
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -32,6 +42,7 @@
|
|||||||
import {computed, ref} from 'vue'
|
import {computed, ref} from 'vue'
|
||||||
import {ElMessage} from "element-plus";
|
import {ElMessage} from "element-plus";
|
||||||
|
|
||||||
|
let formData = new FormData;
|
||||||
const size = ref('')
|
const size = ref('')
|
||||||
computed(() => {
|
computed(() => {
|
||||||
const marginMap = {
|
const marginMap = {
|
||||||
@ -48,6 +59,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
itemList: [],
|
itemList: [],
|
||||||
|
upID: "",
|
||||||
form: {
|
form: {
|
||||||
name: '',
|
name: '',
|
||||||
className: '',
|
className: '',
|
||||||
@ -56,6 +68,13 @@ export default {
|
|||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
total: 0
|
total: 0
|
||||||
},
|
},
|
||||||
|
exFrom: {
|
||||||
|
id: '',
|
||||||
|
experimentId: '',
|
||||||
|
studentId: '',
|
||||||
|
filePath: '',
|
||||||
|
score: ''
|
||||||
|
},
|
||||||
size: '',
|
size: '',
|
||||||
userInfo: {
|
userInfo: {
|
||||||
userId: '',
|
userId: '',
|
||||||
@ -75,15 +94,38 @@ export default {
|
|||||||
this.userInfo.userId = window.sessionStorage.getItem("userId");
|
this.userInfo.userId = window.sessionStorage.getItem("userId");
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
upLoad() {
|
change(row) {
|
||||||
|
this.exFrom.experimentId = row.experimentId;
|
||||||
|
this.exFrom.studentId = row.studentId;
|
||||||
|
this.exFrom.filePath = row.filePath;
|
||||||
|
this.exFrom.score = row.score;
|
||||||
|
this.exFrom.id = row.recordId;
|
||||||
|
},
|
||||||
|
update() {
|
||||||
|
this.$http({
|
||||||
|
url: "/records",
|
||||||
|
method: 'put',
|
||||||
|
data: this.exFrom
|
||||||
|
}).then(({data}) => {
|
||||||
|
if (data.code !== 200) {
|
||||||
|
ElMessage({
|
||||||
|
message: '更新成功',
|
||||||
|
type: 'success',
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.getList()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
this.getList()
|
|
||||||
},
|
},
|
||||||
getList() {
|
getList() {
|
||||||
this.$http({
|
this.$http({
|
||||||
url: "/experiments/" + this.form.pageNum + "/" + this.form.pageSize,
|
url: "/getRecordST/" + this.form.pageNum + "/" + this.form.pageSize,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {}
|
data: {
|
||||||
|
studentId: this.userInfo.userId,
|
||||||
|
className: '',
|
||||||
|
}
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
if (data.code !== 200) {
|
if (data.code !== 200) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
@ -92,9 +134,63 @@ export default {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.itemList = data.list;
|
this.itemList = data.list;
|
||||||
|
this.form.total = data.total;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
download(fileName) {
|
||||||
|
this.$http({
|
||||||
|
url: '/download/' + fileName,
|
||||||
|
method: 'GET',
|
||||||
|
responseType: 'blob',
|
||||||
|
}).then((response) => {
|
||||||
|
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.setAttribute('download', fileName);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
}).catch((error) => {
|
||||||
|
if (error.response && error.response.status === 404) {
|
||||||
|
this.$message.error('文件不存在!');
|
||||||
|
} else {
|
||||||
|
// 对于其他错误,可以选择不同的处理方式
|
||||||
|
this.$message.error('下载文件时发生错误!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
fileChange(files, fileList) {
|
||||||
|
formData.append('file', files.raw)
|
||||||
|
files = null;
|
||||||
|
this.loading = true;
|
||||||
|
this.$http({
|
||||||
|
method: 'post',
|
||||||
|
url: '/upload',
|
||||||
|
data: formData,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data'
|
||||||
|
}
|
||||||
|
}).then(res => {
|
||||||
|
if (res.data.code === 200) {
|
||||||
|
this.$notify({
|
||||||
|
title: '上传成功',
|
||||||
|
message: res.data.msg,
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
this.exFrom.filePath = res.data.fileName;
|
||||||
|
this.update();
|
||||||
|
} else {
|
||||||
|
this.$notify({
|
||||||
|
title: '文件解析失败',
|
||||||
|
message: res.data.msg,
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
formData = null;
|
||||||
|
formData = new FormData();
|
||||||
|
this.loading = false;
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user