Commit 06c32eac authored by 耿迪迪's avatar 耿迪迪

员工管理、培训计划、培训课程

parent e2897c3f
......@@ -61,6 +61,12 @@
<artifactId>digital-management-generator</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.1.1</version>
</dependency>
</dependencies>
<build>
......
package com.zehong.web.controller.baseinfo;
import com.zehong.common.annotation.Log;
import com.zehong.common.constant.UserConstants;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.domain.entity.SysUser;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.baseinfo.TStaff;
import com.zehong.system.domain.form.TStaffForm;
import com.zehong.system.domain.vo.TStaffVo;
import com.zehong.system.domain.vo.UserCourseVo;
import com.zehong.system.service.ISysPostService;
import com.zehong.system.service.ISysRoleService;
import com.zehong.system.service.ISysUserService;
import com.zehong.system.service.baseinfo.ITStaffService;
import com.zehong.system.service.train.ITTrainCourseService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 员工信息管理Controller
*
* @author zehong
* @date 2022-06-17
*/
@RestController
@RequestMapping("/baseInfo/staff")
public class TStaffController extends BaseController
{
@Autowired
private ITStaffService tStaffService;
@Autowired
private ISysRoleService roleService;
@Autowired
private ISysPostService postService;
@Autowired
private ISysUserService userService;
@Autowired
private ITTrainCourseService tTrainCourseService;
/**
* 查询员工信息管理列表
*/
//@PreAuthorize("@ss.hasPermi('safetyManagement:staff:list')")
@GetMapping("/list")
public TableDataInfo list(TStaffForm tStaff)
{
startPage();
List<TStaffVo> list = tStaffService.selectTStaffList(tStaff);
return getDataTable(list);
}
@GetMapping("/allList")
public TableDataInfo allList(TStaffForm tStaff)
{
startPage();
List<TStaffVo> list = tStaffService.allList(tStaff);
return getDataTable(list);
}
/**
* 无分页查询
* @param tStaff
* @return
*/
@GetMapping("/TStaffList")
public TableDataInfo TStaffList(TStaffForm tStaff)
{
List<TStaffVo> list = tStaffService.selectTStaffList(tStaff);
return getDataTable(list);
}
/**
* 导出员工信息管理列表
*/
@Log(title = "员工信息管理", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TStaffForm tStaff)
{
List<TStaffVo> list = tStaffService.selectTStaffList(tStaff);
ExcelUtil<TStaffVo> util = new ExcelUtil<TStaffVo>(TStaffVo.class);
return util.exportExcel(list, "员工信息管理数据");
}
/**
* 获取员工信息管理详细信息
*/
@GetMapping(value = {"/", "/{staffId}"})
public AjaxResult getInfo(@PathVariable(value = "staffId", required = false) Long staffId)
{
AjaxResult ajax = AjaxResult.success();
ajax.put("roles", roleService.selectRoleAll());
ajax.put("posts", postService.selectPostAll());
ajax.put("data", tStaffService.selectTStaffById(staffId));
return ajax;
}
/**
* 新增员工信息管理
*/
@Log(title = "员工信息管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TStaff tStaff)
{
SysUser user=new SysUser();
user.setPhonenumber(tStaff.getPhonenumber());
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(tStaff.getUserName()))) {
return AjaxResult.error("新增用户'" + tStaff.getUserName() + "'失败,登录账号已存在");
} else if (StringUtils.isNotEmpty(tStaff.getPhonenumber())
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
return AjaxResult.error("新增用户'" + tStaff.getUserName() + "'失败,手机号码已存在");
}
//密码加密
tStaff.setPassword(SecurityUtils.encryptPassword(tStaff.getPassword()));
return toAjax(tStaffService.insertTStaff(tStaff));
}
/**
* 修改员工信息管理
*/
@Log(title = "员工信息管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TStaff tStaff)
{
return toAjax(tStaffService.updateTStaff(tStaff));
}
/**
* 删除员工信息管理
*/
@Log(title = "员工信息管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{staffIds}")
public AjaxResult remove(@PathVariable Long[] staffIds)
{
return toAjax(tStaffService.deleteTStaffByIds(staffIds));
}
@ApiOperation("用户课程列表")
@GetMapping("/userCourseList")
public TableDataInfo userCourseList(TStaffForm tStaff){
startPage();
List<UserCourseVo> list = tTrainCourseService.userCourseLists(tStaff);
return getDataTable(list);
}
}
......@@ -74,8 +74,8 @@ public class CommonController
// 上传文件路径
String filePath = DigitalManagementConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
String fileName = file.getOriginalFilename();
String url = serverConfig.getUrl() + FileUploadUtils.upload(filePath, file);
AjaxResult ajax = AjaxResult.success();
ajax.put("fileName", fileName);
ajax.put("url", url);
......
package com.zehong.web.controller.train;
import com.alibaba.fastjson.JSONObject;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.exception.CustomException;
import com.zehong.common.utils.StringUtils;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.train.TBankSubject;
import com.zehong.system.service.train.ITBankSubjectService;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 题目Controller
*
* @author zehong
* @date 2022-12-15
*/
@RestController
@RequestMapping("/train/subject")
public class TBankSubjectController extends BaseController
{
@Autowired
private ITBankSubjectService tBankSubjectService;
/**
* 查询题库题目列表
*/
//@PreAuthorize("@ss.hasPermi('system:subject:list')")
@GetMapping("/list")
public TableDataInfo list(TBankSubject tBankSubject)
{
startPage();
List<TBankSubject> list = tBankSubjectService.selectTBankSubjectList(tBankSubject);
return getDataTable(list);
}
/**
* 导出题库题目列表
*/
//@PreAuthorize("@ss.hasPermi('system:subject:export')")
@Log(title = "题库题目", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TBankSubject tBankSubject)
{
List<TBankSubject> list = tBankSubjectService.selectTBankSubjectList(tBankSubject);
ExcelUtil<TBankSubject> util = new ExcelUtil<TBankSubject>(TBankSubject.class);
return util.exportExcel(list, "题库题目数据");
}
/**
* 获取题库题目详细信息
*/
//@PreAuthorize("@ss.hasPermi('system:subject:query')")
@GetMapping(value = "/{subjectId}")
public AjaxResult getInfo(@PathVariable("subjectId") Long subjectId)
{
return AjaxResult.success(tBankSubjectService.selectTBankSubjectById(subjectId));
}
/**
* 新增题库题目
*/
//@PreAuthorize("@ss.hasPermi('system:subject:add')")
@Log(title = "题库题目", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TBankSubject tBankSubject)
{
return toAjax(tBankSubjectService.insertTBankSubject(tBankSubject));
}
/**
* 修改题库题目
*/
//@PreAuthorize("@ss.hasPermi('system:subject:edit')")
@Log(title = "题库题目", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TBankSubject tBankSubject)
{
return toAjax(tBankSubjectService.updateTBankSubject(tBankSubject));
}
/**
* 删除题库题目
*/
//@PreAuthorize("@ss.hasPermi('system:subject:remove')")
@Log(title = "题库题目", businessType = BusinessType.DELETE)
@DeleteMapping("/{subjectIds}")
public AjaxResult remove(@PathVariable Long[] subjectIds)
{
return toAjax(tBankSubjectService.deleteTBankSubjectByIds(subjectIds));
}
/**
* 导入题目信息管理列表
*/
@Log(title = "题库题目", businessType = BusinessType.IMPORT)
@PostMapping("/import")
public AjaxResult importDevice(MultipartFile file, boolean updateSupport, Long bankId) throws Exception
{
//装载流
XSSFWorkbook workbook = null;
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
try {
// workbook = new XSSFWorkbook(file.getInputStream());
//解析xls
workbook = new XSSFWorkbook(file.getInputStream());
}catch (IOException e) {
e.printStackTrace();
}
//最终添加数据 存储数组
List<TBankSubject> list = new ArrayList<>();
// 获取一个工作表,下标从0开始
XSSFSheet sheet = workbook.getSheetAt(0);
int lastRowNum = sheet.getLastRowNum();
// 通过循环,逐行取出表中每行数据
for(int i=0;i<=lastRowNum;i++){//跳过第一行和第二行
if(i<=1){
continue;
}
// 获取行
XSSFRow row = sheet.getRow(i);
TBankSubject excelEntity = new TBankSubject();
List jsonArray=new ArrayList();
try{
//判断题目 和答案不能为空
if (!StringUtils.isEmpty(row.getCell(0).toString())&&!StringUtils.isEmpty(row.getCell(9).toString())
&&!StringUtils.isEmpty(row.getCell(10).toString())){
successNum++;
/**题库id*/
excelEntity.setBankId(bankId);
/**题目*/
excelEntity.setTopicTitle(row.getCell(0).toString());
String s1= row.getCell(10).toString();
String s2 = StringUtils.substringBefore(s1, ".");
/**题目类型*/
excelEntity.setTopicType(Integer.valueOf(s2));
/**题目*/
for (int s=1;s<=8;s++){
JSONObject jsonObject=new JSONObject();
if (!StringUtils.isEmpty(row.getCell(s).toString())) {
jsonObject.put("value", row.getCell(s).toString());
jsonArray.add(jsonObject);
}
}
System.out.println(row.getCell(9).toString());
/**答案*/
excelEntity.setAnswer((row.getCell(9).toString()).replace(",",",") );
// if ("A".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(0);
// }else if ("B".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(1);
// }else if ("C".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(2);
// }else if ("D".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(3);
// }else if ("E".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(4);
// }else if ("F".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(5);
// }else if ("G".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(6);
// }else if ("H".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(7);
// }
excelEntity.setTopicOption(String.valueOf(jsonArray));
excelEntity.setDatetime(new Date());
list.add(excelEntity);
}
// else {
// failureNum++;
// String msg = "<br/>" + failureNum + "、题目 " + excelEntity.getTopicOption() + " 导入失败:";
// failureMsg.append(msg);
// }
}
catch (Exception e){
failureNum++;
String msg = "<br/>" + failureNum + "题目 " + excelEntity.getTopicOption() + " 导入失败:";
failureMsg.append(msg + e.getMessage());
}
}
if (failureNum > 0)
{
failureMsg.insert(0, "导入完成,共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new CustomException(failureMsg.toString());
}
else
{
successMsg.insert(0, "数据已全部导入成功!共 " + successNum + " 条");
}
if (list.size()!=0){
/**数据添加方法*/
tBankSubjectService.insertBank(list);
}
// String message = tBankSubjectService.importDevice(file, updateSupport);
return AjaxResult.success(successMsg.toString());
}
}
package com.zehong.web.controller.train;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.train.TTrainCourseBank;
import com.zehong.system.service.train.ITTrainCourseBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* bankController
* 题库管理
* @author zehong
* @date 2022-12-14
*/
@RestController
@RequestMapping("/train/bank")
public class TTrainCourseBankController extends BaseController
{
@Autowired
private ITTrainCourseBankService tTrainCourseBankService;
/**
* 查询题库列表
*/
//@PreAuthorize("@ss.hasPermi('system:bank:list')")
@GetMapping("/list")
public TableDataInfo list(TTrainCourseBank tTrainCourseBank)
{
startPage();
List<TTrainCourseBank> list = tTrainCourseBankService.selectTTrainCourseBankList(tTrainCourseBank);
return getDataTable(list);
}
/**
* 导出题库列表
*/
//@PreAuthorize("@ss.hasPermi('system:bank:export')")
@Log(title = "bank", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TTrainCourseBank tTrainCourseBank)
{
List<TTrainCourseBank> list = tTrainCourseBankService.selectTTrainCourseBankList(tTrainCourseBank);
ExcelUtil<TTrainCourseBank> util = new ExcelUtil<TTrainCourseBank>(TTrainCourseBank.class);
return util.exportExcel(list, "bank数据");
}
/**
* 获取bank详细信息
*/
//@PreAuthorize("@ss.hasPermi('system:bank:query')")
@GetMapping(value = "/{bankId}")
public AjaxResult getInfo(@PathVariable("bankId") Long bankId)
{
return AjaxResult.success(tTrainCourseBankService.selectTTrainCourseBankById(bankId));
}
/**
* 新增题库
*/
//@PreAuthorize("@ss.hasPermi('system:bank:add')")
@Log(title = "bank", businessType = BusinessType.INSERT)
@PostMapping
public int add(@RequestBody TTrainCourseBank tTrainCourseBank)
{
tTrainCourseBankService.insertTTrainCourseBank(tTrainCourseBank);
return Math.toIntExact(tTrainCourseBank.getBankId());
}
/**
* 修改bank
*/
//@PreAuthorize("@ss.hasPermi('system:bank:edit')")
@Log(title = "bank", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TTrainCourseBank tTrainCourseBank)
{
return toAjax(tTrainCourseBankService.updateTTrainCourseBank(tTrainCourseBank));
}
/**
* 删除bank
*/
//@PreAuthorize("@ss.hasPermi('system:bank:remove')")
@Log(title = "bank", businessType = BusinessType.DELETE)
@DeleteMapping("/{bankIds}")
public AjaxResult remove(@PathVariable Long[] bankIds)
{
return toAjax(tTrainCourseBankService.deleteTTrainCourseBankByIds(bankIds));
}
}
package com.zehong.web.controller.train;
import com.alibaba.fastjson.JSON;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.domain.entity.SysUser;
import com.zehong.common.core.domain.model.LoginUser;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.ServletUtils;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.framework.web.service.TokenService;
import com.zehong.system.domain.train.StatisticsTrainCourse;
import com.zehong.system.domain.train.TNews;
import com.zehong.system.domain.train.TTrainCourse;
import com.zehong.system.domain.train.TTrainUserCourse;
import com.zehong.system.domain.vo.UserCourseVo;
import com.zehong.system.service.train.ITTrainCourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 培训课程Controller
*
* @author zehong
* @date 2022-09-19
*/
@Api("课程管理")
@RestController
@RequestMapping("/train/course")
public class TTrainCourseController extends BaseController
{
@Autowired
private ITTrainCourseService tTrainCourseService;
@Autowired
private TokenService tokenService;
/**
* 查询培训课程列表
*/
@ApiOperation("课程列表")
@GetMapping("/list")
public TableDataInfo list(TTrainCourse tTrainCourse)
{
startPage();
tTrainCourse.setIsDel(0);
List<TTrainCourse> list = tTrainCourseService.selectTTrainCourseList(tTrainCourse);
return getDataTable(list);
}
@ApiOperation("用户课程列表")
@GetMapping("/userCourseList")
public TableDataInfo userCourseList(Integer type){
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
SysUser user = loginUser.getUser();
startPage();
List<UserCourseVo> list = tTrainCourseService.userCourseList(user.getUserId(),type);
return getDataTable(list);
}
@ApiOperation("用户课程考试")
@GetMapping("/examination")
public AjaxResult examination(Long userCourseId, String answers){
String n="["+answers+']';
//字符串转换成二维数组
Integer[][] integers = JSON.parseObject(n, Integer[][].class);
Map<String,Object> map = tTrainCourseService.examination(userCourseId,integers);
return AjaxResult.success(map);
}
/**
* 导出培训课程列表
*/
//@PreAuthorize("@ss.hasPermi('system:course:export')")
@Log(title = "培训课程", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TTrainCourse tTrainCourse)
{
List<TTrainCourse> list = tTrainCourseService.selectTTrainCourseList(tTrainCourse);
ExcelUtil<TTrainCourse> util = new ExcelUtil<TTrainCourse>(TTrainCourse.class);
return util.exportExcel(list, "培训课程数据");
}
/**
* 获取培训课程详细信息
*/
@ApiOperation("课程详情")
@GetMapping(value = "/{courseId}")
public AjaxResult getInfo(@PathVariable("courseId") Long courseId)
{
return AjaxResult.success(tTrainCourseService.selectTTrainCourseById(courseId));
}
/**
* 获取培训课程详细信息
*/
@ApiOperation("用户课程详情")
@GetMapping(value = "/userCourse")
public AjaxResult getUserCourse(Long userCourseId)
{
return AjaxResult.success(tTrainCourseService.getUserCourse(userCourseId));
}
/**
* 获取培训课程详细信息
*/
@ApiOperation("课程发布")
@GetMapping("/release")
public AjaxResult release(Long courseId)
{
return toAjax(tTrainCourseService.selectTTrainCourseRelease (courseId));
}
/**
* 新增培训课程
*/
@ApiOperation("新增课程")
@Log(title = "培训课程", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TTrainCourse tTrainCourse)
{
return AjaxResult.success(tTrainCourseService.insertTTrainCourse(tTrainCourse));
}
/**
* 修改培训课程
*/
@ApiOperation("修改课程")
@Log(title = "培训课程", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TTrainCourse tTrainCourse)
{
return toAjax(tTrainCourseService.updateTTrainCourse(tTrainCourse));
}
/**
* 修改用户课程
*/
@ApiOperation("修改用户课程")
@Log(title = "修改用户课程", businessType = BusinessType.UPDATE)
@PutMapping("/editUserCourse")
public AjaxResult editUserCourse(@RequestBody TTrainUserCourse tTrainUserCourse)
{
return toAjax(tTrainCourseService.updateTTrainUserCourse(tTrainUserCourse));
}
/**
* 删除培训课程
*/
@ApiOperation("删除课程")
@Log(title = "培训课程", businessType = BusinessType.DELETE)
@DeleteMapping("/{courseId}")
public AjaxResult remove(@PathVariable Long courseId)
{
TTrainCourse tTrainCourse = new TTrainCourse();
tTrainCourse.setCourseId(courseId);
tTrainCourse.setIsDel(1);
return toAjax(tTrainCourseService.updateTTrainCourse(tTrainCourse));
}
/**
* 考试发布
* @param tTrainCourse
* @return
*/
@PostMapping(value = "testPublish")
public AjaxResult testPublish(@RequestBody TTrainCourse tTrainCourse){
return toAjax(tTrainCourseService.testPublish(tTrainCourse));
}
/**
* 考试统计接口
* @param statisticsTrainCourse 统计实体
* @return TableDataInfo
*/
@GetMapping(value = "/statisticsTrainCourse")
public TableDataInfo statisticsTrainCourse(StatisticsTrainCourse statisticsTrainCourse){
startPage();
List<StatisticsTrainCourse> statisticsTrainCourses = tTrainCourseService.statisticsTrainCourse(statisticsTrainCourse);
return getDataTable(statisticsTrainCourses);
}
/**
* 根据考试查询人员考试详情
* @param courseId 考试id
* @return List<TTrainUserCourse>
*/
@GetMapping(value = "testPersonDetailByCourseId")
public TableDataInfo testPersonDetailByCourseId(@RequestParam(value = "courseId") Long courseId){
startPage();
List<TTrainUserCourse> persons = tTrainCourseService.testPersonDetailByCourseId(courseId);
return getDataTable(persons);
}
/**
* 导出所有考试详细数据项
*/
@Log(title = "设备信息管理", businessType = BusinessType.EXPORT)
@GetMapping("/examDetails")
public AjaxResult examDetails(@RequestParam(value = "courseId") Long courseId)
{
List<TTrainUserCourse> persons = tTrainCourseService.examDetails(courseId);
ExcelUtil<TTrainUserCourse> util = new ExcelUtil<TTrainUserCourse>(TTrainUserCourse.class);
return util.exportExcel(persons, "考试详细数据");
}
/**
* 手机端 最新消息查询
*/
@GetMapping("/latestNews")
public TNews latestNews(Long recipientId){
//最新消息查询
return tTrainCourseService.selectLatestNews(recipientId);
}
/**
* 手机端 查询历史消息
* @param recipientId
* @return
*/
@GetMapping("/historicalMessages")
public List<TNews> historicalMessages(Long recipientId){
return tTrainCourseService.historicalMessages(recipientId);
}
/**
* 修改消息状态为已读
*/
@GetMapping("/updateReadStatus")
public AjaxResult updateReadStatus(Long newsId){
return toAjax(tTrainCourseService.updateReadStatus(newsId));
}
}
package com.zehong.web.controller.train;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.train.TTrainCourseTopic;
import com.zehong.system.domain.vo.BatchTopicVo;
import com.zehong.system.service.train.ITTrainCourseTopicService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 培训课程题库Controller
*
* @author zehong
* @date 2022-09-19
*/
@Api("课程题库")
@RestController
@RequestMapping("/train/topic")
public class TTrainCourseTopicController extends BaseController
{
@Autowired
private ITTrainCourseTopicService tTrainCourseTopicService;
/**
* 查询培训课程题库列表
*/
@ApiOperation("课程题库列表")
@GetMapping("/list")
public TableDataInfo list(TTrainCourseTopic tTrainCourseTopic)
{
startPage();
List<TTrainCourseTopic> list = tTrainCourseTopicService.selectTTrainCourseTopicList(tTrainCourseTopic);
return getDataTable(list);
}
@ApiOperation("课程题库列表(没答案)")
@GetMapping("/topiclist")
public AjaxResult CourseTopicList(Long courseId)
{
List<TTrainCourseTopic> list = tTrainCourseTopicService.selectCourseTopicList(courseId);
return AjaxResult.success(list);
}
/**
* 导出培训课程题库列表
*/
@Log(title = "培训课程题库", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TTrainCourseTopic tTrainCourseTopic)
{
List<TTrainCourseTopic> list = tTrainCourseTopicService.selectTTrainCourseTopicList(tTrainCourseTopic);
ExcelUtil<TTrainCourseTopic> util = new ExcelUtil<TTrainCourseTopic>(TTrainCourseTopic.class);
return util.exportExcel(list, "培训课程题库数据");
}
/**
* 获取培训课程题库详细信息
*/
@ApiOperation("课程题详情")
@GetMapping(value = "/{topicId}")
public AjaxResult getInfo(@PathVariable("topicId") Long topicId)
{
return AjaxResult.success(tTrainCourseTopicService.selectTTrainCourseTopicById(topicId));
}
/**
* 新增培训课程题库
*/
@ApiOperation("添加课程题")
@Log(title = "培训课程题库", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TTrainCourseTopic tTrainCourseTopic)
{
if(tTrainCourseTopic.getCourseId()==null||tTrainCourseTopic.getCourseId().equals("")){
return AjaxResult.error("课程id不可为空");
}
return toAjax(tTrainCourseTopicService.insertTTrainCourseTopic(tTrainCourseTopic));
}
/**
* 修改培训课程题库
*/
@ApiOperation("修改课程题")
@Log(title = "培训课程题库", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TTrainCourseTopic tTrainCourseTopic)
{
return toAjax(tTrainCourseTopicService.updateTTrainCourseTopic(tTrainCourseTopic));
}
/**
* 删除培训课程题库
*/
// @Log(title = "培训课程题库", businessType = BusinessType.DELETE)
// @DeleteMapping("/{topicIds}")
// public AjaxResult remove(@PathVariable Long[] topicIds)
// {
// return toAjax(tTrainCourseTopicService.deleteTTrainCourseTopicByIds(topicIds));
// }
/**
* 删除培训课程题库
*/
@ApiOperation("删除课程题")
@Log(title = "培训课程题库", businessType = BusinessType.DELETE)
@DeleteMapping("/{topicId}")
public AjaxResult deleteTopic(@PathVariable Long topicId)
{
return toAjax(tTrainCourseTopicService.deleteTTrainCourseTopicById(topicId));
}
/**
* 题库批量导入试题
* @param batchTopicVo 试题实体
* @return AjaxResult
*/
@PostMapping("/bachAddTopic")
public AjaxResult bachAddTopic(@RequestBody BatchTopicVo batchTopicVo){
return toAjax(tTrainCourseTopicService.bachAddTopic(batchTopicVo));
}
/**
* 培训课程管理批量导入试题
*/
@PostMapping("/addTTrainCourseTopic")
public AjaxResult addTTrainCourseTopic(@RequestBody BatchTopicVo batchTopicVo){
return toAjax(tTrainCourseTopicService.addTTrainCourseTopic(batchTopicVo));
}
}
package com.zehong.web.controller.train;
import com.alibaba.fastjson.JSON;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.train.TTrainPlan;
import com.zehong.system.domain.vo.PlanVo;
import com.zehong.system.service.train.ITTrainPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 培训计划Controller
*
* @author zehong
* @date 2022-09-17
*/
@Api("培训计划")
@RestController
@RequestMapping("/train/plan")
public class TTrainPlanController extends BaseController
{
@Autowired
private ITTrainPlanService tTrainPlanService;
/**
* 查询培训计划列表
*/
@ApiOperation("培训计划列表")
@GetMapping("/list")
public AjaxResult list()
{
List<TTrainPlan> list = tTrainPlanService.selectTTrainPlanList(new TTrainPlan());
return AjaxResult.success(list);
}
@ApiOperation("培训计划下拉列表")
@GetMapping("/downList")
public AjaxResult downList()
{
List<TTrainPlan> list = tTrainPlanService.selectTTrainPlanDownList();
return AjaxResult.success(list);
}
/**
* 导出培训计划列表
*/
@Log(title = "培训计划", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TTrainPlan tTrainPlan)
{
List<TTrainPlan> list = tTrainPlanService.selectTTrainPlanList(tTrainPlan);
ExcelUtil<TTrainPlan> util = new ExcelUtil<TTrainPlan>(TTrainPlan.class);
return util.exportExcel(list, "培训计划数据");
}
/**
* 获取培训计划详细信息
*/
@GetMapping(value = "/{planId}")
public AjaxResult getInfo(@PathVariable("planId") Long planId)
{
return AjaxResult.success(tTrainPlanService.selectTTrainPlanById(planId));
}
/**
* 新增培训计划
*/
@ApiOperation("新增培训计划")
@Log(title = "培训计划", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody PlanVo planVo)
{
TTrainPlan tTrainPlan = new TTrainPlan();
tTrainPlan.setPlanName(planVo.getPlanName());
tTrainPlan.setPersonnelType(planVo.getPersonnelType());
List<Map<String,Object>> list = (List<Map<String,Object>>) JSON.parse(planVo.getPeopleList());
return AjaxResult.success(tTrainPlanService.insertTTrainPlan(tTrainPlan,list));
}
/**
* 修改培训计划
*/
@ApiOperation("编辑培训计划")
@Log(title = "培训计划", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody PlanVo planVo)
{
if(planVo.getPlanId()==null){
return AjaxResult.error("计划id不可为空");
}
TTrainPlan tTrainPlan = new TTrainPlan();
tTrainPlan.setPlanId(planVo.getPlanId());
tTrainPlan.setPlanName(planVo.getPlanName());
tTrainPlan.setPersonnelType(planVo.getPersonnelType());
List<Map<String,Object>> list = (List<Map<String,Object>>) JSON.parse(planVo.getPeopleList());
return toAjax(tTrainPlanService.updateTTrainPlan(tTrainPlan,list));
}
/**
* 删除培训计划
*/
@Log(title = "培训计划", businessType = BusinessType.DELETE)
@DeleteMapping("/{planIds}")
public AjaxResult remove(@PathVariable Long[] planIds)
{
return toAjax(tTrainPlanService.deleteTTrainPlanByIds(planIds));
}
/**
* 删除培训计划
* @param planId
* @return
*/
@ApiOperation("删除培训计划")
@Log(title = "培训计划", businessType = BusinessType.DELETE)
@DeleteMapping("/deleteOne")
public AjaxResult deletePlan(Long planId)
{
return toAjax(tTrainPlanService.deleteTTrainPlanById(planId));
}
}
......@@ -6,9 +6,9 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/digitalManagement?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: root@123
url: jdbc:mysql://36.138.180.82:3309/hebeidakong?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: hebeidakong
password: x7m3j5Smi2D7ncsR
# 从库数据源
slave:
# 从数据源开关/默认关闭
......
......@@ -119,6 +119,12 @@
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.12</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -23,6 +23,18 @@
<artifactId>digital-management-common</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel-core</artifactId>
<version>3.1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.zehong.system.domain.baseinfo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
import java.util.Arrays;
import java.util.Date;
/**
* 员工信息管理对象 t_staff
*
* @author zehong
* @date 2022-06-17
*/
public class TStaff extends BaseEntity
{
private static final long serialVersionUID = 1L;
/**系统用户id*/
private Integer userId;
/** 员工id */
private Integer staffId;
/**用户账号*/
private String userName;
/**用户密码*/
private String password;
/** 姓名 */
@Excel(name = "姓名")
private String staffName;
/** 员工编号 */
@Excel(name = "员工编号")
private String staffCode;
/** 性别 */
@Excel(name = "性别")
private String sex;
/** 部门id */
@Excel(name = "部门id")
private Integer deptId;
/** 手机号码 */
@Excel(name = "手机号码")
private String phonenumber;
/** 岗位id */
@Excel(name = "岗位id")
private Integer postId;
/** 角色组 */
private Long[] roleIds;
/** 角色id */
@Excel(name = "角色id")
private Integer roleId;
/** 职称 */
@Excel(name = "职称")
private String positionalTitles;
/** 工种 */
@Excel(name = "工种")
private String profession;
/** 是否特殊作业人员 */
@Excel(name = "是否特殊作业人员")
private String specialOperators;
/** 证书路径 */
@Excel(name = "证书路径")
private String certificateUrl;
/** 证书名称 */
@Excel(name = "证书名称")
private String certificateName;
/** 证书有效日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "证书有效日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date effectiveDate;
/** 删除标志(0正常,1删除) */
@Excel(name = "删除标志", readConverterExp = "0=正常,1删除")
private String isDel;
public Long[] getRoleIds() {
return roleIds;
}
public void setRoleIds(Long[] roleIds) {
this.roleIds = roleIds;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public void setStaffId(Integer staffId) {
this.staffId = staffId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void setStaffId(int staffId)
{
this.staffId = staffId;
}
public int getStaffId()
{
return staffId;
}
public void setStaffName(String staffName)
{
this.staffName = staffName;
}
public String getStaffName()
{
return staffName;
}
public void setStaffCode(String staffCode)
{
this.staffCode = staffCode;
}
public String getStaffCode()
{
return staffCode;
}
public void setSex(String sex)
{
this.sex = sex;
}
public String getSex()
{
return sex;
}
public void setDeptId(Integer deptId)
{
this.deptId = deptId;
}
public Integer getDeptId()
{
return deptId;
}
public void setPhonenumber(String phonenumber)
{
this.phonenumber = phonenumber;
}
public String getPhonenumber()
{
return phonenumber;
}
public void setPostId(Integer postId)
{
this.postId = postId;
}
public Integer getPostId()
{
return postId;
}
public void setRoleId(Integer roleId)
{
this.roleId = roleId;
}
public Integer getRoleId()
{
return roleId;
}
public void setPositionalTitles(String positionalTitles)
{
this.positionalTitles = positionalTitles;
}
public String getPositionalTitles()
{
return positionalTitles;
}
public void setProfession(String profession)
{
this.profession = profession;
}
public String getProfession()
{
return profession;
}
public void setSpecialOperators(String specialOperators)
{
this.specialOperators = specialOperators;
}
public String getSpecialOperators()
{
return specialOperators;
}
public void setCertificateUrl(String certificateUrl)
{
this.certificateUrl = certificateUrl;
}
public String getCertificateUrl()
{
return certificateUrl;
}
public void setCertificateName(String certificateName)
{
this.certificateName = certificateName;
}
public String getCertificateName()
{
return certificateName;
}
public void setEffectiveDate(Date effectiveDate)
{
this.effectiveDate = effectiveDate;
}
public Date getEffectiveDate()
{
return effectiveDate;
}
public void setIsDel(String isDel)
{
this.isDel = isDel;
}
public String getIsDel()
{
return isDel;
}
@Override
public String toString() {
return "TStaff{" +
"userId=" + userId +
", staffId=" + staffId +
", userName='" + userName + '\'' +
", password='" + password + '\'' +
", staffName='" + staffName + '\'' +
", staffCode='" + staffCode + '\'' +
", sex='" + sex + '\'' +
", deptId=" + deptId +
", phonenumber='" + phonenumber + '\'' +
", postId=" + postId +
", roleIds=" + Arrays.toString(roleIds) +
", roleId=" + roleId +
", positionalTitles='" + positionalTitles + '\'' +
", profession='" + profession + '\'' +
", specialOperators='" + specialOperators + '\'' +
", certificateUrl='" + certificateUrl + '\'' +
", certificateName='" + certificateName + '\'' +
", effectiveDate=" + effectiveDate +
", isDel='" + isDel + '\'' +
'}';
}
}
package com.zehong.system.domain.form;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
/**
* 员工信息管理对象 t_staff
*
* @author zehong
* @date 2022-06-17
*/
public class TStaffForm extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 姓名 */
@Excel(name = "姓名")
private String staffName;
/** 员工编号 */
@Excel(name = "员工编号")
private String staffCode;
/** 性别 */
@Excel(name = "性别")
private String sex;
/** 部门id */
@Excel(name = "部门id")
private Integer deptId;
/** 手机号码 */
@Excel(name = "手机号码")
private String phonenumber;
private Long userId;
private Long staffId;
private int dataKind;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public int getDataKind() {
return dataKind;
}
public void setDataKind(int dataKind) {
this.dataKind = dataKind;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public Long getStaffId() {
return staffId;
}
public void setStaffId(Long staffId) {
this.staffId = staffId;
}
public void setStaffName(String staffName)
{
this.staffName = staffName;
}
public String getStaffName()
{
return staffName;
}
public void setStaffCode(String staffCode)
{
this.staffCode = staffCode;
}
public String getStaffCode()
{
return staffCode;
}
public void setSex(String sex)
{
this.sex = sex;
}
public String getSex()
{
return sex;
}
public Integer getDeptId() {
return deptId;
}
public void setDeptId(Integer deptId) {
this.deptId = deptId;
}
public void setPhonenumber(String phonenumber)
{
this.phonenumber = phonenumber;
}
public String getPhonenumber()
{
return phonenumber;
}
@Override
public String toString() {
return "TStaffForm{" +
"staffName='" + staffName + '\'' +
", staffCode='" + staffCode + '\'' +
", sex='" + sex + '\'' +
", deptId=" + deptId +
", phonenumber='" + phonenumber + '\'' +
", userId=" + userId +
", staffId=" + staffId +
", dataKind=" + dataKind +
'}';
}
}
package com.zehong.system.domain.train;
public class StatisticsTrainCourse {
/**
* 课程id
*/
private Long courseId;
/**
* 课程名称
*/
private String courseName;
/**
* 发布时间
*/
private String releaseTime;
/**
* 考试类型
*/
private String dataKind;
/**
* 应考人数
*/
private String count;
/**
* 参考人数
*/
private String test;
/**
* 通过人数
*/
private String pass;
/**
* 通过率
*/
private String rate;
/**
* 发布开始时间
*/
private String releaseTimeBegin;
/**
* 发布结束时间
*/
private String releaseTimeEnd;
public Long getCourseId() {
return courseId;
}
public void setCourseId(Long courseId) {
this.courseId = courseId;
}
public String getCourseName() {
return courseName;
}
public void setCourseName(String courseName) {
this.courseName = courseName;
}
public String getReleaseTime() {
return releaseTime;
}
public void setReleaseTime(String releaseTime) {
this.releaseTime = releaseTime;
}
public String getDataKind() {
return dataKind;
}
public void setDataKind(String dataKind) {
this.dataKind = dataKind;
}
public String getCount() {
return count;
}
public void setCount(String count) {
this.count = count;
}
public String getTest() {
return test;
}
public void setTest(String test) {
this.test = test;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
public String getRate() {
return rate;
}
public void setRate(String rate) {
this.rate = rate;
}
public String getReleaseTimeBegin() {
return releaseTimeBegin;
}
public void setReleaseTimeBegin(String releaseTimeBegin) {
this.releaseTimeBegin = releaseTimeBegin;
}
public String getReleaseTimeEnd() {
return releaseTimeEnd;
}
public void setReleaseTimeEnd(String releaseTimeEnd) {
this.releaseTimeEnd = releaseTimeEnd;
}
}
package com.zehong.system.domain.train;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
/**
* 题库题目对象 t_bank_subject
*
* @author zehong
* @date 2022-12-15
*/
public class TBankSubject extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 题目id */
private Long subjectId;
/** 所属题库id */
@Excel(name = "所属题库id")
private Long bankId;
/** 题目内容 */
@ExcelProperty(value = "题干(必填)")
private String topicTitle;
/** 题目选项(json) */
@Excel(name = "题目选项", readConverterExp = "j=son")
private String topicOption;
/** 答案 */
@Excel(name = "正确答案(必填)")
private String answer;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date datetime;
/** 题目类型 1单选 2多选 3判断 */
private Integer topicType;
public Integer getTopicType() {
return topicType;
}
public void setTopicType(Integer topicType) {
this.topicType = topicType;
}
public void setSubjectId(Long subjectId)
{
this.subjectId = subjectId;
}
public Long getSubjectId()
{
return subjectId;
}
public void setBankId(Long bankId)
{
this.bankId = bankId;
}
public Long getBankId()
{
return bankId;
}
public void setTopicTitle(String topicTitle)
{
this.topicTitle = topicTitle;
}
public String getTopicTitle()
{
return topicTitle;
}
public void setTopicOption(String topicOption)
{
this.topicOption = topicOption;
}
public String getTopicOption()
{
return topicOption;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
public void setDatetime(Date datetime)
{
this.datetime = datetime;
}
public Date getDatetime()
{
return datetime;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("subjectId", getSubjectId())
.append("bankId", getBankId())
.append("topicTitle", getTopicTitle())
.append("topicOption", getTopicOption())
.append("answer", getAnswer())
.append("datetime", getDatetime())
.toString();
}
}
package com.zehong.system.domain.train;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
* 手机端消息封装类
*/
public class TNews {
private Integer newsId;
/**
* 所属模块 0培训课程 1试卷考试 2隐患台账
*/
private Integer module;
/**
* 消息内容
*/
private String messageContent;
/**
* 发布人id
*/
private Long publisherId;
/**
* 接收人id
*/
private Integer recipientId;
/**
* 发布时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
private Date releaseTime;
/**
* 读取状态 0未读取 1读取
*/
private Integer readStatus;
private Long moduleId;
public Long getModuleId() {
return moduleId;
}
public void setModuleId(Long moduleId) {
this.moduleId = moduleId;
}
public Integer getNewsId() {
return newsId;
}
public void setNewsId(Integer newsId) {
this.newsId = newsId;
}
public Integer getModule() {
return module;
}
public void setModule(Integer module) {
this.module = module;
}
public String getMessageContent() {
return messageContent;
}
public void setMessageContent(String messageContent) {
this.messageContent = messageContent;
}
public Long getPublisherId() {
return publisherId;
}
public void setPublisherId(Long publisherId) {
this.publisherId = publisherId;
}
public Integer getRecipientId() {
return recipientId;
}
public void setRecipientId(Integer recipientId) {
this.recipientId = recipientId;
}
public Date getReleaseTime() {
return releaseTime;
}
public void setReleaseTime(Date releaseTime) {
this.releaseTime = releaseTime;
}
public Integer getReadStatus() {
return readStatus;
}
public void setReadStatus(Integer readStatus) {
this.readStatus = readStatus;
}
@Override
public String toString() {
return "TNews{" +
"newsId=" + newsId +
", module=" + module +
", messageContent='" + messageContent + '\'' +
", publisherId=" + publisherId +
", recipientId=" + recipientId +
", releaseTime=" + releaseTime +
", readStatus=" + readStatus +
'}';
}
}
package com.zehong.system.domain.train;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
/**
* 培训课程对象 t_train_course
*
* @author zehong
* @date 2022-09-19
*/
public class TTrainCourse extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 课程id */
private Long courseId;
/** 课程名称 */
@Excel(name = "课程名称")
private String courseName;
/** 课程类型(培训计划) */
@Excel(name = "课程类型", readConverterExp = "培=训计划")
private Long courseType;
private String planName;
/** 课程内容 */
@Excel(name = "课程内容")
private String courseConent;
/** 0未发布 1已发布 */
@Excel(name = "0未发布 1已发布")
private Integer status;
/** 发布时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "发布时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date releaseTime;
/** 课程附件 */
@Excel(name = "课程附件")
private String enclosure;
/** 课程视频 */
@Excel(name = "课程视频")
private String video;
/** 答题合格分数*/
@Excel(name = "答题合格分数")
private Integer qualifiedNum;
/** 录入题数量 */
@Excel(name = "录入题数量")
private Integer topicNum;
/** 创建人 */
@Excel(name = "创建人")
private String createUser;
/** 0未删除 1已删除 */
@Excel(name = "0未删除 1已删除")
private Integer isDel;
/** 数据类型:0 培训,1 考试 */
@Excel(name = "数据类型:0 培训,1 考试")
private String dataKind;
/** 考试开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "考试开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date testStartTime;
/** 考试结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "考试结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date testEndTime;
/** 考试人员 */
@Excel(name = "考试人员")
private String testPersons;
/**
* 2023-10-09添加培训部门、主讲人
*/
/** 考试人员 */
@Excel(name = "培训部门id")
private String deptId;
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
@Excel(name = "培训部门名称")
private String deptName;
public String getDeptId() {
return deptId;
}
public void setDeptId(String deptId) {
this.deptId = deptId;
}
public String getZhujiang() {
return zhujiang;
}
public void setZhujiang(String zhujiang) {
this.zhujiang = zhujiang;
}
/** 考试人员 */
@Excel(name = "主讲人")
private String zhujiang;
private Integer personnelType;
private Integer duration;
/** 多选题分数*/
private Integer multipleChoiceScore;
/**单选题分数*/
private Integer singleChoiceScore;
/**判断题分数*/
private Integer judgmentScore;
/** 是否人脸认证:1是 2否 */
private String isVeriftyFace;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public Integer getMultipleChoiceScore() {
return multipleChoiceScore;
}
public void setMultipleChoiceScore(Integer multipleChoiceScore) {
this.multipleChoiceScore = multipleChoiceScore;
}
public Integer getSingleChoiceScore() {
return singleChoiceScore;
}
public void setSingleChoiceScore(Integer singleChoiceScore) {
this.singleChoiceScore = singleChoiceScore;
}
public Integer getJudgmentScore() {
return judgmentScore;
}
public void setJudgmentScore(Integer judgmentScore) {
this.judgmentScore = judgmentScore;
}
public Integer getDuration() {
return duration;
}
public void setDuration(Integer duration) {
this.duration = duration;
}
public String getPlanName() {
return planName;
}
public void setPlanName(String planName) {
this.planName = planName;
}
public Integer getPersonnelType() {
return personnelType;
}
public void setPersonnelType(Integer personnelType) {
this.personnelType = personnelType;
}
public void setCourseId(Long courseId)
{
this.courseId = courseId;
}
public Long getCourseId()
{
return courseId;
}
public void setCourseName(String courseName)
{
this.courseName = courseName;
}
public String getCourseName()
{
return courseName;
}
public void setCourseType(Long courseType)
{
this.courseType = courseType;
}
public Long getCourseType()
{
return courseType;
}
public void setCourseConent(String courseConent)
{
this.courseConent = courseConent;
}
public String getCourseConent()
{
return courseConent;
}
public void setStatus(Integer status)
{
this.status = status;
}
public Integer getStatus()
{
return status;
}
public void setReleaseTime(Date releaseTime)
{
this.releaseTime = releaseTime;
}
public Date getReleaseTime()
{
return releaseTime;
}
public void setEnclosure(String enclosure)
{
this.enclosure = enclosure;
}
public String getEnclosure()
{
return enclosure;
}
public void setVideo(String video)
{
this.video = video;
}
public String getVideo()
{
return video;
}
public void setQualifiedNum(Integer qualifiedNum)
{
this.qualifiedNum = qualifiedNum;
}
public Integer getQualifiedNum()
{
return qualifiedNum;
}
public void setTopicNum(Integer topicNum)
{
this.topicNum = topicNum;
}
public Integer getTopicNum()
{
return topicNum;
}
public void setCreateUser(String createUser)
{
this.createUser = createUser;
}
public String getCreateUser()
{
return createUser;
}
public void setIsDel(Integer isDel)
{
this.isDel = isDel;
}
public Integer getIsDel()
{
return isDel;
}
public void setDataKind(String dataKind)
{
this.dataKind = dataKind;
}
public String getDataKind()
{
return dataKind;
}
public void setTestStartTime(Date testStartTime)
{
this.testStartTime = testStartTime;
}
public Date getTestStartTime()
{
return testStartTime;
}
public void setTestEndTime(Date testEndTime)
{
this.testEndTime = testEndTime;
}
public Date getTestEndTime()
{
return testEndTime;
}
public void setTestPersons(String testPersons)
{
this.testPersons = testPersons;
}
public String getTestPersons()
{
return testPersons;
}
public String getIsVeriftyFace() {
return isVeriftyFace;
}
public void setIsVerfityFace(String isVeriftyFace) {
this.isVeriftyFace = isVeriftyFace;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("courseId", getCourseId())
.append("courseName", getCourseName())
.append("courseType", getCourseType())
.append("courseConent", getCourseConent())
.append("status", getStatus())
.append("releaseTime", getReleaseTime())
.append("enclosure", getEnclosure())
.append("video", getVideo())
.append("qualifiedNum", getQualifiedNum())
.append("topicNum", getTopicNum())
.append("createTime", getCreateTime())
.append("createUser", getCreateUser())
.append("isDel", getIsDel())
.append("dataKind", getDataKind())
.append("testStartTime", getTestStartTime())
.append("testEndTime", getTestEndTime())
.append("testPersons", getTestPersons())
.toString();
}
}
package com.zehong.system.domain.train;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
/**
* bank对象 t_train_course_bank
*
* @author zehong
* @date 2022-12-14
*/
public class TTrainCourseBank extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键id */
private Long bankId;
/** 所属部门 */
private Long deptId;
/** 题库名称 */
@Excel(name = "题库名称")
private String bankName;
/**下级题目数量*/
private String numberQuestions;
/** 是否删除 0未删除 1删除 */
private Integer isDel;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getNumberQuestions() {
return numberQuestions;
}
public void setNumberQuestions(String numberQuestions) {
this.numberQuestions = numberQuestions;
}
public void setBankId(Long bankId)
{
this.bankId = bankId;
}
public Long getBankId()
{
return bankId;
}
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
public Long getDeptId()
{
return deptId;
}
public void setBankName(String bankName)
{
this.bankName = bankName;
}
public String getBankName()
{
return bankName;
}
public void setIsDel(Integer isDel)
{
this.isDel = isDel;
}
public Integer getIsDel()
{
return isDel;
}
@Override
public String toString() {
return "TTrainCourseBank{" +
"bankId=" + bankId +
", deptId=" + deptId +
", bankName='" + bankName + '\'' +
", numberQuestions='" + numberQuestions + '\'' +
", isDel=" + isDel +
'}';
}
}
package com.zehong.system.domain.train;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 培训课程题库对象 t_train_course_topic
*
* @author zehong
* @date 2022-09-19
*/
public class TTrainCourseTopic extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 题目id */
private Long topicId;
/** 所属课程id */
@Excel(name = "所属课程id")
private Long courseId;
/** 题目内容 */
@Excel(name = "题目内容")
private String topicTitle;
/** 题目选项(json) */
@Excel(name = "题目选项", readConverterExp = "j=son")
private String topicOption;
/** 答案 */
// @Excel(name = "答案")
// private Integer answer;
/** 答案 */
@Excel(name = "答案")
private String answer;
/** 题目类型 1单选 2多选 3判断 */
private Integer topicType;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public Integer getTopicType() {
return topicType;
}
public void setTopicType(Integer topicType) {
this.topicType = topicType;
}
public void setTopicId(Long topicId)
{
this.topicId = topicId;
}
public Long getTopicId()
{
return topicId;
}
public void setCourseId(Long courseId)
{
this.courseId = courseId;
}
public Long getCourseId()
{
return courseId;
}
public void setTopicTitle(String topicTitle)
{
this.topicTitle = topicTitle;
}
public String getTopicTitle()
{
return topicTitle;
}
public void setTopicOption(String topicOption)
{
this.topicOption = topicOption;
}
public String getTopicOption()
{
return topicOption;
}
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("topicId", getTopicId())
.append("courseId", getCourseId())
.append("topicTitle", getTopicTitle())
.append("topicOption", getTopicOption())
.append("answer", getAnswer())
.append("createTime", getCreateTime())
.toString();
}
}
package com.zehong.system.domain.train;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
import com.zehong.system.domain.vo.PlanPostVo;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.List;
/**
* 培训计划对象 t_train_plan
*
* @author zehong
* @date 2022-09-17
*/
public class TTrainPlan extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long planId;
/** 计划名称 */
@Excel(name = "计划名称")
private String planName;
private Integer personnelType;
/** 排序 */
@Excel(name = "排序")
private Integer sort;
/** 创建人 */
@Excel(name = "创建人")
private String createUser;
private List<PlanPostVo> postList;
public Integer getPersonnelType() {
return personnelType;
}
public void setPersonnelType(Integer personnelType) {
this.personnelType = personnelType;
}
public List<PlanPostVo> getPostList() {
return postList;
}
public void setPostList(List<PlanPostVo> postList) {
this.postList = postList;
}
public void setPlanId(Long planId)
{
this.planId = planId;
}
public Long getPlanId()
{
return planId;
}
public void setPlanName(String planName)
{
this.planName = planName;
}
public String getPlanName()
{
return planName;
}
public void setSort(Integer sort)
{
this.sort = sort;
}
public Integer getSort()
{
return sort;
}
public void setCreateUser(String createUser)
{
this.createUser = createUser;
}
public String getCreateUser()
{
return createUser;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("planId", getPlanId())
.append("planName", getPlanName())
.append("sort", getSort())
.append("createTime", getCreateTime())
.append("createUser", getCreateUser())
.toString();
}
}
package com.zehong.system.domain.train;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
import java.util.Date;
/**
* 用户课程对象 t_train_user_course
*
* @author zehong
* @date 2022-09-19
*/
public class TTrainUserCourse extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 用户课程id */
private Long userCourseId;
/** 用户id */
private Long userId;
/** 课程id */
private Long courseId;
/**人员名称**/
@Excel(name = "考试人员")
private String staffName;
/** 创建人 */
private String createUser;
/**人员部门**/
@Excel(name = "所属部门")
private String deptName;
/** 最后一次考试时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "考试时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date examinationTime;
/** 最后一次考试结果(答对数量) */
@Excel(name = "得分")
private Integer examinationResult;
/** 0未学习 1未通过 2已通过 */
private Integer state;
/** 0未学习 1未通过 2已通过 */
@Excel(name = "考试结果")
private String states;
private Integer personnelType;
private Integer finishDuration;
private Integer trainState;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getStates() {
return states;
}
public void setStates(String states) {
this.states = states;
}
public Integer getFinishDuration() {
return finishDuration;
}
public void setFinishDuration(Integer finishDuration) {
this.finishDuration = finishDuration;
}
public Integer getTrainState() {
return trainState;
}
public void setTrainState(Integer trainState) {
this.trainState = trainState;
}
public Integer getPersonnelType() {
return personnelType;
}
public void setPersonnelType(Integer personnelType) {
this.personnelType = personnelType;
}
public void setUserCourseId(Long userCourseId)
{
this.userCourseId = userCourseId;
}
public Long getUserCourseId()
{
return userCourseId;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getUserId()
{
return userId;
}
public void setCourseId(Long courseId)
{
this.courseId = courseId;
}
public Long getCourseId()
{
return courseId;
}
public void setState(Integer state)
{
this.state = state;
}
public Integer getState()
{
return state;
}
public void setExaminationTime(Date examinationTime)
{
this.examinationTime = examinationTime;
}
public Date getExaminationTime()
{
return examinationTime;
}
public void setExaminationResult(Integer examinationResult)
{
this.examinationResult = examinationResult;
}
public Integer getExaminationResult()
{
return examinationResult;
}
public void setCreateUser(String createUser)
{
this.createUser = createUser;
}
public String getCreateUser()
{
return createUser;
}
public String getStaffName() {
return staffName;
}
public void setStaffName(String staffName) {
this.staffName = staffName;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
@Override
public String toString() {
return "TTrainUserCourse{" +
"userCourseId=" + userCourseId +
", userId=" + userId +
", courseId=" + courseId +
", staffName='" + staffName + '\'' +
", createUser='" + createUser + '\'' +
", deptName='" + deptName + '\'' +
", examinationTime=" + examinationTime +
", examinationResult=" + examinationResult +
", state=" + state +
", states='" + states + '\'' +
", personnelType=" + personnelType +
", finishDuration=" + finishDuration +
", trainState=" + trainState +
'}';
}
}
package com.zehong.system.domain.vo;
import java.util.List;
/**
* @author geng
* 批量导入试题
*/
public class BatchTopicVo {
/**
* 所属考试id
*/
private Long courseId;
private List<TopicInfos> topicInfos;
public Long getCourseId() {
return courseId;
}
public void setCourseId(Long courseId) {
this.courseId = courseId;
}
public List<TopicInfos> getTopicInfos() {
return topicInfos;
}
public void setTopicInfos(List<TopicInfos> topicInfos) {
this.topicInfos = topicInfos;
}
/**
* @author geng
* 题库批量导入试题实体
*/
public static class TopicInfos{
/**
* 题库id
*/
private Long bankId;
/**
* 随机抽取题数量
*/
private int quan;
public Long getBankId() {
return bankId;
}
public void setBankId(Long bankId) {
this.bankId = bankId;
}
public int getQuan() {
return quan;
}
public void setQuan(int quan) {
this.quan = quan;
}
}
}
package com.zehong.system.domain.vo;
public class PlanPostVo {
private Long postId;
private String postName;
private boolean ischeck;
public Long getPostId() {
return postId;
}
public void setPostId(Long postId) {
this.postId = postId;
}
public String getPostName() {
return postName;
}
public void setPostName(String postName) {
this.postName = postName;
}
public boolean isIscheck() {
return ischeck;
}
public void setIscheck(boolean ischeck) {
this.ischeck = ischeck;
}
}
package com.zehong.system.domain.vo;
public class PlanVo {
private Long planId;
private String planName;
private Integer personnelType;
private Long[] postIds;
private String peopleList;
public Long getPlanId() {
return planId;
}
public void setPlanId(Long planId) {
this.planId = planId;
}
public String getPlanName() {
return planName;
}
public void setPlanName(String planName) {
this.planName = planName;
}
public Integer getPersonnelType() {
return personnelType;
}
public void setPersonnelType(Integer personnelType) {
this.personnelType = personnelType;
}
public Long[] getPostIds() {
return postIds;
}
public void setPostIds(Long[] postIds) {
this.postIds = postIds;
}
public String getPeopleList() {
return peopleList;
}
public void setPeopleList(String peopleList) {
this.peopleList = peopleList;
}
}
package com.zehong.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zehong.common.core.domain.BaseEntity;
import java.util.Date;
/**
* 员工信息管理对象 t_staff
*
* @author zehong
* @date 2022-06-17
*/
public class TStaffVo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 员工id */
private Integer staffId;
/** 姓名 */
private String staffName;
/** 员工编号 */
private String staffCode;
/** 性别 */
private String sex;
/** 部门id */
private Integer deptId;
private String deptName;
/** 手机号码 */
private String phonenumber;
/** 岗位id */
private Integer postId;
private String postName;
/** 角色id */
private Integer roleId;
private String roleName;
/** 职称 */
private String positionalTitles;
/** 工种 */
private String profession;
/** 是否特殊作业人员 */
private String specialOperators;
/** 证书路径 */
private String certificateUrl;
/** 证书名称 */
private String certificateName;
/** 证书有效日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date effectiveDate;
/** 删除标志(0正常,1删除) */
private String isDel;
public Integer getStaffId() {
return staffId;
}
public void setStaffId(Integer staffId) {
this.staffId = staffId;
}
public String getStaffName() {
return staffName;
}
public void setStaffName(String staffName) {
this.staffName = staffName;
}
public String getStaffCode() {
return staffCode;
}
public void setStaffCode(String staffCode) {
this.staffCode = staffCode;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public Integer getDeptId() {
return deptId;
}
public void setDeptId(Integer deptId) {
this.deptId = deptId;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public String getPhonenumber() {
return phonenumber;
}
public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
}
public Integer getPostId() {
return postId;
}
public void setPostId(Integer postId) {
this.postId = postId;
}
public String getPostName() {
return postName;
}
public void setPostName(String postName) {
this.postName = postName;
}
public Integer getRoleId() {
return roleId;
}
public void setRoleId(Integer roleId) {
this.roleId = roleId;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getPositionalTitles() {
return positionalTitles;
}
public void setPositionalTitles(String positionalTitles) {
this.positionalTitles = positionalTitles;
}
public String getProfession() {
return profession;
}
public void setProfession(String profession) {
this.profession = profession;
}
public String getSpecialOperators() {
return specialOperators;
}
public void setSpecialOperators(String specialOperators) {
this.specialOperators = specialOperators;
}
public String getCertificateUrl() {
return certificateUrl;
}
public void setCertificateUrl(String certificateUrl) {
this.certificateUrl = certificateUrl;
}
public String getCertificateName() {
return certificateName;
}
public void setCertificateName(String certificateName) {
this.certificateName = certificateName;
}
public Date getEffectiveDate() {
return effectiveDate;
}
public void setEffectiveDate(Date effectiveDate) {
this.effectiveDate = effectiveDate;
}
public String getIsDel() {
return isDel;
}
public void setIsDel(String isDel) {
this.isDel = isDel;
}
}
package com.zehong.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
public class UserCourseVo {
private Long userCourseId;
private Long courseId;
private String courseName;
private String courseType;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date releaseTime;
private Integer topicNum;
private Integer qualifiedNum;
private Integer state;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date examinationTime;
private Integer examinationResult;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
private String dataKind;
private Integer personnelType;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date testStartTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date testEndTime;
private Integer trainState;
/**总分*/
private Integer totalScore;
/**多选题分数*/
private Integer multipleChoiceScore;
/**判断题分数*/
private Integer judgmentScore;
/**单选题分数*/
private Integer singleChoiceScore;
/** 已完成时长*/
private Integer finishDuration;
private Integer isVeriftyFace;
public Long getUserCourseId() {
return userCourseId;
}
public void setUserCourseId(Long userCourseId) {
this.userCourseId = userCourseId;
}
public Long getCourseId() {
return courseId;
}
public void setCourseId(Long courseId) {
this.courseId = courseId;
}
public String getCourseName() {
return courseName;
}
public void setCourseName(String courseName) {
this.courseName = courseName;
}
public String getCourseType() {
return courseType;
}
public void setCourseType(String courseType) {
this.courseType = courseType;
}
public Date getReleaseTime() {
return releaseTime;
}
public void setReleaseTime(Date releaseTime) {
this.releaseTime = releaseTime;
}
public Integer getTopicNum() {
return topicNum;
}
public void setTopicNum(Integer topicNum) {
this.topicNum = topicNum;
}
public Integer getQualifiedNum() {
return qualifiedNum;
}
public void setQualifiedNum(Integer qualifiedNum) {
this.qualifiedNum = qualifiedNum;
}
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
public Date getExaminationTime() {
return examinationTime;
}
public void setExaminationTime(Date examinationTime) {
this.examinationTime = examinationTime;
}
public Integer getExaminationResult() {
return examinationResult;
}
public void setExaminationResult(Integer examinationResult) {
this.examinationResult = examinationResult;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getDataKind() {
return dataKind;
}
public void setDataKind(String dataKind) {
this.dataKind = dataKind;
}
public Integer getPersonnelType() {
return personnelType;
}
public void setPersonnelType(Integer personnelType) {
this.personnelType = personnelType;
}
public Date getTestStartTime() {
return testStartTime;
}
public void setTestStartTime(Date testStartTime) {
this.testStartTime = testStartTime;
}
public Date getTestEndTime() {
return testEndTime;
}
public void setTestEndTime(Date testEndTime) {
this.testEndTime = testEndTime;
}
public Integer getTrainState() {
return trainState;
}
public void setTrainState(Integer trainState) {
this.trainState = trainState;
}
public Integer getTotalScore() {
return totalScore;
}
public void setTotalScore(Integer totalScore) {
this.totalScore = totalScore;
}
public Integer getMultipleChoiceScore() {
return multipleChoiceScore;
}
public void setMultipleChoiceScore(Integer multipleChoiceScore) {
this.multipleChoiceScore = multipleChoiceScore;
}
public Integer getJudgmentScore() {
return judgmentScore;
}
public void setJudgmentScore(Integer judgmentScore) {
this.judgmentScore = judgmentScore;
}
public Integer getSingleChoiceScore() {
return singleChoiceScore;
}
public void setSingleChoiceScore(Integer singleChoiceScore) {
this.singleChoiceScore = singleChoiceScore;
}
public Integer getFinishDuration() {
return finishDuration;
}
public void setFinishDuration(Integer finishDuration) {
this.finishDuration = finishDuration;
}
public Integer getIsVeriftyFace() {
return isVeriftyFace;
}
public void setIsVeriftyFace(Integer isVeriftyFace) {
this.isVeriftyFace = isVeriftyFace;
}
}
package com.zehong.system.mapper.baseinfo;
import com.zehong.system.domain.baseinfo.TStaff;
import com.zehong.system.domain.form.TStaffForm;
import com.zehong.system.domain.vo.TStaffVo;
import java.util.List;
/**
* 员工信息管理Mapper接口
*
* @author zehong
* @date 2022-06-17
*/
public interface TStaffMapper
{
/**
* 获取员工编号
*
* @return 员工编号
*/
public String getStaffCode();
/**
* 查询员工信息管理
*
* @param staffId 员工信息管理ID
* @return 员工信息管理
*/
public TStaffVo selectTStaffById(Long staffId);
/**
* 查询员工信息管理列表
*
* @param tStaff 员工信息管理
* @return 员工信息管理集合
*/
public List<TStaffVo> selectTStaffList(TStaffForm tStaff);
public List<TStaffVo> allList(TStaffForm tStaff);
/**
* 新增员工信息管理
*
* @param tStaff 员工信息管理
* @return 结果
*/
public int insertTStaff(TStaff tStaff);
/**
* 修改员工信息管理
*
* @param tStaff 员工信息管理
* @return 结果
*/
public int updateTStaff(TStaff tStaff);
/**
* 删除员工信息管理
*
* @param staffId 员工信息管理ID
* @return 结果
*/
public int deleteTStaffById(Long staffId);
/**
* 批量删除员工信息管理
*
* @param staffIds 需要删除的数据ID
* @return 结果
*/
public int deleteTStaffByIds(Long[] staffIds);
}
package com.zehong.system.mapper.train;
import com.zehong.system.domain.train.TBankSubject;
import java.util.List;
/**
* 题库题目Mapper接口
*
* @author zehong
* @date 2022-12-15
*/
public interface TBankSubjectMapper
{
/**
* 查询题库题目
*
* @param subjectId 题库题目ID
* @return 题库题目
*/
public TBankSubject selectTBankSubjectById(Long subjectId);
/**
* 查询题库题目列表
*
* @param tBankSubject 题库题目
* @return 题库题目集合
*/
public List<TBankSubject> selectTBankSubjectList(TBankSubject tBankSubject);
/**
* 新增题库题目
*
* @param tBankSubject 题库题目
* @return 结果
*/
public int insertTBankSubject(TBankSubject tBankSubject);
/**
* 修改题库题目
*
* @param tBankSubject 题库题目
* @return 结果
*/
public int updateTBankSubject(TBankSubject tBankSubject);
/**
* 删除题库题目
*
* @param subjectId 题库题目ID
* @return 结果
*/
public int deleteTBankSubjectById(Long subjectId);
/**
* 批量删除题库题目
*
* @param subjectIds 需要删除的数据ID
* @return 结果
*/
public int deleteTBankSubjectByIds(Long[] subjectIds);
/**
* Excel导入
* @param list
*/
void insertBank(List<TBankSubject> list);
}
package com.zehong.system.mapper.train;
import com.zehong.system.domain.train.TTrainCourseBank;
import java.util.List;
/**
* bankMapper接口
*
* @author zehong
* @date 2022-12-14
*/
public interface TTrainCourseBankMapper
{
/**
* 查询bank
*
* @param bankId bankID
* @return bank
*/
public TTrainCourseBank selectTTrainCourseBankById(Long bankId);
/**
* 查询bank列表
*
* @param tTrainCourseBank bank
* @return bank集合
*/
public List<TTrainCourseBank> selectTTrainCourseBankList(TTrainCourseBank tTrainCourseBank);
/**
* 新增bank
*
* @param tTrainCourseBank bank
* @return 结果
*/
public int insertTTrainCourseBank(TTrainCourseBank tTrainCourseBank);
/**
* 修改bank
*
* @param tTrainCourseBank bank
* @return 结果
*/
public int updateTTrainCourseBank(TTrainCourseBank tTrainCourseBank);
/**
* 删除bank
*
* @param bankId bankID
* @return 结果
*/
public int deleteTTrainCourseBankById(Long bankId);
/**
* 批量删除bank
*
* @param bankIds 需要删除的数据ID
* @return 结果
*/
public int deleteTTrainCourseBankByIds(Long[] bankIds);
}
package com.zehong.system.mapper.train;
import com.zehong.system.domain.form.TStaffForm;
import com.zehong.system.domain.train.StatisticsTrainCourse;
import com.zehong.system.domain.train.TNews;
import com.zehong.system.domain.train.TTrainCourse;
import com.zehong.system.domain.vo.UserCourseVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 培训课程Mapper接口
*
* @author zehong
* @date 2022-09-19
*/
public interface TTrainCourseMapper
{
/**
* 查询培训课程
*
* @param courseId 培训课程ID
* @return 培训课程
*/
public TTrainCourse selectTTrainCourseById(Long courseId);
/**
* 查询培训课程列表
*
* @param tTrainCourse 培训课程
* @return 培训课程集合
*/
public List<TTrainCourse> selectTTrainCourseList(TTrainCourse tTrainCourse);
/**
* 新增培训课程
*
* @param tTrainCourse 培训课程
* @return 结果
*/
public int insertTTrainCourse(TTrainCourse tTrainCourse);
/**
* 修改培训课程
*
* @param tTrainCourse 培训课程
* @return 结果
*/
public int updateTTrainCourse(TTrainCourse tTrainCourse);
/**
* 删除培训课程
*
* @param courseId 培训课程ID
* @return 结果
*/
public int deleteTTrainCourseById(Long courseId);
/**
* 批量删除培训课程
*
* @param courseIds 需要删除的数据ID
* @return 结果
*/
public int deleteTTrainCourseByIds(Long[] courseIds);
/**
* 批量新增用户课程
* @param courseId
* @param userIds
* @return
*/
public int insertUserCourse(@Param("courseId") Long courseId, @Param("userIds") List<String> userIds, @Param("personnelType") Integer personnelType);
/**
* 用户课程表
* @param userId
* @return
*/
public List<UserCourseVo> userCourseList(@Param("userId") Long userId, @Param("type") Integer type, @Param("personnelType") Integer personnelType);
/**
* 考试统计接口
* @param statisticsTrainCourse 统计实体
* @return List<StatisticsTrainCourse>
*/
List<StatisticsTrainCourse> statisticsTrainCourse(StatisticsTrainCourse statisticsTrainCourse);
List<UserCourseVo> userCourseLists(TStaffForm tStaff);
/**
* 消息添加
* @param tNews
*/
void insertNews(TNews tNews);
/**
* 手机端 最新消息查询
* @param recipientId
* @return
*/
TNews selectLatestNews(Long recipientId);
/**
* 手机端 查询历史消息
* @param recipientId
* @return
*/
List<TNews> historicalMessages(Long recipientId);
/**
* 修改消息状态为已读
* @param newsId
* @return
*/
int updateReadStatus(Long newsId);
/**
* 查询接收人姓名
*/
String selectRecipient(Long userid);
}
package com.zehong.system.mapper.train;
import com.zehong.system.domain.train.TTrainCourseTopic;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 培训课程题库Mapper接口
*
* @author zehong
* @date 2022-09-19
*/
public interface TTrainCourseTopicMapper
{
/**
* 查询培训课程题库
*
* @param topicId 培训课程题库ID
* @return 培训课程题库
*/
public TTrainCourseTopic selectTTrainCourseTopicById(Long topicId);
/**
* 查询培训课程题库列表
*
* @param tTrainCourseTopic 培训课程题库
* @return 培训课程题库集合
*/
public List<TTrainCourseTopic> selectTTrainCourseTopicList(TTrainCourseTopic tTrainCourseTopic);
public List<TTrainCourseTopic> selectCourseTopicList(@Param("courseId") Long courseId);
/**
* 新增培训课程题库
*
* @param tTrainCourseTopic 培训课程题库
* @return 结果
*/
public int insertTTrainCourseTopic(TTrainCourseTopic tTrainCourseTopic);
/**
* 修改培训课程题库
*
* @param tTrainCourseTopic 培训课程题库
* @return 结果
*/
public int updateTTrainCourseTopic(TTrainCourseTopic tTrainCourseTopic);
/**
* 删除培训课程题库
*
* @param topicId 培训课程题库ID
* @return 结果
*/
public int deleteTTrainCourseTopicById(Long topicId);
/**
* 批量删除培训课程题库
*
* @param topicIds 需要删除的数据ID
* @return 结果
*/
public int deleteTTrainCourseTopicByIds(Long[] topicIds);
/**
* 批量新增
* @param topics 试题试题
* @return
*/
int batchInsertTTrainCourseTopic(List<TTrainCourseTopic> topics);
}
package com.zehong.system.mapper.train;
import com.zehong.system.domain.train.TTrainPlan;
import com.zehong.system.domain.vo.PlanPostVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 培训计划Mapper接口
*
* @author zehong
* @date 2022-09-17
*/
public interface TTrainPlanMapper
{
/**
* 查询培训计划
*
* @param planId 培训计划ID
* @return 培训计划
*/
public TTrainPlan selectTTrainPlanById(Long planId);
/**
* 查询培训计划列表
*
* @param tTrainPlan 培训计划
* @return 培训计划集合
*/
public List<TTrainPlan> selectTTrainPlanList(TTrainPlan tTrainPlan);
/**
* 查询培训计划包含的岗位信息
* @param planId
* @return
*/
public List<PlanPostVo> selectTrainPostByPlanId(Long planId);
/**
* 新增培训计划
*
* @param tTrainPlan 培训计划
* @return 结果
*/
public int insertTTrainPlan(TTrainPlan tTrainPlan);
/**
* 批量添加 培训计划
* @param planId
* @param postIds
* @return
*/
public int insetsPlanPost(@Param("planId") Long planId, @Param("list") List<Map<String, Object>> list);
/**
* 删除计划职位
* @param planId
* @return
*/
public int deletePlanPost(@Param("planId") Long planId);
/**
* 修改培训计划
*
* @param tTrainPlan 培训计划
* @return 结果
*/
public int updateTTrainPlan(TTrainPlan tTrainPlan);
/**
* 删除培训计划
*
* @param planId 培训计划ID
* @return 结果
*/
public int deleteTTrainPlanById(Long planId);
/**
* 批量删除培训计划
*
* @param planIds 需要删除的数据ID
* @return 结果
*/
public int deleteTTrainPlanByIds(Long[] planIds);
/**
* 查询该计划涉及所有人id
* @param planId
* @return
*/
public List<String> selectAlluserByplanId(Long planId);
}
package com.zehong.system.mapper.train;
import com.zehong.system.domain.train.TTrainUserCourse;
import java.util.List;
/**
* 用户课程Mapper接口
*
* @author zehong
* @date 2022-09-19
*/
public interface TTrainUserCourseMapper
{
/**
* 查询用户课程
*
* @param userCourseId 用户课程ID
* @return 用户课程
*/
public TTrainUserCourse selectTTrainUserCourseById(Long userCourseId);
/**
* 查询用户课程列表
*
* @param tTrainUserCourse 用户课程
* @return 用户课程集合
*/
public List<TTrainUserCourse> selectTTrainUserCourseList(TTrainUserCourse tTrainUserCourse);
/**
* 新增用户课程
*
* @param tTrainUserCourse 用户课程
* @return 结果
*/
public int insertTTrainUserCourse(TTrainUserCourse tTrainUserCourse);
/**
* 修改用户课程
*
* @param tTrainUserCourse 用户课程
* @return 结果
*/
public int updateTTrainUserCourse(TTrainUserCourse tTrainUserCourse);
/**
* 删除用户课程
*
* @param userCourseId 用户课程ID
* @return 结果
*/
public int deleteTTrainUserCourseById(Long userCourseId);
/**
* 批量删除用户课程
*
* @param userCourseIds 需要删除的数据ID
* @return 结果
*/
public int deleteTTrainUserCourseByIds(Long[] userCourseIds);
/**
* 根据考试查询人员考试详情
* @param courseId 考试id
* @return List<TTrainUserCourse>
*/
List<TTrainUserCourse> testPersonDetailByCourseId(Long courseId);
/**
* 导出所有考试详细数据项
* @param courseId
* @return
*/
List<TTrainUserCourse> examDetails(Long courseId);
}
package com.zehong.system.service.baseinfo;
import com.zehong.system.domain.baseinfo.TStaff;
import com.zehong.system.domain.form.TStaffForm;
import com.zehong.system.domain.vo.TStaffVo;
import java.util.List;
/**
* 员工信息管理Service接口
*
* @author zehong
* @date 2022-06-17
*/
public interface ITStaffService
{
/**
* 查询员工信息管理
*
* @param staffId 员工信息管理ID
* @return 员工信息管理
*/
public TStaffVo selectTStaffById(Long staffId);
/**
* 查询员工信息管理列表
*
* @param tStaff 员工信息管理
* @return 员工信息管理集合
*/
public List<TStaffVo> selectTStaffList(TStaffForm tStaff);
public List<TStaffVo> allList(TStaffForm tStaff);
/**
* 新增员工信息管理
*
* @param tStaff 员工信息管理
* @return 结果
*/
public int insertTStaff(TStaff tStaff);
/**
* 修改员工信息管理
*
* @param tStaff 员工信息管理
* @return 结果
*/
public int updateTStaff(TStaff tStaff);
/**
* 批量删除员工信息管理
*
* @param staffIds 需要删除的员工信息管理ID
* @return 结果
*/
public int deleteTStaffByIds(Long[] staffIds);
/**
* 删除员工信息管理信息
*
* @param staffId 员工信息管理ID
* @return 结果
*/
public int deleteTStaffById(Long staffId);
}
package com.zehong.system.service.impl.baseinfo;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.SysUserRole;
import com.zehong.system.domain.baseinfo.TStaff;
import com.zehong.system.domain.form.TStaffForm;
import com.zehong.system.domain.vo.TStaffVo;
import com.zehong.system.mapper.SysUserRoleMapper;
import com.zehong.system.mapper.baseinfo.TStaffMapper;
import com.zehong.system.service.baseinfo.ITStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 员工信息管理Service业务层处理
*
* @author zehong
* @date 2022-06-17
*/
@Service
public class TStaffServiceImpl implements ITStaffService
{
@Autowired
private TStaffMapper tStaffMapper;
@Autowired
private SysUserRoleMapper userRoleMapper;
/**
* 查询员工信息管理
*
* @param staffId 员工信息管理ID
* @return 员工信息管理
*/
@Override
public TStaffVo selectTStaffById(Long staffId)
{
return tStaffMapper.selectTStaffById(staffId);
}
/**
* 查询员工信息管理列表
*
* @param tStaff 员工信息管理
* @return 员工信息管理
*/
@Override
public List<TStaffVo> selectTStaffList(TStaffForm tStaff)
{
return tStaffMapper.selectTStaffList(tStaff);
}
@Override
public List<TStaffVo> allList(TStaffForm tStaff)
{
return tStaffMapper.allList(tStaff);
}
/**
* 新增员工信息管理
*
* @param tStaff 员工信息管理
* @return 结果
*/
@Override
public int insertTStaff(TStaff tStaff)
{
String staffCode = tStaffMapper.getStaffCode();
tStaff.setStaffCode(staffCode);
tStaff.setCreateTime(DateUtils.getNowDate());
tStaffMapper.insertTStaff(tStaff);
// 新增用户与角色管理
insertUserRole(tStaff);
return tStaff.getStaffId();
}
/**
* 修改员工信息管理
*
* @param tStaff 员工信息管理
* @return 结果
*/
@Override
public int updateTStaff(TStaff tStaff)
{
// 删除用户与角色关联
userRoleMapper.deleteUserRoleByUserId(Long.valueOf(tStaff.getStaffId()));
// 新增用户与角色管理
insertUserRole(tStaff);
tStaff.setUpdateTime(DateUtils.getNowDate());
return tStaffMapper.updateTStaff(tStaff);
}
/**
* 批量删除员工信息管理
*
* @param staffIds 需要删除的员工信息管理ID
* @return 结果
*/
@Override
public int deleteTStaffByIds(Long[] staffIds)
{
return tStaffMapper.deleteTStaffByIds(staffIds);
}
/**
* 删除员工信息管理信息
*
* @param staffId 员工信息管理ID
* @return 结果
*/
@Override
public int deleteTStaffById(Long staffId)
{
return tStaffMapper.deleteTStaffById(staffId);
}
/**
* 新增用户角色信息
*
* @param user 用户对象
*/
public void insertUserRole(TStaff user)
{
Long[] roles = user.getRoleIds();
if (StringUtils.isNotNull(roles))
{
// 新增用户与角色管理
List<SysUserRole> list = new ArrayList<SysUserRole>();
for (Long roleId : roles)
{
SysUserRole ur = new SysUserRole();
ur.setUserId(Long.valueOf(user.getStaffId()));
ur.setRoleId(roleId);
list.add(ur);
}
if (list.size() > 0)
{
userRoleMapper.batchUserRole(list);
}
}
}
}
package com.zehong.system.service.impl.train;
import com.zehong.common.exception.CustomException;
import com.zehong.system.domain.train.TBankSubject;
import com.zehong.system.mapper.train.TBankSubjectMapper;
import com.zehong.system.service.train.ITBankSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
/**
* 题库题目Service业务层处理
*
* @author zehong
* @date 2022-12-15
*/
@Service
public class TBankSubjectServiceImpl implements ITBankSubjectService
{
@Autowired
private TBankSubjectMapper tBankSubjectMapper;
/**
* 查询题库题目
*
* @param subjectId 题库题目ID
* @return 题库题目
*/
@Override
public TBankSubject selectTBankSubjectById(Long subjectId)
{
return tBankSubjectMapper.selectTBankSubjectById(subjectId);
}
/**
* 查询题库题目列表
*
* @param tBankSubject 题库题目
* @return 题库题目
*/
@Override
public List<TBankSubject> selectTBankSubjectList(TBankSubject tBankSubject)
{
return tBankSubjectMapper.selectTBankSubjectList(tBankSubject);
}
/**
* 新增题库题目
*
* @param tBankSubject 题库题目
* @return 结果
*/
@Override
public int insertTBankSubject(TBankSubject tBankSubject)
{
return tBankSubjectMapper.insertTBankSubject(tBankSubject);
}
/**
* 修改题库题目
*
* @param tBankSubject 题库题目
* @return 结果
*/
@Override
public int updateTBankSubject(TBankSubject tBankSubject)
{
return tBankSubjectMapper.updateTBankSubject(tBankSubject);
}
/**
* 批量删除题库题目
*
* @param subjectIds 需要删除的题库题目ID
* @return 结果
*/
@Override
public int deleteTBankSubjectByIds(Long[] subjectIds)
{
return tBankSubjectMapper.deleteTBankSubjectByIds(subjectIds);
}
/**
* 删除题库题目信息
*
* @param subjectId 题库题目ID
* @return 结果
*/
@Override
public int deleteTBankSubjectById(Long subjectId)
{
return tBankSubjectMapper.deleteTBankSubjectById(subjectId);
}
/**
* 题目信息导入
* @param
* @param updateSupport
* @return
*/
@Override
public String importDevice(MultipartFile file, boolean updateSupport) throws IOException {
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
//文件输入流
// InputStream in=file.getInputStream();
//调用方法进行读取
//吧service直接注入进来为了后面能使用
//因为在listener中不能注入service所以在这个serviceiimpl中,通过listener使service注入进去,为了在listener中能够使用service中的发方法save/
// for (TBankSubject device : userList)
// {
// try
// {
// System.out.println(device);
// }
// catch (Exception e)
// {
// failureNum++;
// String msg = "<br/>" + failureNum + "、设备 " + device.getTopicOption() + "题目" + " 导入失败:";
// failureMsg.append(msg + e.getMessage());
//
// }
// }
if (failureNum > 0)
{
failureMsg.insert(0, "导入完成,共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new CustomException(failureMsg.toString());
}
else
{
successMsg.insert(0, "数据已全部导入成功!共 " + successNum + " 条");
}
return successMsg.toString();
}
/**
* Excel导入
* @param list
*/
@Override
public void insertBank(List<TBankSubject> list) {
tBankSubjectMapper.insertBank(list);
}
}
package com.zehong.system.service.impl.train;
import com.zehong.common.utils.DateUtils;
import com.zehong.system.domain.train.TTrainCourseBank;
import com.zehong.system.mapper.train.TTrainCourseBankMapper;
import com.zehong.system.service.train.ITTrainCourseBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* bankService业务层处理
*
* @author zehong
* @date 2022-12-14
*/
@Service
public class TTrainCourseBankServiceImpl implements ITTrainCourseBankService
{
@Autowired
private TTrainCourseBankMapper tTrainCourseBankMapper;
/**
* 查询bank
*
* @param bankId bankID
* @return bank
*/
@Override
public TTrainCourseBank selectTTrainCourseBankById(Long bankId)
{
return tTrainCourseBankMapper.selectTTrainCourseBankById(bankId);
}
/**
* 查询bank列表
*
* @param tTrainCourseBank bank
* @return bank
*/
@Override
public List<TTrainCourseBank> selectTTrainCourseBankList(TTrainCourseBank tTrainCourseBank)
{
return tTrainCourseBankMapper.selectTTrainCourseBankList(tTrainCourseBank);
}
/**
* 新增bank
*
* @param tTrainCourseBank bank
* @return 结果
*/
@Override
public int insertTTrainCourseBank(TTrainCourseBank tTrainCourseBank)
{
tTrainCourseBank.setCreateTime(DateUtils.getNowDate());
return tTrainCourseBankMapper.insertTTrainCourseBank(tTrainCourseBank);
}
/**
* 修改bank
*
* @param tTrainCourseBank bank
* @return 结果
*/
@Override
public int updateTTrainCourseBank(TTrainCourseBank tTrainCourseBank)
{
tTrainCourseBank.setUpdateTime(DateUtils.getNowDate());
return tTrainCourseBankMapper.updateTTrainCourseBank(tTrainCourseBank);
}
/**
* 批量删除bank
*
* @param bankIds 需要删除的bankID
* @return 结果
*/
@Override
public int deleteTTrainCourseBankByIds(Long[] bankIds)
{
return tTrainCourseBankMapper.deleteTTrainCourseBankByIds(bankIds);
}
/**
* 删除bank信息
*
* @param bankId bankID
* @return 结果
*/
@Override
public int deleteTTrainCourseBankById(Long bankId)
{
return tTrainCourseBankMapper.deleteTTrainCourseBankById(bankId);
}
}
package com.zehong.system.service.impl.train;
import cn.hutool.core.date.DateTime;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zehong.common.core.domain.entity.SysUser;
import com.zehong.common.core.domain.model.LoginUser;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.form.TStaffForm;
import com.zehong.system.domain.train.*;
import com.zehong.system.domain.vo.UserCourseVo;
import com.zehong.system.mapper.train.TTrainCourseMapper;
import com.zehong.system.mapper.train.TTrainCourseTopicMapper;
import com.zehong.system.mapper.train.TTrainPlanMapper;
import com.zehong.system.mapper.train.TTrainUserCourseMapper;
import com.zehong.system.service.train.ITTrainCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 培训课程Service业务层处理
*
* @author zehong
* @date 2022-09-19
*/
@Service
public class TTrainCourseServiceImpl implements ITTrainCourseService
{
@Autowired
private TTrainCourseMapper tTrainCourseMapper;
@Autowired
private TTrainPlanMapper tTrainPlanMapper;
@Autowired
private TTrainUserCourseMapper tTrainUserCourseMapper;
@Autowired
private TTrainCourseTopicMapper tTrainCourseTopicMapper;
/**
* 查询培训课程
*
* @param courseId 培训课程ID
* @return 培训课程
*/
@Override
public TTrainCourse selectTTrainCourseById(Long courseId)
{
return tTrainCourseMapper.selectTTrainCourseById(courseId);
}
/**
* 发布培训课程
* @return
*/
@Override
@Transactional
public Integer selectTTrainCourseRelease(Long courseId){
TTrainCourse course = tTrainCourseMapper.selectTTrainCourseById(courseId);
if(course==null){
return 0;
}
List<String> userIds = tTrainPlanMapper.selectAlluserByplanId(course.getCourseType());
//异常数据
if(userIds==null||userIds.size()==0){
return 0;
}
//查询考试详情
TTrainCourse tTrainCourse1 = tTrainCourseMapper.selectTTrainCourseById(courseId);
for (int i=0;i<userIds.size();i++){
/** 手机端消息新封装类 */
TNews tNews=new TNews();
/**设置所属模块*/
tNews.setModule(Integer.valueOf(tTrainCourse1.getDataKind()));
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String myDate = simpleDateFormat.format(tTrainCourse1.getTestEndTime());
if ("0".equals(tTrainCourse1.getDataKind())){
/**设置消息内容*/
tNews.setMessageContent("培训课程:"+tTrainCourse1.getCourseName()+",已发布,请于"+myDate+"前进行学习");
}else {
SecurityUtils.getUsername();
tNews.setMessageContent("您有一场新的试卷考试");
}
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser user = loginUser.getUser();
Long userId = user.getUserId();
/** 发布人ID*/
tNews.setPublisherId(userId);
/** 接收人id*/
tNews.setRecipientId(Integer.valueOf(userIds.get(i)));
/** 所属模块id*/
tNews.setModuleId(courseId);
tNews.setReleaseTime(new DateTime());
/**
* 消息添加
*/
tTrainCourseMapper.insertNews(tNews);
}
tTrainCourseMapper.insertUserCourse(courseId,userIds,course.getPersonnelType());
course.setStatus(1);
course.setReleaseTime(new Date());
return tTrainCourseMapper.updateTTrainCourse(course);
}
/**
* 查询培训课程列表
*
* @param tTrainCourse 培训课程
* @return 培训课程
*/
@Override
public List<TTrainCourse> selectTTrainCourseList(TTrainCourse tTrainCourse)
{
return tTrainCourseMapper.selectTTrainCourseList(tTrainCourse);
}
/**
* 新增培训课程
*
* @param tTrainCourse 培训课程
* @return 结果
*/
@Override
public Long insertTTrainCourse(TTrainCourse tTrainCourse)
{
if(tTrainCourse.getDuration()!=null){//分钟转化秒
tTrainCourse.setDuration(tTrainCourse.getDuration()*60);
}
if(tTrainCourse.getCourseType()!=null){
TTrainPlan p = tTrainPlanMapper.selectTTrainPlanById(tTrainCourse.getCourseType());
if(p!=null){
tTrainCourse.setPersonnelType(p.getPersonnelType());
}
}
tTrainCourse.setCreateTime(DateUtils.getNowDate());
tTrainCourseMapper.insertTTrainCourse(tTrainCourse);
return tTrainCourse.getCourseId();
}
/**
* 修改培训课程
*
* @param tTrainCourse 培训课程
* @return 结果
*/
@Override
public int updateTTrainCourse(TTrainCourse tTrainCourse)
{
if(tTrainCourse.getDuration()!=null){//分钟转化秒
tTrainCourse.setDuration(tTrainCourse.getDuration()*60);
}
return tTrainCourseMapper.updateTTrainCourse(tTrainCourse);
}
@Override
public int updateTTrainUserCourse(TTrainUserCourse tTrainUserCourse)
{
//判断有没有考试
if(tTrainUserCourse.getTrainState()==1){
List<TTrainCourseTopic> topicList = tTrainCourseTopicMapper.selectCourseTopicList(tTrainUserCourse.getCourseId());
if(topicList.size()==0){
tTrainUserCourse.setState(2);
}
}
return tTrainUserCourseMapper.updateTTrainUserCourse(tTrainUserCourse);
}
/**
* 批量删除培训课程
*
* @param courseIds 需要删除的培训课程ID
* @return 结果
*/
@Override
public int deleteTTrainCourseByIds(Long[] courseIds)
{
return tTrainCourseMapper.deleteTTrainCourseByIds(courseIds);
}
/**
* 删除培训课程信息
*
* @param courseId 培训课程ID
* @return 结果
*/
@Override
public int deleteTTrainCourseById(Long courseId)
{
return tTrainCourseMapper.deleteTTrainCourseById(courseId);
}
/**
* 用户课程表
* @return
*/
@Override
public List<UserCourseVo> userCourseList(Long userId,Integer type){
List<UserCourseVo> list = tTrainCourseMapper.userCourseList(userId,type,1);
for (UserCourseVo v :list){
if(v.getTestEndTime()!=null&&v.getTestEndTime().getTime()<new Date().getTime()&&v.getState()!=2){
v.setState(3);
}
if(v.getTestStartTime()!=null&&v.getTestStartTime().getTime()>new Date().getTime()){
v.setState(4);
}
}
for (int i=0;i<list.size();i++){
int totalScore=0;
Long courseId = list.get(i).getCourseId();
//查询课程下面的题
List<TTrainCourseTopic> tTrainCourseTopics = tTrainCourseTopicMapper.selectCourseTopicList(courseId);
for (int t = 0; t < tTrainCourseTopics.size(); t++) {
if (StringUtils.isEmpty(String.valueOf(tTrainCourseTopics.get(t).getTopicType()))) {
if (tTrainCourseTopics.get(t).getTopicType() == 1) {
totalScore = totalScore + list.get(i).getSingleChoiceScore();
} else if (tTrainCourseTopics.get(t).getTopicType() == 2) {
totalScore = totalScore + list.get(i).getMultipleChoiceScore();
} else if (tTrainCourseTopics.get(t).getTopicType() == 3) {
totalScore = totalScore + list.get(i).getJudgmentScore();
}
}
}
list.get(i).setTotalScore(totalScore);
}
return list;
}
@Override
public List<UserCourseVo> userCourseLists(TStaffForm tStaff) {
List<UserCourseVo> list = tTrainCourseMapper.userCourseLists(tStaff);
for (UserCourseVo v :list){
if(v.getTestEndTime()!=null&&v.getTestEndTime().getTime()<new Date().getTime()){
v.setState(3);
}
if(v.getTestStartTime()!=null&&v.getTestStartTime().getTime()>new Date().getTime()){
v.setState(4);
}
}
for (int i=0;i<list.size();i++){
int totalScore=0;
Long courseId = list.get(i).getCourseId();
//查询课程下面的题
List<TTrainCourseTopic> tTrainCourseTopics = tTrainCourseTopicMapper.selectCourseTopicList(courseId);
for (int t = 0; t < tTrainCourseTopics.size(); t++) {
if (StringUtils.isEmpty(String.valueOf(tTrainCourseTopics.get(t).getTopicType()))) {
if (tTrainCourseTopics.get(t).getTopicType() == 1) {
totalScore = totalScore + list.get(i).getSingleChoiceScore();
} else if (tTrainCourseTopics.get(t).getTopicType() == 2) {
totalScore = totalScore + list.get(i).getMultipleChoiceScore();
} else if (tTrainCourseTopics.get(t).getTopicType() == 3) {
totalScore = totalScore + list.get(i).getJudgmentScore();
}
}
}
list.get(i).setTotalScore(totalScore);
}
return list;
}
/**
* 承包商课程表
* @return
*/
@Override
public List<UserCourseVo> youkeCourseList(Long userId,Integer type){
List<UserCourseVo> list = tTrainCourseMapper.userCourseList(userId,type,2);
return list;
}
/**
* 考试判断
* @param userCourseId
* @param answers
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Map<String,Object> examination (Long userCourseId,Integer[][] answers){
//查询用户课程信息
TTrainUserCourse userCourse = tTrainUserCourseMapper.selectTTrainUserCourseById(userCourseId);
TTrainCourseTopic topic = new TTrainCourseTopic();
/**添加所属课程id*/
topic.setCourseId(userCourse.getCourseId());
/**查询培训课程题库列表*/
List<TTrainCourseTopic> list = tTrainCourseTopicMapper.selectTTrainCourseTopicList(topic);
/**查询培训课程*/
TTrainCourse c = tTrainCourseMapper.selectTTrainCourseById(userCourse.getCourseId());
/**获取各个题目类型多少分*/
//多选题分数
Integer multipleChoiceScore = c.getMultipleChoiceScore();
//单选题分数
Integer singleChoiceScore = c.getSingleChoiceScore();
//判断题分数
Integer judgmentScore = c.getJudgmentScore();
//答题合格分数
Integer qualifiedNum = c.getQualifiedNum();
//已获得分数
int num = 0;
/**
* 大循环 共有多少答案 此循环最后只算出 得了多少分
*/
for (int i=0;i<answers.length;i++){
/**答题是否正确 0 不正确 1正确*/
int PassedNot =0;
/*题目答案*/
String answer = list.get(i).getAnswer();
//答案转换成数组
Integer[] integers = JSON.parseObject(answer, Integer[].class);
/**判断所选答案是否与正确答案长度相等*/
if (integers.length==answers[i].length){
boolean adopt=true;
for (int n=0;n<integers.length;n++){
if (integers[n]!=answers[i][n]){
adopt=false;
break;
}
}
if (adopt){
/** 1单选 2多选 3判断*/
if (list.get(i).getTopicType()==1){
num=num+singleChoiceScore;
}else if (list.get(i).getTopicType()==2){
num=num+multipleChoiceScore;
}else if (list.get(i).getTopicType()==3){
num=num+judgmentScore;
}
}
}
/**
* 小循环 循环出每次的答案
*/
// for (int s=0;s<answers[i].length;s++){
// System.out.println("所选答案"+answers[i][s]);
// }
}
// for(Integer i=0;i<answers.length;i++){
// String demosub = list.get(i).getAnswer().substring(1,list.get(i).getAnswer().length()-1);
// if(Integer.parseInt(answers[i])==demosub){
// num++;
// }
// }
/**已获得分数*/
userCourse.setExaminationResult(num);
/**生成日期*/
userCourse.setExaminationTime(new Date());
/**判断已获得分数 是否通过 1未通过 2已通过*/
if(num>=qualifiedNum){
userCourse.setState(2);
}else {
userCourse.setState(1);
}
tTrainUserCourseMapper.updateTTrainUserCourse(userCourse);
Map<String,Object> map = new HashMap<>();
map.put("answer",num); //得分分数
map.put("qualifiedNum",c.getQualifiedNum()); //答题合格分数
map.put("topicNum",list.size()); //题目数据
return map;
}
/**
* 考试发布
* @param tTrainCourse 考试实体
* @return int
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int testPublish( TTrainCourse tTrainCourse){
//查询考试人员信息
TTrainCourse course = tTrainCourseMapper.selectTTrainCourseById(tTrainCourse.getCourseId());
if(course==null){
return 0;
}
//新增考试人员
List<JSONObject> personList = JSONObject.parseArray(course.getTestPersons(),JSONObject.class);
List<String> persons = personList.stream().map(item ->String.valueOf(item.get("peoPleId"))).collect(Collectors.toList());
//查询考试详情
TTrainCourse tTrainCourse1 = tTrainCourseMapper.selectTTrainCourseById(tTrainCourse.getCourseId());
for (int i=0;i<persons.size();i++){
/** 手机端消息新封装类 */
TNews tNews=new TNews();
/**设置所属模块*/
tNews.setModule(Integer.valueOf(tTrainCourse1.getDataKind()));
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String myDate = simpleDateFormat.format(tTrainCourse1.getTestEndTime());
if ("0".equals(tTrainCourse1.getDataKind())){
/**设置消息内容*/
tNews.setMessageContent("培训课程:"+tTrainCourse1.getCourseName()+"已发布,请于"+myDate+"前进行学习");
}else {
tNews.setMessageContent("考试:"+tTrainCourse1.getCourseName()+"已发布,请于"+myDate+"前进行学习");
}
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser user = loginUser.getUser();
Long userId = user.getUserId();
/** 发布人ID*/
tNews.setPublisherId(userId);
/** 接收人id*/
tNews.setRecipientId(Integer.valueOf(persons.get(i)));
/** 所属模块id*/
tNews.setModuleId(tTrainCourse.getCourseId());
tNews.setReleaseTime(new DateTime());
/**
* 消息添加
*/
tTrainCourseMapper.insertNews(tNews);
}
tTrainCourseMapper.insertUserCourse(tTrainCourse.getCourseId(),persons,tTrainCourse.getPersonnelType());
tTrainCourse.setStatus(1);
tTrainCourse.setReleaseTime(new Date());
return tTrainCourseMapper.updateTTrainCourse(tTrainCourse);
}
/**
* 考试统计接口
* @param statisticsTrainCourse 统计实体
* @return List<StatisticsTrainCourse>
*/
@Override
public List<StatisticsTrainCourse> statisticsTrainCourse(StatisticsTrainCourse statisticsTrainCourse){
return tTrainCourseMapper.statisticsTrainCourse(statisticsTrainCourse);
}
/**
* 根据考试查询人员考试详情
* @param courseId 考试id
* @return List<TTrainUserCourse>
*/
@Override
public List<TTrainUserCourse> testPersonDetailByCourseId(Long courseId){
return tTrainUserCourseMapper.testPersonDetailByCourseId(courseId);
}
/**
* 导出所有考试详细数据项
* @param courseId
* @return
*/
@Override
public List<TTrainUserCourse> examDetails(Long courseId) {
return tTrainUserCourseMapper.examDetails(courseId);
}
@Override
public TTrainUserCourse getUserCourse(Long userCourseId){
TTrainUserCourse userCourse = tTrainUserCourseMapper.selectTTrainUserCourseById(userCourseId);
TTrainCourse v = tTrainCourseMapper.selectTTrainCourseById(userCourse.getCourseId());
if(v.getTestEndTime()!=null&&v.getTestEndTime().getTime()<new Date().getTime()&&userCourse.getState()!=2){
userCourse.setState(3);
}
return userCourse;
}
/**
* 手机端 最新消息查询
* @param recipientId
* @return
*/
@Override
public TNews selectLatestNews(Long recipientId) {
return tTrainCourseMapper.selectLatestNews(recipientId);
}
/**
* 手机端 查询历史消息
* @param recipientId
* @return
*/
@Override
public List<TNews> historicalMessages(Long recipientId) {
return tTrainCourseMapper.historicalMessages(recipientId);
}
/**
* 修改消息状态为已读
* @param newsId
* @return
*/
@Override
public int updateReadStatus(Long newsId) {
return tTrainCourseMapper.updateReadStatus(newsId);
}
}
package com.zehong.system.service.impl.train;
import cn.hutool.core.collection.CollectionUtil;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.train.TBankSubject;
import com.zehong.system.domain.train.TTrainCourse;
import com.zehong.system.domain.train.TTrainCourseTopic;
import com.zehong.system.domain.vo.BatchTopicVo;
import com.zehong.system.mapper.train.TBankSubjectMapper;
import com.zehong.system.mapper.train.TTrainCourseMapper;
import com.zehong.system.mapper.train.TTrainCourseTopicMapper;
import com.zehong.system.service.train.ITTrainCourseTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/**
* 培训课程题库Service业务层处理
*
* @author zehong
* @date 2022-09-19
*/
@Service
public class TTrainCourseTopicServiceImpl implements ITTrainCourseTopicService
{
@Autowired
private TTrainCourseTopicMapper tTrainCourseTopicMapper;
@Autowired
private TTrainCourseMapper tTrainCourseMapper;
@Resource
private TBankSubjectMapper tBankSubjectMapper;
/**
* 查询培训课程题库
*
* @param topicId 培训课程题库ID
* @return 培训课程题库
*/
@Override
public TTrainCourseTopic selectTTrainCourseTopicById(Long topicId)
{
return tTrainCourseTopicMapper.selectTTrainCourseTopicById(topicId);
}
/**
* 查询培训课程题库列表
*
* @param tTrainCourseTopic 培训课程题库
* @return 培训课程题库
*/
@Override
public List<TTrainCourseTopic> selectTTrainCourseTopicList(TTrainCourseTopic tTrainCourseTopic)
{
return tTrainCourseTopicMapper.selectTTrainCourseTopicList(tTrainCourseTopic);
}
@Override
public List<TTrainCourseTopic> selectCourseTopicList(Long courseId)
{
return tTrainCourseTopicMapper.selectCourseTopicList(courseId);
}
/**
* 新增培训课程题库
*
* @param tTrainCourseTopic 培训课程题库
* @return 结果
*/
@Override
@Transactional
public int insertTTrainCourseTopic(TTrainCourseTopic tTrainCourseTopic)
{
tTrainCourseTopic.setCreateTime(DateUtils.getNowDate());
TTrainCourse course = tTrainCourseMapper.selectTTrainCourseById(tTrainCourseTopic.getCourseId());
if(course!=null){
course.setTopicNum(course.getTopicNum()+1);
tTrainCourseMapper.updateTTrainCourse(course);
}
return tTrainCourseTopicMapper.insertTTrainCourseTopic(tTrainCourseTopic);
}
/**
* 修改培训课程题库
*
* @param tTrainCourseTopic 培训课程题库
* @return 结果
*/
@Override
public int updateTTrainCourseTopic(TTrainCourseTopic tTrainCourseTopic)
{
return tTrainCourseTopicMapper.updateTTrainCourseTopic(tTrainCourseTopic);
}
/**
* 批量删除培训课程题库
*
* @param topicIds 需要删除的培训课程题库ID
* @return 结果
*/
@Override
public int deleteTTrainCourseTopicByIds(Long[] topicIds)
{
return tTrainCourseTopicMapper.deleteTTrainCourseTopicByIds(topicIds);
}
/**
* 删除培训课程题库信息
*
* @param topicId 培训课程题库ID
* @return 结果
*/
@Override
@Transactional
public int deleteTTrainCourseTopicById(Long topicId)
{
TTrainCourseTopic topic = tTrainCourseTopicMapper.selectTTrainCourseTopicById(topicId);
if(topic==null){
return 0;
}
TTrainCourse course = tTrainCourseMapper.selectTTrainCourseById(topic.getCourseId());
if(course!=null){
course.setTopicNum(course.getTopicNum()-1);
tTrainCourseMapper.updateTTrainCourse(course);
}
return tTrainCourseTopicMapper.deleteTTrainCourseTopicById(topicId);
}
/**
* 题库批量导入试题
* @param batchTopicVo 试题实体
* @return int
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int bachAddTopic(BatchTopicVo batchTopicVo){
if(CollectionUtil.isEmpty(batchTopicVo.getTopicInfos()) || StringUtils.isEmpty(String.valueOf(batchTopicVo.getCourseId()))){
return 0;
}
List<TTrainCourseTopic> topics = new ArrayList<>();
int count = 0;
for(BatchTopicVo.TopicInfos topic : batchTopicVo.getTopicInfos()){
//获取题库试题
TBankSubject tBankSubject = new TBankSubject();
tBankSubject.setBankId(topic.getBankId());
List<TBankSubject> bankSubjects = tBankSubjectMapper.selectTBankSubjectList(tBankSubject);
//获取随机试题
Collections.shuffle(bankSubjects);
for(int i = 0;i<topic.getQuan();i++){
TTrainCourseTopic courseTopic = new TTrainCourseTopic();
courseTopic.setCourseId(batchTopicVo.getCourseId());
courseTopic.setTopicTitle(bankSubjects.get(i).getTopicTitle());
courseTopic.setTopicOption(bankSubjects.get(i).getTopicOption());
courseTopic.setAnswer(String.valueOf(bankSubjects.get(i).getAnswer()));
courseTopic.setCreateTime(new Date());
courseTopic.setTopicType(bankSubjects.get(i).getTopicType());
topics.add(courseTopic);
}
count += topic.getQuan();
}
//批量新增试题
tTrainCourseTopicMapper.batchInsertTTrainCourseTopic(topics);
//更新试题数量
TTrainCourse course = tTrainCourseMapper.selectTTrainCourseById(batchTopicVo.getCourseId());
course.setTopicNum(course.getTopicNum() + count);
return tTrainCourseMapper.updateTTrainCourse(course);
}
/**
* 培训课程管理批量导入试题
* @param batchTopicVo
* @return
*/
@Override
public int addTTrainCourseTopic(BatchTopicVo batchTopicVo) {
if(CollectionUtil.isEmpty(batchTopicVo.getTopicInfos()) || StringUtils.isEmpty(String.valueOf(batchTopicVo.getCourseId()))){
return 0;
}
List<TTrainCourseTopic> topics = new ArrayList<>();
int count = 0;
for(BatchTopicVo.TopicInfos topic : batchTopicVo.getTopicInfos()){
//获取题库试题
TBankSubject tBankSubject = new TBankSubject();
tBankSubject.setBankId(topic.getBankId());
List<TBankSubject> bankSubjects = tBankSubjectMapper.selectTBankSubjectList(tBankSubject);
//获取随机试题
Collections.shuffle(bankSubjects);
for(int i = 0;i<topic.getQuan();i++){
TTrainCourseTopic courseTopic = new TTrainCourseTopic();
courseTopic.setCourseId(batchTopicVo.getCourseId());
courseTopic.setTopicTitle(bankSubjects.get(i).getTopicTitle());
courseTopic.setTopicOption(bankSubjects.get(i).getTopicOption());
courseTopic.setAnswer(String.valueOf(bankSubjects.get(i).getAnswer()));
courseTopic.setCreateTime(new Date());
topics.add(courseTopic);
}
count += topic.getQuan();
}
//批量新增试题
tTrainCourseTopicMapper.batchInsertTTrainCourseTopic(topics);
//更新试题数量
TTrainCourse course = tTrainCourseMapper.selectTTrainCourseById(batchTopicVo.getCourseId());
course.setTopicNum(course.getTopicNum() + count);
return tTrainCourseMapper.updateTTrainCourse(course);
}
}
package com.zehong.system.service.impl.train;
import com.zehong.common.utils.DateUtils;
import com.zehong.system.domain.train.TTrainPlan;
import com.zehong.system.domain.vo.PlanPostVo;
import com.zehong.system.mapper.train.TTrainPlanMapper;
import com.zehong.system.service.train.ITTrainPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
* 培训计划Service业务层处理
*
* @author zehong
* @date 2022-09-17
*/
@Service
public class TTrainPlanServiceImpl implements ITTrainPlanService
{
@Autowired
private TTrainPlanMapper tTrainPlanMapper;
/**
* 查询培训计划
*
* @param planId 培训计划ID
* @return 培训计划
*/
@Override
public TTrainPlan selectTTrainPlanById(Long planId)
{
return tTrainPlanMapper.selectTTrainPlanById(planId);
}
/**
* 查询培训计划列表
*
* @param tTrainPlan 培训计划
* @return 培训计划
*/
@Override
public List<TTrainPlan> selectTTrainPlanList(TTrainPlan tTrainPlan)
{
List<TTrainPlan> list = tTrainPlanMapper.selectTTrainPlanList(tTrainPlan);
for(TTrainPlan t : list){
List<PlanPostVo> mapList = tTrainPlanMapper.selectTrainPostByPlanId(t.getPlanId());
t.setPostList(mapList);
}
return list;
}
public List<TTrainPlan> selectTTrainPlanDownList(){
return tTrainPlanMapper.selectTTrainPlanList(null);
}
/**
* 新增培训计划
*
* @param tTrainPlan 培训计划
* @return 结果
*/
@Override
@Transactional
public Long insertTTrainPlan(TTrainPlan tTrainPlan, List<Map<String,Object>> list)
{
tTrainPlan.setCreateTime(DateUtils.getNowDate());
int a = tTrainPlanMapper.insertTTrainPlan(tTrainPlan);
tTrainPlanMapper.insetsPlanPost(tTrainPlan.getPlanId(),list);
return tTrainPlan.getPlanId();
}
/**
* 修改培训计划
*
* @param tTrainPlan 培训计划
* @return 结果
*/
@Override
@Transactional
public int updateTTrainPlan(TTrainPlan tTrainPlan, List<Map<String,Object>> list)
{
int a = tTrainPlanMapper.updateTTrainPlan(tTrainPlan);
tTrainPlanMapper.deletePlanPost(tTrainPlan.getPlanId());
tTrainPlanMapper.insetsPlanPost(tTrainPlan.getPlanId(),list);
return a;
}
/**
* 批量删除培训计划
*
* @param planIds 需要删除的培训计划ID
* @return 结果
*/
@Override
public int deleteTTrainPlanByIds(Long[] planIds)
{
return tTrainPlanMapper.deleteTTrainPlanByIds(planIds);
}
/**
* 删除培训计划信息
*
* @param planId 培训计划ID
* @return 结果
*/
@Override
public int deleteTTrainPlanById(Long planId)
{
int a = tTrainPlanMapper.deleteTTrainPlanById(planId);
tTrainPlanMapper.deletePlanPost(planId);
return a;
}
}
package com.zehong.system.service.train;
import com.zehong.system.domain.train.TBankSubject;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
/**
* 题库题目Service接口
*
* @author zehong
* @date 2022-12-15
*/
public interface ITBankSubjectService
{
/**
* 查询题库题目
*
* @param subjectId 题库题目ID
* @return 题库题目
*/
public TBankSubject selectTBankSubjectById(Long subjectId);
/**
* 查询题库题目列表
*
* @param tBankSubject 题库题目
* @return 题库题目集合
*/
public List<TBankSubject> selectTBankSubjectList(TBankSubject tBankSubject);
/**
* 新增题库题目
*
* @param tBankSubject 题库题目
* @return 结果
*/
public int insertTBankSubject(TBankSubject tBankSubject);
/**
* 修改题库题目
*
* @param tBankSubject 题库题目
* @return 结果
*/
public int updateTBankSubject(TBankSubject tBankSubject);
/**
* 批量删除题库题目
*
* @param subjectIds 需要删除的题库题目ID
* @return 结果
*/
public int deleteTBankSubjectByIds(Long[] subjectIds);
/**
* 删除题库题目信息
*
* @param subjectId 题库题目ID
* @return 结果
*/
public int deleteTBankSubjectById(Long subjectId);
/**
* 题目信息导入
* @param userList
* @param updateSupport
* @return
*/
String importDevice(MultipartFile userList, boolean updateSupport) throws IOException;
/**
* excel导入
* @param list
*/
void insertBank(List<TBankSubject> list);
}
package com.zehong.system.service.train;
import com.zehong.system.domain.train.TTrainCourseBank;
import java.util.List;
/**
* bankService接口
*
* @author zehong
* @date 2022-12-14
*/
public interface ITTrainCourseBankService
{
/**
* 查询bank
*
* @param bankId bankID
* @return bank
*/
public TTrainCourseBank selectTTrainCourseBankById(Long bankId);
/**
* 查询bank列表
*
* @param tTrainCourseBank bank
* @return bank集合
*/
public List<TTrainCourseBank> selectTTrainCourseBankList(TTrainCourseBank tTrainCourseBank);
/**
* 新增bank
*
* @param tTrainCourseBank bank
* @return 结果
*/
public int insertTTrainCourseBank(TTrainCourseBank tTrainCourseBank);
/**
* 修改bank
*
* @param tTrainCourseBank bank
* @return 结果
*/
public int updateTTrainCourseBank(TTrainCourseBank tTrainCourseBank);
/**
* 批量删除bank
*
* @param bankIds 需要删除的bankID
* @return 结果
*/
public int deleteTTrainCourseBankByIds(Long[] bankIds);
/**
* 删除bank信息
*
* @param bankId bankID
* @return 结果
*/
public int deleteTTrainCourseBankById(Long bankId);
}
package com.zehong.system.service.train;
import com.zehong.system.domain.form.TStaffForm;
import com.zehong.system.domain.train.StatisticsTrainCourse;
import com.zehong.system.domain.train.TNews;
import com.zehong.system.domain.train.TTrainCourse;
import com.zehong.system.domain.train.TTrainUserCourse;
import com.zehong.system.domain.vo.UserCourseVo;
import java.util.List;
import java.util.Map;
/**
* 培训课程Service接口
*
* @author zehong
* @date 2022-09-19
*/
public interface ITTrainCourseService
{
/**
* 查询培训课程
*
* @param courseId 培训课程ID
* @return 培训课程
*/
public TTrainCourse selectTTrainCourseById(Long courseId);
/**
* 发布培训课程
* @param courseId
* @return
*/
public Integer selectTTrainCourseRelease(Long courseId);
/**
* 查询培训课程列表
*
* @param tTrainCourse 培训课程
* @return 培训课程集合
*/
public List<TTrainCourse> selectTTrainCourseList(TTrainCourse tTrainCourse);
/**
* 新增培训课程
*
* @param tTrainCourse 培训课程
* @return 结果
*/
public Long insertTTrainCourse(TTrainCourse tTrainCourse);
/**
* 修改培训课程
*
* @param tTrainCourse 培训课程
* @return 结果
*/
public int updateTTrainCourse(TTrainCourse tTrainCourse);
public int updateTTrainUserCourse(TTrainUserCourse tTrainUserCourse);
/**
* 批量删除培训课程
*
* @param courseIds 需要删除的培训课程ID
* @return 结果
*/
public int deleteTTrainCourseByIds(Long[] courseIds);
/**
* 删除培训课程信息
*
* @param courseId 培训课程ID
* @return 结果
*/
public int deleteTTrainCourseById(Long courseId);
public TTrainUserCourse getUserCourse(Long userCourseId);
/**
* 用户id
* @param userId
* @return
*/
public List<UserCourseVo> userCourseList(Long userId, Integer type);
public List<UserCourseVo> userCourseLists(TStaffForm tStaff);
public List<UserCourseVo> youkeCourseList(Long userId, Integer type);
/**
* 考试
*/
public Map<String,Object> examination(Long userCourseId, Integer[][] answers);
/**
* 考试发布
* @param tTrainCourse 考试实体
* @return int
*/
int testPublish(TTrainCourse tTrainCourse);
/**
* 考试统计接口
* @param statisticsTrainCourse 统计实体
* @return List<StatisticsTrainCourse>
*/
List<StatisticsTrainCourse> statisticsTrainCourse(StatisticsTrainCourse statisticsTrainCourse);
/**
* 根据考试查询人员考试详情
* @param courseId 考试id
* @return List<TTrainUserCourse>
*/
List<TTrainUserCourse> testPersonDetailByCourseId(Long courseId);
/**
* 导出所有考试详细数据项
* @param courseId
* @return
*/
List<TTrainUserCourse> examDetails(Long courseId);
/**
* 最新消息查询
* @param recipientId
* @return
*/
TNews selectLatestNews(Long recipientId);
/**
* 手机端 查询历史消息
* @param recipientId
* @return
*/
List<TNews> historicalMessages(Long recipientId);
/**
* 修改消息状态为已读
* @param newsId
* @return
*/
int updateReadStatus(Long newsId);
}
package com.zehong.system.service.train;
import com.zehong.system.domain.train.TTrainCourseTopic;
import com.zehong.system.domain.vo.BatchTopicVo;
import java.util.List;
/**
* 培训课程题库Service接口
*
* @author zehong
* @date 2022-09-19
*/
public interface ITTrainCourseTopicService
{
/**
* 查询培训课程题库
*
* @param topicId 培训课程题库ID
* @return 培训课程题库
*/
public TTrainCourseTopic selectTTrainCourseTopicById(Long topicId);
/**
* 查询培训课程题库列表
*
* @param tTrainCourseTopic 培训课程题库
* @return 培训课程题库集合
*/
public List<TTrainCourseTopic> selectTTrainCourseTopicList(TTrainCourseTopic tTrainCourseTopic);
public List<TTrainCourseTopic> selectCourseTopicList(Long courseId);
/**
* 新增培训课程题库
*
* @param tTrainCourseTopic 培训课程题库
* @return 结果
*/
public int insertTTrainCourseTopic(TTrainCourseTopic tTrainCourseTopic);
/**
* 修改培训课程题库
*
* @param tTrainCourseTopic 培训课程题库
* @return 结果
*/
public int updateTTrainCourseTopic(TTrainCourseTopic tTrainCourseTopic);
/**
* 批量删除培训课程题库
*
* @param topicIds 需要删除的培训课程题库ID
* @return 结果
*/
public int deleteTTrainCourseTopicByIds(Long[] topicIds);
/**
* 删除培训课程题库信息
*
* @param topicId 培训课程题库ID
* @return 结果
*/
public int deleteTTrainCourseTopicById(Long topicId);
/**
* 题库批量导入试题
* @param batchTopicVo 试题实体
* @return int
*/
int bachAddTopic(BatchTopicVo batchTopicVo);
/**
* 培训课程管理批量导入试题
* @param batchTopicVo
* @return
*/
int addTTrainCourseTopic(BatchTopicVo batchTopicVo);
}
package com.zehong.system.service.train;
import com.zehong.system.domain.train.TTrainPlan;
import java.util.List;
import java.util.Map;
/**
* 培训计划Service接口
*
* @author zehong
* @date 2022-09-17
*/
public interface ITTrainPlanService
{
/**
* 查询培训计划
*
* @param planId 培训计划ID
* @return 培训计划
*/
public TTrainPlan selectTTrainPlanById(Long planId);
/**
* 查询培训计划列表
*
* @param tTrainPlan 培训计划
* @return 培训计划集合
*/
public List<TTrainPlan> selectTTrainPlanList(TTrainPlan tTrainPlan);
public List<TTrainPlan> selectTTrainPlanDownList();
/**
* 新增培训计划
*
* @param tTrainPlan 培训计划
* @return 结果
*/
public Long insertTTrainPlan(TTrainPlan tTrainPlan, List<Map<String, Object>> list);
/**
* 修改培训计划
*
* @param tTrainPlan 培训计划
* @return 结果
*/
public int updateTTrainPlan(TTrainPlan tTrainPlan, List<Map<String, Object>> list);
/**
* 批量删除培训计划
*
* @param planIds 需要删除的培训计划ID
* @return 结果
*/
public int deleteTTrainPlanByIds(Long[] planIds);
/**
* 删除培训计划信息
*
* @param planId 培训计划ID
* @return 结果
*/
public int deleteTTrainPlanById(Long planId);
}
<?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.zehong.system.mapper.baseinfo.TStaffMapper">
<resultMap type="TStaffVo" id="TStaffResult">
<result property="staffId" column="staff_id" />
<result property="staffName" column="staff_name" />
<result property="staffCode" column="staff_code" />
<result property="sex" column="sex" />
<result property="deptId" column="dept_id" />
<result property="deptName" column="dept_name" />
<result property="phonenumber" column="phonenumber" />
<result property="postId" column="post_id" />
<result property="postName" column="post_name" />
<result property="roleId" column="role_id" />
<result property="roleName" column="role_name" />
<result property="positionalTitles" column="positional_titles" />
<result property="profession" column="profession" />
<result property="specialOperators" column="special_operators" />
<result property="certificateUrl" column="certificate_url" />
<result property="certificateName" column="certificate_name" />
<result property="effectiveDate" column="effective_date" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="isDel" column="is_del" />
</resultMap>
<select id="getStaffCode" resultType="String">
select nextval('seq_staff_code') as staff_code
</select>
<sql id="selectTStaffVo">
select t.user_id as staff_id, t.staff_name, t.staff_code, t.sex, t.dept_id, t.phonenumber, t.post_id, t.role_id, t.positional_titles, t.profession, t.special_operators, t.certificate_url, t.certificate_name, t.effective_date, t.create_time, t.update_time, t.remark, t.is_del,
d.dept_name, r.role_name, p.post_name
from sys_user t
left join sys_dept d on t.dept_id = d.dept_id
left join sys_role r on t.role_id = r.role_id
left join sys_post p on t.post_id = p.post_id
</sql>
<select id="selectTStaffList" parameterType="TStaffForm" resultMap="TStaffResult">
select t.user_id as staff_id, t.staff_name, t.staff_code, t.sex, t.dept_id, t.phonenumber, t.post_id, t.role_id, t.positional_titles, t.profession, t.special_operators, t.certificate_url, t.certificate_name, t.effective_date, t.create_time, t.update_time, t.remark, t.is_del,
d.dept_name, r.role_name, p.post_name
from sys_user t
left join sys_dept d on t.dept_id = d.dept_id
left join sys_role r on t.role_id = r.role_id
left join sys_post p on t.post_id = p.post_id
<where> t.is_del = '0' and t.user_staff='1'
<if test="staffName != null and staffName != ''"> and t.staff_name like concat('%', #{staffName}, '%')</if>
<if test="staffCode != null and staffCode != ''"> and t.staff_code like concat('%', #{staffCode}, '%')</if>
<if test="sex != null and sex != ''"> and t.sex = #{sex}</if>
<if test="deptId != null "> and t.dept_id = #{deptId}</if>
<if test="phonenumber != null and phonenumber != ''">
AND t.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(t.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(t.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
group by t.user_id desc
</select>
<select id="allList" parameterType="TStaffForm" resultMap="TStaffResult">
SELECT *,user_id as staff_id FROM sys_user WHERE is_del = '0'
</select>
<select id="selectTStaffById" parameterType="Long" resultMap="TStaffResult">
<include refid="selectTStaffVo"/>
where t.user_id = #{staffId}
</select>
<insert id="insertTStaff" parameterType="TStaff" useGeneratedKeys = "true" keyProperty = "staffId">
insert into sys_user
<trim prefix="(" suffix=")" suffixOverrides=",">
user_staff,
<if test="password != null">password,</if>
<if test="userName != null">user_name,</if>
<if test="staffName != null">nick_name,</if>
<if test="staffName != null">staff_name,</if>
<if test="staffCode != null">staff_code,</if>
<if test="sex != null">sex,</if>
<if test="deptId != null">dept_id,</if>
<if test="phonenumber != null">phonenumber,</if>
<if test="postId != null">post_id,</if>
<if test="roleId != null">role_id,</if>
<if test="positionalTitles != null">positional_titles,</if>
<if test="profession != null">profession,</if>
<if test="specialOperators != null">special_operators,</if>
<if test="certificateUrl != null">certificate_url,</if>
<if test="certificateName != null">certificate_name,</if>
<if test="effectiveDate != null">effective_date,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="isDel != null">is_del,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
'1',
<if test="password != null">#{password},</if>
<if test="userName != null">#{userName},</if>
<if test="staffName != null">#{staffName},</if>
<if test="staffName != null">#{staffName},</if>
<if test="staffCode != null">#{staffCode},</if>
<if test="sex != null">#{sex},</if>
<if test="deptId != null">#{deptId},</if>
<if test="phonenumber != null">#{phonenumber},</if>
<if test="postId != null">#{postId},</if>
<if test="roleId != null">#{roleId},</if>
<if test="positionalTitles != null">#{positionalTitles},</if>
<if test="profession != null">#{profession},</if>
<if test="specialOperators != null">#{specialOperators},</if>
<if test="certificateUrl != null">#{certificateUrl},</if>
<if test="certificateName != null">#{certificateName},</if>
<if test="effectiveDate != null">#{effectiveDate},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="isDel != null">#{isDel},</if>
</trim>
</insert>
<update id="updateTStaff" parameterType="TStaff">
update sys_user
<trim prefix="SET" suffixOverrides=",">
<if test="staffName != null">staff_name = #{staffName},</if>
<if test="staffCode != null">staff_code = #{staffCode},</if>
<if test="sex != null">sex = #{sex},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="phonenumber != null">phonenumber = #{phonenumber},</if>
<if test="postId != null">post_id = #{postId},</if>
<if test="roleId != null">role_id = #{roleId},</if>
<if test="positionalTitles != null">positional_titles = #{positionalTitles},</if>
<if test="profession != null">profession = #{profession},</if>
<if test="specialOperators != null">special_operators = #{specialOperators},</if>
<if test="certificateUrl != null">certificate_url = #{certificateUrl},</if>
<if test="certificateName != null">certificate_name = #{certificateName},</if>
effective_date = #{effectiveDate},
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="isDel != null">is_del = #{isDel},</if>
</trim>
where user_id = #{staffId}
</update>
<delete id="deleteTStaffById" parameterType="Long">
delete from sys_user where user_id = #{staffId}
</delete>
<delete id="deleteTStaffByIds" parameterType="String">
delete from sys_user where user_id in
<foreach item="staffId" collection="array" open="(" separator="," close=")">
#{staffId}
</foreach>
</delete>
</mapper>
<?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.zehong.system.mapper.train.TBankSubjectMapper">
<resultMap type="TBankSubject" id="TBankSubjectResult">
<result property="subjectId" column="subject_id" />
<result property="bankId" column="bank_id" />
<result property="topicTitle" column="topic_title" />
<result property="topicOption" column="topic_option" />
<result property="answer" column="answer" />
<result property="datetime" column="datetime" />
<result property="topicType" column="topic_type" />
</resultMap>
<sql id="selectTBankSubjectVo">
select subject_id, bank_id, topic_title, topic_option, answer, datetime ,topic_type from t_bank_subject
</sql>
<select id="selectTBankSubjectList" parameterType="TBankSubject" resultMap="TBankSubjectResult">
<include refid="selectTBankSubjectVo"/>
<where>
<if test="bankId != null "> and bank_id = #{bankId}</if>
<!-- <if test="topicTitle != null and topicTitle != ''"> and topic_title = #{topicTitle}</if>-->
<!-- <if test="topicOption != null and topicOption != ''"> and topic_option = #{topicOption}</if>-->
<!-- <if test="answer != null "> and answer = #{answer}</if>-->
<!-- <if test="datetime != null "> and datetime = #{datetime}</if>-->
</where>
group by subject_id desc
</select>
<select id="selectTBankSubjectById" parameterType="Long" resultMap="TBankSubjectResult">
<include refid="selectTBankSubjectVo"/>
where subject_id = #{subjectId}
</select>
<insert id="insertTBankSubject" parameterType="TBankSubject" useGeneratedKeys="true" keyProperty="subjectId">
insert into t_bank_subject
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="bankId != null">bank_id,</if>
<if test="topicTitle != null">topic_title,</if>
<if test="topicOption != null">topic_option,</if>
<if test="answer != null">answer,</if>
<if test="datetime != null">datetime,</if>
<if test="topicType != null">topic_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bankId != null">#{bankId},</if>
<if test="topicTitle != null">#{topicTitle},</if>
<if test="topicOption != null">#{topicOption},</if>
<if test="answer != null">#{answer},</if>
<if test="datetime != null">#{datetime},</if>
<if test="topicType != null">#{topicType},</if>
</trim>
</insert>
<update id="updateTBankSubject" parameterType="TBankSubject">
update t_bank_subject
<trim prefix="SET" suffixOverrides=",">
<if test="bankId != null">bank_id = #{bankId},</if>
<if test="topicTitle != null">topic_title = #{topicTitle},</if>
<if test="topicOption != null">topic_option = #{topicOption},</if>
<if test="answer != null">answer = #{answer},</if>
<if test="datetime != null">datetime = #{datetime},</if>
<if test="topicType != null">topic_type = #{topicType},</if>
</trim>
where subject_id = #{subjectId}
</update>
<delete id="deleteTBankSubjectById" parameterType="Long">
delete from t_bank_subject where subject_id = #{subjectId}
</delete>
<delete id="deleteTBankSubjectByIds" parameterType="String">
delete from t_bank_subject where subject_id in
<foreach item="subjectId" collection="array" open="(" separator="," close=")">
#{subjectId}
</foreach>
</delete>
<!--excel导入-->
<insert id="insertBank">
insert into t_bank_subject (bank_id,topic_title,topic_option,answer,datetime,topic_type)
values
<foreach collection="list" item="item" index= "index" separator =",">
( #{item.bankId},#{item.topicTitle},#{item.topicOption},#{item.answer},#{item.datetime},#{item.topicType})
</foreach>
</insert>
</mapper>
<?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.zehong.system.mapper.train.TTrainCourseBankMapper">
<resultMap type="TTrainCourseBank" id="TTrainCourseBankResult">
<result property="bankId" column="bank_id" />
<result property="deptId" column="dept_id" />
<result property="bankName" column="bank_name" />
<result property="isDel" column="is_del" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="numberQuestions" column="numberQuestions" />
</resultMap>
<sql id="selectTTrainCourseBankVo">
select bank_id, dept_id, bank_name, is_del, create_by, create_time, update_by, update_time from t_train_course_bank
</sql>
<select id="selectTTrainCourseBankList" parameterType="TTrainCourseBank" resultMap="TTrainCourseBankResult">
select a.*,count(b.subject_id) as numberQuestions
from t_train_course_bank a left join t_bank_subject b on a.bank_id=b.bank_id
<where>
<if test="bankName != null and bankName != ''"> and a.bank_name like concat('%', #{bankName}, '%')</if>
</where>
<where>
<if test="deptId != null and deptId != ''"> and a.dept_id = #{deptId} </if>
</where>
group by bank_id desc
</select>
<select id="selectTTrainCourseBankById" parameterType="Long" resultMap="TTrainCourseBankResult">
<include refid="selectTTrainCourseBankVo"/>
where bank_id = #{bankId}
</select>
<insert id="insertTTrainCourseBank" parameterType="TTrainCourseBank" useGeneratedKeys="true" keyProperty="bankId">
insert into t_train_course_bank
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deptId != null">dept_id,</if>
<if test="bankName != null">bank_name,</if>
<if test="isDel != null">is_del,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deptId != null">#{deptId},</if>
<if test="bankName != null">#{bankName},</if>
<if test="isDel != null">#{isDel},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateTTrainCourseBank" parameterType="TTrainCourseBank">
update t_train_course_bank
<trim prefix="SET" suffixOverrides=",">
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="bankName != null">bank_name = #{bankName},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where bank_id = #{bankId}
</update>
<delete id="deleteTTrainCourseBankById" parameterType="Long">
delete from t_train_course_bank where bank_id = #{bankId}
</delete>
<delete id="deleteTTrainCourseBankByIds" parameterType="String">
delete from t_train_course_bank where bank_id in
<foreach item="bankId" collection="array" open="(" separator="," close=")">
#{bankId}
</foreach>
</delete>
</mapper>
<?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.zehong.system.mapper.train.TTrainCourseMapper">
<resultMap type="TTrainCourse" id="TTrainCourseResult">
<result property="courseId" column="course_id" />
<result property="courseName" column="course_name" />
<result property="courseType" column="course_type" />
<result property="planName" column="plan_name" />
<result property="courseConent" column="course_conent" />
<result property="status" column="status" />
<result property="personnelType" column="personnel_type" />
<result property="releaseTime" column="release_time" />
<result property="enclosure" column="enclosure" />
<result property="video" column="video" />
<result property="qualifiedNum" column="qualified_num" />
<result property="topicNum" column="topic_num" />
<result property="createTime" column="create_time" />
<result property="createUser" column="create_user" />
<result property="isDel" column="is_del" />
<result property="dataKind" column="data_kind" />
<result property="testStartTime" column="test_start_time" />
<result property="testEndTime" column="test_end_time" />
<result property="testPersons" column="test_persons" />
<result property="duration" column="duration" />
<result property="multipleChoiceScore" column="multiple_choice_score" />
<result property="singleChoiceScore" column="single_choice_score" />
<result property="judgmentScore" column="judgment_score" />
<result property="isVeriftyFace" column="is_verifty_face" />
<result property="deptName" column="dept_name" />
</resultMap>
<resultMap id="StatisticsTrainCourseResult" type="StatisticsTrainCourse">
<result property="courseId" column="course_id" />
<result property="courseName" column="course_name" />
<result property="releaseTime" column="release_time" />
<result property="dataKind" column="data_kind" />
<result property="count" column="count" />
<result property="test" column="test" />
<result property="pass" column="pass" />
<result property="rate" column="rate" />
</resultMap>
<resultMap id="TNewsResult" type="TNews">
<result property="newsId" column="news_id" />
<result property="module" column="module" />
<result property="messageContent" column="message_content" />
<result property="publisherId" column="publisher_id" />
<result property="recipientId" column="recipient_id" />
<result property="releaseTime" column="release_time" />
<result property="readStatus" column="read_status" />
</resultMap>
<sql id="selectTTrainCourseVo">
select multiple_choice_score,single_choice_score,judgment_score,course_id, course_name, course_type, course_conent, status,personnel_type, release_time, enclosure, video, qualified_num, topic_num, create_time, create_user, is_del, data_kind, test_start_time, test_end_time, test_persons,duration,is_verifty_face,zhujiang,deptid from t_train_course
</sql>
<select id="selectTTrainCourseList" parameterType="TTrainCourse" resultMap="TTrainCourseResult">
select c.*,p.plan_name,d.dept_name from t_train_course c
left join sys_dept d on c.deptid=d.dept_id
LEFT JOIN t_train_plan p on p.plan_id = c.course_type
<where>
<if test="courseName != null and courseName != ''"> and c.course_name like concat('%', #{courseName}, '%')</if>
<if test="courseType != null "> and c.course_type = #{courseType}</if>
<if test="courseConent != null and courseConent != ''"> and c.course_conent = #{courseConent}</if>
<if test="status != null "> and c.status = #{status}</if>
<if test="enclosure != null and enclosure != ''"> and c.enclosure = #{enclosure}</if>
<if test="video != null and video != ''"> and c.video = #{video}</if>
<if test="qualifiedNum != null "> and c.qualified_num = #{qualifiedNum}</if>
<if test="topicNum != null "> and c.topic_num = #{topicNum}</if>
<if test="createUser != null and createUser != ''"> and c.create_user = #{createUser}</if>
<if test="isDel != null "> and c.is_del = #{isDel}</if>
<if test="dataKind != null and dataKind != ''"> and data_kind = #{dataKind}</if>
<if test="dataKind == null and dataKind != ''"> and data_kind != '1'</if>
<if test="testStartTime != null "> and test_start_time = #{testStartTime}</if>
<if test="testEndTime != null "> and test_end_time = #{testEndTime}</if>
<if test="testPersons != null and testPersons != ''"> and test_persons = #{testPersons}</if>
<if test="zhujiang != null and zhujiang != ''"> and zhujiang like concat('%', #{zhujiang}, '%')</if>
<if test="deptId != null and deptId != ''"> and deptid = #{deptId}</if>
</where>
order by create_time desc
</select>
<select id="selectTTrainCourseById" parameterType="Long" resultMap="TTrainCourseResult">
<include refid="selectTTrainCourseVo"/>
where course_id = #{courseId}
</select>
<insert id="insertTTrainCourse" parameterType="TTrainCourse" useGeneratedKeys="true" keyProperty="courseId">
insert into t_train_course
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="courseName != null">course_name,</if>
<if test="courseType != null">course_type,</if>
<if test="courseConent != null">course_conent,</if>
<if test="status != null">status,</if>
<if test="personnelType != null">personnel_type,</if>
<if test="releaseTime != null">release_time,</if>
<if test="enclosure != null">enclosure,</if>
<if test="video != null">video,</if>
<if test="qualifiedNum != null">qualified_num,</if>
<if test="topicNum != null">topic_num,</if>
<if test="createTime != null">create_time,</if>
<if test="createUser != null">create_user,</if>
<if test="isDel != null">is_del,</if>
<if test="dataKind != null">data_kind,</if>
<if test="testStartTime != null">test_start_time,</if>
<if test="testEndTime != null">test_end_time,</if>
<if test="testPersons != null">test_persons,</if>
<if test="duration != null">duration,</if>
<if test="multipleChoiceScore != null">multiple_choice_score,</if>
<if test="singleChoiceScore != null">single_choice_score,</if>
<if test="judgmentScore != null">judgment_score,</if>
<if test="isVeriftyFace != null">is_verifty_face,</if>
<if test="zhujiang != null">zhujiang,</if>
<if test="deptId != null">deptid,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="courseName != null">#{courseName},</if>
<if test="courseType != null">#{courseType},</if>
<if test="courseConent != null">#{courseConent},</if>
<if test="status != null">#{status},</if>
<if test="personnelType != null">#{personnelType},</if>
<if test="releaseTime != null">#{releaseTime},</if>
<if test="enclosure != null">#{enclosure},</if>
<if test="video != null">#{video},</if>
<if test="qualifiedNum != null">#{qualifiedNum},</if>
<if test="topicNum != null">#{topicNum},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createUser != null">#{createUser},</if>
<if test="isDel != null">#{isDel},</if>
<if test="dataKind != null">#{dataKind},</if>
<if test="testStartTime != null">#{testStartTime},</if>
<if test="testEndTime != null">#{testEndTime},</if>
<if test="testPersons != null">#{testPersons},</if>
<if test="duration != null">#{duration},</if>
<if test="multipleChoiceScore != null">#{multipleChoiceScore},</if>
<if test="singleChoiceScore != null">#{singleChoiceScore},</if>
<if test="judgmentScore != null">#{judgmentScore},</if>
<if test="isVeriftyFace != null">#{isVeriftyFace},</if>
<if test="zhujiang != null">#{zhujiang},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
<update id="updateTTrainCourse" parameterType="TTrainCourse">
update t_train_course
<trim prefix="SET" suffixOverrides=",">
<if test="courseName != null">course_name = #{courseName},</if>
<if test="courseType != null">course_type = #{courseType},</if>
<if test="courseConent != null">course_conent = #{courseConent},</if>
<if test="status != null">status = #{status},</if>
<if test="personnelType != null">personnel_type = #{personnelType},</if>
<if test="releaseTime != null">release_time = #{releaseTime},</if>
<if test="enclosure != null">enclosure = #{enclosure},</if>
<if test="video != null">video = #{video},</if>
<if test="qualifiedNum != null">qualified_num = #{qualifiedNum},</if>
<if test="topicNum != null">topic_num = #{topicNum},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createUser != null">create_user = #{createUser},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="dataKind != null">data_kind = #{dataKind},</if>
<if test="testStartTime != null">test_start_time = #{testStartTime},</if>
<if test="testEndTime != null">test_end_time = #{testEndTime},</if>
<if test="testPersons != null">test_persons = #{testPersons},</if>
<if test="duration != null">duration = #{duration},</if>
<if test="multipleChoiceScore != null">multiple_choice_score = #{multipleChoiceScore},</if>
<if test="singleChoiceScore != null">single_choice_score = #{singleChoiceScore},</if>
<if test="judgmentScore != null">judgment_score = #{judgmentScore},</if>
<if test="isVeriftyFace != null">is_verifty_face = #{isVeriftyFace},</if>
<if test="zhujiang != null">zhujiang=#{zhujiang},</if>
<if test="deptId != null">deptid=#{deptId},</if>
</trim>
where course_id = #{courseId}
</update>
<delete id="deleteTTrainCourseById" parameterType="Long">
delete from t_train_course where course_id = #{courseId}
</delete>
<delete id="deleteTTrainCourseByIds" parameterType="String">
delete from t_train_course where course_id in
<foreach item="courseId" collection="array" open="(" separator="," close=")">
#{courseId}
</foreach>
</delete>
<insert id="insertUserCourse">
INSERT INTO t_train_user_course(user_id,course_id,personnel_type,create_time) VALUES
<foreach collection="userIds" separator="," item="item">
(#{item},#{courseId},#{personnelType},NOW())
</foreach>
</insert>
<select id="userCourseList" resultType="com.zehong.system.domain.vo.UserCourseVo">
SELECT uc.user_course_id AS userCourseId,uc.state ,uc.examination_time AS examinationTime,uc.train_state AS trainState,c.is_verifty_face AS isVeriftyFace,
uc.`examination_result` AS examinationResult,uc.`create_time` AS createTime,c.test_start_time as testStartTime,c.test_end_time as testEndTime,
c.`course_name` AS courseName, c.`topic_num` AS topicNum,c.`release_time` AS releaseTime,c.data_kind as dataKind,c.personnel_type as personnelType,
p.`plan_name` AS courseType,c.course_id as courseId,c.qualified_num as qualifiedNum,c.multiple_choice_score as multipleChoiceScore,
c.judgment_score as judgmentScore,c.single_choice_score as singleChoiceScore
FROM t_train_user_course uc
LEFT JOIN t_train_course c ON c.`course_id` = uc.`course_id`
LEFT JOIN t_train_plan p ON p.`plan_id` = c.`course_type`
WHERE uc.user_id = #{userId} and uc.personnel_type =#{personnelType}
<if test="type!=null and type == 1">
and uc.state !=2
</if>
<if test="type!=null and type == 2">
and uc.state = 2
</if>
<if test="type!=null and type == 3">
and uc.state !=0
order by uc.examination_time desc
</if>
</select>
<select id="statisticsTrainCourse" parameterType="StatisticsTrainCourse" resultMap="StatisticsTrainCourseResult">
SELECT
course.course_id,
course.course_name,
course.release_time,
course.data_kind,
COUNT(user.user_course_id)AS count,
SUM(case when user.state > 0 then 1 else 0 end)AS test,
SUM(case when user.state = 2 then 1 else 0 end)AS pass,
ROUND(SUM(case when user.state = 2 then 1 else 0 end)/COUNT(user.user_course_id)*100)AS rate
FROM
t_train_course course
INNER JOIN t_train_user_course user ON course.course_id = user.course_id
<where>
course.status = '1' AND course.is_del = '0' AND course.personnel_type = '1' AND course.topic_num>0
<if test="courseName != null and courseName != ''"> and course.course_name like concat('%', #{courseName}, '%')</if>
<if test="dataKind != null and dataKind != ''"> and course.data_kind = #{dataKind}</if>
<if test="releaseTimeBegin != null and releaseTimeBegin != '' and releaseTimeEnd != null and releaseTimeEnd != ''"> and course.release_time BETWEEN #{releaseTimeBegin} AND #{releaseTimeEnd}</if>
</where>
GROUP BY course.course_id
</select>
<select id="userCourseLists" resultType="com.zehong.system.domain.vo.UserCourseVo">
SELECT uc.user_course_id AS userCourseId,uc.finish_duration AS finishDuration,uc.state ,uc.examination_time AS examinationTime,uc.train_state AS trainState,
uc.`examination_result` AS examinationResult,uc.`create_time` AS createTime,c.test_start_time as testStartTime,c.test_end_time as testEndTime,
c.`course_name` AS courseName, c.`topic_num` AS topicNum,c.`release_time` AS releaseTime,c.data_kind as dataKind,c.personnel_type as personnelType,
p.`plan_name` AS courseType,c.course_id as courseId,c.qualified_num as qualifiedNum,c.multiple_choice_score as multipleChoiceScore,
c.judgment_score as judgmentScore,c.single_choice_score as singleChoiceScore
FROM t_train_user_course uc
LEFT JOIN t_train_course c ON c.`course_id` = uc.`course_id`
LEFT JOIN t_train_plan p ON p.`plan_id` = c.`course_type`
WHERE uc.user_id = #{staffId} and uc.personnel_type ='1'
and data_kind=#{dataKind}
</select>
<!--消息添加-->
<insert id="insertNews">
insert into t_news (module_id,module,message_content,publisher_id,recipient_id,release_time)
values (#{moduleId},#{module},#{messageContent},#{publisherId},#{recipientId},#{releaseTime})
</insert>
<!--手机端 最新消息查询-->
<select id="selectLatestNews" resultMap="TNewsResult" >
select * from t_news where read_status='0'and recipient_id=#{recipientId} order by release_time desc limit 0,1
</select>
<!--手机端 查询历史消息-->
<select id="historicalMessages" resultMap="TNewsResult">
select * from t_news where read_status='1' and recipient_id=#{recipientId} order by release_time desc
</select>
<!--修改消息状态为已读-->
<update id="updateReadStatus">
update t_news set read_status='1' where news_id=#{newsId}
</update>
<!--查询接收人姓名-->
<select id="selectRecipient" resultType="java.lang.String">
select nick_name from sys_user where user_id=#{userid}
</select>
</mapper>
<?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.zehong.system.mapper.train.TTrainCourseTopicMapper">
<resultMap type="TTrainCourseTopic" id="TTrainCourseTopicResult">
<result property="topicId" column="topic_id" />
<result property="courseId" column="course_id" />
<result property="topicTitle" column="topic_title" />
<result property="topicOption" column="topic_option" />
<result property="answer" column="answer" />
<result property="createTime" column="create_time" />
<result property="topicType" column="topic_type" />
</resultMap>
<sql id="selectTTrainCourseTopicVo">
select topic_id, course_id, topic_title, topic_option, answer, create_time,topic_type from t_train_course_topic
</sql>
<select id="selectTTrainCourseTopicList" parameterType="TTrainCourseTopic" resultMap="TTrainCourseTopicResult">
<include refid="selectTTrainCourseTopicVo"/>
<where>
<if test="courseId != null "> and course_id = #{courseId}</if>
<if test="topicTitle != null and topicTitle != ''"> and topic_title = #{topicTitle}</if>
<if test="topicOption != null and topicOption != ''"> and topic_option = #{topicOption}</if>
<if test="answer != null "> and answer = #{answer}</if>
</where>
</select>
<select id="selectCourseTopicList" resultMap="TTrainCourseTopicResult">
select topic_id, course_id, topic_title, topic_option, answer, create_time,topic_type from t_train_course_topic
WHERE course_id = #{courseId}
</select>
<select id="selectTTrainCourseTopicById" parameterType="Long" resultMap="TTrainCourseTopicResult">
<include refid="selectTTrainCourseTopicVo"/>
where topic_id = #{topicId}
</select>
<insert id="insertTTrainCourseTopic" parameterType="TTrainCourseTopic">
insert into t_train_course_topic
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="topicId != null">topic_id,</if>
<if test="courseId != null">course_id,</if>
<if test="topicTitle != null">topic_title,</if>
<if test="topicOption != null">topic_option,</if>
<if test="answer != null">answer,</if>
<if test="createTime != null">create_time,</if>
<if test="topicType != null">topic_type</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="topicId != null">#{topicId},</if>
<if test="courseId != null">#{courseId},</if>
<if test="topicTitle != null">#{topicTitle},</if>
<if test="topicOption != null">#{topicOption},</if>
<if test="answer != null">#{answer},</if>
<if test="createTime != null">#{createTime},</if>
<if test="topicType != null">#{topicType},</if>
</trim>
</insert>
<update id="updateTTrainCourseTopic" parameterType="TTrainCourseTopic">
update t_train_course_topic
<trim prefix="SET" suffixOverrides=",">
<if test="courseId != null">course_id = #{courseId},</if>
<if test="topicTitle != null">topic_title = #{topicTitle},</if>
<if test="topicOption != null">topic_option = #{topicOption},</if>
<if test="answer != null">answer = #{answer},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="topicType != null">topic_type= #{topicType}</if>
</trim>
where topic_id = #{topicId}
</update>
<delete id="deleteTTrainCourseTopicById" parameterType="Long">
delete from t_train_course_topic where topic_id = #{topicId}
</delete>
<delete id="deleteTTrainCourseTopicByIds" parameterType="String">
delete from t_train_course_topic where topic_id in
<foreach item="topicId" collection="array" open="(" separator="," close=")">
#{topicId}
</foreach>
</delete>
<insert id="batchInsertTTrainCourseTopic" parameterType="java.util.List">
insert into t_train_course_topic(course_id,topic_title,topic_option,answer,create_time,topic_type) values
<foreach collection="list" item="topic" index="index" separator="," >
(#{topic.courseId},#{topic.topicTitle},#{topic.topicOption},#{topic.answer},#{topic.createTime},#{topic.topicType})
</foreach>
</insert>
</mapper>
<?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.zehong.system.mapper.train.TTrainPlanMapper">
<resultMap type="TTrainPlan" id="TTrainPlanResult">
<result property="planId" column="plan_id" />
<result property="planName" column="plan_name" />
<result property="sort" column="sort" />
<result property="personnelType" column="personnel_type" />
<result property="createTime" column="create_time" />
<result property="createUser" column="create_user" />
</resultMap>
<sql id="selectTTrainPlanVo">
select plan_id, plan_name, sort, create_time,personnel_type, create_user from t_train_plan
</sql>
<select id="selectTTrainPlanList" parameterType="TTrainPlan" resultMap="TTrainPlanResult">
<include refid="selectTTrainPlanVo"/>
<where>
<if test="planName != null and planName != ''"> and plan_name like concat('%', #{planName}, '%')</if>
<if test="sort != null "> and sort = #{sort}</if>
<if test="createUser != null and createUser != ''"> and create_user = #{createUser}</if>
</where>
</select>
<select id="selectTTrainPlanById" parameterType="Long" resultMap="TTrainPlanResult">
<include refid="selectTTrainPlanVo"/>
where plan_id = #{planId}
</select>
<insert id="insertTTrainPlan" parameterType="TTrainPlan" useGeneratedKeys="true" keyProperty="planId">
insert into t_train_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="planId != null">plan_id,</if>
<if test="planName != null">plan_name,</if>
<if test="sort != null">sort,</if>
<if test="personnelType != null">personnel_type,</if>
<if test="createTime != null">create_time,</if>
<if test="createUser != null">create_user,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="planId != null">#{planId},</if>
<if test="planName != null">#{planName},</if>
<if test="sort != null">#{sort},</if>
<if test="personnelType != null">#{personnelType},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createUser != null">#{createUser},</if>
</trim>
</insert>
<insert id="insetsPlanPost">
INSERT INTO t_train_plan_post(plan_id,post_id) VALUES
<foreach collection="list" separator="," item="item">
(#{planId},#{item.peoPleId})
</foreach>
</insert>
<delete id="deletePlanPost" >
DELETE FROM t_train_plan_post WHERE plan_id = #{planId}
</delete>
<update id="updateTTrainPlan" parameterType="TTrainPlan">
update t_train_plan
<trim prefix="SET" suffixOverrides=",">
<if test="planName != null">plan_name = #{planName},</if>
<if test="sort != null">sort = #{sort},</if>
<if test="personnelType != null">personnel_type = #{personnelType},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createUser != null">create_user = #{createUser},</if>
</trim>
where plan_id = #{planId}
</update>
<delete id="deleteTTrainPlanById" parameterType="Long">
delete from t_train_plan where plan_id = #{planId}
</delete>
<delete id="deleteTTrainPlanByIds" parameterType="String">
delete from t_train_plan where plan_id in
<foreach item="planId" collection="array" open="(" separator="," close=")">
#{planId}
</foreach>
</delete>
<select id="selectTrainPostByPlanId" parameterType="Long" resultType="com.zehong.system.domain.vo.PlanPostVo">
SELECT u.user_id AS postId, u.staff_name AS postName,TRUE AS ischeck FROM
t_train_plan_post p LEFT JOIN sys_user u ON u.`user_id` = p.`post_id`
WHERE p.`plan_id` = #{planId}
</select>
<select id="selectAlluserByplanId" resultType="java.lang.String">
SELECT post_id FROM t_train_plan_post WHERE plan_id =#{planId}
</select>
</mapper>
\ No newline at end of file
<?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.zehong.system.mapper.train.TTrainUserCourseMapper">
<resultMap type="TTrainUserCourse" id="TTrainUserCourseResult">
<result property="userCourseId" column="user_course_id" />
<result property="userId" column="user_id" />
<result property="courseId" column="course_id" />
<result property="state" column="state" />
<result property="personnelType" column="personnel_type" />
<result property="examinationTime" column="examination_time" />
<result property="examinationResult" column="examination_result" />
<result property="createTime" column="create_time" />
<result property="createUser" column="create_user" />
<result property="staffName" column="staff_name"/>
<result property="deptName" column="dept_name"/>
<result property="finishDuration" column="finish_duration"/>
<result property="trainState" column="train_state"/>
<result property="states" column="states"/>
</resultMap>
<sql id="selectTTrainUserCourseVo">
select user_course_id, user_id, course_id, state, examination_time, personnel_type,examination_result, create_time, create_user,finish_duration,train_state from t_train_user_course
</sql>
<select id="selectTTrainUserCourseList" parameterType="TTrainUserCourse" resultMap="TTrainUserCourseResult">
<include refid="selectTTrainUserCourseVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="courseId != null "> and course_id = #{courseId}</if>
<if test="state != null "> and state = #{state}</if>
<if test="examinationTime != null "> and examination_time = #{examinationTime}</if>
<if test="examinationResult != null "> and examination_result = #{examinationResult}</if>
<if test="createUser != null and createUser != ''"> and create_user = #{createUser}</if>
</where>
</select>
<select id="selectTTrainUserCourseById" parameterType="Long" resultMap="TTrainUserCourseResult">
<include refid="selectTTrainUserCourseVo"/>
where user_course_id = #{userCourseId}
</select>
<insert id="insertTTrainUserCourse" parameterType="TTrainUserCourse" useGeneratedKeys="true" keyProperty="userCourseId">
insert into t_train_user_course
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="courseId != null">course_id,</if>
<if test="state != null">state,</if>
<if test="personnelType != null">personnel_type,</if>
<if test="examinationTime != null">examination_time,</if>
<if test="examinationResult != null">examination_result,</if>
<if test="createTime != null">create_time,</if>
<if test="createUser != null">create_user,</if>
<if test="finishDuration != null">finish_duration,</if>
<if test="trainState != null">train_state,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
<if test="courseId != null">#{courseId},</if>
<if test="state != null">#{state},</if>
<if test="personnelType != null">#{personnelType},</if>
<if test="examinationTime != null">#{examinationTime},</if>
<if test="examinationResult != null">#{examinationResult},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createUser != null">#{createUser},</if>
<if test="finishDuration != null">#{finishDuration},</if>
<if test="trainState != null">#{trainState},</if>
</trim>
</insert>
<update id="updateTTrainUserCourse" parameterType="TTrainUserCourse">
update t_train_user_course
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="courseId != null">course_id = #{courseId},</if>
<if test="state != null">state = #{state},</if>
<if test="personnelType != null">personnel_type = #{personnelType},</if>
<if test="examinationTime != null">examination_time = #{examinationTime},</if>
<if test="examinationResult != null">examination_result = #{examinationResult},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createUser != null">create_user = #{createUser},</if>
<if test="finishDuration != null">finish_duration = #{finishDuration},</if>
<if test="trainState != null">train_state = #{trainState},</if>
</trim>
where user_course_id = #{userCourseId}
</update>
<delete id="deleteTTrainUserCourseById" parameterType="Long">
delete from t_train_user_course where user_course_id = #{userCourseId}
</delete>
<delete id="deleteTTrainUserCourseByIds" parameterType="String">
delete from t_train_user_course where user_course_id in
<foreach item="userCourseId" collection="array" open="(" separator="," close=")">
#{userCourseId}
</foreach>
</delete>
<select id="testPersonDetailByCourseId" parameterType="Long" resultMap="TTrainUserCourseResult">
SELECT
sys.staff_name,
d.dept_name,
train.examination_result,
train.state,
train.examination_time
FROM
t_train_user_course train
LEFT JOIN sys_user sys ON train.user_id = sys.user_id
left join sys_dept d on sys.dept_id = d.dept_id
WHERE train.course_id = #{courseId}
</select>
<!--导出所有考试详细数据项-->
<select id="examDetails" parameterType="Long" resultMap="TTrainUserCourseResult">
SELECT
sys.staff_name,
d.dept_name,
train.examination_result,
train.examination_result,
CASE
WHEN train.state = 0 THEN
'未考试'
WHEN train.state = 1 THEN
'未通过'
WHEN train.state = 2 THEN
'已通过'
END AS states ,
train.examination_time
FROM
t_train_user_course train
LEFT JOIN sys_user sys ON train.user_id = sys.user_id
left join sys_dept d on sys.dept_id = d.dept_id
WHERE train.course_id = #{courseId}
</select>
</mapper>
......@@ -39,7 +39,7 @@
"clipboard": "2.0.6",
"core-js": "^3.19.1",
"echarts": "4.9.0",
"element-ui": "2.15.0",
"element-ui": "^2.15.10",
"file-saver": "2.0.4",
"fuse.js": "6.4.3",
"highlight.js": "9.18.5",
......
import request from '@/utils/request'
import { praseStrEmpty } from "@/utils/zehong";
// 查询员工信息管理列表
export function listStaff(query) {
return request({
url: '/baseInfo/staff/list',
method: 'get',
params: query
})
}
// 查询员工信息管理列表
export function listAllStaff(query) {
return request({
url: '/baseInfo/staff/allList',
method: 'get',
params: query
})
}
// 查询员工用户课程列表 无分页
export function TStaffLisst(query) {
return request({
url: '/baseInfo/staff/userCourseList',
method: 'get',
params: query
})
}
// 查询员工信息管理列表 无分页
export function TStaffList(query) {
return request({
url: '/baseInfo/staff/TStaffList',
method: 'get',
params: query
})
}
// 查询员工信息管理详细
export function getStaff(staffId) {
return request({
url: '/baseInfo/staff/' + praseStrEmpty(staffId),
method: 'get'
})
}
// 新增员工信息管理
export function addStaff(data) {
return request({
url: '/baseInfo/staff',
method: 'post',
data: data
})
}
// 修改员工信息管理
export function updateStaff(data) {
return request({
url: '/baseInfo/staff',
method: 'put',
data: data
})
}
// 删除员工信息管理
export function delStaff(staffId) {
return request({
url: '/baseInfo/staff/' + staffId,
method: 'delete'
})
}
// 导出员工信息管理
export function exportStaff(query) {
return request({
url: '/baseInfo/staff/export',
method: 'get',
params: query
})
}
/*
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-23 11:02:24
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-01-29 14:53:07
* @FilePath: /danger-manage-web/src/api/train/trainingProgram.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import request from '@/utils/request'
//培训计划管理
// 获取所有课程
export function getLessons(query) {
return request({
url: '/train/course/list',
method: 'get',
params: query
})
}
// 当前用户的课程列表
export function getUserLessons(query) {
return request({
url: 'train/course/userCourseList',
method: 'get',
params: query
})
}
// 用id查询课程
export function getLessonById(id) {
return request({
url: 'train/course/'+id,
method: 'get',
})
}
//用户课程状态
export function getUserLessonById(query) {
return request({
url: 'train/course/userCourse',
method: 'get',
params: query
})
}
// 添加课程
export function addLessons(data) {
return request({
url: '/train/course',
method: 'post',
data: data
})
}
// // 修改课程
export function changeLesson(data) {
return request({
url: '/train/course',
method: 'put',
data:data
})
}
// // 修改用户课程
export function changeUserLesson(data) {
return request({
url: '/train/course/editUserCourse',
method: 'put',
data:data
})
}
// 发布课程
export function issue(query) {
return request({
url: '/train/course/release',
method: 'get',
params: query
})
}
// 删除课程
export function deleteLesson(query) {
return request({
url: '/train/course/'+query,
method: 'delete',
})
}
//考试发布
export function testPublish(data) {
return request({
url: '/train/course/testPublish',
method: 'post',
data:data
})
}
// 获取课程的题目详情列表列表
export function getQuestion(query) {
return request({
url: '/train/topic/list',
method: 'get',
params: query
})
}
// 添加课程考试题目
export function addQuestion(data) {
return request({
url: '/train/topic',
method: 'post',
data: data
})
}
// 修改课程考试题目
export function changeQuestion(data) {
return request({
url: '/train/topic',
method: 'put',
data: data
})
}
// 删除
export function deleteQuestion(query) {
return request({
url: 'train/topic/'+query,
method: 'delete',
// params: query
})
}
// 查看单独题目
export function checkQuestion(query) {
return request({
url: '/train/topic/'+query,
method: 'get',
})
}
// 考试的题目
export function userQuestionList(query) {
return request({
url: '/train/topic/topiclist',
method: 'get',
params: query
})
}
// 交卷
export function setAnswer(query) {
return request({
url: '/train/course/examination',
method: 'get',
params: query
})
}
//统计
export function statisticsTrainCourse(query) {
return request({
url: '/train/course/statisticsTrainCourse',
method: 'get',
params: query
})
}
//成绩详情
export function testPersonDetailByCourseId(query) {
return request({
url: '/train/course/testPersonDetailByCourseId',
method: 'get',
params: query
})
}
/**
* 从题库导入试题
* @param data
*/
export function bachAddTopic(data) {
return request({
url: 'train/topic/bachAddTopic',
method: 'post',
data: data
})
}
/*export function bachAddTopicGuest(data) {
return request({
url: '/contractTrainTopic/bachAddTopic',
method: 'post',
data: data
})
}*/
export function exportDeviceInfo(query) {
return request({
url: '/train/course/examDetails',
method: 'get',
params: query
})
}
import request from '@/utils/request'
// 查询bank列表
export function listBank(query) {
return request({
url: '/train/bank/list',
method: 'get',
params: query
})
}
// 查询bank详细
export function getBank(bankId) {
return request({
url: '/train/bank/' + bankId,
method: 'get'
})
}
// 新增bank
export function addBank(data) {
return request({
url: '/train/bank',
method: 'post',
data: data
})
}
// 修改bank
export function updateBank(data) {
return request({
url: '/train/bank',
method: 'put',
data: data
})
}
// 删除bank
export function delBank(bankId) {
return request({
url: '/train/bank/' + bankId,
method: 'delete'
})
}
// 导出bank
export function exportBank(query) {
return request({
url: '/train/bank/export',
method: 'get',
params: query
})
}
import request from '@/utils/request'
// 查询题库题目列表
export function listSubject(query) {
return request({
url: '/train/subject/list',
method: 'get',
params: query
})
}
// 查询题库题目详细
export function getSubject(subjectId) {
return request({
url: '/train/subject/' + subjectId,
method: 'get'
})
}
// 新增题库题目
export function addSubject(data) {
return request({
url: '/train/subject',
method: 'post',
data: data
})
}
// 修改题库题目
export function updateSubject(data) {
return request({
url: '/train/subject',
method: 'put',
data: data
})
}
// 删除题库题目
export function delSubject(subjectId) {
return request({
url: '/train/subject/' + subjectId,
method: 'delete'
})
}
// 导出题库题目
export function exportSubject(query) {
return request({
url: '/train/subject/export',
method: 'get',
params: query
})
}
/*
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-23 11:02:24
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-09-28 16:58:26
* @FilePath: /danger-manage-web/src/api/train/trainingProgram.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import request from '@/utils/request'
//培训计划管理
// 获取所有培训人员类型
export function getPersonnel(query) {
return request({
url: '/system/post/optionselect',
method: 'get',
params: query
})
}
// 新增培训计划
export function addPlan(data) {
return request({
url: '/train/plan',
method: 'post',
data: data
})
}
// 编辑培训计划
export function editPlan(data) {
return request({
url: '/train/plan',
method: 'put',
data: data
})
}
// 培训计划列表
export function getPlanList(query) {
return request({
url: '/train/plan/list',
method: 'get',
params: query
})
}
// 培训计划列表
export function deletePlan(query) {
return request({
url: '/train/plan/deleteOne',
method: 'delete',
params: query
})
}
export function getPlan(query) {
return request({
url: '/train/plan/'+ query,
method: 'get',
})
}
......@@ -189,3 +189,12 @@ aside {
.multiselect--active {
z-index: 1000 !important;
}
.flex{
display: flex;
}
.all-flex-h {
display: flex;
flex-direction: column;
}
/**
* 通用css样式布局处理
* Copyright (c) 2019 zehong
*/
/**
* 通用css样式布局处理
* Copyright (c) 2019 zehong
*/
/** 基础通用 **/
/** 基础通用 **/
.pt5 {
padding-top: 5px;
}
.pr5 {
padding-right: 5px;
}
.pb5 {
padding-bottom: 5px;
}
.mt5 {
margin-top: 5px;
}
.mr5 {
margin-right: 5px;
}
.mb5 {
margin-bottom: 5px;
}
.mb8 {
margin-bottom: 8px;
}
.ml5 {
margin-left: 5px;
}
.mt10 {
margin-top: 10px;
}
.mr10 {
margin-right: 10px;
}
.mb10 {
margin-bottom: 10px;
}
.ml0 {
margin-left: 10px;
}
.mt20 {
margin-top: 20px;
}
.mr20 {
margin-right: 20px;
}
.mb20 {
margin-bottom: 20px;
}
.m20 {
margin-left: 20px;
}
.el-dialog:not(.is-fullscreen){
.el-dialog:not(.is-fullscreen) {
margin-top: 6vh !important;
}
.el-table {
.el-table__header-wrapper, .el-table__fixed-header-wrapper {
.el-table__header-wrapper,
.el-table__fixed-header-wrapper {
th {
word-break: break-word;
background-color: #f8f8f9;
......@@ -67,8 +84,9 @@
font-size: 13px;
}
}
.el-table__body-wrapper {
.el-button [class*="el-icon-"] + span {
.el-button [class*="el-icon-"]+span {
margin-left: 1px;
}
}
......@@ -76,11 +94,11 @@
/** 表单布局 **/
.form-header {
font-size:15px;
color:#6379bb;
border-bottom:1px solid #ddd;
margin:8px 10px 25px 10px;
padding-bottom:5px
font-size: 15px;
color: #6379bb;
border-bottom: 1px solid #ddd;
margin: 8px 10px 25px 10px;
padding-bottom: 5px
}
/** 表格布局 **/
......@@ -97,7 +115,7 @@
margin-top: 5px;
border: 1px solid #e5e6e7;
background: #FFFFFF none;
border-radius:4px;
border-radius: 4px;
}
.pagination-container .el-pagination {
......@@ -111,11 +129,11 @@
width: inherit;
}
.el-tree-node__content > .el-checkbox {
.el-tree-node__content>.el-checkbox {
margin-right: 8px;
}
.list-group-striped > .list-group-item {
.list-group-striped>.list-group-item {
border-left: 0;
border-right: 0;
border-radius: 0;
......@@ -227,13 +245,195 @@
}
/* 拖拽列样式 */
.sortable-ghost{
.sortable-ghost {
opacity: .8;
color: #fff!important;
background: #42b983!important;
color: #fff !important;
background: #42b983 !important;
}
.top-right-btn {
position: relative;
float: right;
}
.el-message-box {
.el-message-box__btns {
position: relative;
button {
position: relative;
left: 67px;
&.el-button--primary {
left: -67px;
}
}
}
}
// 多余部分省略号
.zzz {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.video-js .vjs-big-play-button {
margin-top: -0.75em !important;
top: 50% !important;
left: 50% !important;
margin-left: -1.5em !important;
}
// 课后考试的title样式
.answerLesson {
.el-dialog__title {
font-size: 16px;
color: #101010;
}
.el-dialog__close {
color: #101010;
}
.el-dialog {
max-width: 1105px;
}
.el-dialog__body {
padding: 0;
}
.el-dialog__header {
padding-bottom: 0;
}
.el-dialog__footer {
padding-right: 50px !important;
}
}
// 添加新课程的dilog
.add-lession {
.el-dialog__title {
font-size: 16px;
color: #101010;
}
.el-dialog__header {
padding-left: 36px;
}
.el-dialog__body {
padding: 0;
}
.el-dialog__header {
padding-bottom: 0;
}
.el-dialog__footer {
padding-right: 50px !important;
}
}
.noAttr {
.el-form-item__label-wrap {
label {
color: #1890ff;
}
}
}
// 这个下面的p标签取消padding
.check-lession {
p {
margin: 0;
}
}
// text-Paper lession.vue table样式
.left-middle-table {
.el-table th.el-table__cell.is-leaf,
.el-table td.el-table__cell {
border: none
}
.has-gutter .el-table th.el-table__cell.is-leaf,
.el-table td.el-table__cell {
border-bottom: 1px solid #E5E6EB;
}
.el-table th.el-table__cell.is-leaf,
.el-table td.el-table__cell {
box-sizing: border-box;
}
.el-table--medium .el-table__cell:nth-child(1) {
padding: 0;
}
.el-table .el-table__header-wrapper th,
.el-table .el-table__fixed-header-wrapper th {
background-color: #F7F7F7;
}
.el-table--fit {
// height: 100%;
}
.el-table th.el-table__cell>.cell {
padding-left: 14px;
}
.el-table::before {
height: 0px;
}
// 表头的input样式
.el-checkbox__input.is-indeterminate .el-checkbox__inner {
background-color: rgba(0, 0, 0, 0);
border-color: #C4C4C4;
}
.el-checkbox__input.is-indeterminate .el-checkbox__inner:before{
background-color:#62656C !important;
}
// 内容的
// 改变对钩颜色
.el-checkbox__inner:after {
border-color: #62656C !important;
}
.el-checkbox__inner {
border: 1px solid #C4C4C4;
}
.el-checkbox__input.is-checked .el-checkbox__inner {
background-color: rgba(0, 0, 0, 0);
border-color: #C4C4C4;
}
.el-checkbox__input.is-checked .el-checkbox__inner {
border-color: #C4C4C4;
}
.el-checkbox__input.is-focus .el-checkbox__inner {
border-color: #C4C4C4;
}
.el-checkbox__inner:hover {
border-color: #C4C4C4;
}
}
......@@ -2,30 +2,58 @@
<div class="upload-file">
<el-upload
:action="uploadFileUrl"
:disabled="disabled"
:before-upload="handleBeforeUpload"
:file-list="fileList"
:file-list="fileArr"
:limit="1"
:fileType="fileType"
:list-type="listType"
:on-error="handleUploadError"
:on-exceed="handleExceed"
:on-success="handleUploadSuccess"
:show-file-list="false"
:on-remove="handleRemove"
:on-preview="handleFileClick"
:on-change="fileChange"
:show-file-list="true"
:headers="headers"
class="upload-file-uploader"
:class="{ hide: fileArr.length > 0 || addShow }"
ref="upload"
>
<!-- 上传按钮 -->
<el-button size="mini" type="primary">选取文件</el-button>
<el-button :disabled="disabled" plain type="primary">选取文件</el-button>
<!--<i class="el-icon-plus"></i>-->
<!-- 上传提示 -->
<div class="el-upload__tip" slot="tip" v-if="showTip">
请上传
<template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
<template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
的文件
<template v-if="fileSize">
大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b>
</template>
<template v-if="fileType">
格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b>
</template>
的文件,且不超过一个
</div>
</el-upload>
<el-image
v-show="false"
id="img"
ref="previewImg"
:src="dialogImageUrl"
:preview-src-list="bigImageArr"
:z-index="9999999"
></el-image>
<!-- <el-dialog
:center="true"
width="50%"
:modal="modal"
:visible.sync="dialogVisible"
>
<img :src="dialogImageUrl" alt="" />
</el-dialog> -->
<!-- 文件列表 -->
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
<!-- <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
<li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in list">
<el-link :href="file.url" :underline="false" target="_blank">
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
......@@ -34,21 +62,29 @@
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
</div>
</li>
</transition-group>
</transition-group> -->
</div>
</template>
<script>
import { getToken } from "@/utils/auth";
import { getToken } from "@/utils/auth";
export default {
export default {
props: {
// 值
value: [String, Object, Array],
listType: {
type: String,
defaule: "text",
},
// 大小限制(MB)
fileSize: {
type: Number,
default: 5,
default: 50,
},
fileArr: {
type: Array,
default: [],
},
// 文件类型, 例如['png', 'jpg', 'jpeg']
fileType: {
......@@ -58,8 +94,12 @@ export default {
// 是否显示提示
isShowTip: {
type: Boolean,
default: true
}
default: true,
},
disabled: {
type: Boolean,
default:false,
},
},
data() {
return {
......@@ -68,6 +108,10 @@ export default {
Authorization: "Bearer " + getToken(),
},
fileList: [],
modal: false,
dialogVisible: false,
dialogImageUrl: "",
addShow: true,
};
},
computed: {
......@@ -94,6 +138,9 @@ export default {
return [];
}
},
bigImageArr() {
return [this.dialogImageUrl];
},
},
methods: {
// 上传前校检格式和大小
......@@ -110,7 +157,9 @@ export default {
return false;
});
if (!isTypeOk) {
this.$message.error(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
this.$message.error(
`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`
);
return false;
}
}
......@@ -135,12 +184,42 @@ export default {
// 上传成功回调
handleUploadSuccess(res, file) {
this.$message.success("上传成功");
this.$emit("input", res.url);
this.$emit("resFun", res);
},
// 文件列表移除文件
handleRemove(file, fileList) {
console.log("列表移除", file, fileList);
this.addShow = fileList.length > 0 ? true : false;
this.$emit("remove", file);
},
// 删除文件
handleDelete(index) {
this.fileList.splice(index, 1);
this.$emit("input", '');
this.$emit("input", "");
// let that = this,
// param;
// param = file.response ? file.response.fileName.replace(/\\/g, "%")
// : file.response.url.replace(/\\/g, "%").slice(9);
// $.ajax({
// type: "GET",
// url: process.env.VUE_APP_BASE_API + "/common/deleteFile",
// data: {savePath: param},
// dataType: "json",
// success: function(data){
// if (data) that.$message.success("删除成功");
// else return false;
// }
// });
},
handleFileClick(file, fileList) {
this.dialogImageUrl = file.response ? file.response.url : file.url;
// this.dialogImageUrl =if(this.fileArr) this.fileArr[0].url;
// this.dialogVisible = true;
this.$refs.previewImg.showViewer = false;
console.log(file);
// console.log(file.response.url)
},
// 获取文件名称
getFileName(name) {
......@@ -149,31 +228,40 @@ export default {
} else {
return "";
}
}
},
// 当改变列表改变时
fileChange(file, fileList) {
this.addShow = fileList.length > 0 ? true : false;
},
},
created() {
this.fileList = this.list;
console.log(this.fileArr);
// this.fileList = this.list;
this.addShow = this.fileArr.length > 0 ? true : false;
},
};
};
</script>
<style scoped lang="scss">
.upload-file-uploader {
img {
width: 100%;
}
.upload-file-uploader {
margin-bottom: 5px;
}
.upload-file-list .el-upload-list__item {
}
.upload-file-list .el-upload-list__item {
border: 1px solid #e4e7ed;
line-height: 2;
margin-bottom: 10px;
position: relative;
}
.upload-file-list .ele-upload-list__item-content {
}
.upload-file-list .ele-upload-list__item-content {
display: flex;
justify-content: space-between;
align-items: center;
color: inherit;
}
.ele-upload-list__item-content-action .el-link {
}
.ele-upload-list__item-content-action .el-link {
margin-right: 10px;
}
}
</style>
<template>
<div class="upload-file">
<el-upload
:action="uploadFileUrl"
:before-upload="handleBeforeUpload"
:file-list="fileArr"
:limit="1"
:list-type="listType"
:on-error="handleUploadError"
:on-exceed="handleExceed"
:on-success="handleUploadSuccess"
:on-remove="handleRemove"
:on-preview="handleFileClick"
:on-change="fileChange"
:show-file-list="true"
:headers="headers"
class="upload-file-uploader"
:class="{ hide: fileArr.length>0 ||addShow }"
ref="upload"
:disabled="readOnly"
>
<!-- 上传按钮 -->
<!-- <el-button size="mini" icon="" type="primary"></el-button> -->
<i class="el-icon-plus"></i>
<!-- 上传提示 -->
<div class="el-upload__tip" slot="tip" v-if="showTip">
请上传
<template v-if="fileSize">
大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b>
</template>
<template v-if="fileType">
格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b>
</template>
的文件
</div>
</el-upload>
<el-image v-show="false"
id="img"
ref="previewImg"
:src="dialogImageUrl"
:preview-src-list="bigImageArr"
:z-index="9999999"
></el-image>
<!-- <el-dialog
:center="true"
width="50%"
:modal="modal"
:visible.sync="dialogVisible"
>
<img :src="dialogImageUrl" alt="" />
</el-dialog> -->
<!-- 文件列表 -->
<!-- <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
<li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in list">
<el-link :href="file.url" :underline="false" target="_blank">
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
</el-link>
<div class="ele-upload-list__item-content-action">
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
</div>
</li>
</transition-group> -->
</div>
</template>
<script>
import { getToken } from "@/utils/auth";
export default {
props: {
// 值
value: [String, Object, Array],
listType: {
type: String,
defaule: "text",
},
// 大小限制(MB)
fileSize: {
type: Number,
default: 5,
},
fileArr: {
type: Array,
default: [],
},
// 文件类型, 例如['png', 'jpg', 'jpeg']
fileType: {
type: Array,
// default: () => ["doc", "xls", "ppt", "txt", "pdf", "png", "jpg", "jpeg"],
default: () => ["png", "jpg", "jpeg", "gif"],
},
// 是否显示提示
isShowTip: {
type: Boolean,
default: true,
},
readOnly: false
},
data() {
return {
uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
headers: {
Authorization: "Bearer " + getToken(),
},
fileList: [],
modal: false,
dialogVisible: false,
dialogImageUrl: "",
addShow: true,
};
},
computed: {
// 是否显示提示
showTip() {
return this.isShowTip && (this.fileType || this.fileSize);
},
// 列表
list() {
let temp = 1;
if (this.value) {
// 首先将值转为数组
const list = Array.isArray(this.value) ? this.value : [this.value];
// 然后将数组转为对象数组
return list.map((item) => {
if (typeof item === "string") {
item = { name: item, url: item };
}
item.uid = item.uid || new Date().getTime() + temp++;
return item;
});
} else {
this.fileList = [];
return [];
}
},
bigImageArr() {
return [this.dialogImageUrl]
},
},
methods: {
// 上传前校检格式和大小
handleBeforeUpload(file) {
// 校检文件类型
if (this.fileType) {
let fileExtension = "";
if (file.name.lastIndexOf(".") > -1) {
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
}
const isTypeOk = this.fileType.some((type) => {
if (file.type.indexOf(type) > -1) return true;
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
return false;
});
if (!isTypeOk) {
this.$message.error(
`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`
);
return false;
}
}
// 校检文件大小
if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize;
if (!isLt) {
this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`);
return false;
}
}
return true;
},
// 文件个数超出
handleExceed() {
this.$message.error(`只允许上传单个文件`);
},
// 上传失败
handleUploadError(err) {
this.$message.error("上传失败, 请重试");
},
// 上传成功回调
handleUploadSuccess(res, file) {
this.$message.success("上传成功");
this.$emit("resFun", res);
},
// 文件列表移除文件
handleRemove(file, fileList) {
console.log("列表移除", file, fileList);
this.addShow = fileList.length > 0 ? true : false;
this.$emit("remove", file);
},
// 删除文件
handleDelete(index) {
this.fileList.splice(index, 1);
this.$emit("input", "");
// let that = this,
// param;
// param = file.response ? file.response.fileName.replace(/\\/g, "%")
// : file.response.url.replace(/\\/g, "%").slice(9);
// $.ajax({
// type: "GET",
// url: process.env.VUE_APP_BASE_API + "/common/deleteFile",
// data: {savePath: param},
// dataType: "json",
// success: function(data){
// if (data) that.$message.success("删除成功");
// else return false;
// }
// });
},
handleFileClick(file, fileList) {
this.dialogImageUrl = file.response ? file.response.url : file.url;
// this.dialogImageUrl =if(this.fileArr) this.fileArr[0].url;
// this.dialogVisible = true;
this.$refs.previewImg.showViewer = true;
console.log(file);
// console.log(file.response.url)
},
// 获取文件名称
getFileName(name) {
if (name.lastIndexOf("/") > -1) {
return name.slice(name.lastIndexOf("/") + 1).toLowerCase();
} else {
return "";
}
},
// 当改变列表改变时
fileChange(file, fileList) {
this.addShow = fileList.length > 0 ? true : false;
},
},
created() {
// this.fileList = this.list;
this.addShow = this.fileArr.length > 0 ? true : false;
},
};
</script>
<style scoped lang="scss">
img {
width: 100%;
}
.upload-file-uploader {
margin-bottom: 5px;
}
.upload-file-list .el-upload-list__item {
border: 1px solid #e4e7ed;
line-height: 2;
margin-bottom: 10px;
position: relative;
}
.upload-file-list .ele-upload-list__item-content {
display: flex;
justify-content: space-between;
align-items: center;
color: inherit;
}
.ele-upload-list__item-content-action .el-link {
margin-right: 10px;
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-12-19 15:23:58
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-02-01 17:24:30
* @FilePath: /danger-manage-web/src/views/educationPlanExam/textPaper/components/Lesson-table.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div>
<el-table
v-loading="loading"
:data="nameList"
height="305"
@select="select"
@select-all="all"
ref="multipleTable"
>
<el-table-column
v-if='!disabled'
type="selection"
></el-table-column>
<el-table-column label="姓名" align="center" prop="staffName">
</el-table-column>
<el-table-column
label="所属部门"
align="center"
prop="deptName"
:formatter="formatter"
>
</el-table-column>
<el-table-column
label="岗位"
align="center"
prop="profession"
:formatter="formatter"
>
</el-table-column>
</el-table>
<!-- <div> -->
<el-pagination
:layout="'prev, pager, next'"
v-show="total > 0"
:total="total"
:current-page="queryParams.pageNum"
:page-sizes="[queryParams.pageSize]"
@current-change="currentChangeClick"
/>
<!-- </div> -->
</div>
</template>
<script>
import { listStaff } from "@/api/baseinfo/staff";
export default {
name: "",
props: {
selectNameList: {
type: Array,
},
disabled: {
type: Boolean,
},
},
created() {
// this.listStaff();
},
data() {
return {
queryParams: {
pageNum: 1,
pageSize: 10,
deptId: null,
staffName: null,
},
total: 0,
nameList: [],
loading: false,
};
},
mounted() {
},
methods: {
listStaff() {
this.loading = true;
listStaff(this.queryParams).then((res) => {
this.total = res.total;
this.nameList = res.rows;
this.$nextTick((item) => {
this.selectNameList.forEach((item) => {
this.toggleSelection(item.staffId, true);
});
this.loading = false;
});
});
},
// toggleSelection(rows) {
// if (rows) {
// rows.forEach((row) => {
// this.$refs.multipleTable.toggleRowSelection(row);
// });
// } else {
// this.$refs.multipleTable.clearSelection();
// }
// },
select(all, row) {
this.$emit("selectOne", all, row);
},
all(all) {
console.log(all);
// true是全选,false是全清
let allSelect = false;
if (all.length == 0 || (all.length == 1 && [0] == undefined)) {
allSelect = false;
} else if (all.length > 1) {
allSelect = true;
}
this.$emit("selectAll", this.nameList, allSelect);
},
selectable(row, rowIndex) {
if (!this.disabled) {
return true;
}
},
// 切换选项
toggleSelection(staffId, SeclctFlag = false) {
const item = this.nameList.find((item) => {
return item.staffId == staffId;
});
this.$refs.multipleTable.toggleRowSelection(item, SeclctFlag);
},
currentChangeClick(val) {
this.queryParams.pageNum = val;
this.listStaff();
},
formatter(row, column, cellValue, index) {
// console.log(row, column, cellValue, index);
if (!cellValue) return "-";
else return cellValue;
},
},
};
</script>
<style lang="scss" scoped>
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-12-19 17:39:55
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-02-02 10:56:52
* @FilePath: /danger-manage-web/src/views/educationPlanExam/textPaper/components/ChangePapel.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="changePeople-wrapper flex">
<div class="changePeople-left">
<div class="top-search flex">
<el-select
v-model="deptId"
filterable
placeholder="请选择"
size="mini"
style="width: 40%"
clearable
>
<el-option
v-for="item in searchList"
:key="item.deptId"
:label="item.deptName"
:value="item.deptId"
>
</el-option>
</el-select>
<el-input
v-model="staffName"
size="mini"
placeholder="请输入姓名"
suffix-icon="el-icon-date"
style="width: 48%"
>
</el-input>
<div>
<el-button @click="searchTable" size="mini">搜索</el-button>
</div>
</div>
<div class="left-middle-table">
<ChangPapelTable
ref="table"
:selectNameList.sync="selectNameList"
:disabled="disabled"
@selectOne="selectOne"
@selectAll="selectAll"
/>
</div>
<!-- <div class="bottom-text">共有3n人</div> -->
</div>
<div class="middle flex">
<div>>>></div>
</div>
<div class="changePeople-right flex">
<div class="people-card flex zzz">
<div
class="item flex"
v-for="item in selectNameList"
:key="item.staffId"
>
<div>{{ item.staffName }}</div>
<div class="close" @click="deleteName(item.staffId)">x</div>
</div>
</div>
<div class="bottom-text">已选择{{selectNameList.length}}</div>
</div>
</div>
</template>
<script>
import ChangPapelTable from "./ChangPapelTable";
import { listDept } from "@/api/system/dept";
export default {
name: "changepeopel",
components: {
ChangPapelTable,
},
props: {
// 传进组件的已经被选择的人名
jsonSelectNameList: {
type: String,
default: null,
},
disabled:{
type:Boolean,
}
},
data() {
return {
selectNameList: [],
searchList: [],
deptId: null,
staffName: null,
};
},
created() {
listDept().then((res) => {
console.log(res);
this.searchList = res.data;
});
},
mounted() {},
watch: {
selectNameList() {
let json;
if (this.selectNameList.length == 0) {
json = null;
}
if (Array.isArray(this.selectNameList)) {
json = this.selectNameList.map((item) => {
return {
peoPleId: item.staffId,
peoPleName: item.staffName,
};
});
} else {
json = this.selectNameList;
}
this.$emit("getPeopleList", JSON.stringify(json));
},
},
methods: {
changeNameList(jsonSelectNameList) {
if (jsonSelectNameList) {
this.selectNameList = JSON.parse(jsonSelectNameList).map((item) => {
return {
staffId: item.peoPleId,
staffName: item.peoPleName,
};
});
} else {
this.selectNameList = [];
}
this.$refs.table.listStaff();
},
searchTable() {
this.$refs.table.queryParams = {
pageNum: 1,
pageSize: 10,
deptId: this.deptId,
staffName: this.staffName,
};
this.$refs.table.listStaff();
},
deleteName(staffId) {
if(this.disabled) return;
const index = this.selectNameList.findIndex((item) => {
return item.staffId == staffId;
});
if (index >= 0) {
console.log(index);
this.selectNameList.splice(index, 1);
this.$refs.table.toggleSelection(staffId);
}
},
addName(row) {
const index = this.selectNameList.findIndex((item) => {
// console.log(item.id)
return item.staffId == row.staffId;
});
console.log(index);
if (index >= 0) {
this.selectNameList.splice(index, 1);
} else {
this.selectNameList.push(row);
}
},
selectAll(all, allSelect) {
// console.log(all);
console.log(allSelect);
if (allSelect) {
all.forEach((item) => {
const index = this.selectNameList.findIndex((iten) => {
return iten.staffId == item.staffId;
});
if (index < 0) {
this.selectNameList.push(item);
}
});
} else {
all.forEach((item) => {
this.deleteName(item.staffId);
});
}
},
selectOne(all, row) {
this.addName(row);
// console.log(all,row)
},
},
};
</script>
<style lang="scss" scoped>
.changePeople-wrapper {
width: 100%;
height: 400px;
// background-color: red;
margin-top: 10px;
justify-content: space-between;
& > div {
flex-direction: column;
}
.changePeople-left,
.changePeople-right {
width: 415px;
height: 100%;
border: 1px solid #e5e6eb;
}
.middle {
align-items: center;
justify-content: center;
div {
color: #1890ff;
font-weight: 2000;
}
}
.changePeople-left {
padding: 14px 20px 11px 16px;
flex-direction: column;
.top-search {
margin-bottom: 12px;
justify-content: space-between;
}
.left-middle-table {
flex: 1;
// background: red;
}
.bottom-text {
padding-top: 10px;
font-size: 12px;
height: 20px;
line-height: 20px;
text-align: right;
color: #1890ff;
}
}
.changePeople-right {
flex-direction: column;
padding-top: 14px;
height: 100%;
.people-card {
flex-wrap: wrap;
align-content: flex-start;
width: 100%;
flex: 1;
height: 0;
padding-left: 11px;
overflow-y: scroll;
&::-webkit-scrollbar {
// display: none; /* Chrome Safari */
}
.item {
width: 70px;
height: 30px;
line-height: 30px;
padding-left: 10px;
padding-right: 5px;
margin-right: 10px;
color: #3d3d3d;
box-sizing: border-box;
margin-bottom: 10px;
box-sizing: border-box;
border: 1px solid #a3d3ff;
border-radius: 3px;
font-size: 12px;
position: relative;
justify-content: space-between;
}
.close {
cursor: pointer;
}
}
.bottom-text {
// padding-top: 10px;
padding-right: 10px;
font-size: 12px;
height: 20px;
line-height: 20px;
text-align: right;
color: #1890ff;
}
}
}
</style>
......@@ -14,5 +14,6 @@ const getters = {
topbarRouters:state => state.permission.topbarRouters,
defaultRoutes:state => state.permission.defaultRoutes,
sidebarRouters:state => state.permission.sidebarRouters,
courseOptions:state=> state.edu.courseOptions,
}
export default getters
......@@ -2,6 +2,7 @@ import Vue from 'vue'
import Vuex from 'vuex'
import app from './modules/app'
import user from './modules/user'
import edu from './modules/edu'
import tagsView from './modules/tagsView'
import permission from './modules/permission'
import settings from './modules/settings'
......@@ -13,6 +14,7 @@ const store = new Vuex.Store({
modules: {
app,
user,
edu,
tagsView,
permission,
settings
......
/*
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-26 15:45:54
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-09-26 15:48:52
* @FilePath: /danger-manage-web/src/store/modules/edu.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { login, logout, getInfo } from "@/api/login";
import { getToken, setToken, removeToken } from "@/utils/auth";
const edu = {
state: {
courseOptions:[],
},
mutations: {
SET_COURSE_OPTIONS: (state, courseOptions) => {
state.courseOptions = courseOptions;
},
},
actions: {
},
};
export default edu;
<template>
<div class="app-container" >
<el-row :gutter="20">
<!--部门数据-->
<el-col :span="4" :xs="24">
<div style="height: 810px; border: solid 1px #e6ebf5;overflow-y:auto">
<div class="head-container" style = "padding: 10px">
<el-input
v-model="deptName"
placeholder="请输入部门名称"
clearable
size="small"
prefix-icon="el-icon-search"
/>
</div>
<div class="head-container" style = "padding: 10px">
<el-tree
:data="deptOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
highlight-current
ref="tree"
default-expand-all
@node-click="handleNodeClick"
/>
</div>
</div>
</el-col>
<!--员工数据-->
<el-col :span="20" :xs="24">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="员工编号" prop="staffCode">
<el-input
v-model="queryParams.staffCode"
placeholder="请输入员工编号"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="员工姓名" prop="staffName">
<el-input
v-model="queryParams.staffName"
placeholder="请输入员工姓名"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="dateRange"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</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"
>新增</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="staffList" @selection-change="handleSelectionChange">
<!-- <el-table-column type="selection" width="50" align="center" />-->
<el-table-column label="员工编号" align="center" prop="staffCode" />
<el-table-column label="员工姓名" align="center" prop="staffName" />
<el-table-column label="员工性别" align="center" prop="sex" width="100">
<template slot-scope="scope">
<span v-if="scope.row.sex == '0'"></span>
<span v-if="scope.row.sex == '1'"></span>
<span v-if="scope.row.sex == '2'">未知</span>
</template>
</el-table-column>
<el-table-column label="归属部门" align="center" prop="deptName" />
<el-table-column label="岗位" align="center" prop="postName" />
<el-table-column label="手机号码" align="center" prop="phonenumber"/>
<el-table-column label="证书有效日期" align="center" width="200">
<template slot-scope="scope">
<span v-if="scope.row.effectiveDate != null && scope.row.effectiveDate != '' && getDays(scope.row.effectiveDate, new Date())<30" style="color: red;">
{{ scope.row.effectiveDate }}(即将到期)
</span>
<span v-if="scope.row.effectiveDate != null && scope.row.effectiveDate != '' && getDays(scope.row.effectiveDate, new Date())>30">
{{ scope.row.effectiveDate }}
</span>
<span v-if="scope.row.effectiveDate == null || scope.row.effectiveDate == ''">-</span>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" width="160">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
width="160"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="showDetail(scope.row)"
>详情</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</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-col>
</el-row>
<!-- 档案信息对话框 -->
<el-dialog title="档案信息" width="1200px" :visible.sync="dialogTableVisible">
<template>
<el-descriptions class="margin-top" :column="3" border>
<el-descriptions-item>
<template slot="label">
姓名
</template>
{{form.staffName}}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
性别
</template>
<p v-if="form.sex==0"></p>
<p v-if="form.sex==1"></p>
<p v-if="form.sex==2">未知</p>
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
手机号码
</template>
{{form.phonenumber}}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
归属部门
</template>
{{form.deptName}}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
职称
</template>
{{form.positionalTitles}}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
岗位
</template>
{{form.postName}}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
工种
</template>
{{form.profession}}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
是否为特种作业人员
</template>
<p v-if="form.specialOperators=='Y'"></p>
<p v-if="form.specialOperators=='N'"></p>
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
人像照片
</template>
<el-image style="width: 100px; height: 100px" :src="form.certificateUrl"></el-image>
<!-- <MyFileUpload-->
<!-- listType="picture-card"-->
<!-- @resFun="getFileInfo"-->
<!-- :fileArr="fileList"-->
<!-- />-->
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
证书名称
</template>
{{form.certificateName}}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
证书有效日期
</template>
{{form.effectiveDate}}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
备注
</template>
{{form.remark}}
</el-descriptions-item>
</el-descriptions>
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="培训信息" name="first">
<el-table v-loading="loading" :data="examinationList" @selection-change="handleSelectionChange">
<el-table-column label="培训课程" align="center" prop="courseName" >
<span slot-scope="scope" v-if="scope.row.courseName">{{scope.row.courseName}}</span>
<span v-else>-</span>
</el-table-column>
<el-table-column label="是否完成" align="center" prop="trainState">
<template slot-scope="scope">
<span v-if="scope.row.trainState == '0'">未完成</span>
<span v-if="scope.row.trainState == '1'">已完成</span>
</template>
</el-table-column>
<el-table-column label="培训时长(分钟)" align="center" prop="finishDuration" />
<el-table-column label="考试开始时间" align="center" prop="testStartTime" />
<el-table-column label="考试结束时间" align="center" prop="testEndTime" />
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getListS"
/>
</el-tab-pane>
<el-tab-pane label="考试信息" name="second">
<el-table v-loading="loading" :data="examinationList" @selection-change="handleSelectionChange">
<el-table-column label="培训课程" align="center" prop="courseName" >
<span slot-scope="scope" v-if="scope.row.courseName">{{scope.row.courseName}}</span>
<span v-else>-</span>
</el-table-column>
<el-table-column label="考试" align="center" prop="state">
<template slot-scope="scope">
<span v-if="scope.row.state == 0">未考试</span>
<span v-if="scope.row.state == 1">未通过</span>
<span v-if="scope.row.state == 2">已通过</span>
<span v-if="scope.row.state == 3||scope.row.state ==4">未考试</span>
</template>
</el-table-column>
<el-table-column label="考试开始时间" align="center" prop="testStartTime" />
<el-table-column label="考试结束时间" align="center" prop="testEndTime" />
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getListS"
/>
</el-tab-pane>
</el-tabs>
</template>
</el-dialog>
<!-- 添加参数配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-row>
<el-col :span="11">
<el-form-item label="姓名" prop="staffName">
<el-input v-model="form.staffName" placeholder="请输入员工姓名" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="性别" prop="sex" label-width="140px">
<el-select v-model="form.sex" placeholder="请选择员工性别" style="width: 100%">
<el-option
v-for="dict in sexOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row >
<el-col :span="11">
<el-form-item label="账号" prop="userName">
<el-input v-model="form.userName" placeholder="请输账号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="密码" prop="password" label-width="140px">
<el-input v-model="form.password" placeholder="请输入密码" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="11">
<el-form-item label="手机号码" prop="phonenumber">
<el-input v-model="form.phonenumber" placeholder="请输入手机号码" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="归属部门" prop="deptId" label-width="140px">
<treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="11">
<el-form-item label="岗位" prop="postId">
<el-select v-model="form.postId" placeholder="请选择岗位" style="width: 100%">
<el-option
v-for="item in postOptions"
:key="item.postId"
:label="item.postName"
:value="item.postId"
:disabled="item.status == 1"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="职称" prop="positionalTitles" label-width="140px">
<el-input v-model="form.positionalTitles" placeholder="请输入员工职称" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="11">
<el-form-item label="工种" prop="profession">
<el-input v-model="form.profession" placeholder="请输入员工工种" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否为特种作业人员" label-width="140px">
<el-select v-model="form.specialOperators" placeholder="请选择是否为特种作业人员" style="width: 100%">
<el-option
v-for="dict in specialOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="11">
<el-form-item label="角色">
<el-select v-model="form.roleIds" multiple placeholder="请选择">
<el-option
v-for="item in roleOptions"
:key="item.roleId"
:label="item.roleName"
:value="item.roleId"
:disabled="item.status == 1"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="23">
<el-form-item label="证书照片" prop="certificateUrl">
<MyFileUpload
listType="picture-card"
@resFun="getFileInfo"
@remove="listRemove"
:fileArr="fileList"
/>
<el-input v-show="false" disabled v-model="form.certificateUrl"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="11">
<el-form-item label="证书名称" prop="certificateName">
<el-input v-model="form.certificateName" placeholder="请输入证书名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="证书有效日期" prop="effectiveDate" label-width="140px">
<el-date-picker clearable
v-model="form.effectiveDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择证书有效日期"
style="width: 100%">
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="23">
<el-form-item label="备注">
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注信息"></el-input>
</el-form-item>
</el-col>
</el-row>
</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>
<!-- 修改参数配置对话框 -->
<el-dialog :title="title" :visible.sync="opens" width="900px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-row>
<el-col :span="11">
<el-form-item label="姓名" prop="staffName">
<el-input v-model="form.staffName" placeholder="请输入员工姓名" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="性别" prop="sex" label-width="140px">
<el-select v-model="form.sex" placeholder="请选择员工性别" style="width: 100%">
<el-option
v-for="dict in sexOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="11">
<el-form-item label="手机号码" prop="phonenumber">
<el-input v-model="form.phonenumber" placeholder="请输入手机号码" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="归属部门" prop="deptId" label-width="140px">
<treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="11">
<el-form-item label="岗位" prop="postId">
<el-select v-model="form.postId" placeholder="请选择岗位" style="width: 100%">
<el-option
v-for="item in postOptions"
:key="item.postId"
:label="item.postName"
:value="item.postId"
:disabled="item.status == 1"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="职称" prop="positionalTitles" label-width="140px">
<el-input v-model="form.positionalTitles" placeholder="请输入员工职称" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="11">
<el-form-item label="工种" prop="profession">
<el-input v-model="form.profession" placeholder="请输入员工工种" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否为特种作业人员" label-width="140px">
<el-select v-model="form.specialOperators" placeholder="请选择是否为特种作业人员" style="width: 100%">
<el-option
v-for="dict in specialOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="11">
<!-- <el-form-item label="角色">-->
<!-- <el-select v-model="form.roleId" placeholder="请选择角色" style="width: 100%">-->
<!-- <el-option-->
<!-- v-for="item in roleOptions"-->
<!-- :key="item.roleId"-->
<!-- :label="item.roleName"-->
<!-- :value="item.roleId"-->
<!-- :disabled="item.status == 1"-->
<!-- ></el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item label="角色">
<el-select v-model="form.roleId" placeholder="请选择">
<el-option
v-for="item in roleOptions"
:key="item.roleId"
:label="item.roleName"
:value="item.roleId"
:disabled="item.status == 1"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="23">
<el-form-item label="人像照片" prop="certificateUrl">
<MyFileUpload
listType="picture-card"
@resFun="getFileInfo"
@remove="listRemove"
:fileArr="fileList"
/>
<el-input v-show="false" disabled v-model="form.certificateUrl"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="11">
<el-form-item label="证书名称" prop="certificateName">
<el-input v-model="form.certificateName" placeholder="请输入证书名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="证书有效日期" prop="effectiveDate" label-width="140px">
<el-date-picker clearable
v-model="form.effectiveDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择证书有效日期"
style="width: 100%">
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="23">
<el-form-item label="备注">
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注信息"></el-input>
</el-form-item>
</el-col>
</el-row>
</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 { listStaff, getStaff, delStaff, addStaff, updateStaff, exportStaff,TStaffLisst } from "@/api/baseinfo/staff";
import { treeselect } from "@/api/system/dept";
import MyFileUpload from '@/components/MyFileUpload';
import Treeselect from "@riophae/vue-treeselect";
import { listUser, getUser, delUser, addUser, updateUser, exportUser, resetUserPwd, changeUserStatus, importTemplate } from "@/api/system/user";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "staff",
components: { Treeselect, MyFileUpload },
data() {
return {
staffId:0,
//详情标签页使用
activeName: 'second',
//用户详细信息遮罩层
dialogTableVisible : false,
// 遮罩层
loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 员工表格数据
staffList: null,
//考试信息
examinationList:null,
// 弹出层标题
title: "",
titleDetail: "",
// 部门树选项
deptOptions: [],
// 是否显示弹出层
open: false,
// 修改是否显示弹出层
opens: false,
openDetail: false,
// 部门名称
deptName: undefined,
// 日期范围
dateRange: [],
// 性别状态字典
sexOptions: [],
// 是否特种作业人员字典
specialOptions: [],
// 岗位选项
postOptions: [],
// 角色选项
roleOptions: [],
// 上传文件列表
fileList: [],
// 表单参数
form: {},
detailForm: {},
defaultProps: {
children: "children",
label: "label"
},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
staffName: null,
phonenumber: null,
sex: null,
deptId: null,
staffId:0,
dataKind:1,
},
// 表单校验
rules: {
staffName: [
{ required: true, message: "姓名不能为空", trigger: "blur" }
],
userName: [
{ required: true, message: "账号不能为空", trigger: "blur" }
],
password: [
{ required: true, message: "密码不能为空", trigger: "blur" }
],
phonenumber: [
{
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: "请输入正确的手机号码",
trigger: "blur"
}
]
}
};
},
watch: {
// 根据名称筛选部门树
deptName(val) {
this.$refs.tree.filter(val);
}
},
created() {
this.getList();
this.getTreeselect();
this.getDicts("sys_user_sex").then(response => {
this.sexOptions = response.data;
});
this.getDicts("sys_yes_no").then(response => {
this.specialOptions = response.data;
});
},
methods: {
/***/
handleClick(tab, event) {
this.queryParams.dataKind=tab.index
TStaffLisst(this.queryParams).then(response => {
this.examinationList = response.rows;
this.total = response.total;
this.loading = false;
});
},
/**查看详情*/
showDetail(row){
this.dialogTableVisible=true;
//获取id
const staffId = row.staffId || this.ids;
getUser().then(response => {
this.roleOptions = response.roles;
});
getStaff(staffId).then(response => {
this.form = response.data;
this.postOptions = response.posts;
if (this.form.certificateUrl) {
this.fileList.push({
url: this.form.certificateUrl,
});
}
});
this.queryParams.staffId=row.staffId;
TStaffLisst(this.queryParams).then(response => {
this.examinationList = response.rows;
this.total = response.total;
this.loading = false;
});
},
/** 查询员工列表 */
getListS() {
this.loading = true;
TStaffLisst(this.queryParams).then(response => {
this.examinationList = response.rows;
this.total = response.total;
this.loading = false;
});
},
/** 查询员工列表 */
getList() {
this.loading = true;
listStaff(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.staffList = response.rows;
this.total = response.total;
this.loading = false;
}
);
},
/** 查询部门下拉树结构 */
getTreeselect() {
treeselect().then(response => {
this.deptOptions = response.data;
});
},
// 筛选节点
filterNode(value, data) {
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
// 节点单击事件
handleNodeClick(data) {
this.queryParams.deptId = data.id;
this.getList();
},
// 取消按钮
cancel() {
this.open = false;
this.opens = false;
this.reset();
},
cancelDetail() {
this.openDetail = false;
this.resetDetail();
},
// 表单重置
reset() {
this.form = {
staffId: null,
deptId: null,
staffName: null,
staffCode: null,
phonenumber: null,
sex: null,
roleId: null,
postId: null,
effectiveDate: null,
isDel: null,
remark: null
};
this.resetForm("form");
this.fileList = [];
},
resetDetail() {
this.detailForm = {
staffId: null,
deptId: null,
staffName: null,
staffCode: null,
phonenumber: null,
sex: null,
roleId: null,
postId: null,
effectiveDate: null,
isDel: null,
remark: null
};
this.resetForm("detailForm");
this.fileList = [];
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.page = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = [];
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
console.log(selection)
this.ids = selection.map(item => item.staffId);
this.single = selection.length != 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.getTreeselect();
// this.open = true;
// this.title = "添加员工信息";
// getStaff().then(response => {
// this.postOptions = response.posts;
// this.roleOptions = response.roles;
// this.open = true;
// this.title = "添加员工信息";
// });
getUser().then(response => {
this.postOptions = response.posts;
this.roleOptions = response.roles;
this.open = true;
this.title = "添加员工信息";
});
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.getTreeselect();
const staffId = row.staffId || this.ids;
getUser().then(response => {
this.roleOptions = response.roles;
});
getStaff(staffId).then(response => {
this.form = response.data;
console.log("form",response.data)
this.postOptions = response.posts;
if (this.form.certificateUrl) {
this.fileList.push({
url: this.form.certificateUrl,
});
}
this.opens = true;
this.title = "修改员工信息";
});
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.staffId != null) {
updateStaff(this.form).then(response => {
this.msgSuccess("修改成功");
this.opens = false;
this.getList();
});
} else {
addStaff(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
// const staffIds = row.staffId || this.ids;
row.isDel = "1";
this.$confirm('是否确认删除 ' + row.staffName + '(' + row.staffCode + ') 的员工信息?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return updateStaff(row);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(() => {});
},
getFileInfo(res){
this.form.certificateUrl = res.url;
//this.$set(this.feedBookForm,'iconUrl',res.url)
},
listRemove(e) {
this.form.certificateUrl = "";
this.fileList = [];
},
/** 详细信息跳转 */
/*showDetail(row) {
this.resetDetail();
getStaff(row.staffId).then(response => {
this.detailForm = response.data;
this.postOptions = response.posts;
this.roleOptions = response.roles;
this.openDetail = true;
this.titleDetail = "员工信息详情";
});
},*/
getDays(date1 , date2){
var time = new Date(date1).getTime() - date2.getTime();
var days = parseInt(time/1000/60/60/24);
return days;
}
}
};
</script>
......@@ -374,7 +374,7 @@ export default {
// 弹出层标题
title: "",
// 部门树选项
deptOptions: undefined,
deptOptions: [],
// 是否显示弹出层
open: false,
// 部门名称
......
<template>
<div ref="myBody" class="add-question flex">
<div class="text flex">
<div class="left">
目前录入题目是第<span>{{ questionNextNum }}</span
>道题
</div>
<div>
<el-radio-group
v-model="form.topicType"
size="mini"
@input="topicTypeChange"
>
<el-radio-button :disabled="checkLock" :label="1"
>单选</el-radio-button
>
<el-radio-button :disabled="checkLock" :label="2"
>多选</el-radio-button
>
<el-radio-button :disabled="checkLock" :label="3"
>判断</el-radio-button
>
</el-radio-group>
</div>
<div class="right">{{ courseName }}</div>
</div>
<el-form class="form flex" ref="form" :model="form" label-width="auto">
<!-- <div class="top flex"> -->
<div>
<el-form-item
label="题目内容"
prop="topicTitle"
:rules="{
required: true,
message: '必须输入题目内容',
trigger: ['blur', 'change'],
}"
>
<el-input
type="textarea"
placeholder="多行输入"
resize="none"
rows="4"
v-model="form.topicTitle"
:disabled="checkLock"
>
</el-input>
</el-form-item>
</div>
<div class="bottom">
<!-- <el-form-item label="选项1" prop="title">
<el-input v-model="form.title" placeholder="请输入"></el-input>
</el-form-item> -->
<el-form-item
v-for="(question, index) in form.questions"
:label="'选项' + (index + 1)"
:key="question.key"
:prop="'questions.' + index + '.value'"
:rules="{
required: true,
message: '选项内容不能为空不能为空',
trigger: ['blur', 'change'],
}"
>
<div class="add-select flex">
<el-input
type="textarea"
placeholder="多行输入"
style="flex: 1; margin-right: 10px"
rows="2"
v-model="question.value"
:disabled="checkLock"
></el-input>
<div class="flex algin-items">
<div
@click="rightAnswerClick(index)"
class="right"
:class="{
active: answerNum.indexOf(index) >= 0,
}"
>
设为正确答案
</div>
<el-button
size="mini"
type="danger"
v-if="index > 0 && form.topicType != 3"
@click.prevent="removeDomain(question)"
:disabled="checkLock"
>删除</el-button
>
</div>
</div>
</el-form-item>
<!-- <el-form-item
class="noAttr"
:label="`选项${form.questions.length + 1}`"
prop=""
>
<div class="add-select flex">
<el-input
type="textarea"
placeholder="多行输入"
resize="none"
rows="2"
v-model="addValue"
style="flex: 1; margin-right: 10px"
>
</el-input>
<div class="flex algin-items">
<div
@click="rightAnswerClick(form.questions.length)"
class="right"
:class="{ active: answerNum === form.questions.length }"
>
设为正确答案
</div> -->
<div style="padding-left: 30px" v-if="form.topicType != 3">
<el-button
size="mini"
:disabled="checkLock"
type="primary"
@click.prevent="add(addValue)"
>新增选项</el-button
>
</div>
<!-- </div>
</div>
</el-form-item> -->
</div>
</el-form>
</div>
</template>
<script>
import {
addQuestion,
checkQuestion,
changeQuestion,
getQuestion,
getLessonById,
} from "@/api/train/lessonsProgram.js";
export default {
name: "AnswerLesson",
props: {
// visible: {
// type: Boolean,
// default: false,
// },
courseId: {
type: Number,
},
topicId: {
type: Number,
},
// 如果是查看,就禁止修改
checkLock: {
type: Boolean,
},
},
components: {},
data() {
return {
// topicType:1,
form: {
topicType: 1,
topicTitle: "",
questions: [{ value: "" }, { value: "" }],
},
answerNum: [],
addValue: "",
// 录入的是第几道题
questionNextNum: 1,
courseName: "",
};
},
created() {
// 如果存在就是修改
if (this.topicId) {
checkQuestion(this.topicId).then((res) => {
console.log(res.data);
const data = res.data;
this.form = {
topicType: data.topicType,
topicTitle: data.topicTitle,
questions: JSON.parse(data.topicOption),
};
this.answerNum = JSON.parse(data.answer);
});
}
// 查询是第几道题
this.getQuestion();
// 获取课程标题
this.getLessonById(this.courseId);
},
methods: {
// 题目类型变化
topicTypeChange(num) {
if (num == 1) {
this.answerNum = [];
} else if (num == 2) {
this.answerNum = [];
// this.form.questions=[{ value: "" }, { value: "" }];
} else {
this.answerNum = [];
const form = {
topicType: 3,
topicTitle: this.form.topicTitle,
questions: [{ value: "对" }, { value: "错" }],
};
this.form = form;
}
},
getQuestion() {
getQuestion({ courseId: this.courseId }).then((res) => {
// 如果是修改 就是原来的值,如果不是,就是总数+1
console.log(res);
if (this.topicId) {
res.rows.forEach((item, index) => {
if (item.topicId == this.topicId) {
this.questionNextNum = index + 1;
}
});
} else {
this.questionNextNum = res.total + 1;
}
});
},
getLessonById(courseId) {
getLessonById(courseId).then((res) => {
console.log(res);
this.courseName = res.data.courseName;
});
},
addQuestion(data) {
// 如果是修改,就用修改的方法,如果是新增,就用新增的方法
if (this.topicId) {
return changeQuestion({ topicId: this.topicId, ...data });
} else {
return addQuestion({ courseId: this.courseId, ...data });
}
},
rightAnswerClick(index) {
if (this.checkLock) return;
if (this.form.topicType === 2) {
const ind = this.answerNum.indexOf(index);
if (ind < 0) {
this.answerNum.push(index);
} else {
this.answerNum.splice(ind, 1);
}
this.answerNum = this.answerNum.sort((a, b) => {
return a - b;
});
console.log(this.answerNum);
} else {
// 判断跟单选模式差不多
this.answerNum = [index];
}
},
// 删除选项
removeDomain(question) {
if (this.checkLock) return;
const index = this.form.questions.indexOf(question);
console.log(index);
// 如果是正确答案,就让正确答案清空
const ind = this.answerNum.indexOf(index);
if (ind >= 0) {
this.answerNum.splice(ind, 1);
}
// 如果是最后一位呗删除,那不用管,如果不是最后一位置,这一位删除之后,则这一位后面的所有数字都要-1;
if (index != this.form.questions.length - 1) {
this.answerNum = this.answerNum.map((item, i) => {
if (item >= index) {
return item - 1;
} else {
return item;
}
});
}
if (index >= 0) {
this.form.questions.splice(index, 1);
}
console.log(this.answerNum);
// console.log(this.form.questions)
},
// 新增选项
add(addValue) {
this.form.questions.push({ value: addValue });
},
save(num = 2) {
return new Promise((resove) => {
if (this.answerNum.length <= 0) {
this.$message({
message: "警告,请设置一个正确答案",
type: "warning",
});
return resove(false);
}
this.$refs.form.validate((valid) => {
if (valid) {
const data = {};
data.topicTitle = this.form.topicTitle;
data.topicOption = JSON.stringify(this.form.questions);
data.answer = JSON.stringify(this.answerNum);
data.topicType = this.form.topicType;
console.log(data);
this.addQuestion(data).then((res) => {
if (res.code == 200) {
// 把修改的这个归位,变成正常添加
this.$emit("update:topicId", null);
console.log("updateTopicId", this.topicId);
this.$message({
message: "添加题目成功",
type: "success",
});
this.$parent.$parent.componentsNumChange(num);
this.$parent.$parent.$parent.getList();
resove(true);
}
});
}
});
});
},
saveAndNext() {
this.save(3).then((res) => {
if (res) {
this.reset();
// this.questionNextNum++;
this.getQuestion();
}
});
},
reset() {
const topicType = this.form.topicType;
this.form = {
topicType,
topicTitle: "",
questions: [{ value: "" }, { value: "" }],
};
this.answerNum = [];
this.addValue = "";
},
},
};
</script>
<style lang="scss" scoped>
.add-question {
width: 100%;
height: 550px;
// overflow: hidden;
flex-direction: column;
padding-bottom: 7px;
margin-bottom: 20px;
border-bottom: 1px solid #bbbbbb;
.form {
flex: 1;
flex-direction: column;
height: 100%;
.bottom {
overflow-y: auto;
height: 330px;
box-sizing: border-box;
.algin-items {
align-items: center;
width: 200px;
}
.right {
display: inline-block;
width: 133px;
margin-right: 10px;
line-height: initial;
padding: 4px 0;
border: 1px solid #bbbbbb;
color: #101010;
font-size: 12px;
text-align: center;
border-radius: 4px;
box-sizing: border-box;
cursor: pointer;
&.active {
background-color: #0bab0c;
color: #ffffff;
}
&:hover {
background-color: rgba(11, 171, 12, 0.5);
color: #ffffff;
}
}
}
}
.text {
margin-top: 13px;
margin-bottom: 34px;
justify-content: space-between;
height: 28px;
.left {
line-height: 28px;
color: #101010;
font-size: 14px;
}
.right {
width: 411px;
line-height: 28px;
background: #1d84ff;
padding-right: 5px;
color: #fff;
text-align: right;
}
}
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-12-27 09:30:19
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-02-01 16:15:10
* @FilePath: /danger-manage-web/src/views/train/textPaper/components/ChangeQuestion.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="table-wrapper">
<el-form :model="queryParams" ref="queryForm" :inline="true">
<el-form-item label="所属单位" prop="deptId" ref="treeItem">
<Treeselect
class="tree"
v-model="queryParams.deptId"
:options="deptOptions"
:show-count="true"
placeholder="请选择归属部门"
style="width: 200px"
/>
</el-form-item>
<el-form-item label="题库名称" prop="bankName">
<el-input
v-model="queryParams.bankName"
placeholder="考试时间"
clearable
size="small"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="search"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetClick"
>重置</el-button
>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="list" height="435" ref="multipleTable">
<!-- <el-table-column type="selection"></el-table-column> -->
<el-table-column label="" align="center" prop="profession">
<template v-slot="{ row }">
<!-- <div> -->
<el-checkbox
:disabled="row.numberQuestions == 0"
v-model="row.checked"
></el-checkbox>
<!-- </div> -->
</template>
</el-table-column>
<el-table-column label="题库名称" align="center" prop="bankName">
</el-table-column>
<el-table-column label="所属单位" align="center" prop="courseType">
<template v-slot="scope">
<div>
{{ selectList(deptOptions, scope.row.deptId) || "-" }}
</div>
</template>
</el-table-column>
<el-table-column
label="包含题目数量"
align="center"
prop="numberQuestions"
:formatter="formatter"
>
</el-table-column>
<el-table-column label="选取题目数量" align="center" prop="profession">
<template v-slot="{ row }">
<div>
<!-- <el-input
:disabled="!row.checked|| row.numberQuestions==0 "
v-model="row.changeNum"
size="mini"
style="width: 100px"
></el-input> -->
<el-input-number
v-model="row.changeNum"
:disabled="!row.checked || row.numberQuestions == 0"
size="mini"
:min="1"
:max="+row.numberQuestions ? +row.numberQuestions : 1000000"
label="描述文字"
></el-input-number>
</div>
</template>
</el-table-column>
</el-table>
<!-- <div> -->
<el-pagination
:layout="'prev, pager, next'"
v-show="total > 0"
:total="total"
:current-page="queryParams.pageNum"
:page-sizes="[queryParams.pageSize]"
@current-change="currentChangeClick"
/>
</div>
</template>
<script>
import { listBank, delBank } from "@/api/train/questionBank";
import { bachAddTopic } from "@/api/train/lessonsProgram.js";
// 部门列表
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "",
components: {
Treeselect,
},
props: {
courseId: {
type: Number,
},
},
data() {
return {
queryParams: {
deptId: null,
courseName: "",
pageNum: 1,
pageSize: 10,
},
list: [
{
checked: false,
},
],
total: 20,
loading: false,
// 题库id
deptId: null,
// 归属部门列表
deptOptions: [],
};
},
created() {
this.getList();
this.getTreeselect();
},
methods: {
getTreeselect() {
treeselect().then((response) => {
this.deptOptions = response.data;
// console.log("123", this.deptOptions);
// console.log(this.selectList(this.deptOptions, 175));
});
},
// 递归查值的方法
selectList(list, id) {
for (let i = 0; i < list.length; i++) {
let item = list[i];
if (item.id == id) {
return item.label;
} else {
if (Array.isArray(item.children)) {
let a = this.selectList(item.children, id);
if (a) {
return a;
}
}
}
}
},
getList() {
this.loading = true;
listBank(this.queryParams)
.then((res) => {
console.log(res);
this.list = res.rows.map((item, index) => {
return {
bankNum:
index +
1 +
(this.queryParams.pageNum - 1) * this.queryParams.pageSize,
checked: false,
changeNum: 0,
...item,
};
});
this.total = res.total;
})
.finally(() => {
this.loading = false;
});
},
save(num=2) {
const topicInfos = this.list
.filter((item) => item.checked)
.map((item) => {
return {
bankId: item.bankId,
quan: item.changeNum,
};
});
console.log(this.courseId, topicInfos);
const data = { courseId: this.courseId, topicInfos };
console.log(data);
bachAddTopic(data).then((res) => {
console.log(res);
if (res.code == 200) {
this.$parent.$parent.componentsNumChange(num);
this.$parent.$parent.$parent.getList();
}
});
},
saveAndNext(){
this.save(3)
},
resetClick() {},
search() {
this.getList();
},
currentChangeClick() {},
formatter(row, column, cellValue, index) {
// console.log(row, column, cellValue, index);
if (!cellValue) return "-";
else return cellValue;
},
},
};
</script>
<style lang="scss" scoped>
.table-wrapper {
padding-top: 22px;
width: 100%;
height: 550px;
overflow: hidden;
// padding-bottom: 10px;
margin-bottom: 20px;
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 10:38:49
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-02-01 16:16:44
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/addLesson.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<el-dialog
class="add-lession"
:title="title"
:visible.sync="visible"
width="1050px"
:close-on-click-modal="false"
:close-on-press-escape="false"
:before-close="dialogCancel"
@closed="closeFinished"
destroy-on-close
>
<div v-if="visible" ref="myBody" class="body">
<transition name="fade" mode="out-in">
<component
:is="currentComponent"
:courseId.sync="courseId"
:topicId.sync="topicId"
:checkLock="checkLock"
ref="current"
></component>
</transition>
<!-- <Lesson ref='lesson'/> -->
<!-- <AddQuestion />
<QuestionList/> -->
</div>
<div slot="footer" class="dialog-footer" v-if="!checkLock">
<el-button
type="primary"
v-if="this.componentsNum == 2 && !checkLock"
@click="componentsNumChange(4)"
>从题库选择</el-button
>
<el-button
type="primary"
v-if="this.componentsNum == 4 ||this.componentsNum==3"
@click="componentsNumChange(2)"
>返回题目列表</el-button
>
<el-button
type="primary"
v-if="
this.componentsNum == 1 ||
this.componentsNum == 3 ||
this.componentsNum == 4
"
@click="save"
>保存</el-button
>
<el-button type="primary" @click="saveAndNext" v-if="!checkLock">{{
saveNextText
}}</el-button>
<el-button
v-if="this.componentsNum == 2"
type="primary"
@click="dialogCancel"
>{{ "确认" }}</el-button
>
<el-button @click="dialogCancel">取消</el-button>
</div>
<div slot="footer" class="dialog-footer" v-else>
<el-button
type="primary"
v-if="this.componentsNum == 3 && checkLock"
@click="componentsNumChange(2)"
>返回题目列表</el-button
>
<el-button type="primary" @click="dialogCancel">{{ "确认" }}</el-button>
<el-button @click="dialogCancel">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import Lesson from "./Lesson";
import AddQuestion from "./AddQuestion";
import QuestionList from "./QuestionList";
import ChangeQuestion from "./ChangeQuestion";
export default {
name: "AnswerLesson",
props: {
visible: {
type: Boolean,
default: false,
},
componentsNum: {
type: Number,
default: 1,
},
courseId: {
type: Number,
},
checkLock: {
type: Boolean,
},
},
// components: {
// Lesson,
// AddQuestion,
// QuestionList,
// },
data() {
return {
title: "录入课程",
currentComponent: Lesson,
// 当前题目查看
topicId: null,
};
},
watch: {
componentsNum: {
handler(num) {
if (num === 1) {
this.currentComponent = Lesson;
if (this.courseId) {
this.title = "修改课程";
} else {
this.title = "新增课程";
}
} else if (num === 2) {
this.currentComponent = QuestionList;
this.title = "题目列表";
} else if (num === 3) {
this.currentComponent = AddQuestion;
if (this.topicId) {
this.title = "修改题目";
} else {
this.title = "新增题目";
}
} else if (num == 4) {
this.currentComponent = ChangeQuestion;
this.title = "从题库选题";
}
},
deep: true,
},
},
computed: {
saveNextText() {
let text;
if (this.componentsNum == 1) {
text = "保存并录入题目";
} else if (this.componentsNum == 2) {
text = "录入考题";
} else {
text = "保存并录入下一题";
}
return text;
},
},
methods: {
saveBody() {
this.startHeight = this.$refs.myBody.offsetHeight - 55 + "px";
},
closeFinished() {},
// 关闭之后
// 只保存
save() {
// this.answerClear();
this.$refs.current.save();
},
// 保存并录入
saveAndNext() {
this.$refs.current.saveAndNext();
},
// 隐藏与显示dialog
dialogCancel() {
// 录入考题的时候不会有修改的缓存
if (this.topicId) {
this.topicId = null;
}
this.$emit("update:visible", false);
// 关闭的时候归位
this.$emit("update:checkLock", false);
},
// 把ID改变了
changeCourseId(courseId) {
this.$emit("update:courseId", courseId);
},
// 改变当前组件
componentsNumChange(num) {
this.$emit("update:componentsNum", num);
},
answerClear() {
this.answerArr = [];
this.changeCourseId(null);
},
},
};
</script>
<style lang="scss" scoped>
.body {
width: 100%;
height: 100%;
padding-right: 40px;
padding-left: 36px;
}
</style>
<template>
<div>
<el-upload
:action="uploadUrl"
:on-success="handleUploadSuccess"
:on-error="handleUploadError"
name="file"
:show-file-list="false"
:headers="headers"
style="display: none"
ref="upload"
v-if="this.uploadUrl"
>
</el-upload>
<div class="editor" ref="editor" :style="styles"></div>
</div>
</template>
<script>
import Quill from "quill";
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
import { getToken } from "@/utils/auth";
export default {
name: "Editor",
props: {
/* 编辑器的内容 */
value: {
type: String,
default: "",
},
/* 高度 */
height: {
type: Number,
default: null,
},
/* 最小高度 */
minHeight: {
type: Number,
default: null,
},
/* 只读 */
readOnly: {
type: Boolean,
default: false,
},
/* 上传地址 */
uploadUrl: {
type: String,
default: "",
}
},
data() {
return {
headers: {
Authorization: "Bearer " + getToken()
},
Quill: null,
currentValue: "",
options: {
theme: "snow",
bounds: document.body,
debug: "warn",
modules: {
// 工具栏配置
toolbar: [
["bold", "italic", "underline", "strike"], // 加粗 斜体 下划线 删除线
["blockquote", "code-block"], // 引用 代码块
[{ list: "ordered" }, { list: "bullet" }], // 有序、无序列表
[{ indent: "-1" }, { indent: "+1" }], // 缩进
[{ size: ["small", false, "large", "huge"] }], // 字体大小
[{ header: [1, 2, 3, 4, 5, 6, false] }], // 标题
[{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色
[{ align: [] }], // 对齐方式
["clean"], // 清除文本格式
["link", "image"] // 链接、图片、视频"video"
],
},
placeholder: "请输入内容",
readOnly: this.readOnly,
},
};
},
computed: {
styles() {
let style = {};
if (this.minHeight) {
style.minHeight = `${this.minHeight}px`;
}
if (this.height) {
style.height = `${this.height}px`;
}
return style;
},
},
watch: {
value: {
handler(val) {
if (val !== this.currentValue) {
this.currentValue = val === null ? "" : val;
if (this.Quill) {
this.Quill.pasteHTML(this.currentValue);
}
}
},
immediate: true,
},
},
mounted() {
this.init();
},
beforeDestroy() {
this.Quill = null;
},
methods: {
init() {
const editor = this.$refs.editor;
this.Quill = new Quill(editor, this.options);
// 如果设置了上传地址则自定义图片上传事件
if (this.uploadUrl) {
let toolbar = this.Quill.getModule("toolbar");
toolbar.addHandler("image", (value) => {
this.uploadType = "image";
if (value) {
this.$refs.upload.$children[0].$refs.input.click();
} else {
this.quill.format("image", false);
}
});
toolbar.addHandler("video", (value) => {
this.uploadType = "video";
if (value) {
this.$refs.upload.$children[0].$refs.input.click();
} else {
this.quill.format("video", false);
}
});
}
this.Quill.pasteHTML(this.currentValue);
this.Quill.on("text-change", (delta, oldDelta, source) => {
const html = this.$refs.editor.children[0].innerHTML;
const text = this.Quill.getText();
const quill = this.Quill;
this.currentValue = html;
this.$emit("input", html);
this.$emit("on-change", { html, text, quill });
});
this.Quill.on("text-change", (delta, oldDelta, source) => {
this.$emit("on-text-change", delta, oldDelta, source);
});
this.Quill.on("selection-change", (range, oldRange, source) => {
this.$emit("on-selection-change", range, oldRange, source);
});
this.Quill.on("editor-change", (eventName, ...args) => {
this.$emit("on-editor-change", eventName, ...args);
});
},
handleUploadSuccess(res, file) {
// 获取富文本组件实例
let quill = this.Quill;
// 如果上传成功
if (res.code == 200) {
// 获取光标所在位置
let length = quill.getSelection().index;
// 插入图片 res.url为服务器返回的图片地址
quill.insertEmbed(length, "image", res.url);
// 调整光标到最后
quill.setSelection(length + 1);
} else {
this.$message.error("图片插入失败");
}
},
handleUploadError() {
this.$message.error("图片插入失败");
},
},
};
</script>
<style>
.editor, .ql-toolbar {
white-space: pre-wrap !important;
line-height: normal !important;
}
.quill-img {
display: none;
}
.ql-snow .ql-tooltip[data-mode="link"]::before {
content: "请输入链接地址:";
}
.ql-snow .ql-tooltip.ql-editing a.ql-action::after {
border-right: 0px;
content: "保存";
padding-right: 0px;
}
.ql-snow .ql-tooltip[data-mode="video"]::before {
content: "请输入视频地址:";
}
.ql-snow .ql-picker.ql-size .ql-picker-label::before,
.ql-snow .ql-picker.ql-size .ql-picker-item::before {
content: "14px";
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="small"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="small"]::before {
content: "10px";
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="large"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="large"]::before {
content: "18px";
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="huge"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="huge"]::before {
content: "32px";
}
.ql-snow .ql-picker.ql-header .ql-picker-label::before,
.ql-snow .ql-picker.ql-header .ql-picker-item::before {
content: "文本";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="1"]::before {
content: "标题1";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before {
content: "标题2";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before {
content: "标题3";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="4"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="4"]::before {
content: "标题4";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="5"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="5"]::before {
content: "标题5";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="6"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="6"]::before {
content: "标题6";
}
.ql-snow .ql-picker.ql-font .ql-picker-label::before,
.ql-snow .ql-picker.ql-font .ql-picker-item::before {
content: "标准字体";
}
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="serif"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="serif"]::before {
content: "衬线字体";
}
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="monospace"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="monospace"]::before {
content: "等宽字体";
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 10:59:44
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-02-01 15:21:15
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/Lession.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="form-wrapper">
<el-form
class="form"
ref="form"
:model="form"
label-width="auto"
:rules="rules"
>
<div class="top flex">
<el-form-item label="培训部门" prop="deptId">
<treeselect v-model="form.deptId" style="width: 220px;" :options="deptOptions" :show-count="true" placeholder="请选择培训部门" />
</el-form-item>
<el-form-item label="课程标题" prop="courseName" style="margin-left: -30px">
<el-input style="width: 532px" v-model="form.courseName" :disabled="checkLock"></el-input>
</el-form-item>
<!--<el-form-item label="培训计划" prop="courseType">-->
<!--<el-select-->
<!--v-model="form.courseType"-->
<!--placeholder="请选择培训计划"-->
<!--clearable-->
<!--size="small"-->
<!--&gt;-->
<!--<el-option-->
<!--v-for="course in courseOptions"-->
<!--:key="course.planId"-->
<!--:label="course.planName"-->
<!--:value="course.planId"-->
<!--/>-->
<!--</el-select>-->
<!--</el-form-item>-->
</div>
<div class="flex">
<el-form-item label="培训计划" prop="courseType">
<el-select
v-model="form.courseType"
placeholder="请选择培训计划"
clearable
size="small"
:disabled="checkLock"
style="width:220px"
>
<el-option
v-for="course in courseOptions"
:key="course.planId"
:label="course.planName"
:value="course.planId"
/>
</el-select>
</el-form-item>
<el-form-item
label="培训时长"
prop="duration"
style="margin-left: 30px"
>
<el-input
style="width: 160px"
placeholder="分钟"
type="number"
v-model="form.duration"
:disabled="checkLock"
></el-input>
(分钟)
</el-form-item>
<el-form-item
label="主讲人"
prop="zhujiang"
style="margin-left: 30px"
>
<el-input
style="width: 180px"
placeholder="填写主讲人"
v-model="form.zhujiang"
:disabled="checkLock"
></el-input>
</el-form-item>
</div>
<div class="flex">
<el-form-item label="开始时间" prop="testStartTime">
<el-date-picker
style="margin-right: 30px"
v-model="form.testStartTime"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
placeholder="选择日期时间"
default-time="00:00:00"
:disabled="checkLock"
/>
</el-form-item>
<el-form-item label="结束时间" prop="testEndTime">
<el-date-picker
v-model="form.testEndTime"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
placeholder="选择日期时间"
default-time="00:00:00"
:disabled="checkLock"
/>
</el-form-item>
<el-form-item label="是否人脸认证" prop="isVeriftyFace" style="margin-left: 50px">
<el-radio v-model="form.isVeriftyFace" label="1" :disabled="checkLock"></el-radio>
<el-radio v-model="form.isVeriftyFace" label="2" :disabled="checkLock"></el-radio>
</el-form-item>
</div>
<!-- </div> -->
<el-form-item label="课程内容" prop="courseConent">
<Editor v-model="form.courseConent" :min-height="192" :readOnly="checkLock"/>
<el-input
v-show="false"
disabled
v-model="form.courseConent"
></el-input>
</el-form-item>
<div class="flex">
<el-form-item label="视频上传" v-if="!readOnly" prop="video">
<FileUpload
listType="picture"
@resFun="getFileInfoVideo"
@remove="listRemoveVideo"
:fileArr="fileListVideo"
:fileSize="500"
:fileType="['mp4']"
:disabled="checkLock"
/>
<el-input v-show="false" disabled v-model="form.video"></el-input>
</el-form-item>
<el-form-item label="附件上传" v-if="!readOnly" prop="enclosure">
<FileUpload
listType="picture"
@resFun="getFileInfoFile"
@remove="listRemoveFile"
:fileArr="fileListFile"
:fileType="fileType"
:disabled="checkLock"
/>
<el-input v-show="false" disabled v-model="form.enclosure"></el-input>
</el-form-item>
</div>
</el-form>
</div>
</template>
<script>
import { treeselect } from "@/api/system/dept";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import Editor from "./Editor";
import FileUpload from "@/components/FileUpload";
import uploadfile from "@/assets/uploadfile.png";
import { mapGetters } from "vuex";
import {
addLessons,
getLessonById,
changeLesson,
} from "@/api/train/lessonsProgram";
import Treeselect from "@riophae/vue-treeselect";
export default {
name: "",
props: {
courseId: {
type: Number,
},
checkLock:{
type:Boolean,
}
},
components: {
Editor,
FileUpload,
Treeselect
},
data() {
return {
form: {
courseName: "",
courseDept:"",
courseType: "",
courseConent: "",
video: "",
enclosure: "",
isVeriftyFace: "2"
},
fileType: ["pdf","txt"],
fileListVideo: [],
fileListFile: [],
readOnly: false,
rules: {
deptId: [
{ required: true, trigger: "blur", message: "培训部门不能为空" },
],
courseName: [
{ required: true, trigger: "blur", message: "课程标题不能为空" },
],
courseType: [
{ required: true, trigger: "change", message: "课程类型不能为空" },
],
courseConent: [
{ required: true, trigger: "blur", message: "课程内容不能为空" },
],
// video: [{ required: true, trigger: "blue", message: "视频不能为空" }],
enclosure: [
{ required: true, trigger: "blur", message: "附件不能为空" },
],
duration: [
{ required: true, trigger: "blur", message: "培训时长不能为空" },
],
zhujiang: [
{ required: true, trigger: "blur", message: "主讲人不能为空" },
],
testStartTime: [
{ required: true, trigger: "blur", message: "开始时间不能为空" },
],
testEndTime: [
{ required: true, trigger: "blur", message: "结束时间不能为空" },
],
},
// 部门树选项
deptOptions: [],
};
},
computed: {
// 获取课程类型
...mapGetters(["courseOptions"]),
},
created() {
if (this.courseId) {
this.getLessonById();
}
this.getTreeselect();
},
mounted() {},
methods: {
// 添加课程
addLessons(data) {
console.log("this.courseId", this.courseId);
if (!this.courseId) {
console.log("添加");
return addLessons(data);
} else {
console.log("修改");
return changeLesson({ courseId: this.courseId, ...data });
}
},
// 复现
getLessonById() {
getLessonById(this.courseId).then((res) => {
if (res.code == 200) {
res.data.duration=res.data.duration/60;
const data = res.data;
const {
courseName,
courseType,
courseConent,
video,
enclosure,
duration,
testStartTime,
testEndTime,
isVeriftyFace,
zhujiang,
deptId
} = data;
this.form = {
courseName,
courseType,
courseConent,
video,
enclosure,
duration,
testStartTime,
testEndTime,
isVeriftyFace,
zhujiang,
deptId
};
console.log('video',video)
this.fileListVideo = video? [
{
name: courseName + "视频",
url: uploadfile,
},
]:[];
this.fileListFile = [
{
name: courseName + "附件",
url: uploadfile,
},
];
console.log("--", this.fileListFile);
}
});
},
getFileInfoVideo(res) {
this.form.video = res.url;
// this.form.videoName = res.fileName;
this.fileListVideo = [
{
name: res.fileName,
url: uploadfile,
},
];
},
listRemoveVideo(e) {
this.fileListVideo = [];
this.form.video = "";
// this.form.videoName = null;
},
getFileInfoFile(res) {
this.form.enclosure = res.url;
// this.form.enclosureName = res.fileName;
console.log("=============",res)
this.fileListFile = [
{
name: res.fileName,
url: uploadfile,
},
];
},
listRemoveFile(e) {
this.fileListFild = [];
this.form.enclosure = "";
// this.form.fileName = null;
},
save(num = 2) {
// 因为富文本编辑器会残留<p><br></p>,所以要清
if (this.form.courseConent === "<p><br></p>") {
this.form.courseConent = "";
}
this.$refs.form.validate((valid) => {
if (valid) {
// console.log(this.form);
this.addLessons({ ...this.form }).then((res) => {
// 如果添加会传回来,就用传回来的,如果是修改本身就有,就用本身的
const courseId = res.data || this.courseId;
if (res.code == 200) {
// 这样调比较纯函数一点
if (num == 2) {
this.$message({
message: "保存课程成功",
type: "success",
});
// 隐藏dia
this.$parent.$parent.dialogCancel()
} else if (num == 3) {
this.$message({
message: "保存课程成功,请开始录入题目",
type: "success",
});
// 跳转动态路由,并且把ID改变添加用
this.$parent.$parent.componentsNumChange(num);
this.$parent.$parent.changeCourseId(courseId);
}
this.$parent.$parent.$parent.getList();
return true;
}
});
}
});
},
// 保存并进入题目
saveAndNext() {
this.save(3);
},
/** 查询部门下拉树结构 */
getTreeselect() {
treeselect().then(response => {
console.log('部门树返回值')
this.deptOptions = response.data;
});
},
},
};
</script>
<style lang="scss" scoped>
.form-wrapper {
padding-top: 22px;
width: 100%;
height: 680px;
overflow: hidden;
// padding-bottom: 10px;
margin-bottom: 20px;
border-bottom: 1px solid #bbbbbb;
.top {
width: 100%;
justify-content: space-between;
}
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 17:56:05
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-02-02 10:05:15
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/QuestionList.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div ref="myBody" class="add-question flex">
<div class="text flex">
<div class="left">
目前有<span>{{ questionNum }}</span
>道题
<span class="warn">温馨提示:发布课程前需要进行考试设置</span>
</div>
<div class="right">{{ courseName }}</div>
</div>
<div class="detail flex">
<div class="detail-item">
单选题<span>{{ bottomFrom.singleChoiceScore }}</span
>分/题,共<span>{{ danxs }}</span
>题,计<span class="textC">{{
danxs * bottomFrom.singleChoiceScore
}}</span
>
</div>
<div class="detail-item">
多选题<span>{{ bottomFrom.multipleChoiceScore }}</span
>分/题,共<span>{{ duoxs }}</span> 题,计<span class="textC">{{
duoxs * bottomFrom.multipleChoiceScore
}}</span
>
</div>
<div class="detail-item">
判断题<span>{{ bottomFrom.judgmentScore }}</span
>/题,共<span>{{ pds }}</span> 题,计<span class="textC">{{
pds * bottomFrom.judgmentScore
}}</span
>
</div>
<div class="detail-item">
一共<span>{{ danxs + duoxs + pds }}</span
>道题,总共计<span class="textC">{{
danxs * bottomFrom.singleChoiceScore +
duoxs * bottomFrom.multipleChoiceScore +
pds * bottomFrom.judgmentScore
}}</span
>
</div>
</div>
<div class="table flex" v-loading="loading">
<div class="th flex">
<div class="left">序号</div>
<div class="type">题目类型</div>
<div class="middle">题目名称</div>
<div class="right">操作</div>
</div>
<div class="td-wrapper">
<div
v-for="(item, index) in questionList"
:key="item.topicId"
class="td flex"
>
<div class="left">{{ index + 1 }}</div>
<div class="type">{{ topicTypeArr[item.topicType] }}</div>
<div class="middle zzz">
{{ item.topicTitle }}
</div>
<div class="right">
<div>
<el-button
v-if="!checkLock"
@click="edit(item.topicId)"
icon="el-icon-edit"
type="text"
>修改</el-button
>
<el-button
v-if="checkLock"
@click="edit(item.topicId)"
icon="el-icon-edit"
type="text"
>查看</el-button
>
<el-button
v-if="!checkLock"
@click="deleteLesson(item.topicId)"
icon="el-icon-delete"
type="text"
>删除</el-button
>
</div>
</div>
</div>
</div>
</div>
<div class="rightNum flex">
<div class="left">考试设置</div>
<div class="middle flex">
<div class="left-text">单选一题</div>
<div>
<el-input
v-model="bottomFrom.singleChoiceScore"
style="width: 50px"
size="mini"
:disabled="checkLock"
></el-input>
</div>
<div></div>
</div>
<div class="middle flex">
<div class="left-text">多选一题</div>
<div>
<el-input
v-model="bottomFrom.multipleChoiceScore"
style="width: 50px"
size="mini"
:disabled="checkLock"
></el-input>
</div>
<div></div>
</div>
<div class="middle flex">
<div class="left-text">判断一题</div>
<div>
<el-input
v-model="bottomFrom.judgmentScore"
style="width: 50px"
size="mini"
:disabled="checkLock"
></el-input>
</div>
<div></div>
</div>
<div class="middle flex">
<div class="left-text">总分大于</div>
<div>
<el-input
v-model="bottomFrom.qualifiedNum"
style="width: 60px"
size="mini"
:disabled="checkLock"
></el-input>
</div>
<div>为合格</div>
</div>
<div class="right">
<el-button
@click="saveRightNum"
icon="el-icon-check"
size="mini"
type="success"
:disabled="checkLock"
>保存</el-button
>
</div>
</div>
</div>
</template>
<script>
import {
getQuestion,
deleteQuestion,
changeLesson,
getLessonById,
} from "@/api/train/lessonsProgram";
export default {
name: "AnswerLesson",
props: {
courseId: {
type: Number,
},
checkLock: {
type: Boolean,
},
},
components: {},
data() {
return {
// 当前课程的第几题,调一遍接口
questionNum: null,
// 答对几道题
// rightNum: 0,
bottomFrom: {
singleChoiceScore: 0,
multipleChoiceScore: 0,
judgmentScore: 0,
qualifiedNum: 0,
},
questionList: [],
loading: false,
courseName: "",
topicTypeArr: {
1: "单选题",
2: "多选题",
3: "判断题",
},
};
},
// watch: {
// visible(newValue) {
// if (newValue) {
// this.$nextTick(() => {
// this.saveBody();
// });
// }
// },
// },
computed: {
danxs() {
return this.questionList.filter((item) => item.topicType === 1).length;
},
duoxs() {
return this.questionList.filter((item) => item.topicType === 2).length;
},
pds() {
return this.questionList.filter((item) => item.topicType === 3).length;
},
},
created() {
console.log("this.courseId", this.courseId);
if (this.courseId) {
this.getQuestion({ courseId: this.courseId });
// 获取只题目正确几题算过关
this.getLessonById(this.courseId);
}
},
methods: {
save() {
console.log("QuestionList");
},
saveAndNext() {
this.$parent.$parent.componentsNumChange(3);
},
getQuestion(courseId) {
return getQuestion(courseId).then((res) => {
console.log(res);
this.questionList = res.rows.map((item) => {
return {
topicType: item.topicType,
topicId: item.topicId,
topicTitle: item.topicTitle,
};
});
this.questionNum = res.total;
return true;
});
},
getLessonById(courseId) {
getLessonById(courseId).then((res) => {
console.log(res);
this.bottomFrom = {
singleChoiceScore: res.data.singleChoiceScore || 0,
multipleChoiceScore: res.data.multipleChoiceScore || 0,
judgmentScore: res.data.judgmentScore || 0,
qualifiedNum: res.data.qualifiedNum || 0,
};
this.courseName = res.data.courseName;
});
},
edit(topicId) {
this.$emit("update:topicId", topicId);
this.$parent.$parent.componentsNumChange(3);
},
deleteLesson(topicId) {
this.$confirm("请确定删除该题", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.loading = true;
return deleteQuestion(topicId);
})
.then((res) => {
if (res.code == 200) {
this.$message({
message: "删除成功",
type: "success",
});
}
return this.getQuestion({ courseId: this.courseId });
})
.finally(() => {
this.loading = false;
// 课程列表重置一下
this.$parent.$parent.$parent.getList();
});
},
saveRightNum() {
// if (this.bottomFrom.rightNum > this.questionList.length) {
// this.$message({
// message: "答对题目数应小于等于考试题目总数",
// type: "warning",
// });
// return;
// }
// const danx = this.questionList.filter(item=>item.topicType===1);
// const duox = this.questionList.filter(item=>item.topicType===2);
// const pd = this.questionList.filter(item=>item.topicType===3);
// 如果有一个没写,就不允许保存
if (
!(
this.bottomFrom.singleChoiceScore >= 0 &&
this.bottomFrom.multipleChoiceScore >= 0 &&
this.bottomFrom.judgmentScore >= 0 &&
this.bottomFrom.qualifiedNum >= 0
)
) {
this.$message({
message: "请将分数填写完整",
type: "warning",
});
return;
}
changeLesson({
courseId: this.courseId,
// qualifiedNum: this.rightNum,
...this.bottomFrom,
}).then((res) => {
if (res.code == 200) {
this.$message({
message: "答题合格数修改成功",
type: "success",
});
}
});
},
},
};
</script>
<style lang="scss" scoped>
.add-question {
width: 100%;
height: 550px;
// overflow: hidden;
flex-direction: column;
padding-bottom: 7px;
margin-bottom: 20px;
border-bottom: 1px solid #bbbbbb00;
position: relative;
.text {
margin-top: 13px;
margin-bottom: 32px;
justify-content: space-between;
height: 28px;
.left {
line-height: 28px;
color: #101010;
font-size: 14px;
.warn {
display: inline-flex;
font-size: 12px;
color: red;
margin-left: 10px;
}
}
.right {
width: 411px;
line-height: 28px;
background: #1d84ff;
padding-right: 5px;
color: #fff;
text-align: right;
}
}
.detail {
position: absolute;
bottom: -20px;
left: 10px;
.textC {
font-weight: 800;
font-size: 18px;
}
.detail-item {
margin-right: 20px;
color: red;
}
}
.table {
flex: 1;
height: 0;
flex-direction: column;
.th {
width: 100%;
height: 70px;
line-height: 70px;
background: #f5f5f5;
color: #606266;
> div {
height: 100%;
}
.left {
width: 15%;
text-align: center;
}
.type {
width: 10%;
text-align: center;
}
.middle {
width: 50%;
padding-left: 50px;
}
.right {
width: 25%;
text-align: center;
}
}
.td-wrapper {
flex: 1;
overflow-y: auto;
// 这样子元素才能有滚动条
.td {
height: 68px;
line-height: 68px;
box-sizing: border-box;
border-bottom: 1px solid #bbbbbb;
&:last-child {
border-bottom: none;
}
> div {
height: 100%;
}
.left {
width: 15%;
text-align: center;
}
.type {
width: 10%;
text-align: center;
}
.middle {
width: 50%;
padding-left: 50px;
}
.right {
width: 25%;
text-align: center;
}
}
}
}
.rightNum {
margin-top: 5px;
height: 55px;
box-sizing: border-box;
border: 1px solid #bbbbbb;
line-height: 55px;
> .left {
width: 140px;
background: #0bab0c;
font-size: 14px;
color: #fff;
text-align: center;
}
> .middle {
> div {
margin-right: 5px;
}
.left-text {
margin-left: 10px;
}
.middle {
margin-right: 20px;
}
}
.right {
margin-left: 20px;
}
// background: black;
}
}
</style>
<template>
<div class="app-container">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
label-width="68px"
>
<el-form-item label="培训部门" prop="deptId">
<treeselect v-model="queryParams.deptId" style="width: 220px;" :options="deptOptions" :show-count="true" placeholder="请选择培训部门" />
</el-form-item>
<el-form-item label="主讲人" prop="courseName">
<el-input
v-model="queryParams.zhujiang"
placeholder="请输入主讲人"
clearable
size="small"
/>
</el-form-item>
<el-form-item label="培训计划" prop="courseType">
<el-select
v-model="queryParams.courseType"
placeholder="请选择培训计划"
clearable
size="small"
>
<el-option
v-for="course in courseOptions"
:key="course.planId"
:label="course.planName"
:value="course.planId"
/>
</el-select>
</el-form-item>
<el-form-item label="课程标题" prop="courseName">
<el-input
v-model="queryParams.courseName"
placeholder="请输入课程标题"
clearable
size="small"
/>
</el-form-item>
<!-- <el-form-item label="发布时间" prop="releaseTime">-->
<!-- <el-date-picker-->
<!-- v-model="queryParams.releaseTime"-->
<!-- value-format="yyyy-MM-dd HH:mm:ss"-->
<!-- type="datetime"-->
<!-- placeholder="选择日期时间"-->
<!-- default-time="12:00:00"-->
<!-- >-->
<!-- </el-date-picker>-->
<!-- </el-form-item>-->
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="search"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetClick"
>重置</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:book:add']"
>新增</el-button
>
</el-col>
</el-row>
<el-table v-loading="loading" :data="lessonsList">
<el-table-column label="培训部门" align="center" prop="deptName" width="120"/>
<el-table-column label="课程标题" align="center" prop="courseName" />
<el-table-column label="主讲人" align="center" prop="zhujiang" width="100"/>
<!-- <el-table-column label="课程类别" align="center" prop="planName">
<template v-slot="scope">
<div>
{{
courseOptions.filter(
(item) => item.planId == scope.row.courseType
)[0].planName
}}
</div>
</template>
</el-table-column> -->
<el-table-column label="培训计划" align="center" prop="courseType">
<template v-slot="scope">
<div>
{{
scope.row.courseType &&
courseOptions.filter(
(item) => item.planId == scope.row.courseType
)[0] &&
courseOptions.filter(
(item) => item.planId == scope.row.courseType
)[0].planName
}}
</div>
</template>
</el-table-column>
<el-table-column label="课程状态" align="center" prop="status" width="100">
<template v-slot="scope">
<div>{{ ["未发布", "已发布"][scope.row.status] }}</div>
</template>
</el-table-column>
<el-table-column label="附件" align="center" prop="enclosure" width="100">
<template v-slot="{ row: { enclosure } }">
<a
v-if="enclosure && enclosure.indexOf('.txt') >= 0"
@click="downloadText(enclosure)"
class="down-load"
>下载附件</a
>
<a v-else :href="enclosure" class="down-load">下载附件</a>
</template>
</el-table-column>
<!--<el-table-column label="视频" align="center" prop="video">-->
<!--<template v-slot="{ row: { courseName, video } }">-->
<!--<a @click="downLoadVideo(video, courseName)" class="down-load"-->
<!--&gt;下载视频</a-->
<!--&gt;-->
<!--</template>-->
<!--</el-table-column>-->
<el-table-column
label="发布时间"
align="center"
prop="releaseTime"
:formatter="formatter"
/>
<el-table-column
label="考试题"
align="center"
prop="topicNum"
width="180"
>
<template v-slot="{ row: { topicNum, courseId, status } }">
<span>
<span
class="timuNum"
@click="checkQuestion(courseId, status)"
v-if="topicNum > 0"
>
{{ status == 0 ? `已录入${topicNum}题` : "查看" }}
</span>
<span v-else-if="status === 1 && topicNum == 0"> - </span>
<span
class="timuNum"
@click="checkQuestion(courseId, status)"
v-else
>未录入</span
>
</span>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template
v-slot="{ row: { courseName, courseType, status, courseId } }"
>
<!-- <div>{{status}}</div> -->
<el-button
v-if="status == 0"
size="mini"
type="text"
icon="el-icon-edit"
@click="changeLesson(courseId)"
>修改</el-button
>
<el-button
v-if="status == 1"
size="mini"
type="text"
icon="el-icon-edit"
@click="checkLesson(courseId)"
>详情</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="deletLesson(courseId)"
>删除</el-button
>
<el-button
v-if="status == 0"
size="mini"
type="text"
icon="el-icon-delete"
@click="issueDilog(courseId, courseName, courseType)"
>发布</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"
/>
<Dia
ref="Dia"
:componentsNum.sync="componentsNum"
:courseId.sync="courseId"
:checkLock.sync="checkLock"
:visible.sync="dilogFlag"
/>
<el-dialog
class="lessons-program"
title="培训考试发布详情"
:visible.sync="issueVisible"
width="60%"
>
<span class="dialogName"
>培训名称: <span class="a">{{ dilogName }}</span>
</span>
<span class="dialogName"
>培训计划: <span class="a">{{ dilogType }}</span></span
>
<div class="detail flex">
<div class="detail-item">
单选题<span>{{ bottomFrom.singleChoiceScore }}</span
>/,<span>{{ danxs }}</span
>题,计<span class="textC">{{
danxs * bottomFrom.singleChoiceScore
}}</span
>
</div>
<div class="detail-item">
多选题<span>{{ bottomFrom.multipleChoiceScore }}</span
>/,<span>{{ duoxs }}</span> 题,计<span class="textC">{{
duoxs * bottomFrom.multipleChoiceScore
}}</span
>
</div>
<div class="detail-item">
判断题<span>{{ bottomFrom.judgmentScore }}</span
>/题,共<span>{{ pds }}</span> 题,计<span class="textC">{{
pds * bottomFrom.judgmentScore
}}</span
>
</div>
</div>
<div class="detail">
<div class="detail-item">
<span>{{ danxs + duoxs + pds }}</span
>道题,总共计<span class="textC">{{
danxs * bottomFrom.singleChoiceScore +
duoxs * bottomFrom.multipleChoiceScore +
pds * bottomFrom.judgmentScore
}}</span
>
</div>
</div>
<div class="detail">
<div class="detail-item">
合格分数为<span class="textC">{{ bottomFrom.qualifiedNum }}</span
>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="issueVisible = false"> </el-button>
<el-button type="primary" @click="issueLesson(issueCourseId)"
>确认发布</el-button
>
</span>
</el-dialog>
</div>
</template>
<script>
import {
getQuestion,
getLessons,
getLessonById,
issue,
deleteLesson,
} from "@/api/train/lessonsProgram.js";
// 获取培训计划
import { getPlanList } from "@/api/train/trainingProgram";
import { mapGetters, mapMutations } from "vuex";
import { treeselect } from "@/api/system/dept";
import Dia from "./components/Dia";
import Treeselect from "@riophae/vue-treeselect";
export default {
name: "Book",
components: {
Dia,
Treeselect
},
data() {
return {
// 遮罩层
loading: false,
// 总条数
total: 0,
// courseOptions: [],
lessonsList: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
courseType: null,
courseName: null,
releaseTime: "",
},
// 表单参数
form: {},
// 表单校验
dilogFlag: false,
// 发布弹框
issueVisible: false,
dilogName: "",
dilogType: null,
bottomFrom: {
singleChoiceScore: 0,
multipleChoiceScore: 0,
judgmentScore: 0,
qualifiedNum: 0,
},
issueCourseId: null,
questionList: [],
componentsNum: 1,
// 点击的id,如果是新增为空
courseId: null,
// false为编辑,true为查看,查看不允许编辑的时候
checkLock: false,
// 部门树选项
deptOptions: [],
};
},
computed: {
...mapGetters(["courseOptions"]),
danxs() {
return this.questionList.filter((item) => item.topicType === 1).length || 0;
},
duoxs() {
return this.questionList.filter((item) => item.topicType === 2).length || 0;
},
pds() {
return this.questionList.filter((item) => item.topicType === 3).length || 0;
},
},
created() {
this.getPlanList();
this.getList();
this.getTreeselect();
},
methods: {
...mapMutations({ setOptions: "SET_COURSE_OPTIONS" }),
// 获取课程类别,也就是计划名称
getPlanList() {
getPlanList().then((res) => {
const courseOptions = res.data.map((item) => {
return {
planId: item.planId,
planName: item.planName,
};
});
// this.$store.commit("SET_COURSE_OPTIONS");
this.setOptions(courseOptions);
});
},
/** 查询部门下拉树结构 */
getTreeselect() {
treeselect().then(response => {
console.log('部门树返回值')
this.deptOptions = response.data;
});
},
/** 查询课程列表 */
getList() {
this.loading = true;
getLessons(this.queryParams)
.then((res) => {
console.log(res);
this.lessonsList = res.rows;
this.total = res.total;
})
.finally(() => {
this.loading = false;
});
},
search() {
// console.log(this.queryParams);
this.getList();
},
/** 新增按钮操作 */
handleAdd() {
this.checkLock = false;
this.$refs.Dia.title = "新增培训课程";
this.componentsNum = 1;
this.courseId = null;
this.dilogFlag = true;
},
changeLesson(courseId) {
this.checkLock = false;
this.$refs.Dia.title = "修改培训课程";
this.componentsNum = 1;
this.courseId = courseId;
this.dilogFlag = true;
},
checkLesson(courseId) {
this.checkLock = true;
this.$refs.Dia.title = "查看培训课程";
this.componentsNum = 1;
this.courseId = courseId;
this.dilogFlag = true;
},
// 直接查看考题
checkQuestion(courseId, status) {
// 要查看考题的id
if (status == 1) {
this.checkLock = true;
}
this.courseId = courseId;
console.log(this.courseId);
// 2代表列表组件
this.componentsNum = 2;
this.dilogFlag = true;
},
// 重置
resetClick() {
this.reset();
this.getList();
},
// 复位
reset() {
this.queryParams = {
pageNum: 1,
pageSize: 10,
courseType: null,
courseName: null,
releaseTime: "",
};
},
deletLesson(courseId) {
this.$confirm("请确定删除", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
return deleteLesson(courseId);
})
.then((res) => {
if (res.code == 200) {
this.$message({
message: "删除成功",
type: "success",
});
}
this.getList();
})
.catch(() => {});
},
// 发布弹框
issueDilog(courseId, name, type) {
getQuestion({ courseId })
.then((res) => {
this.questionList = res.rows.map((item) => {
return {
topicType: item.topicType,
topicId: item.topicId,
topicTitle: item.topicTitle,
};
});
})
.then((res) => {
return getLessonById(courseId);
})
.then((res) => {
this.bottomFrom = {
singleChoiceScore: res.data.singleChoiceScore || 0,
multipleChoiceScore: res.data.multipleChoiceScore || 0,
judgmentScore: res.data.judgmentScore || 0,
qualifiedNum: res.data.qualifiedNum || 0,
};
})
.then((res) => {
this.dilogName = name;
this.dilogType =
type &&
this.courseOptions.filter((item) => item.planId == type)[0] &&
this.courseOptions.filter((item) => item.planId == type)[0]
.planName;
this.issueVisible = true;
this.issueCourseId = courseId;
});
//
},
// 发布
issueLesson(courseId) {
// this.$confirm("确定要发布吗", {
// confirmButtonText: "确定",
// cancelButtonText: "取消",
// type: "warning",
// })
// .then(() => {
// // 判断是否录入答题合格数
// return getLessonById(courseId);
// })
getLessonById(courseId)
.then((res) => {
// if (
// res.data.singleChoiceScore >= 0 &&
// res.data.multipleChoiceScore >= 0 &&
// res.data.judgmentScore >= 0 &&
// res.data.qualifiedNum >= 0
// ) {
return true;
// }
})
.then((res) => {
if (res) {
// 成功就发布
return issue({ courseId });
} else {
this.$message({
message: "请先在题目列表录入题目分数跟合格分数",
type: "warning",
});
}
})
.then((res) => {
if (res.code == 200) {
this.$message({
message: "发布成功",
type: "success",
});
this.getList();
this.issueVisible = false;
}
})
.catch(() => {});
},
formatter(row, column, cellValue, index) {
// console.log(row, column, cellValue, index);
if (!cellValue) return "-";
else return cellValue;
},
downloadText(url) {
// url = url.replace(/\\/g, "/");
const xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.responseType = "blob";
//xhr.setRequestHeader('Authorization', 'Basic a2VybWl0Omtlcm1pdA==');
xhr.onload = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
let blob = this.response;
console.log(blob);
// 转换一个blob链接
// 注: URL.createObjectURL() 静态方法会创建一个 DOMString(DOMString 是一个UTF-16字符串),
// 其中包含一个表示参数中给出的对象的URL。这个URL的生命周期和创建它的窗口中的document绑定
let downLoadUrl = window.URL.createObjectURL(
new Blob([blob], {
type: "txt",
})
);
// 视频的type是video/mp4,图片是image/jpeg
// 01.创建a标签
let a = document.createElement("a");
// 02.给a标签的属性download设定名称
a.download = name;
// 03.设置下载的文件名
a.href = downLoadUrl;
// 04.对a标签做一个隐藏处理
a.style.display = "none";
// 05.向文档中添加a标签
document.body.appendChild(a);
// 06.启动点击事件
a.click();
// 07.下载完毕删除此标签
a.remove();
}
};
xhr.send();
},
downLoadVideo(url, name) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.responseType = "arraybuffer"; // 返回类型blob
xhr.onload = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
let blob = this.response;
console.log(blob);
// 转换一个blob链接
// 注: URL.createObjectURL() 静态方法会创建一个 DOMString(DOMString 是一个UTF-16字符串),
// 其中包含一个表示参数中给出的对象的URL。这个URL的生命周期和创建它的窗口中的document绑定
let downLoadUrl = window.URL.createObjectURL(
new Blob([blob], {
type: "video/mp4",
})
);
// 视频的type是video/mp4,图片是image/jpeg
// 01.创建a标签
let a = document.createElement("a");
// 02.给a标签的属性download设定名称
a.download = name;
// 03.设置下载的文件名
a.href = downLoadUrl;
// 04.对a标签做一个隐藏处理
a.style.display = "none";
// 05.向文档中添加a标签
document.body.appendChild(a);
// 06.启动点击事件
a.click();
// 07.下载完毕删除此标签
a.remove();
}
};
xhr.send();
},
},
};
</script>
<style lang="scss" scoped>
.down-load {
color: #0bab0c;
}
.timuNum {
color: #1d84ff;
cursor: pointer;
}
::v-deep .el-select {
width: 100%;
}
::v-deep .el-dialog {
margin-top: 10vh !important;
}
::v-deep .el-dialog .el-dialog__body {
padding-top: 5px;
}
.dialogName {
margin-right: 50px;
// color: #ccc;
font-size: 16px;
}
.detail {
// position: absolute;
// bottom: -20px;
// left: 10px;
margin-top: 20px;
.textC {
font-weight: 800;
font-size: 18px;
}
.detail-item {
margin-right: 20px;
color: red;
}
}
</style>
<template>
<div ref="myBody" class="add-question flex">
<div class="text flex">
<div class="left">
目前录入题目是第<span>{{ questionNextNum }}</span
>道题
</div>
<div>
<el-radio-group
v-model="form.topicType"
size="mini"
@input="topicTypeChange"
>
<el-radio-button :label="1">单选</el-radio-button>
<el-radio-button :label="2">多选</el-radio-button>
<el-radio-button :label="3">判断</el-radio-button>
</el-radio-group>
</div>
<div class="right">{{ courseName }}</div>
</div>
<el-form class="form flex" ref="form" :model="form" label-width="auto">
<!-- <div class="top flex"> -->
<div>
<el-form-item
label="题目内容"
prop="topicTitle"
:rules="{
required: true,
message: '必须输入题目内容',
trigger: 'blur',
}"
>
<el-input
type="textarea"
placeholder="多行输入"
resize="none"
rows="4"
v-model="form.topicTitle"
>
</el-input>
</el-form-item>
</div>
<div class="bottom">
<!-- <el-form-item label="选项1" prop="title">
<el-input v-model="form.title" placeholder="请输入"></el-input>
</el-form-item> -->
<el-form-item
v-for="(question, index) in form.questions"
:label="'选项' + (index + 1)"
:key="question.key"
:prop="'questions.' + index + '.value'"
:rules="
index === 0
? {
required: true,
message: '第一项不能为空不能为空',
trigger: 'blur',
}
: {}
"
>
<div class="add-select flex">
<el-input
type="textarea"
placeholder="多行输入"
style="flex: 1; margin-right: 10px"
rows="2"
v-model="question.value"
></el-input>
<div class="flex algin-items">
<div
@click="rightAnswerClick(index)"
class="right"
:class="{ active: answerNum.indexOf(index) >= 0 }"
>
设为正确答案
</div>
<el-button
size="mini"
type="danger"
v-if="index > 0 && form.topicType != 3"
@click.prevent="removeDomain(question)"
>删除</el-button
>
</div>
</div>
</el-form-item>
<!-- <el-form-item
class="noAttr"
:label="`选项${form.questions.length + 1}`"
prop=""
>
<div class="add-select flex">
<el-input
type="textarea"
placeholder="多行输入"
resize="none"
rows="2"
v-model="addValue"
style="flex: 1; margin-right: 10px"
>
</el-input>
<div class="flex algin-items">
<div
@click="rightAnswerClick(form.questions.length)"
class="right"
:class="{ active: answerNum === form.questions.length }"
>
设为正确答案
</div> -->
<div style="padding-left: 30px" v-if="form.topicType != 3">
<el-button size="mini" type="primary" @click.prevent="add(addValue)"
>新增选项</el-button
>
</div>
<!-- </div>
</div>
</el-form-item> -->
</div>
</el-form>
</div>
</template>
<script>
// import {
// addQuestion,
// checkQuestion,
// changeQuestion,
// getQuestion,
// getLessonById,
// } from "@/api/train/lessonsProgram.js";
import {
addSubject,
getSubject,
listSubject,
updateSubject,
} from "@/api/train/subject";
export default {
name: "AnswerLesson",
props: {
// visible: {
// type: Boolean,
// default: false,
// },
bankId: {
type: Number,
},
subjectId: {
type: Number,
},
},
components: {},
data() {
return {
form: {
topicType: 1,
topicTitle: "",
questions: [{ value: "" }, { value: "" }],
},
answerNum: [],
addValue: "",
// 录入的是第几道题
questionNextNum: 1,
courseName: "",
};
},
created() {
// 如果存在就是修改
if (this.subjectId) {
getSubject(this.subjectId).then((res) => {
console.log("?", res.data);
const data = res.data;
this.form = {
topicType: data.topicType,
topicTitle: data.topicTitle,
questions: JSON.parse(data.topicOption),
};
// this.answerNum = data.answer;
this.answerNum = JSON.parse(data.answer);
});
}
// 查询是第几道题
this.getQuestion();
// 获取课程标题
// this.getLessonById(this.bankId);
},
methods: {
// 题目类型变化
topicTypeChange(num) {
if (num == 1) {
this.answerNum = [];
} else if (num == 2) {
this.answerNum = [];
// this.form.questions=[{ value: "" }, { value: "" }];
} else {
this.answerNum = [];
const form = {
topicType: 3,
topicTitle: this.form.topicTitle,
questions: [{ value: "对" }, { value: "错" }],
};
this.form = form;
}
},
getQuestion() {
listSubject({ bankId: this.bankId }).then((res) => {
console.log(res);
// 如果是修改 就是原来的值,如果不是,就是总数+1
if (this.subjectId) {
res.rows.forEach((item, index) => {
if (item.subjectId == this.subjectId) {
this.questionNextNum = index + 1;
}
});
} else {
this.questionNextNum = res.total + 1;
}
});
},
// getLessonById(bankId) {
// getLessonById(bankId).then((res) => {
// console.log(res);
// this.courseName = res.data.courseName;
// });
// },
addQuestion(data) {
// 如果是修改,就用修改的方法,如果是新增,就用新增的方法
if (this.subjectId) {
return updateSubject({ subjectId: this.subjectId, ...data });
} else {
return addSubject({ bankId: this.bankId, ...data });
}
},
rightAnswerClick(index) {
if (this.form.topicType === 2) {
const ind = this.answerNum.indexOf(index);
if (ind < 0) {
this.answerNum.push(index);
} else {
this.answerNum.splice(ind, 1);
}
this.answerNum = this.answerNum.sort((a, b) => {
return a - b;
});
console.log(this.answerNum);
} else {
// 判断跟单选模式差不多
this.answerNum = [index];
}
},
// 删除选项
removeDomain(question) {
const index = this.form.questions.indexOf(question);
console.log(index);
// 如果是正确答案,就让正确答案清空
const ind = this.answerNum.indexOf(index);
if (ind >= 0) {
this.answerNum.splice(ind, 1);
}
// 如果是最后一位呗删除,那不用管,如果不是最后一位置,这一位删除之后,则这一位后面的所有数字都要-1;
if (index != this.form.questions.length - 1) {
this.answerNum = this.answerNum.map((item, i) => {
if (item >= index) {
return item - 1;
} else {
return item;
}
});
}
if (index >= 0) {
this.form.questions.splice(index, 1);
}
console.log(this.answerNum);
// console.log(this.form.questions)
},
// 新增选项
add(addValue) {
this.form.questions.push({ value: addValue });
console.log();
},
save(num = 2) {
return new Promise((resove) => {
if (this.answerNum.length <= 0) {
this.$message({
message: "警告,请设置一个正确答案",
type: "warning",
});
return resove(false);
}
this.$refs.form.validate((valid) => {
if (valid) {
const data = {};
data.topicTitle = this.form.topicTitle;
data.topicOption = JSON.stringify(this.form.questions);
// data.answer = this.answerNum;
data.answer = JSON.stringify(this.answerNum);
data.topicType = this.form.topicType;
this.addQuestion(data).then((res) => {
if (res.code == 200) {
// 把修改的这个归位,变成正常添加
this.$emit("update:subjectId", null);
this.$message({
message: this.subjectId ? "添加题目成功" : "修改题目成功",
type: "success",
});
this.$parent.$parent.componentsNumChange(num);
this.$parent.$parent.$parent.getList();
resove(true);
}
});
}
});
});
},
saveAndNext() {
this.save(3).then((res) => {
if (res) {
this.reset();
// this.questionNextNum++;
this.getQuestion();
}
});
},
reset() {
this.form = {
topicTitle: "",
questions: [{ value: "" }, { value: "" }],
};
this.answerNum = [];
this.addValue = "";
},
},
};
</script>
<style lang="scss" scoped>
.add-question {
width: 100%;
height: 550px;
// overflow: hidden;
flex-direction: column;
padding-bottom: 7px;
margin-bottom: 20px;
border-bottom: 1px solid #bbbbbb;
.form {
flex: 1;
flex-direction: column;
height: 100%;
.bottom {
overflow-y: auto;
height: 330px;
box-sizing: border-box;
.algin-items {
align-items: center;
width: 200px;
}
.right {
display: inline-block;
width: 133px;
margin-right: 10px;
line-height: initial;
padding: 4px 0;
border: 1px solid #bbbbbb;
color: #101010;
font-size: 12px;
text-align: center;
border-radius: 4px;
box-sizing: border-box;
cursor: pointer;
&.active {
background-color: #0bab0c;
color: #ffffff;
}
&:hover {
background-color: rgba(11, 171, 12, 0.5);
color: #ffffff;
}
}
}
}
.text {
margin-top: 13px;
margin-bottom: 34px;
justify-content: space-between;
height: 28px;
.left {
line-height: 28px;
color: #101010;
font-size: 14px;
}
.right {
width: 411px;
line-height: 28px;
background: #1d84ff;
padding-right: 5px;
color: #fff;
text-align: right;
}
}
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 10:38:49
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-12-26 09:55:56
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/addLesson.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<el-dialog
class="add-lession"
:title="title"
:visible.sync="visible"
width="1000px"
:close-on-click-modal="false"
:close-on-press-escape="false"
:before-close="dialogCancel"
@closed="closeFinished"
destroy-on-close
>
<div v-if="visible" ref="myBody" class="body">
<transition name="fade" mode="out-in">
<component
:is="currentComponent"
:bankId.sync="bankId"
:subjectId.sync="subjectId"
ref="current"
></component>
</transition>
<!-- <Lesson ref='lesson'/> -->
<!-- <AddQuestion />
<QuestionList/> -->
</div>
<div slot="footer" class="dialog-footer">
<el-button
type="primary"
v-if="this.componentsNum == 1 || this.componentsNum == 3"
@click="save"
>保存</el-button
>
<el-button type="primary" @click="saveAndNext">{{
saveNextText
}}</el-button>
<el-button
v-if="this.componentsNum == 2"
type="primary"
@click="dialogCancel"
>{{ "确认" }}</el-button
>
<el-button @click="dialogCancel">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import Lesson from "./Lesson";
import AddQuestion from "./AddQuestion";
import QuestionList from "./QuestionList";
export default {
name: "AnswerLesson",
props: {
visible: {
type: Boolean,
default: false,
},
componentsNum: {
type: Number,
default: 1,
},
bankId: {
type: Number,
},
},
// components: {
// Lesson,
// AddQuestion,
// QuestionList,
// },
data() {
return {
title: "录入课程",
currentComponent: Lesson,
// 当前题目查看
subjectId: null,
};
},
watch: {
componentsNum: {
handler(num) {
if (num === 1) {
this.currentComponent = Lesson;
if (this.bankId) {
this.title = "修改课程";
} else {
this.title = "新增课程";
}
} else if (num === 2) {
this.currentComponent = QuestionList;
this.title = "题目列表";
} else {
this.currentComponent = AddQuestion;
if (this.subjectId) {
this.title = "修改题目";
} else {
this.title = "新增题目";
}
}
},
deep: true,
},
},
computed: {
saveNextText() {
let text;
if (this.componentsNum == 1) {
text = "保存并录入题目";
} else if (this.componentsNum == 2) {
text = "录入考题";
} else {
text = "保存并录入下一题";
}
return text;
},
},
methods: {
saveBody() {
this.startHeight = this.$refs.myBody.offsetHeight - 55 + "px";
},
closeFinished() {},
// 关闭之后
// 只保存
save() {
// this.answerClear();
this.$refs.current.save();
},
// 保存并录入
saveAndNext() {
this.$refs.current.saveAndNext();
},
// 隐藏与显示dialog
dialogCancel() {
// 录入题目的时候不会有修改的缓存
if (this.subjectId) {
this.subjectId = null;
}
this.$emit("update:visible", false);
},
// 把ID改变了
changeCourseId(bankId) {
this.$emit("update:bankId", bankId);
},
// 改变当前组件
componentsNumChange(num) {
this.$emit("update:componentsNum", num);
},
answerClear() {
this.answerArr = [];
this.changeCourseId(null);
},
},
};
</script>
<style lang="scss" scoped>
.body {
width: 100%;
height: 100%;
padding-right: 40px;
padding-left: 36px;
}
</style>
<template>
<div>
<el-upload
:action="uploadUrl"
:on-success="handleUploadSuccess"
:on-error="handleUploadError"
name="file"
:show-file-list="false"
:headers="headers"
style="display: none"
ref="upload"
v-if="this.uploadUrl"
>
</el-upload>
<div class="editor" ref="editor" :style="styles"></div>
</div>
</template>
<script>
import Quill from "quill";
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
import { getToken } from "@/utils/auth";
export default {
name: "Editor",
props: {
/* 编辑器的内容 */
value: {
type: String,
default: "",
},
/* 高度 */
height: {
type: Number,
default: null,
},
/* 最小高度 */
minHeight: {
type: Number,
default: null,
},
/* 只读 */
readOnly: {
type: Boolean,
default: false,
},
/* 上传地址 */
uploadUrl: {
type: String,
default: "",
}
},
data() {
return {
headers: {
Authorization: "Bearer " + getToken()
},
Quill: null,
currentValue: "",
options: {
theme: "snow",
bounds: document.body,
debug: "warn",
modules: {
// 工具栏配置
toolbar: [
["bold", "italic", "underline", "strike"], // 加粗 斜体 下划线 删除线
["blockquote", "code-block"], // 引用 代码块
[{ list: "ordered" }, { list: "bullet" }], // 有序、无序列表
[{ indent: "-1" }, { indent: "+1" }], // 缩进
[{ size: ["small", false, "large", "huge"] }], // 字体大小
[{ header: [1, 2, 3, 4, 5, 6, false] }], // 标题
[{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色
[{ align: [] }], // 对齐方式
["clean"], // 清除文本格式
["link", "image"] // 链接、图片、视频"video"
],
},
placeholder: "请输入内容",
readOnly: this.readOnly,
},
};
},
computed: {
styles() {
let style = {};
if (this.minHeight) {
style.minHeight = `${this.minHeight}px`;
}
if (this.height) {
style.height = `${this.height}px`;
}
return style;
},
},
watch: {
value: {
handler(val) {
if (val !== this.currentValue) {
this.currentValue = val === null ? "" : val;
if (this.Quill) {
this.Quill.pasteHTML(this.currentValue);
}
}
},
immediate: true,
},
},
mounted() {
this.init();
},
beforeDestroy() {
this.Quill = null;
},
methods: {
init() {
const editor = this.$refs.editor;
this.Quill = new Quill(editor, this.options);
// 如果设置了上传地址则自定义图片上传事件
if (this.uploadUrl) {
let toolbar = this.Quill.getModule("toolbar");
toolbar.addHandler("image", (value) => {
this.uploadType = "image";
if (value) {
this.$refs.upload.$children[0].$refs.input.click();
} else {
this.quill.format("image", false);
}
});
toolbar.addHandler("video", (value) => {
this.uploadType = "video";
if (value) {
this.$refs.upload.$children[0].$refs.input.click();
} else {
this.quill.format("video", false);
}
});
}
this.Quill.pasteHTML(this.currentValue);
this.Quill.on("text-change", (delta, oldDelta, source) => {
const html = this.$refs.editor.children[0].innerHTML;
const text = this.Quill.getText();
const quill = this.Quill;
this.currentValue = html;
this.$emit("input", html);
this.$emit("on-change", { html, text, quill });
});
this.Quill.on("text-change", (delta, oldDelta, source) => {
this.$emit("on-text-change", delta, oldDelta, source);
});
this.Quill.on("selection-change", (range, oldRange, source) => {
this.$emit("on-selection-change", range, oldRange, source);
});
this.Quill.on("editor-change", (eventName, ...args) => {
this.$emit("on-editor-change", eventName, ...args);
});
},
handleUploadSuccess(res, file) {
// 获取富文本组件实例
let quill = this.Quill;
// 如果上传成功
if (res.code == 200) {
// 获取光标所在位置
let length = quill.getSelection().index;
// 插入图片 res.url为服务器返回的图片地址
quill.insertEmbed(length, "image", res.url);
// 调整光标到最后
quill.setSelection(length + 1);
} else {
this.$message.error("图片插入失败");
}
},
handleUploadError() {
this.$message.error("图片插入失败");
},
},
};
</script>
<style>
.editor, .ql-toolbar {
white-space: pre-wrap !important;
line-height: normal !important;
}
.quill-img {
display: none;
}
.ql-snow .ql-tooltip[data-mode="link"]::before {
content: "请输入链接地址:";
}
.ql-snow .ql-tooltip.ql-editing a.ql-action::after {
border-right: 0px;
content: "保存";
padding-right: 0px;
}
.ql-snow .ql-tooltip[data-mode="video"]::before {
content: "请输入视频地址:";
}
.ql-snow .ql-picker.ql-size .ql-picker-label::before,
.ql-snow .ql-picker.ql-size .ql-picker-item::before {
content: "14px";
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="small"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="small"]::before {
content: "10px";
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="large"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="large"]::before {
content: "18px";
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="huge"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="huge"]::before {
content: "32px";
}
.ql-snow .ql-picker.ql-header .ql-picker-label::before,
.ql-snow .ql-picker.ql-header .ql-picker-item::before {
content: "文本";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="1"]::before {
content: "标题1";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before {
content: "标题2";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before {
content: "标题3";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="4"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="4"]::before {
content: "标题4";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="5"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="5"]::before {
content: "标题5";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="6"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="6"]::before {
content: "标题6";
}
.ql-snow .ql-picker.ql-font .ql-picker-label::before,
.ql-snow .ql-picker.ql-font .ql-picker-item::before {
content: "标准字体";
}
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="serif"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="serif"]::before {
content: "衬线字体";
}
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="monospace"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="monospace"]::before {
content: "等宽字体";
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 10:59:44
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-12-17 14:36:14
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/Lession.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="form-wrapper">
<el-form
class="form"
ref="form"
:model="form"
label-width="auto"
:rules="rules"
>
<div class="top flex">
<el-form-item label="题库名称" prop="bankName">
<el-input style="width: 300px" v-model="form.bankName"></el-input>
</el-form-item>
<el-form-item
label="归属部门"
prop="deptId"
label-width="140px"
ref="treeItem"
>
<Treeselect
class="tree"
v-model="form.deptId"
:options="deptOptions"
:show-count="true"
placeholder="请选择归属部门"
@open="treeOpen"
@close="treeClose"
@select="select"
/>
</el-form-item>
</div>
<!-- </div> -->
<!-- <el-form-item label="课程内容" prop="courseConent">
<Editor v-model="form.courseConent" :min-height="192" />
<el-input
v-show="false"
disabled
v-model="form.courseConent"
></el-input>
</el-form-item> -->
<!-- <div class="flex">
<el-form-item label="视频上传" v-if="!readOnly" prop="video">
<FileUpload
listType="picture"
@resFun="getFileInfoVideo"
@remove="listRemoveVideo"
:fileArr="fileListVideo"
:fileSize="500"
:fileType="['mp4']"
/>
<el-input v-show="false" disabled v-model="form.video"></el-input>
</el-form-item>
<el-form-item label="附件上传" v-if="!readOnly" prop="enclosure">
<FileUpload
listType="picture"
@resFun="getFileInfoFile"
@remove="listRemoveFile"
:fileArr="fileListFile"
/>
<el-input v-show="false" disabled v-model="form.enclosure"></el-input>
</el-form-item>
</div> -->
</el-form>
</div>
</template>
<script>
import Editor from "./Editor";
import FileUpload from "@/components/FileUpload";
import uploadfile from "@/assets/uploadfile.png";
// import { mapGetters } from "vuex";
// import {
// addLessons,
// getLessonById,
// changeLesson,
// } from "@/api/train/lessonsProgram";
import {
listBank,
addBank,
updateBank,
getBank,
} from "@/api/train/questionBank";
// 所有部门
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "",
props: {
bankId: {
type: Number,
},
},
components: {
Editor,
FileUpload,
Treeselect,
},
data() {
return {
form: {
bankName: "",
// courseType: "",
// courseConent: "",
// video: "",
// enclosure: "",
deptId: null,
},
// 归属部门列表
deptOptions: [],
fileListVideo: [],
fileListFile: [],
readOnly: false,
rules: {
bankName: [
{ required: true, trigger: "blur", message: "课程名称不能为空" },
],
deptId: [
{ required: true, trigger: "blur", message: "请选择所属部门" },
],
// courseType: [
// { required: true, trigger: "change", message: "课程类型不能为空" },
// ],
// courseConent: [
// { required: true, trigger: "blur", message: "课程内容不能为空" },
// ],
// video: [{ required: true, trigger: "blue", message: "视频不能为空" }],
// enclosure: [
// { required: true, trigger: "blur", message: "附件不能为空" },
// ],
},
};
},
computed: {
// 获取课程类型
// ...mapGetters(["courseOptions"]),
},
created() {
if (this.bankId) {
this.getLessonById();
}
// 归属部门列表
this.getTreeselect();
},
mounted() {},
methods: {
// 添加课程
addLessons(data) {
if (!this.bankId) {
console.log("添加");
return addBank(data);
} else {
console.log("修改");
return updateBank({ bankId: this.bankId, ...data });
}
},
/** 查询部门下拉树结构 */
getTreeselect() {
treeselect().then((response) => {
this.deptOptions = response.data;
console.log(this.deptOptions);
});
},
// 当树形组件打开
treeOpen() {
document.querySelector(".vue-treeselect__control").style.borderColor = "";
},
// 当属性组件关闭
treeClose(a, b) {
if (!a) {
// 手动添加报红功能,没值的时候报红
document.querySelector(".vue-treeselect__control").style.borderColor =
"red";
this.save();
} else {
document.querySelector(".vue-treeselect__control").style.borderColor =
"";
this.$refs.treeItem.clearValidate();
}
},
select() {},
// 复现
getLessonById() {
getBank(this.bankId).then((res) => {
console.log("res", res);
if (res.code == 200) {
this.form = {
bankName: res.data.bankName,
deptId: res.data.deptId,
};
// const data = res.data;
// const { bankName, courseType, courseConent, video, enclosure } =
// data;
// this.form = {
// bankName,
// courseType,
// courseConent,
// video,
// enclosure,
// };
// this.fileListVideo = [
// {
// name: bankName + "视频",
// url: uploadfile,
// },
// ];
// this.fileListFile = [
// {
// name: bankName + "附件",
// url: uploadfile,
// },
// ];
}
});
},
getFileInfoVideo(res) {
this.form.video = res.url;
// this.form.videoName = res.fileName;
this.fileListVideo = [
{
name: res.fileName,
url: uploadfile,
},
];
},
listRemoveVideo(e) {
this.fileListVideo = [];
this.form.video = "";
// this.form.videoName = null;
},
getFileInfoFile(res) {
this.form.enclosure = res.url;
// this.form.enclosureName = res.fileName;
this.fileListFile = [
{
name: res.fileName,
url: uploadfile,
},
];
},
listRemoveFile(e) {
this.fileListFild = [];
this.form.enclosure = "";
// this.form.fileName = null;
},
save(num = 2) {
// 因为富文本编辑器会残留<p><br></p>,所以要清
// if (this.form.courseConent === "<p><br></p>") {
// this.form.courseConent = "";
// }
this.$refs.form.validate((valid) => {
if (valid) {
this.addLessons({ ...this.form }).then((res) => {
// 如果添加会传回来,就用传回来的,如果是修改本身就有,就用本身的
// console.log('res',res)
const bankId = this.bankId || res;
// if (res.code == 200) {
// 这样调比较纯函数一点
if (num == 2) {
this.$message({
message: "保存题库成功",
type: "success",
});
} else if (num == 3) {
this.$message({
message: "保存题库成功,请开始录入题目",
type: "success",
});
}
this.$parent.$parent.componentsNumChange(num);
this.$parent.$parent.changeCourseId(bankId);
this.$parent.$parent.$parent.getList();
return true;
// }
});
} else {
if (!this.form.deptId) {
document.querySelector(
".vue-treeselect__control"
).style.borderColor = "red";
} else {
document.querySelector(
".vue-treeselect__control"
).style.borderColor = "";
this.$refs.treeItem.clearValidate();
}
}
});
},
// 保存并进入题目
saveAndNext() {
this.save(3);
},
},
};
</script>
<style lang="scss" scoped>
.form-wrapper {
padding-top: 22px;
width: 100%;
height: 100px;
// overflow: hidden;
// padding-bottom: 10px;
margin-bottom: 20px;
border-bottom: 1px solid #bbbbbb;
.top {
width: 100%;
justify-content: space-between;
}
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 17:56:05
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-01-15 13:47:35
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/QuestionList.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div ref="myBody" class="add-question flex">
<div class="text flex">
<div class="left">
目前有<span>{{ questionNum || 0 }}</span
>道题
<!-- <span class="warn">温馨提示:发布课程前需要进行考试设置</span> -->
</div>
<div class="right">{{ courseName }}</div>
</div>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
>导入</el-button
>
</el-col>
</el-row>
<div class="table flex" v-loading="loading">
<div class="th flex">
<div class="left">序号</div>
<div class="type">题目类型</div>
<div class="middle">题目名称</div>
<div class="right">操作</div>
</div>
<div class="td-wrapper">
<div
v-for="(item, index) in questionList"
:key="item.subjectId"
class="td flex"
>
<div class="left">{{ index + 1 }}</div>
<div class="type">{{ topicTypeArr[item.topicType] }}</div>
<div class="middle zzz">
{{ item.topicTitle }}
</div>
<div class="right">
<div>
<el-button
@click="edit(item.subjectId)"
icon="el-icon-edit"
type="text"
>修改</el-button
>
<el-button
@click="deleteLesson(item.subjectId)"
icon="el-icon-delete"
type="text"
>删除</el-button
>
</div>
</div>
</div>
</div>
</div>
<!-- <div class="rightNum flex">
<div class="left">录入考题</div>
<div class="middle flex">
<div class="left-text">答对题目大于</div>
<div>
<el-input
v-model="rightNum"
style="width: 60px"
size="mini"
></el-input>
</div>
<div>为合格</div>
</div>
<div class="right">
<el-button
@click="saveRightNum"
icon="el-icon-check"
size="mini"
type="success"
>保存</el-button
>
</div>
</div> -->
<!-- 设备导入对话框 -->
<el-dialog
:title="upload.title"
:visible.sync="upload.open"
width="400px"
append-to-body
>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="
upload.url +
'?updateSupport=' +
upload.updateSupport +
'&bankId=' +
upload.bankId
"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">
<!-- <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的设备数据-->
<!-- <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>-->
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleDownload(upload)"
>下载模板</el-button
>
</div>
<div class="el-upload__tip" style="color: red" slot="tip">
提示:仅允许导入“xls”或“xlsx”格式文件!
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm">确 定</el-button>
<el-button @click="upload.open = false">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
getQuestion,
deleteQuestion,
changeLesson,
getLessonById,
} from "@/api/train/lessonsProgram";
import { listSubject, delSubject } from "@/api/train/subject";
import { getBank } from "@/api/train/questionBank";
import { getToken } from "@/utils/auth";
export default {
name: "AnswerLesson",
props: {
bankId: {
type: Number,
},
},
components: {},
data() {
return {
// 当前课程的第几题,调一遍接口
questionNum: null,
// 答对几道题
rightNum: 0,
questionList: [],
loading: false,
courseName: "",
// 是否显示弹出层
open: false,
// 设备导入参数
upload: {
//题库id
bankId: 0,
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/system/subject/import",
},
queryParams: {
bankId: 0,
},
topicTypeArr: {
1: "单选题",
2: "多选题",
3: "判断题",
},
};
},
// watch: {
// visible(newValue) {
// if (newValue) {
// this.$nextTick(() => {
// this.saveBody();
// });
// }
// },
// },
created() {
console.log("this.bankId", this.bankId);
if (this.bankId) {
this.getQuestion({ bankId: this.bankId });
// 获取只题目正确几题算过关
this.getLessonById(this.bankId);
}
},
methods: {
// 文件下载处理
handleDownload(row) {
const a = document.createElement("a");
a.setAttribute("download", "试题导入模板");
a.setAttribute("target", "_blank");
a.setAttribute(
"href",
"http://36.138.181.113:8091/dangerManage/profile/upload/2022/kaoshi/shitimoban.xlsx"
);
a.click();
},
/** 导入按钮操作 */
handleImport() {
this.upload.bankId = this.bankId;
this.upload.title = "题目导入";
this.upload.open = true;
},
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
this.getQuestion({ bankId: this.bankId });
// this.getList();
this.$parent.$parent.$parent.getList();
},
/** 下载模板操作 */
importTemplate() {
importTemplate().then((response) => {
this.download(response.msg);
});
},
// 提交上传文件
submitFileForm() {
this.$refs.upload.submit();
},
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
save() {
console.log("QuestionList");
},
saveAndNext() {
this.$parent.$parent.componentsNumChange(3);
},
getQuestion(bankId) {
return listSubject(bankId).then((res) => {
this.questionList = res.rows.map((item) => {
return {
topicType:item.topicType,
subjectId: item.subjectId,
topicTitle: item.topicTitle,
};
});
this.questionNum = res.total;
return true;
});
},
getLessonById(bankId) {
getBank(bankId).then((res) => {
// console.log(res);
// this.rightNum = res.data.qualifiedNum;
this.courseName = res.data.bankName;
});
},
edit(subjectId) {
this.$emit("update:subjectId", subjectId);
this.$parent.$parent.componentsNumChange(3);
},
deleteLesson(subjectId) {
this.$confirm("请确定删除该题", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.loading = true;
return delSubject(subjectId);
})
.then((res) => {
if (res.code == 200) {
this.$message({
message: "删除成功",
type: "success",
});
}
return this.getQuestion({ bankId: this.bankId });
})
.finally(() => {
this.loading = false;
// 课程列表重置一下
this.$parent.$parent.$parent.getList();
});
},
saveRightNum() {
if (this.rightNum > this.questionList.length) {
this.$message({
message: "答对题目数应小于等于考试题目总数",
type: "warning",
});
return;
}
changeLesson({
bankId: this.bankId,
qualifiedNum: this.rightNum,
}).then((res) => {
if (res.code == 200) {
this.$message({
message: "答题合格数修改成功",
type: "success",
});
}
});
},
},
};
</script>
<style lang="scss" scoped>
.add-question {
width: 100%;
height: 550px;
// overflow: hidden;
flex-direction: column;
padding-bottom: 7px;
margin-bottom: 20px;
border-bottom: 1px solid #bbbbbb00;
.text {
margin-top: 13px;
margin-bottom: 32px;
justify-content: space-between;
height: 28px;
.left {
line-height: 28px;
color: #101010;
font-size: 14px;
.warn {
display: inline-flex;
font-size: 12px;
color: red;
margin-left: 10px;
}
}
.right {
width: 411px;
line-height: 28px;
background: #1d84ff;
padding-right: 5px;
color: #fff;
text-align: right;
}
}
.table {
flex: 1;
height: 0;
flex-direction: column;
.th {
width: 100%;
height: 70px;
line-height: 70px;
background: #f5f5f5;
color: #606266;
> div {
height: 100%;
}
.left {
width: 15%;
text-align: center;
}
.type {
width: 10%;
text-align: center;
}
.middle {
width: 50%;
padding-left: 50px;
}
.right {
width: 25%;
text-align: center;
}
}
.td-wrapper {
flex: 1;
overflow-y: auto;
// 这样子元素才能有滚动条
.td {
height: 68px;
line-height: 68px;
box-sizing: border-box;
border-bottom: 1px solid #bbbbbb;
&:last-child {
border-bottom: none;
}
> div {
height: 100%;
}
.left {
width: 15%;
text-align: center;
}
.type {
width: 10%;
text-align: center;
}
.middle {
width: 50%;
padding-left: 50px;
}
.right {
width: 25%;
text-align: center;
}
}
}
}
.rightNum {
margin-top: 5px;
height: 55px;
box-sizing: border-box;
border: 1px solid #bbbbbb;
line-height: 55px;
> .left {
width: 140px;
background: #0bab0c;
font-size: 14px;
color: #fff;
text-align: center;
}
> .middle {
> div {
margin-right: 5px;
}
.left-text {
margin-left: 10px;
}
.middle {
margin-right: 20px;
}
}
.right {
margin-left: 20px;
}
// background: black;
}
}
</style>
<template>
<div class="app-container">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
label-width="68px"
>
<!-- <el-form-item label="课件类别" prop="courseType">
<el-select
v-model="queryParams.courseType"
placeholder="请选择课程类型"
clearable
size="small"
>
<el-option
v-for="course in courseOptions"
:key="course.planId"
:label="course.planName"
:value="course.planId"
/>
</el-select>
</el-form-item> -->
<el-form-item
label="归属部门"
prop="deptId"
ref="treeItem"
>
<Treeselect
class="tree"
v-model="queryParams.deptId"
:options="deptOptions"
:show-count="true"
placeholder="请选择归属部门"
style="width:200px"
/>
</el-form-item>
<el-form-item label="题库名称" prop="courseName">
<el-input
v-model="queryParams.bankName"
placeholder="题库名称"
clearable
size="small"
/>
</el-form-item>
<!-- <el-form-item label="发布时间" prop="releaseTime">
<el-date-picker
v-model="queryParams.releaseTime"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
placeholder="选择日期时间"
default-time="12:00:00"
>
</el-date-picker>
</el-form-item> -->
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="search"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetClick"
>重置</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:book:add']"
>新增</el-button
>
</el-col>
</el-row>
<el-table v-loading="loading" :data="bankList">
<el-table-column label="序号" width='50' align="center" prop="bankNum"/>
<el-table-column label="题库名称" align="center" prop="bankName">
</el-table-column>
<el-table-column
label="归属部门"
align="center"
prop="courseType"
>
<template v-slot="scope">
<div>
{{ selectList(deptOptions, scope.row.deptId)||'-' }}
</div>
</template>
</el-table-column>
<!-- <el-table-column label="附件" align="center" prop="enclosure">
<template v-slot="{ row: { enclosure } }">
<a
v-if="enclosure && enclosure.indexOf('.txt') >= 0"
@click="downloadText(enclosure)"
class="down-load"
>下载附件</a
>
<a v-else :href="enclosure" class="down-load">下载附件</a>
</template>
</el-table-column> -->
<!-- <el-table-column label="视频" align="center" prop="video">
<template v-slot="{ row: { courseName, video } }">
<a @click="downLoadVideo(video, courseName)" class="down-load"
>下载视频</a
>
</template>
</el-table-column>
<el-table-column
label="发布时间"
align="center"
prop="releaseTime"
:formatter="formatter"
/> -->
<el-table-column
label="考试题数量"
align="center"
prop="topicNum"
width="180"
>
<template v-slot="{ row: { numberQuestions, bankId } }">
<div @click="checkQuestion(bankId)" class="timuNum">
<div v-if="numberQuestions > 0">{{ `已录入${numberQuestions}题` }}</div>
<div v-else>未录入</div>
</div>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template v-slot="{ row: { bankId } }">
<!-- <div>{{status}}</div> -->
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="changeBank(bankId)"
>编辑</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="deletBank(bankId)"
>删除</el-button
>
<!-- <el-button
v-if="status == 0"
size="mini"
type="text"
icon="el-icon-delete"
@click="issueLesson(bankId)"
>发布</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"
/>
<Dia
ref="Dia"
:componentsNum.sync="componentsNum"
:bankId.sync="bankId"
:visible.sync="dilogFlag"
/>
<el-dialog> </el-dialog>
</div>
</template>
<script>
// import {
// getLessons,
// getLessonById,
// issue,
// deleteLesson,
// } from "@/api/train/lessonsProgram.js";
import { listBank,delBank } from "@/api/train/questionBank";
// 部门列表
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
// 获取课程类型
// import { getPlanList } from "@/api/train/trainingProgram";
// import { mapGetters, mapMutations } from "vuex";
import Dia from "./components/Dia";
export default {
name: "questionBank",
components: {
Dia,
Treeselect
},
data() {
return {
// 遮罩层
loading: false,
// 总条数
total: 0,
// courseOptions: [],
bankList: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
// 所属部门
deptId: null,
// 题库名称
bankName: null,
releaseTime: "",
numberQuestions:0
},
// 表单参数
form: {},
// 表单校验
dilogFlag: false,
componentsNum: 1,
// 点击的id,如果是新增为空
bankId: null,
// 题库id
deptId: null,
// 归属部门列表
deptOptions: [],
};
},
computed: {
// ...mapGetters(["courseOptions"]),
},
created() {
// this.getPlanList();
this.getTreeselect();
this.getList();
},
methods: {
// ...mapMutations({ setOptions: "SET_COURSE_OPTIONS" }),
/** 查询部门下拉树结构 */
getTreeselect() {
treeselect().then((response) => {
this.deptOptions = response.data;
// console.log("123", this.deptOptions);
// console.log(this.selectList(this.deptOptions, 175));
});
},
// 递归查值的方法
selectList(list, id) {
for (let i = 0; i < list.length; i++) {
let item = list[i];
if (item.id == id) {
return item.label;
} else {
if (Array.isArray(item.children)) {
let a = this.selectList(item.children, id);
if (a) {
return a;
}
}
}
}
},
// 获取课程类别,也就是计划名称
// getPlanList() {
// getPlanList().then((res) => {
// const courseOptions = res.data.map((item) => {
// return {
// planId: item.planId,
// planName: item.planName,
// };
// });
// // this.$store.commit("SET_COURSE_OPTIONS");
// this.setOptions(courseOptions);
// });
// },
/** 查询课程列表 */
getList() {
this.loading = true;
listBank(this.queryParams)
.then((res) => {
console.log(res);
this.bankList = res.rows.map((item, index) => {
return {
bankNum:
index +
1 +
(this.queryParams.pageNum - 1) * this.queryParams.pageSize,
...item,
};
});
this.total = res.total;
})
.finally(() => {
this.loading = false;
});
},
search() {
// console.log(this.queryParams);
this.getList();
},
/** 新增按钮操作 */
handleAdd() {
this.$refs.Dia.title = "新增题库";
this.componentsNum = 1;
this.bankId = null;
this.dilogFlag = true;
},
changeBank(bankId) {
this.$refs.Dia.title = "修改题库";
this.componentsNum = 1;
this.bankId = bankId;
this.dilogFlag = true;
},
// 直接查看考题
checkQuestion(bankId) {
// 要查看考题的id
this.bankId = bankId;
// 2代表列表组件
this.componentsNum = 2;
this.dilogFlag = true;
},
// 重置
resetClick() {
this.reset();
this.getList();
},
// 复位
reset() {
this.queryParams = {
pageNum: 1,
pageSize: 10,
courseType: null,
courseName: null,
releaseTime: "",
};
},
deletBank(bankId) {
this.$confirm("请确定删除", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
return delBank(bankId);
})
.then((res) => {
if (res.code == 200) {
this.$message({
message: "删除成功",
type: "success",
});
}
this.getList();
})
.catch(() => {});
},
// 发布
// issueLesson(bankId) {
// this.$confirm("请确定发布", {
// confirmButtonText: "确定",
// cancelButtonText: "取消",
// type: "warning",
// })
// .then(() => {
// // 判断是否录入答题合格数
// return getLessonById(bankId);
// })
// .then((res) => {
// if (res.data.qualifiedNum > 0) {
// return true;
// }
// })
// .then((res) => {
// if (res) {
// // 成功就发布
// return issue({ bankId });
// } else {
// this.$message({
// message: "请先录入答题合格数",
// type: "warning",
// });
// }
// })
// .then((res) => {
// if (res.code == 200) {
// this.$message({
// message: "发布成功",
// type: "success",
// });
// this.getList();
// }
// })
// .catch(() => {});
// },
formatter(row, column, cellValue, index) {
// console.log(row, column, cellValue, index);
if (!cellValue) return "-";
else return cellValue;
},
// downloadText(url) {
// // url = url.replace(/\\/g, "/");
// const xhr = new XMLHttpRequest();
// xhr.open("GET", url, true);
// xhr.responseType = "blob";
// //xhr.setRequestHeader('Authorization', 'Basic a2VybWl0Omtlcm1pdA==');
// xhr.onload = function () {
// if (xhr.readyState === 4 && xhr.status === 200) {
// let blob = this.response;
// console.log(blob);
// // 转换一个blob链接
// // 注: URL.createObjectURL() 静态方法会创建一个 DOMString(DOMString 是一个UTF-16字符串),
// // 其中包含一个表示参数中给出的对象的URL。这个URL的生命周期和创建它的窗口中的document绑定
// let downLoadUrl = window.URL.createObjectURL(
// new Blob([blob], {
// type: "txt",
// })
// );
// // 视频的type是video/mp4,图片是image/jpeg
// // 01.创建a标签
// let a = document.createElement("a");
// // 02.给a标签的属性download设定名称
// a.download = name;
// // 03.设置下载的文件名
// a.href = downLoadUrl;
// // 04.对a标签做一个隐藏处理
// a.style.display = "none";
// // 05.向文档中添加a标签
// document.body.appendChild(a);
// // 06.启动点击事件
// a.click();
// // 07.下载完毕删除此标签
// a.remove();
// }
// };
// xhr.send();
// },
// downLoadVideo(url, name) {
// var xhr = new XMLHttpRequest();
// xhr.open("GET", url, true);
// xhr.responseType = "arraybuffer"; // 返回类型blob
// xhr.onload = function () {
// if (xhr.readyState === 4 && xhr.status === 200) {
// let blob = this.response;
// console.log(blob);
// // 转换一个blob链接
// // 注: URL.createObjectURL() 静态方法会创建一个 DOMString(DOMString 是一个UTF-16字符串),
// // 其中包含一个表示参数中给出的对象的URL。这个URL的生命周期和创建它的窗口中的document绑定
// let downLoadUrl = window.URL.createObjectURL(
// new Blob([blob], {
// type: "video/mp4",
// })
// );
// // 视频的type是video/mp4,图片是image/jpeg
// // 01.创建a标签
// let a = document.createElement("a");
// // 02.给a标签的属性download设定名称
// a.download = name;
// // 03.设置下载的文件名
// a.href = downLoadUrl;
// // 04.对a标签做一个隐藏处理
// a.style.display = "none";
// // 05.向文档中添加a标签
// document.body.appendChild(a);
// // 06.启动点击事件
// a.click();
// // 07.下载完毕删除此标签
// a.remove();
// }
// };
// xhr.send();
// },
},
};
</script>
<style lang="scss" scoped>
.down-load {
color: #0bab0c;
}
.timuNum {
color: #1d84ff;
cursor: pointer;
}
::v-deep .el-select {
width: 100%;
}
::v-deep .el-dialog {
margin-top: 15vh !important;
}
</style>
<template>
<div ref="myBody" class="add-question flex">
<div class="text flex">
<div class="left">
目前录入题目是第<span>{{ questionNextNum }}</span
>道题
</div>
<div>
<el-radio-group
v-model="form.topicType"
size="mini"
@input="topicTypeChange"
>
<el-radio-button :disabled="checkLock" :label="1"
>单选</el-radio-button
>
<el-radio-button :disabled="checkLock" :label="2"
>多选</el-radio-button
>
<el-radio-button :disabled="checkLock" :label="3"
>判断</el-radio-button
>
</el-radio-group>
</div>
<div class="right">{{ courseName }}</div>
</div>
<el-form class="form flex" ref="form" :model="form" label-width="auto">
<!-- <div class="top flex"> -->
<div>
<el-form-item
label="题目内容"
prop="topicTitle"
:rules="{
required: true,
message: '必须输入题目内容',
trigger: ['blur', 'change'],
}"
>
<el-input
type="textarea"
placeholder="多行输入"
resize="none"
rows="4"
v-model="form.topicTitle"
:disabled="checkLock"
>
</el-input>
</el-form-item>
</div>
<div class="bottom">
<!-- <el-form-item label="选项1" prop="title">
<el-input v-model="form.title" placeholder="请输入"></el-input>
</el-form-item> -->
<el-form-item
v-for="(question, index) in form.questions"
:label="'选项' + (index + 1)"
:key="question.key"
:prop="'questions.' + index + '.value'"
:rules="{
required: true,
message: '第一项不能为空不能为空',
trigger: ['blur', 'change'],
}"
>
<div class="add-select flex">
<el-input
type="textarea"
placeholder="多行输入"
style="flex: 1; margin-right: 10px"
rows="2"
v-model="question.value"
:disabled="checkLock"
></el-input>
<div class="flex algin-items">
<div
@click="rightAnswerClick(index)"
class="right"
:class="{ active: answerNum.indexOf(index) >= 0 }"
>
设为正确答案
</div>
<el-button
size="mini"
type="danger"
v-if="index > 0 && form.topicType != 3"
@click.prevent="removeDomain(question)"
:disabled="checkLock"
>删除</el-button
>
</div>
</div>
</el-form-item>
<!-- <el-form-item
class="noAttr"
:label="`选项${form.questions.length + 1}`"
prop=""
>
<div class="add-select flex">
<el-input
type="textarea"
placeholder="多行输入"
resize="none"
rows="2"
v-model="addValue"
style="flex: 1; margin-right: 10px"
>
</el-input>
<div class="flex algin-items">
<div
@click="rightAnswerClick(form.questions.length)"
class="right"
:class="{ active: answerNum === form.questions.length }"
>
设为正确答案
</div> -->
<div style="padding-left: 30px">
<el-button
size="mini"
type="primary"
@click.prevent="add(addValue)"
:disabled="checkLock"
>新增选项</el-button
>
</div>
<!-- </div>
</div>
</el-form-item> -->
</div>
</el-form>
</div>
</template>
<script>
import {
addQuestion,
checkQuestion,
changeQuestion,
getQuestion,
getLessonById,
} from "@/api/train/lessonsProgram.js";
export default {
name: "AnswerLesson",
props: {
// visible: {
// type: Boolean,
// default: false,
// },
courseId: {
type: Number,
},
topicId: {
type: Number,
},
checkLock: {
type: Boolean,
},
},
components: {},
data() {
return {
form: {
topicType: 1,
topicTitle: "",
questions: [{ value: "" }, { value: "" }],
},
answerNum: [],
addValue: "",
// 录入的是第几道题
questionNextNum: 1,
courseName: "",
};
},
created() {
// 如果存在就是修改
if (this.topicId) {
checkQuestion(this.topicId).then((res) => {
console.log(res.data);
const data = res.data;
this.form = {
topicType: data.topicType,
topicTitle: data.topicTitle,
questions: JSON.parse(data.topicOption),
};
// this.answerNum = data.answer;
this.answerNum = JSON.parse(data.answer);
});
}
// 查询是第几道题
this.getQuestion();
// 获取课程标题
this.getLessonById(this.courseId);
},
methods: {
// 题目类型变化
topicTypeChange(num) {
if (num == 1) {
this.answerNum = [];
} else if (num == 2) {
this.answerNum = [];
// this.form.questions=[{ value: "" }, { value: "" }];
} else {
this.answerNum = [];
const form = {
topicType: 3,
topicTitle: this.form.topicTitle,
questions: [{ value: "对" }, { value: "错" }],
};
this.form = form;
}
},
getQuestion() {
getQuestion({ courseId: this.courseId }).then((res) => {
// 如果是修改 就是原来的值,如果不是,就是总数+1
console.log(res);
if (this.topicId) {
res.rows.forEach((item, index) => {
if (item.topicId == this.topicId) {
this.questionNextNum = index + 1;
}
});
} else {
this.questionNextNum = res.total + 1;
}
});
},
getLessonById(courseId) {
getLessonById(courseId).then((res) => {
console.log(res);
this.courseName = res.data.courseName;
});
},
addQuestion(data) {
// 如果是修改,就用修改的方法,如果是新增,就用新增的方法
if (this.topicId) {
return changeQuestion({ topicId: this.topicId, ...data });
} else {
return addQuestion({ courseId: this.courseId, ...data });
}
},
rightAnswerClick(index) {
if (this.checkLock) return;
if (this.form.topicType === 2) {
const ind = this.answerNum.indexOf(index);
if (ind < 0) {
this.answerNum.push(index);
} else {
this.answerNum.splice(ind, 1);
}
this.answerNum = this.answerNum.sort((a, b) => {
return a - b;
});
console.log(this.answerNum);
} else {
// 判断跟单选模式差不多
this.answerNum = [index];
}
},
// 删除选项
removeDomain(question) {
if (this.checkLock) return;
const index = this.form.questions.indexOf(question);
console.log(index);
// 如果是正确答案,就让正确答案清空
const ind = this.answerNum.indexOf(index);
if (ind >= 0) {
this.answerNum.splice(ind, 1);
}
// 如果是最后一位呗删除,那不用管,如果不是最后一位置,这一位删除之后,则这一位后面的所有数字都要-1;
if (index != this.form.questions.length - 1) {
this.answerNum = this.answerNum.map((item, i) => {
if (item >= index) {
return item - 1;
} else {
return item;
}
});
}
if (index >= 0) {
this.form.questions.splice(index, 1);
}
console.log(this.answerNum);
// console.log(this.form.questions)
},
// 删除选项
// removeDomain(question) {
// const index = this.form.questions.indexOf(question);
// // 如果是正确答案,就让正确答案清空
// if (this.answerNum === index) {
// this.answerNum = null;
// }
// if (index >= 0) {
// this.form.questions.splice(index, 1);
// }
// },
// 新增选项
add(addValue) {
this.form.questions.push({ value: addValue });
console.log();
},
save(num = 2) {
return new Promise((resove) => {
if (!this.answerNum && this.answerNum !== 0) {
this.$message({
message: "警告,请设置一个正确答案",
type: "warning",
});
return resove(false);
}
this.$refs.form.validate((valid) => {
if (valid) {
const data = {};
data.topicTitle = this.form.topicTitle;
data.topicOption = JSON.stringify(this.form.questions);
// data.answer = this.answerNum;
data.answer = JSON.stringify(this.answerNum);
data.topicType = this.form.topicType;
this.addQuestion(data).then((res) => {
if (res.code == 200) {
// 把修改的这个归位,变成正常添加
this.$emit("update:topicId", null);
this.$message({
message: "添加题目成功",
type: "success",
});
this.$parent.$parent.componentsNumChange(num);
this.$parent.$parent.$parent.getList();
resove(true);
}
});
}
});
});
},
saveAndNext() {
this.save(3).then((res) => {
if (res) {
this.reset();
// this.questionNextNum++;
this.getQuestion();
}
});
},
reset() {
this.form = {
topicTitle: "",
questions: [{ value: "" }, { value: "" }],
};
this.answerNum = [];
this.addValue = "";
},
},
};
</script>
<style lang="scss" scoped>
.add-question {
width: 100%;
height: 550px;
// overflow: hidden;
flex-direction: column;
padding-bottom: 7px;
margin-bottom: 20px;
border-bottom: 1px solid #bbbbbb;
.form {
flex: 1;
flex-direction: column;
height: 100%;
.bottom {
overflow-y: auto;
height: 330px;
box-sizing: border-box;
.algin-items {
align-items: center;
width: 200px;
}
.right {
display: inline-block;
width: 133px;
margin-right: 10px;
line-height: initial;
padding: 4px 0;
border: 1px solid #bbbbbb;
color: #101010;
font-size: 12px;
text-align: center;
border-radius: 4px;
box-sizing: border-box;
cursor: pointer;
&.active {
background-color: #0bab0c;
color: #ffffff;
}
&:hover {
background-color: rgba(11, 171, 12, 0.5);
color: #ffffff;
}
}
}
}
.text {
margin-top: 13px;
margin-bottom: 34px;
justify-content: space-between;
height: 28px;
.left {
line-height: 28px;
color: #101010;
font-size: 14px;
}
.right {
width: 411px;
line-height: 28px;
background: #1d84ff;
padding-right: 5px;
color: #fff;
text-align: right;
}
}
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-12-27 09:30:19
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-02-01 18:02:14
* @FilePath: /danger-manage-web/src/views/train/textPaper/components/ChangeQuestion.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="table-wrapper">
<el-form :model="queryParams" ref="queryForm" :inline="true">
<el-form-item label="所属单位" prop="deptId" ref="treeItem">
<Treeselect
class="tree"
v-model="queryParams.deptId"
:options="deptOptions"
:show-count="true"
placeholder="请选择归属部门"
style="width: 200px"
/>
</el-form-item>
<el-form-item label="题库名称" prop="bankName">
<el-input
v-model="queryParams.bankName"
placeholder="考试时间"
clearable
size="small"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="search"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetClick"
>重置</el-button
>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="list" height="435" ref="multipleTable">
<!-- <el-table-column type="selection"></el-table-column> -->
<el-table-column label="" align="center" prop="profession">
<template v-slot="{ row }">
<!-- <div> -->
<el-checkbox
:disabled="row.numberQuestions == 0"
v-model="row.checked"
></el-checkbox>
<!-- </div> -->
</template>
</el-table-column>
<el-table-column label="题库名称" align="center" prop="bankName">
</el-table-column>
<el-table-column label="所属单位" align="center" prop="courseType">
<template v-slot="scope">
<div>
{{ selectList(deptOptions, scope.row.deptId) || "-" }}
</div>
</template>
</el-table-column>
<el-table-column
label="包含题目数量"
align="center"
prop="numberQuestions"
:formatter="formatter"
>
</el-table-column>
<el-table-column label="选取题目数量" align="center" prop="profession">
<template v-slot="{ row }">
<div>
<!-- <el-input
:disabled="!row.checked|| row.numberQuestions==0 "
v-model="row.changeNum"
size="mini"
style="width: 100px"
></el-input> -->
<el-input-number
v-model="row.changeNum"
:disabled="!row.checked || row.numberQuestions == 0"
size="mini"
:min="1"
:max="+row.numberQuestions ? +row.numberQuestions : 1000000"
label="描述文字"
></el-input-number>
</div>
</template>
</el-table-column>
</el-table>
<!-- <div> -->
<el-pagination
:layout="'prev, pager, next'"
v-show="total > 0"
:total="total"
:current-page="queryParams.pageNum"
:page-sizes="[queryParams.pageSize]"
@current-change="currentChangeClick"
/>
</div>
</template>
<script>
import { listBank, delBank } from "@/api/train/questionBank";
import { bachAddTopic } from "@/api/train/lessonsProgram.js";
// 部门列表
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "",
components: {
Treeselect,
},
props: {
courseId: {
type: Number,
},
},
data() {
return {
queryParams: {
deptId: null,
courseName: "",
pageNum: 1,
pageSize: 10,
},
list: [
{
checked: false,
},
],
total: 20,
loading: false,
// 题库id
deptId: null,
// 归属部门列表
deptOptions: [],
};
},
created() {
this.getList();
this.getTreeselect();
},
methods: {
getTreeselect() {
treeselect().then((response) => {
this.deptOptions = response.data;
// console.log("123", this.deptOptions);
// console.log(this.selectList(this.deptOptions, 175));
});
},
// 递归查值的方法
selectList(list, id) {
for (let i = 0; i < list.length; i++) {
let item = list[i];
if (item.id == id) {
return item.label;
} else {
if (Array.isArray(item.children)) {
let a = this.selectList(item.children, id);
if (a) {
return a;
}
}
}
}
},
getList() {
this.loading = true;
listBank(this.queryParams)
.then((res) => {
console.log(res);
this.list = res.rows.map((item, index) => {
return {
bankNum:
index +
1 +
(this.queryParams.pageNum - 1) * this.queryParams.pageSize,
checked: false,
changeNum: 0,
...item,
};
});
this.total = res.total;
})
.finally(() => {
this.loading = false;
});
},
save(num = 2) {
const topicInfos = this.list
.filter((item) => item.checked)
.map((item) => {
return {
bankId: item.bankId,
quan: item.changeNum,
};
});
console.log(this.courseId, topicInfos);
const data = { courseId: this.courseId, topicInfos };
console.log(data);
bachAddTopic(data).then((res) => {
console.log(res);
if (res.code == 200) {
this.$parent.$parent.componentsNumChange(num);
this.$parent.$parent.$parent.getList();
}
});
},
saveAndNext() {
this.save(3);
},
resetClick() {},
search() {
this.getList();
},
currentChangeClick() {},
formatter(row, column, cellValue, index) {
// console.log(row, column, cellValue, index);
if (!cellValue) return "-";
else return cellValue;
},
},
};
</script>
<style lang="scss" scoped>
.table-wrapper {
padding-top: 22px;
width: 100%;
height: 550px;
overflow: hidden;
// padding-bottom: 10px;
margin-bottom: 20px;
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 10:38:49
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-02-01 17:34:25
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/addLesson.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<el-dialog
class="add-lession"
:title="title"
:visible.sync="visible"
width="1020px"
:close-on-click-modal="false"
:close-on-press-escape="false"
:before-close="dialogCancel"
@closed="closeFinished"
destroy-on-close
>
<div v-if="visible" ref="myBody" class="body">
<transition name="fade" mode="out-in">
<component
:is="currentComponent"
:courseId.sync="courseId"
:topicId.sync="topicId"
:checkLock="checkLock"
ref="current"
></component>
</transition>
<!-- <Lesson ref='lesson'/> -->
<!-- <AddQuestion />
<QuestionList/> -->
</div>
<!-- <div slot="footer" class="dialog-footer">
<el-button
type="primary"
v-if="this.componentsNum == 2"
@click="componentsNumChange(4)"
>从题库选择</el-button
>
<el-button
type="primary"
v-if="this.componentsNum == 1 || this.componentsNum == 3"
@click="save"
>保存</el-button
>
<el-button
type="primary"
v-if="this.componentsNum == 4"
@click="componentsNumChange(2)"
>返回题目列表</el-button
>
<el-button type="primary" @click="saveAndNext">{{
saveNextText
}}</el-button>
<el-button
v-if="this.componentsNum == 2"
type="primary"
@click="dialogCancel"
>{{ "确认" }}</el-button
>
<el-button @click="dialogCancel">取消</el-button>
</div> -->
<div slot="footer" class="dialog-footer" v-if="!checkLock">
<el-button
type="primary"
v-if="this.componentsNum == 2 && !checkLock"
@click="componentsNumChange(4)"
>从题库选择</el-button
>
<el-button
type="primary"
v-if="this.componentsNum == 4 || this.componentsNum == 3"
@click="componentsNumChange(2)"
>返回题目列表</el-button
>
<el-button
type="primary"
v-if="
this.componentsNum == 1 ||
this.componentsNum == 3 ||
this.componentsNum == 4
"
@click="save"
>保存</el-button
>
<el-button type="primary" @click="saveAndNext" v-if="!checkLock">{{
saveNextText
}}</el-button>
<el-button
v-if="this.componentsNum == 2"
type="primary"
@click="dialogCancel"
>{{ "确认" }}</el-button
>
<el-button @click="dialogCancel">取消</el-button>
</div>
<div slot="footer" class="dialog-footer" v-else>
<el-button
type="primary"
v-if="this.componentsNum == 3 && checkLock"
@click="componentsNumChange(2)"
>返回题目列表</el-button
>
<el-button type="primary" @click="dialogCancel">{{ "确认" }}</el-button>
<el-button @click="dialogCancel">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import Lesson from "./Lesson";
import AddQuestion from "./AddQuestion";
import QuestionList from "./QuestionList";
import ChangeQuestion from "./ChangeQuestion";
export default {
name: "AnswerLesson",
props: {
visible: {
type: Boolean,
default: false,
},
componentsNum: {
type: Number,
default: 1,
},
courseId: {
type: Number,
},
checkLock: {
type: Boolean,
},
},
// components: {
// Lesson,
// AddQuestion,
// QuestionList,
// },
data() {
return {
title: "录入课程",
currentComponent: Lesson,
// 当前题目查看
topicId: null,
};
},
watch: {
componentsNum: {
handler(num) {
if (num === 1) {
this.currentComponent = Lesson;
if (this.courseId) {
this.title = "修改课程";
} else {
this.title = "新增课程";
}
} else if (num === 2) {
this.currentComponent = QuestionList;
this.title = "题目列表";
} else if (num === 3) {
this.currentComponent = AddQuestion;
if (this.topicId) {
this.title = "修改题目";
} else {
this.title = "新增题目";
}
} else if (num == 4) {
this.currentComponent = ChangeQuestion;
this.title = "从题库选题";
}
},
deep: true,
},
},
computed: {
saveNextText() {
let text;
if (this.componentsNum == 1) {
text = "保存并录入题目";
} else if (this.componentsNum == 2) {
text = "录入考题";
} else {
text = "保存并录入下一题";
}
return text;
},
},
methods: {
saveBody() {
this.startHeight = this.$refs.myBody.offsetHeight - 55 + "px";
},
closeFinished() {},
// 关闭之后
// 只保存
save() {
// this.answerClear();
this.$refs.current.save();
},
// 保存并录入
saveAndNext() {
this.$refs.current.saveAndNext();
},
// 隐藏与显示dialog
dialogCancel() {
// 录入考题的时候不会有修改的缓存
if (this.topicId) {
this.topicId = null;
}
this.$emit("update:visible", false);
this.$emit("update:checkLock", false);
},
// 把ID改变了
changeCourseId(courseId) {
this.$emit("update:courseId", courseId);
},
// 改变当前组件
componentsNumChange(num) {
this.$emit("update:componentsNum", num);
},
answerClear() {
this.answerArr = [];
this.changeCourseId(null);
},
},
};
</script>
<style lang="scss" scoped>
.body {
width: 100%;
height: 100%;
padding-right: 40px;
padding-left: 36px;
}
</style>
<template>
<div>
<el-upload
:action="uploadUrl"
:on-success="handleUploadSuccess"
:on-error="handleUploadError"
name="file"
:show-file-list="false"
:headers="headers"
style="display: none"
ref="upload"
v-if="this.uploadUrl"
>
</el-upload>
<div class="editor" ref="editor" :style="styles"></div>
</div>
</template>
<script>
import Quill from "quill";
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
import { getToken } from "@/utils/auth";
export default {
name: "Editor",
props: {
/* 编辑器的内容 */
value: {
type: String,
default: "",
},
/* 高度 */
height: {
type: Number,
default: null,
},
/* 最小高度 */
minHeight: {
type: Number,
default: null,
},
/* 只读 */
readOnly: {
type: Boolean,
default: false,
},
/* 上传地址 */
uploadUrl: {
type: String,
default: "",
}
},
data() {
return {
headers: {
Authorization: "Bearer " + getToken()
},
Quill: null,
currentValue: "",
options: {
theme: "snow",
bounds: document.body,
debug: "warn",
modules: {
// 工具栏配置
toolbar: [
["bold", "italic", "underline", "strike"], // 加粗 斜体 下划线 删除线
["blockquote", "code-block"], // 引用 代码块
[{ list: "ordered" }, { list: "bullet" }], // 有序、无序列表
[{ indent: "-1" }, { indent: "+1" }], // 缩进
[{ size: ["small", false, "large", "huge"] }], // 字体大小
[{ header: [1, 2, 3, 4, 5, 6, false] }], // 标题
[{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色
[{ align: [] }], // 对齐方式
["clean"], // 清除文本格式
["link", "image"] // 链接、图片、视频"video"
],
},
placeholder: "请输入内容",
readOnly: this.readOnly,
},
};
},
computed: {
styles() {
let style = {};
if (this.minHeight) {
style.minHeight = `${this.minHeight}px`;
}
if (this.height) {
style.height = `${this.height}px`;
}
return style;
},
},
watch: {
value: {
handler(val) {
if (val !== this.currentValue) {
this.currentValue = val === null ? "" : val;
if (this.Quill) {
this.Quill.pasteHTML(this.currentValue);
}
}
},
immediate: true,
},
},
mounted() {
this.init();
},
beforeDestroy() {
this.Quill = null;
},
methods: {
init() {
const editor = this.$refs.editor;
this.Quill = new Quill(editor, this.options);
// 如果设置了上传地址则自定义图片上传事件
if (this.uploadUrl) {
let toolbar = this.Quill.getModule("toolbar");
toolbar.addHandler("image", (value) => {
this.uploadType = "image";
if (value) {
this.$refs.upload.$children[0].$refs.input.click();
} else {
this.quill.format("image", false);
}
});
toolbar.addHandler("video", (value) => {
this.uploadType = "video";
if (value) {
this.$refs.upload.$children[0].$refs.input.click();
} else {
this.quill.format("video", false);
}
});
}
this.Quill.pasteHTML(this.currentValue);
this.Quill.on("text-change", (delta, oldDelta, source) => {
const html = this.$refs.editor.children[0].innerHTML;
const text = this.Quill.getText();
const quill = this.Quill;
this.currentValue = html;
this.$emit("input", html);
this.$emit("on-change", { html, text, quill });
});
this.Quill.on("text-change", (delta, oldDelta, source) => {
this.$emit("on-text-change", delta, oldDelta, source);
});
this.Quill.on("selection-change", (range, oldRange, source) => {
this.$emit("on-selection-change", range, oldRange, source);
});
this.Quill.on("editor-change", (eventName, ...args) => {
this.$emit("on-editor-change", eventName, ...args);
});
},
handleUploadSuccess(res, file) {
// 获取富文本组件实例
let quill = this.Quill;
// 如果上传成功
if (res.code == 200) {
// 获取光标所在位置
let length = quill.getSelection().index;
// 插入图片 res.url为服务器返回的图片地址
quill.insertEmbed(length, "image", res.url);
// 调整光标到最后
quill.setSelection(length + 1);
} else {
this.$message.error("图片插入失败");
}
},
handleUploadError() {
this.$message.error("图片插入失败");
},
},
};
</script>
<style>
.editor, .ql-toolbar {
white-space: pre-wrap !important;
line-height: normal !important;
}
.quill-img {
display: none;
}
.ql-snow .ql-tooltip[data-mode="link"]::before {
content: "请输入链接地址:";
}
.ql-snow .ql-tooltip.ql-editing a.ql-action::after {
border-right: 0px;
content: "保存";
padding-right: 0px;
}
.ql-snow .ql-tooltip[data-mode="video"]::before {
content: "请输入视频地址:";
}
.ql-snow .ql-picker.ql-size .ql-picker-label::before,
.ql-snow .ql-picker.ql-size .ql-picker-item::before {
content: "14px";
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="small"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="small"]::before {
content: "10px";
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="large"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="large"]::before {
content: "18px";
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="huge"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="huge"]::before {
content: "32px";
}
.ql-snow .ql-picker.ql-header .ql-picker-label::before,
.ql-snow .ql-picker.ql-header .ql-picker-item::before {
content: "文本";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="1"]::before {
content: "标题1";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before {
content: "标题2";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before {
content: "标题3";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="4"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="4"]::before {
content: "标题4";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="5"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="5"]::before {
content: "标题5";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="6"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="6"]::before {
content: "标题6";
}
.ql-snow .ql-picker.ql-font .ql-picker-label::before,
.ql-snow .ql-picker.ql-font .ql-picker-item::before {
content: "标准字体";
}
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="serif"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="serif"]::before {
content: "衬线字体";
}
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="monospace"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="monospace"]::before {
content: "等宽字体";
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 10:59:44
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-02-01 16:58:26
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/Lession.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="form-wrapper">
<el-form
class="form"
ref="form"
:model="form"
label-width="auto"
:rules="rules"
>
<el-form-item label="考试标题" prop="courseName">
<el-input
:disabled="checkLock"
style="width: 700px"
v-model="form.courseName"
></el-input>
</el-form-item>
<div class="top flex">
<el-form-item label="开始时间" prop="testStartTime">
<el-date-picker
style="margin-right: 50px"
v-model="form.testStartTime"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
placeholder="选择日期时间"
default-time="00:00:00"
:disabled="checkLock"
/>
</el-form-item>
<el-form-item label="结束时间" prop="testEndTime">
<el-date-picker
v-model="form.testEndTime"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
placeholder="选择日期时间"
default-time="00:00:00"
:disabled="checkLock"
/>
</el-form-item>
<el-form-item label="是否人脸认证" prop="isVeriftyFace" style="margin-left: 50px">
<el-radio v-model="form.isVeriftyFace" label="1"></el-radio>
<el-radio v-model="form.isVeriftyFace" label="2"></el-radio>
</el-form-item>
</div>
<el-form-item label="选择人员" prop="testPersons">
<ChangePapel
ref="changePaple"
:jsonSelectNameList="jsonSelectNameList"
:disabled="checkLock"
@getPeopleList="getPeopleList"
/>
</el-form-item>
<!-- </div> -->
</el-form>
</div>
</template>
<script>
import ChangePapel from "@/components/PeopleChange";
// import Editor from "./Editor";
// import FileUpload from "@/components/FileUpload";
// import uploadfile from "@/assets/uploadfile.png";
// import { mapGetters } from "vuex";
import {
addLessons,
getLessonById,
changeLesson,
} from "@/api/train/lessonsProgram";
export default {
name: "",
props: {
courseId: {
type: Number,
},
checkLock: {
type: Boolean,
},
},
components: {
// Editor,
// FileUpload,
ChangePapel,
},
data() {
return {
form: {
courseName: "",
testStartTime: "",
testEndTime: "",
testPersons: "",
isVeriftyFace: "2"
},
jsonSelectNameList: null,
// '[{"peoPleId":880,"peoPleName":"孙卓亚"},{"peoPleId":871,"peoPleName":"张玉宾"}]',
fileListVideo: [],
fileListFile: [],
readOnly: false,
rules: {
courseName: [
{ required: true, trigger: "blur", message: "课程名称不能为空" },
],
testStartTime: [
{ required: true, trigger: "blur", message: "考试开始时间不能为空" },
],
testEndTime: [
{ required: true, trigger: "blur", message: "课程名称不能为空" },
],
},
};
},
computed: {
// 获取课程类型
// ...mapGetters(["courseOptions"]),
},
created() {
if (this.courseId) {
this.getLessonById();
}
},
mounted() {
this.$refs.changePaple.changeNameList(this.jsonSelectNameList);
},
methods: {
// 添加课程
addLessons(data) {
console.log("this.courseId", this.courseId);
if (!this.courseId) {
console.log("添加");
return addLessons({ dataKind: 1, ...data });
} else {
console.log("修改");
return changeLesson({ courseId: this.courseId, ...data });
}
},
getPeopleList(list) {
console.log("参考人员", list);
// this.peopleList = list;
this.form.testPersons = list;
},
// 复现
getLessonById() {
getLessonById(this.courseId).then((res) => {
if (res.code == 200) {
const data = res.data;
const { courseName, testStartTime, testEndTime, testPersons, isVeriftyFace } = data;
this.form = {
courseName,
testStartTime,
testEndTime,
testPersons,
isVeriftyFace,
};
this.jsonSelectNameList = testPersons;
this.$refs.changePaple.changeNameList(this.jsonSelectNameList);
}
});
},
getFileInfoVideo(res) {
this.form.video = res.url;
// this.form.videoName = res.fileName;
this.fileListVideo = [
{
name: res.fileName,
url: uploadfile,
},
];
},
listRemoveVideo(e) {
this.fileListVideo = [];
this.form.video = "";
// this.form.videoName = null;
},
getFileInfoFile(res) {
this.form.enclosure = res.url;
// this.form.enclosureName = res.fileName;
this.fileListFile = [
{
name: res.fileName,
url: uploadfile,
},
];
},
listRemoveFile(e) {
this.fileListFild = [];
this.form.enclosure = "";
// this.form.fileName = null;
},
save(num = 2) {
// 因为富文本编辑器会残留<p><br></p>,所以要清
// if (this.form.courseConent === "<p><br></p>") {
// this.form.courseConent = "";
// }
this.$refs.form.validate((valid) => {
if (valid) {
// console.log(this.form);
this.addLessons({ ...this.form }).then((res) => {
// 如果添加会传回来,就用传回来的,如果是修改本身就有,就用本身的
const courseId = res.data || this.courseId;
if (res.code == 200) {
// 这样调比较纯函数一点
if (num == 2) {
this.$message({
message: "保存课程成功",
type: "success",
});
this.$parent.$parent.dialogCancel();
} else if (num == 3) {
this.$message({
message: "保存课程成功,请开始录入题目",
type: "success",
});
this.$parent.$parent.componentsNumChange(num);
this.$parent.$parent.changeCourseId(courseId);
}
// this.$parent.$parent.componentsNumChange(num);
// this.$parent.$parent.changeCourseId(courseId);
this.$parent.$parent.$parent.getList();
return true;
}
});
}
});
},
// 保存并进入题目
saveAndNext() {
this.save(3);
},
},
};
</script>
<style lang="scss" scoped>
.form-wrapper {
padding-top: 22px;
width: 100%;
height: 550px;
overflow: hidden;
// padding-bottom: 10px;
margin-bottom: 20px;
// border-bottom: 1px solid #bbbbbb;
.top {
width: 100%;
// justify-content: space-between;
}
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 17:56:05
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-02-01 17:45:09
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/QuestionList.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div ref="myBody" class="add-question flex">
<div class="text flex">
<div class="left">
目前有<span>{{ questionNum }}</span
>道题
<span class="warn">温馨提示:发布课程前需要进行考试设置</span>
</div>
<div class="right">{{ courseName }}</div>
</div>
<div class="detail flex">
<div class="detail-item">
单选题<span>{{ bottomFrom.singleChoiceScore }}</span
>分/题,共<span>{{ danxs }}</span
>题,计<span class="textC">{{
danxs * bottomFrom.singleChoiceScore
}}</span
>
</div>
<div class="detail-item">
多选题<span>{{ bottomFrom.multipleChoiceScore }}</span
>分/题,共<span>{{ duoxs }}</span> 题,计<span class="textC">{{
duoxs * bottomFrom.multipleChoiceScore
}}</span
>
</div>
<div class="detail-item">
判断题<span>{{ bottomFrom.judgmentScore }}</span
>/题,共<span>{{ pds }}</span> 题,计<span class="textC">{{
pds * bottomFrom.judgmentScore
}}</span
>
</div>
<div class="detail-item">
一共<span>{{ danxs + duoxs + pds }}</span
>道题,总共计<span class="textC">{{
danxs * bottomFrom.singleChoiceScore +
duoxs * bottomFrom.multipleChoiceScore +
pds * bottomFrom.judgmentScore
}}</span
>
</div>
</div>
<div class="table flex" v-loading="loading">
<div class="th flex">
<div class="left">序号</div>
<div class="type">题目类型</div>
<div class="middle">题目名称</div>
<div class="right">操作</div>
</div>
<div class="td-wrapper">
<div
v-for="(item, index) in questionList"
:key="item.topicId"
class="td flex"
>
<div class="left">{{ index + 1 }}</div>
<div class="type">{{ topicTypeArr[item.topicType] }}</div>
<div class="middle zzz">
{{ item.topicTitle }}
</div>
<div class="right">
<div>
<el-button
v-if="!checkLock"
@click="edit(item.topicId)"
icon="el-icon-edit"
type="text"
>修改</el-button
>
<el-button
v-if="checkLock"
@click="edit(item.topicId)"
icon="el-icon-edit"
type="text"
>查看</el-button
>
<el-button
v-if="!checkLock"
@click="deleteLesson(item.topicId)"
icon="el-icon-delete"
type="text"
>删除</el-button
>
</div>
</div>
</div>
</div>
</div>
<div class="rightNum flex">
<div class="left">考试设置</div>
<!-- <div class="middle flex">
<div class="left-text">答对题目大于</div>
<div>
<el-input
v-model="rightNum"
style="width: 60px"
size="mini"
></el-input>
</div>
<div>为合格</div>
</div> -->
<div class="middle flex">
<div class="left-text">单选一题</div>
<div>
<el-input
v-model="bottomFrom.singleChoiceScore"
style="width: 50px"
size="mini"
:disabled="checkLock"
></el-input>
</div>
<div></div>
</div>
<div class="middle flex">
<div class="left-text">多选一题</div>
<div>
<el-input
v-model="bottomFrom.multipleChoiceScore"
style="width: 50px"
size="mini"
:disabled="checkLock"
></el-input>
</div>
<div></div>
</div>
<div class="middle flex">
<div class="left-text">判断一题</div>
<div>
<el-input
v-model="bottomFrom.judgmentScore"
style="width: 50px"
size="mini"
:disabled="checkLock"
></el-input>
</div>
<div></div>
</div>
<div class="middle flex">
<div class="left-text">总分大于</div>
<div>
<el-input
v-model="bottomFrom.qualifiedNum"
style="width: 60px"
size="mini"
:disabled="checkLock"
></el-input>
</div>
<div>为合格</div>
</div>
<div class="right">
<el-button
@click="saveRightNum"
icon="el-icon-check"
size="mini"
type="success"
:disabled="checkLock"
>保存</el-button
>
</div>
</div>
</div>
</template>
<script>
import {
getQuestion,
deleteQuestion,
changeLesson,
getLessonById,
} from "@/api/train/lessonsProgram";
export default {
name: "AnswerLesson",
props: {
courseId: {
type: Number,
},
checkLock: {
type: Boolean,
},
},
components: {},
data() {
return {
// 当前课程的第几题,调一遍接口
questionNum: null,
bottomFrom: {
singleChoiceScore: 0,
multipleChoiceScore: 0,
judgmentScore: 0,
qualifiedNum: 0,
},
// 答对几道题
rightNum: 0,
questionList: [],
loading: false,
courseName: "",
topicTypeArr: {
1: "单选题",
2: "多选题",
3: "判断题",
},
};
},
// watch: {
// visible(newValue) {
// if (newValue) {
// this.$nextTick(() => {
// this.saveBody();
// });
// }
// },
// },
computed: {
danxs() {
return this.questionList.filter((item) => item.topicType === 1).length;
},
duoxs() {
return this.questionList.filter((item) => item.topicType === 2).length;
},
pds() {
return this.questionList.filter((item) => item.topicType === 3).length;
},
},
created() {
console.log("this.courseId", this.courseId);
if (this.courseId) {
this.getQuestion({ courseId: this.courseId });
// 获取只题目正确几题算过关
this.getLessonById(this.courseId);
}
},
methods: {
save() {
console.log("QuestionList");
},
saveAndNext() {
this.$parent.$parent.componentsNumChange(3);
},
getQuestion(courseId) {
return getQuestion(courseId).then((res) => {
console.log(res);
this.questionList = res.rows.map((item) => {
return {
topicType: item.topicType,
topicId: item.topicId,
topicTitle: item.topicTitle,
};
});
this.questionNum = res.total;
return true;
});
},
getLessonById(courseId) {
getLessonById(courseId).then((res) => {
console.log(res);
// this.rightNum = res.data.qualifiedNum;
this.bottomFrom = {
singleChoiceScore: res.data.singleChoiceScore || 0,
multipleChoiceScore: res.data.multipleChoiceScore || 0,
judgmentScore: res.data.judgmentScore || 0,
qualifiedNum: res.data.qualifiedNum || 0,
};
this.courseName = res.data.courseName;
});
},
edit(topicId) {
this.$emit("update:topicId", topicId);
this.$parent.$parent.componentsNumChange(3);
},
deleteLesson(topicId) {
this.$confirm("请确定删除该题", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.loading = true;
return deleteQuestion(topicId);
})
.then((res) => {
if (res.code == 200) {
this.$message({
message: "删除成功",
type: "success",
});
}
return this.getQuestion({ courseId: this.courseId });
})
.finally(() => {
this.loading = false;
// 课程列表重置一下
this.$parent.$parent.$parent.getList();
});
},
saveRightNum() {
// if (this.rightNum > this.questionList.length) {
// this.$message({
// message: "答对题目数应小于等于考试题目总数",
// type: "warning",
// });
// return;
// }
if (
!(
this.bottomFrom.singleChoiceScore >= 0 &&
this.bottomFrom.multipleChoiceScore >= 0 &&
this.bottomFrom.judgmentScore >= 0 &&
this.bottomFrom.qualifiedNum >= 0
)
) {
this.$message({
message: "请将分数填写完整",
type: "warning",
});
return;
}
changeLesson({
courseId: this.courseId,
// qualifiedNum: this.rightNum,
...this.bottomFrom,
}).then((res) => {
if (res.code == 200) {
this.$message({
message: "答题合格数修改成功",
type: "success",
});
this.$parent.$parent.$parent.getList();
}
});
},
},
};
</script>
<style lang="scss" scoped>
.add-question {
width: 100%;
height: 550px;
// overflow: hidden;
flex-direction: column;
padding-bottom: 7px;
margin-bottom: 20px;
border-bottom: 1px solid #bbbbbb00;
position: relative;
.text {
margin-top: 13px;
margin-bottom: 32px;
justify-content: space-between;
height: 28px;
.left {
line-height: 28px;
color: #101010;
font-size: 14px;
.warn {
display: inline-flex;
font-size: 12px;
color: red;
margin-left: 10px;
}
}
.right {
width: 411px;
line-height: 28px;
background: #1d84ff;
padding-right: 5px;
color: #fff;
text-align: right;
}
}
.detail {
position: absolute;
bottom: -20px;
left: 10px;
.textC {
font-weight: 800;
font-size: 18px;
}
.detail-item {
margin-right: 20px;
color: red;
}
}
.table {
flex: 1;
height: 0;
flex-direction: column;
.th {
width: 100%;
height: 70px;
line-height: 70px;
background: #f5f5f5;
color: #606266;
> div {
height: 100%;
}
.left {
width: 15%;
text-align: center;
}
.type {
width: 10%;
text-align: center;
}
.middle {
width: 50%;
padding-left: 50px;
}
.right {
width: 25%;
text-align: center;
}
}
.td-wrapper {
flex: 1;
overflow-y: auto;
// 这样子元素才能有滚动条
.td {
height: 68px;
line-height: 68px;
box-sizing: border-box;
border-bottom: 1px solid #bbbbbb;
&:last-child {
border-bottom: none;
}
> div {
height: 100%;
}
.left {
width: 15%;
text-align: center;
}
.type {
width: 10%;
text-align: center;
}
.middle {
width: 50%;
padding-left: 50px;
}
.right {
width: 25%;
text-align: center;
}
}
}
}
.rightNum {
margin-top: 5px;
height: 55px;
box-sizing: border-box;
border: 1px solid #bbbbbb;
line-height: 55px;
> .left {
width: 140px;
background: #0bab0c;
font-size: 14px;
color: #fff;
text-align: center;
}
> .middle {
> div {
margin-right: 5px;
}
.left-text {
margin-left: 10px;
}
.middle {
margin-right: 20px;
}
}
.right {
margin-left: 20px;
}
// background: black;
}
}
</style>
<template>
<div class="app-container">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
label-width="100px"
>
<el-form-item label="考试名称" prop="courseType">
<el-input
v-model="queryParams.courseName"
placeholder="请输入课程名称"
clearable
size="small"
/>
</el-form-item>
<el-form-item label="考试开始时间" prop="startTime">
<el-date-picker
v-model="queryParams.testStartTime"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
placeholder="选择日期时间"
default-time="12:00:00"
/>
</el-form-item>
<el-form-item label="考试结束时间" prop="endTime">
<el-date-picker
v-model="queryParams.testEndTime"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
placeholder="选择日期时间"
default-time="12:00:00"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="search"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetClick"
>重置</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:book:add']"
>新增</el-button
>
</el-col>
</el-row>
<el-table v-loading="loading" :data="lessonsList">
<el-table-column label="序号" align="center" prop="bankNum" width="55" />
<el-table-column label="考试名称" align="center" prop="courseName" />
<el-table-column
label="开始时间"
align="center"
prop="testStartTime"
:formatter="formatter"
/>
<el-table-column
label="结束时间"
align="center"
prop="testEndTime"
:formatter="formatter"
/>
<el-table-column
label="考试题"
align="center"
prop="topicNum"
width="180"
>
<template v-slot="{ row: { topicNum, courseId, status } }">
<span class="timuNum" @click="checkQuestion(courseId, status)">
<span v-if="topicNum > 0">
{{ status == 0 ? `已录入${topicNum}题` : "查看" }}
</span>
<span v-else>未录入</span>
</span>
</template>
</el-table-column>
<el-table-column
label="合格分数"
align="center"
prop="qualifiedNum"
:formatter="formatter"
/>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template
v-slot="{
row: { courseName, topicNum, status, courseId,testStartTime,testEndTime },
}"
>
<!-- <div>{{status}}</div> -->
<!-- <el-button
v-if="status == 0"
size="mini"
type="text"
icon="el-icon-edit"
@click="checkQuestion(courseId)"
>录入考题</el-button
> -->
<el-button
v-if="status == 0"
size="mini"
type="text"
icon="el-icon-edit"
@click="changeLesson(courseId)"
>编辑</el-button
>
<el-button
v-if="status == 1"
size="mini"
type="text"
icon="el-icon-edit"
@click="checkLesson(courseId)"
>详情</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="deletLesson(courseId)"
>删除</el-button
>
<el-button
v-if="status == 0"
size="mini"
type="text"
icon="el-icon-delete"
@click="issueDilog(courseId, courseName, topicNum,testStartTime,testEndTime)"
>发布</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"
/>
<Dia
ref="Dia"
:componentsNum.sync="componentsNum"
:courseId.sync="courseId"
:checkLock.sync="checkLock"
:visible.sync="dilogFlag"
/>
<el-dialog
class="lessons-program"
title="试卷考试发布详情"
:visible.sync="issueVisible"
width="60%"
>
<div>
<span class="dialogName"
>考试名称: <span class="a">{{ dilogName }}</span>
</span>
</div>
<div style="margin-top:20px">
<span class="dialogName"
>开始时间: <span class="a">{{ dilogStartTime }}</span>
</span>
<span class="dialogName"
>结束时间: <span class="a">{{ dilogEndTime }}</span>
</span>
</div>
<!-- <span class="dialogName"
>培训计划: <span class="a">{{ dilogType }}</span></span
> -->
<div class="detail flex">
<div class="detail-item">
单选题<span>{{ bottomFrom.singleChoiceScore }}</span
>/,<span>{{ danxs }}</span
>题,计<span class="textC">{{
danxs * bottomFrom.singleChoiceScore
}}</span
>
</div>
<div class="detail-item">
多选题<span>{{ bottomFrom.multipleChoiceScore }}</span
>/,<span>{{ duoxs }}</span> 题,计<span class="textC">{{
duoxs * bottomFrom.multipleChoiceScore
}}</span
>
</div>
<div class="detail-item">
判断题<span>{{ bottomFrom.judgmentScore }}</span
>/题,共<span>{{ pds }}</span> 题,计<span class="textC">{{
pds * bottomFrom.judgmentScore
}}</span
>
</div>
</div>
<div class="detail">
<div class="detail-item">
<span>{{ danxs + duoxs + pds }}</span
>道题,总共计<span class="textC">{{
danxs * bottomFrom.singleChoiceScore +
duoxs * bottomFrom.multipleChoiceScore +
pds * bottomFrom.judgmentScore
}}</span
>
</div>
</div>
<div class="detail">
<div class="detail-item">
合格分数为<span class="textC">{{ bottomFrom.qualifiedNum }}</span
>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="issueVisible = false"> </el-button>
<el-button type="primary" @click="issueLesson(issueCourseId)"
>确认发布</el-button
>
</span>
</el-dialog>
</div>
</template>
<script>
import {
getQuestion,
getLessons,
getLessonById,
issue,
deleteLesson,
testPublish,
} from "@/api/train/lessonsProgram.js";
// 获取培训计划
import { getPlanList } from "@/api/train/trainingProgram";
import { mapGetters, mapMutations } from "vuex";
import Dia from "./components/Dia";
export default {
name: "Book",
components: {
Dia,
},
data() {
return {
// 遮罩层
loading: false,
// 总条数
total: 0,
// courseOptions: [],
lessonsList: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
dataKind: 1,
courseName: null,
testStartTime: "",
testEndTime: "",
},
// 表单参数
form: {},
// 表单校验
dilogFlag: false,
// 发布
issueVisible: false,
dilogName: "",
dilogTopicNum: 0,
dilogStartTime:0,
dilogEndTime:0,
// dilogType: null,
bottomFrom: {
singleChoiceScore: 0,
multipleChoiceScore: 0,
judgmentScore: 0,
qualifiedNum: 0,
},
issueCourseId: null,
questionList: [],
componentsNum: 1,
// 点击的id,如果是新增为空
courseId: null,
issue: false,
// false为编辑,true为查看,查看不允许编辑的时候
checkLock: false,
};
},
computed: {
...mapGetters(["courseOptions"]),
danxs() {
return this.questionList.filter((item) => item.topicType === 1).length;
},
duoxs() {
return this.questionList.filter((item) => item.topicType === 2).length;
},
pds() {
return this.questionList.filter((item) => item.topicType === 3).length;
},
},
created() {
// this.getPlanList();
this.getList();
},
methods: {
...mapMutations({ setOptions: "SET_COURSE_OPTIONS" }),
// 获取课程类别,也就是计划名称
// getPlanList() {
// getPlanList().then((res) => {
// const courseOptions = res.data.map((item) => {
// return {
// planId: item.planId,
// planName: item.planName,
// };
// });
// // this.$store.commit("SET_COURSE_OPTIONS");
// this.setOptions(courseOptions);
// });
// },
/** 查询课程列表 */
getList() {
this.loading = true;
getLessons(this.queryParams)
.then((res) => {
console.log(res);
this.lessonsList = res.rows.map((item, index) => {
return {
bankNum:
index +
1 +
(this.queryParams.pageNum - 1) * this.queryParams.pageSize,
...item,
};
});
this.total = res.total;
})
.finally(() => {
this.loading = false;
});
},
search() {
// console.log(this.queryParams);
this.getList();
},
/** 新增按钮操作 */
handleAdd() {
this.checkLock = false;
this.$refs.Dia.title = "新增考试试卷";
this.componentsNum = 1;
this.courseId = null;
this.dilogFlag = true;
},
changeLesson(courseId) {
this.checkLock = false;
this.$refs.Dia.title = "修改考试试卷";
this.componentsNum = 1;
this.courseId = courseId;
this.dilogFlag = true;
},
checkLesson(courseId) {
this.checkLock = true;
this.$refs.Dia.title = "修改考试试卷";
this.componentsNum = 1;
this.courseId = courseId;
this.dilogFlag = true;
},
// 直接查看考题
checkQuestion(courseId, status) {
// 要查看考题的id
if (status == 1) {
this.checkLock = true;
}
this.courseId = courseId;
console.log(this.courseId);
// 2代表列表组件
this.componentsNum = 2;
this.dilogFlag = true;
},
// 重置
resetClick() {
this.reset();
this.getList();
},
// 复位
reset() {
this.queryParams = {
pageNum: 1,
pageSize: 10,
dataKind: 1,
courseName: null,
testStartTime: "",
testEndTime: "",
};
},
deletLesson(courseId) {
this.$confirm("请确定删除", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
return deleteLesson(courseId);
})
.then((res) => {
if (res.code == 200) {
this.$message({
message: "删除成功",
type: "success",
});
}
this.getList();
})
.catch(() => {});
},
// 发布
issueDilog(courseId, name, num,startTime,endTime) {
if (num === 0) {
this.$message({
message: "请至少录入一道考题在发布",
type: "warning",
});
return;
}
getQuestion({ courseId })
.then((res) => {
console.log(res);
this.questionList = res.rows.map((item) => {
return {
topicType: item.topicType,
topicId: item.topicId,
topicTitle: item.topicTitle,
};
});
})
.then((res) => {
return getLessonById(courseId);
})
.then((res) => {
this.bottomFrom = {
singleChoiceScore: res.data.singleChoiceScore || 0,
multipleChoiceScore: res.data.multipleChoiceScore || 0,
judgmentScore: res.data.judgmentScore || 0,
qualifiedNum: res.data.qualifiedNum || 0,
};
})
.then((res) => {
// 名称
this.dilogName = name;
this.dilogStartTime=startTime;
this.dilogEndTime=endTime;
this.issueVisible = true;
this.issueCourseId = courseId;
});
//
},
issueLesson(courseId) {
// this.$confirm("确定要发布吗", {
// confirmButtonText: "确定",
// cancelButtonText: "取消",
// type: "warning",
// })
// .then(() => {
// // 判断是否录入答题合格数
// return getLessonById(courseId);
// })
getLessonById(courseId)
.then((res) => {
// if (
// res.data.singleChoiceScore > 0 &&
// res.data.multipleChoiceScore > 0 &&
// res.data.judgmentScore > 0 &&
// res.data.qualifiedNum > 0
// ) {
return true;
// }
})
.then((res) => {
if (res) {
// 成功就发布
// return issue({ courseId });
return testPublish({ courseId, personnelType: 1 });
} else {
this.$message({
message: "请先在题目列表录入题目分数跟合格分数",
type: "warning",
});
}
})
.then((res) => {
if (res.code == 200) {
this.$message({
message: "发布成功",
type: "success",
});
this.getList();
this.issueVisible = false;
}
})
.catch(() => {});
},
formatter(row, column, cellValue, index) {
// console.log(row, column, cellValue, index);
if (!cellValue) return "-";
else return cellValue;
},
},
};
</script>
<style lang="scss" scoped>
.down-load {
color: #0bab0c;
}
.timuNum {
color: #1d84ff;
cursor: pointer;
}
::v-deep .el-select {
width: 100%;
}
::v-deep .el-dialog {
margin-top: 10vh !important;
}
::v-deep .el-dialog .el-dialog__body {
padding-top: 5px;
}
.dialogName {
margin-right: 50px;
// color: #ccc;
font-size: 16px;
}
.detail {
// position: absolute;
// bottom: -20px;
// left: 10px;
margin-top: 20px;
.textC {
font-weight: 800;
font-size: 18px;
}
.detail-item {
margin-right: 20px;
color: red;
}
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 10:38:49
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-12-28 15:01:59
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/addLesson.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<el-dialog
class="add-lession"
:title="title"
:visible.sync="visible"
width="1020px"
:close-on-click-modal="false"
:close-on-press-escape="false"
:before-close="dialogCancel"
@closed="closeFinished"
destroy-on-close
>
<div v-if="visible" ref="myBody" class="body">
<transition name="fade" mode="out-in">
<component
:is="currentComponent"
:bankId.sync="bankId"
:subjectId.sync="subjectId"
:jsonData="jsonData"
ref="current"
></component>
</transition>
<!-- <Lesson ref='lesson'/> -->
<!-- <AddQuestion />
<QuestionList/> -->
</div>
<div slot="footer" class="dialog-footer">
<!--<el-button-->
<!--type="primary"-->
<!--v-if="this.componentsNum == 1 || this.componentsNum == 3"-->
<!--@click="save"-->
<!--&gt;保存</el-button-->
<!--&gt;-->
<!--<el-button type="primary" @click="saveAndNext">{{-->
<!--saveNextText-->
<!--}}</el-button>-->
<el-button
v-if="this.componentsNum == 2"
type="primary"
@click="savePlan"
>{{ "确认" }}</el-button
>
<el-button @click="dialogCancel">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import Lesson from "./Lesson";
import AddQuestion from "../../textPaper/components/AddQuestion";
import QuestionList from "../../textPaper/components/QuestionList";
export default {
name: "AnswerLesson",
props: {
visible: {
type: Boolean,
default: false,
},
componentsNum: {
type: Number,
default: 1,
},
bankId: {
type: Number,
},
jsonData:{
type:Array,
}
},
// components: {
// Lesson,
// AddQuestion,
// QuestionList,
// },
data() {
return {
title: "录入课程",
currentComponent: Lesson,
// 当前题目查看
subjectId: null,
};
},
watch: {
componentsNum: {
handler(num) {
if (num === 1) {
this.currentComponent = Lesson;
if (this.bankId) {
this.title = "修改课程";
} else {
this.title = "新增课程";
}
} else if (num === 2) {
this.currentComponent = QuestionList;
this.title = "题目列表";
} else {
this.currentComponent = AddQuestion;
if (this.subjectId) {
this.title = "修改题目";
} else {
this.title = "新增题目";
}
}
},
deep: true,
},
},
computed: {
saveNextText() {
let text;
if (this.componentsNum == 1) {
text = "保存并录入题目";
} else if (this.componentsNum == 2) {
text = "录入考题";
} else {
text = "保存并录入下一题";
}
return text;
},
},
methods: {
saveBody() {
this.startHeight = this.$refs.myBody.offsetHeight - 55 + "px";
},
closeFinished() {},
// 关闭之后
// 只保存
save() {
// this.answerClear();
this.$refs.current.save();
},
savePlan() {
// this.answerClear();
this.$refs.current.savePlan();
},
// 保存并录入
saveAndNext() {
this.$refs.current.saveAndNext();
},
// 隐藏与显示dialog
dialogCancel() {
this.$emit("update:visible", false);
},
// 把ID改变了
changeCourseId(bankId) {
this.$emit("update:bankId", bankId);
},
// 改变当前组件
componentsNumChange(num) {
this.$emit("update:componentsNum", num);
},
answerClear() {
this.answerArr = [];
this.changeCourseId(null);
},
},
};
</script>
<style lang="scss" scoped>
.body {
width: 100%;
height: 100%;
padding-right: 40px;
padding-left: 36px;
}
</style>
<template>
<div class="item-wrapper flex" v-loading="loading">
<div class="item flex" :class="{ active: isActive }">
<div class="left flex">
<div class="left-item flex" :class="{ active: isActive }">
<div class="text flex">
<div class="i-wrapper">
<i class="iconfont icon-24gl-checklist" />
</div>
<div ref="tp" class="text-center-wrapper flex">
<div ref="t" style="margin-right: 10px" v-if="!isActive">
{{ infoData.planName }}
</div>
</div>
<!-- <el-input
v-else
size="mini"
v-model="infoData.planName"
placeholder="请输入内容"
style="width: 120px"
></el-input> -->
</div>
</div>
</div>
<div class="right flex" style="line-height: 110px">
<div style="margin-left: 20px" v-if="infoData.personnelType == 1">
员工培训
</div>
<div style="margin-left: 20px" v-if="infoData.personnelType == 2">
承包商培训
</div>
</div>
<div class="middle flex">
<div>
<div class="top">参与培训人员({{ personnelOptions.length }})</div>
<div class="bottom">
<!-- <el-checkbox-group class="" v-model="infoData.postIds"> -->
<el-checkbox
:disabled="!isActive"
v-model="personnel.ischeck"
v-for="personnel in personnelOptions"
:label="personnel.postId"
:key="personnel.postId"
>{{ personnel.postName }}</el-checkbox
>
<!-- </el-checkbox-group> -->
</div>
</div>
</div>
<div class="right flex">
<template v-if="!isActive">
<div>
<el-button type="text" @click="edit(personnelOptions)"
>编辑</el-button
>
<el-button type="text" @click="deletePlan">删除</el-button>
</div>
</template>
<template v-else>
<div>
<el-button type="text" @click="save">保存</el-button>
<el-button type="text" @click="cancel">取消</el-button>
</div>
</template>
</div>
</div>
</div>
</template>
<script>
import { editPlan, deletePlan } from "@/api/train/trainingProgram";
export default {
name: "trainingProgram-item",
props: {
personnelOptions: {
type: Array,
},
isActiveId: {
type: [String, Number],
default: 999,
},
infoData: {
type: Object,
default: () => {
return {
planId: 1,
planName: "安全岗位生产",
postIds: [1, 2, 3, 4],
};
},
},
},
computed: {
isActive() {
return this.isActiveId === this.infoData.planId;
},
},
mounted() {
console.log(this.$refs.t.offsetHeight);
// 如果子元素的高大于父元素的高,就改变上下居中策略,改为滚动条展示
if (this.$refs.t.offsetHeight > this.$refs.tp.offsetHeight) {
console.log(this.$refs.tp.style);
this.$refs.tp.style.overflow = "auto";
this.$refs.tp.style.alignItems = "";
} else {
// console.log(this.$refs.t.offsetHeight)
// this.$refs.t.style.alignItems='center'
}
},
data() {
return {
// 记录初始的选项
oldInfoData: JSON.stringify(this.infoData),
// isActive: false,
loading: false,
};
},
methods: {
edit(personnelOptions) {
// 编辑
console.log(personnelOptions);
this.$parent.addClick(this.infoData, personnelOptions);
//this.$emit("edit", this.oldInfoData);
},
save() {
if (this.infoData.planName == "") {
this.$message({
message: "请输入培训计划名称",
type: "warning",
});
return;
}
if (this.infoData.postIds.length == 0) {
this.$message({
message: "请选择至少一种参与培训人员",
type: "warning",
});
return;
}
this.$confirm("请确定更改培训计划", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.loading = true;
return editPlan(this.infoData);
})
.then((res) => {
if (res.code == 200) {
// 成功也要将oldInfoData 变成最新的
// this.oldInfoData = "newInfoData";
const dataJson = JSON.stringify(this.infoData);
this.$emit("save", dataJson);
// 成功之后
this.oldInfoData = dataJson;
this.$message({
message: "修改培训计划成功",
type: "success",
});
}
this.loading = false;
})
.catch(() => {
this.loading = false;
});
},
deletePlan() {
console.log(this.infoData);
this.$confirm("请确定删除当前培训计划", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
return deletePlan({ planId: this.infoData.planId });
})
.then((res) => {
if (res.code == 200) {
this.$emit("deletePlan", this.oldInfoData);
this.$message({
message: "删除成功",
type: "success",
});
}
});
},
// 当bool为true时候,监听用的,不去改videoID,这样就不会监听锁死
// 当bool为false时,是取消用的,会变成999
cancel() {
this.$emit("cancel", this.oldInfoData);
},
},
};
</script>
<style lang="scss" scoped>
.item-wrapper {
width: 100%;
flex-direction: column;
align-items: center;
margin-bottom: 20px;
.item {
transition: all 0.5s;
width: 93.2%;
max-width: 1600px;
min-height: 111px;
border: 1px solid #cecece;
box-shadow: -4px 0px 0px 0px rgba(0, 0, 0, 0.1);
background: linear-gradient(
180deg,
rgba(255, 255, 255, 1) 0%,
rgba(255, 255, 255, 1) 100%
);
border-radius: 5px;
&.active {
box-shadow: -4px 0px 0px 0px #1d84ff, 0px 2px 6px 0px rgba(0, 0, 0, 0.15);
}
// background: blue;
.left {
width: 225px;
height: 100%;
align-items: center;
justify-content: right;
margin-top: 25px;
.left-item {
transition: all 0.5s;
width: 200px;
height: 60px;
// line-height: 60px;
font-size: 14px;
padding-left: 25px;
border: 1px solid #efefef;
border-radius: 5px;
box-sizing: border-box;
background: linear-gradient(
180deg,
rgba(255, 255, 255, 0) 8%,
rgba(239, 239, 239, 1) 100%
);
&.active {
background: #1d84ff;
color: #fff;
}
.i-wrapper {
height: 60px;
line-height: 60px;
padding-right: 10px;
}
.text-center-wrapper {
height: 100%;
width: 100%;
// overflow: auto;
align-items: center;
}
}
}
.middle {
flex: 1;
// flex-direction: column;
align-items: center;
// background: white;
padding-left: 25px;
// padding-top: 25px;
padding-right: 25px;
.top {
font-size: 14px;
margin-bottom: 9px;
}
.bottom {
justify-content: space-between;
font-size: 14px;
}
}
.right {
padding-right: 20px;
width: 120px;
height: 100%;
justify-items: center;
align-items: center;
}
}
}
</style>
<template>
<div class="item-wrapper flex">
<div class="item flex" :class="{ active: isActive }">
<div class="left flex">
<div class="left-item flex" :class="{ active: isActive }">
<div class="text">
<i class="iconfont icon-24gl-checklist" />
<span v-if="!isActive">{{ infoData.title }}</span>
<el-input
v-else
v-model="infoData.title"
placeholder="请输入内容"
style="width: 140px; margin-left: 5px"
></el-input>
</div>
</div>
</div>
<div class="middle">
<div class="top">参与培训人员</div>
<div class="bottom">
<el-checkbox-group class="" v-model="infoData.checkedActive">
<el-checkbox
:disabled="!isActive"
v-for="(city, index) in cityOptions"
:label="index"
:key="city"
>{{ city }}</el-checkbox
>
</el-checkbox-group>
</div>
</div>
<div class="right flex">
<template v-if="!isActive">
<el-button type="text" @click="edit">编辑</el-button>
<!-- <el-button type="text">删除</el-button> -->
</template>
<template v-else>
<el-button type="text" @click="save">保存</el-button>
<el-button type="text" @click="cancel(false)">取消</el-button>
</template>
</div>
</div>
</div>
</template>
<script>
export default {
name: "trainingProgram-item",
props: {
cityOptions: {
type: Array,
},
isActiveId: {
type: [String, Number],
default: 999,
},
infoData: {
type: Object,
default: () => {
return {
id: 1,
title: "安全岗位生产",
checkedActive: [1, 2, 3, 4],
};
},
},
},
computed: {
// isActive() {
// return this.isActiveId === this.infoData.id;
// },
},
mounted() {},
watch: {
isActiveId(newVal) {
if (newVal === this.infoData.id) {
this.isActive = true;
} else {
this.cancel(true);
this.isActive = false;
}
},
},
data() {
return {
// 记录初始的选项
oldInfoData: JSON.stringify(this.infoData),
isActive: false,
};
},
methods: {
edit() {
// 编辑
this.$emit("edit", this.infoData.id);
console.log('编辑')
},
save() {
// 成功也要将oldInfoData 变成最新的
// this.oldInfoData = "newInfoData";
const dataJson = JSON.stringify(this.infoData);
setTimeout(() => {
alert("成功");
this.$emit("save", dataJson);
// 成功之后
this.oldInfoData = dataJson;
}, 1000);
},
// 当bool为true时候,监听用的,不去改videoID,这样就不会监听锁死
// 当bool为false时,是取消用的,会变成999
cancel(bool=false) {
// 取消的时候将初始的传出去
// console.log(this.isActive)
// 如果是选中状态才会走下面的方法
if (this.isActive === false) return;
this.$emit("cancel", this.oldInfoData);
if(!bool){
this.$emit("edit", 999)
}
},
},
};
</script>
<style lang="scss" scoped>
.item-wrapper {
width: 100%;
flex-direction: column;
align-items: center;
margin-bottom: 20px;
.item {
width: 93.2%;
max-width: 1600px;
height: 111px;
border: 1px solid #cecece;
box-shadow: -4px 0px 0px 0px rgba(0, 0, 0, 0.1);
background: linear-gradient(
180deg,
rgba(255, 255, 255, 1) 0%,
rgba(255, 255, 255, 1) 100%
);
border-radius: 5px;
&.active {
box-shadow: -4px 0px 0px 0px #1d84ff, 0px 2px 6px 0px rgba(0, 0, 0, 0.15);
}
// background: blue;
.left {
width: 225px;
height: 100%;
align-items: center;
justify-content: right;
.left-item {
width: 200px;
height: 60px;
line-height: 60px;
font-size: 14px;
padding-left: 25px;
border: 1px solid #efefef;
border-radius: 5px;
box-sizing: border-box;
background: linear-gradient(
180deg,
rgba(255, 255, 255, 0) 8%,
rgba(239, 239, 239, 1) 100%
);
&.active {
background: #1d84ff;
color: #fff;
}
span {
margin-left: 10px;
}
}
}
.middle {
flex: 1;
// background: white;
padding-left: 25px;
padding-top: 25px;
padding-right: 25px;
.top {
font-size: 14px;
margin-bottom: 9px;
}
.bottom {
justify-content: space-between;
font-size: 14px;
}
}
.right {
padding-right: 20px;
width: 120px;
height: 100%;
justify-items: center;
}
}
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 10:59:44
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-12-28 15:06:07
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/Lession.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="form-wrapper">
<el-form
class="form"
ref="form"
:model="form"
label-width="auto"
:rules="rules"
>
<div class="top flex">
<el-form-item label="计划名称" prop="bankName">
<el-input style="width: 500px" v-model="form.bankName"></el-input>
</el-form-item>
<!--<el-form-item label="人员类型" prop="personnelType">-->
<!--<el-select v-model="form.personnelType" placeholder="请选择">-->
<!--<el-option-->
<!--v-for="item in options"-->
<!--:key="item.value"-->
<!--:label="item.label"-->
<!--:value="item.value"-->
<!--&gt;-->
<!--</el-option>-->
<!--</el-select>-->
<!--</el-form-item>-->
<!--<el-form-item label="开始时间" prop="releaseTime">-->
<!--<el-date-picker-->
<!--v-model="form.startTime"-->
<!--value-format="yyyy-MM-dd HH:mm:ss"-->
<!--type="datetime"-->
<!--placeholder="开始时间"-->
<!--default-time="12:00:00"-->
<!--&gt;-->
<!--</el-date-picker>-->
<!--</el-form-item>-->
</div>
<!--<el-form-item label="结束时间" prop="releaseTime">-->
<!--<el-date-picker-->
<!--v-model="form.endTime"-->
<!--value-format="yyyy-MM-dd HH:mm:ss"-->
<!--type="datetime"-->
<!--placeholder="结束时间"-->
<!--default-time="12:00:00"-->
<!--&gt;-->
<!--</el-date-picker>-->
<!--</el-form-item>-->
<el-form-item label="选择人员" prop="releaseTime">
<!-- table -->
<!-- jsonSelectNameList就是呗选中的人员的json -->
<!-- getPeopleList 是每次选中或者删除人员都会返回 一个所有人员列表的json串,[{staffId:staffId,staffName:staffName},{staffId:staffId,staffName:staffName}] -->
<!-- 要在jsonSelectNameList赋值完毕之后 调用一下 this.$refs.changePaple.changeNameList 135行 -->
<ChangePapel
ref="changePaple"
:jsonSelectNameList="jsonSelectNameList"
@getPeopleList="getPeopleList"
/>
</el-form-item>
</el-form>
</div>
</template>
<script>
import ChangePapel from "@/components/PeopleChange";
// import { mapGetters } from "vuex";
// import {
// addLessons,
// getLessonById,
// changeLesson,
// } from "@/api/train/lessonsProgram";
import {
listBank,
addBank,
updateBank,
getBank,
} from "@/api/train/questionBank";
// 所有部门
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {
getPersonnel,
addPlan,
editPlan,
getPlanList,
getPlan,
} from "@/api/train/trainingProgram";
export default {
name: "",
props: {
bankId: {
type: Number,
},
jsonData: {
tyoe: Array,
},
// jsonSelectNameList: {
// type: String,
// default:
// '[{"staffId":880,"staffName":"孙卓亚"},{"staffId":871,"staffName":"张玉宾"},{"staffId":869,"staffName":"李二朝"},{"staffId":870,"staffName":"盖永峰"},{"staffId":868,"staffName":"刘丽艳"},{"staffId":867,"staffName":"霍文俊"},{"staffId":866,"staffName":"刘志坚"},{"staffId":865,"staffName":"郝文权"},{"staffId":864,"staffName":"齐雪军"},{"staffId":852,"staffName":"刘江平"},{"staffId":853,"staffName":"谷建海"},{"staffId":851,"staffName":"丁振国"},{"staffId":850,"staffName":"齐江波"},{"staffId":849,"staffName":"周立新"},{"staffId":848,"staffName":"史志波"},{"staffId":847,"staffName":"王增波"},{"staffId":846,"staffName":"杨彦龙"},{"staffId":845,"staffName":"杨华国"},{"staffId":844,"staffName":"王青华"}]',
// },
},
components: {
ChangePapel,
},
data() {
return {
options: [
{
value: 1,
label: "内部员工",
},
{
value: 2,
label: "承包商培训",
},
],
form: {
bankName: "",
// courseType: "",
// courseConent: "",
// video: "",
// enclosure: "",
deptId: null,
personnelType: 1,
abc: 0,
},
// 参考人员
jsonSelectNameList: null,
peopleList: [],
// 归属部门列表
deptOptions: [],
fileListVideo: [],
fileListFile: [],
readOnly: false,
// selectNameList: [],
rules: {
bankName: [
{ required: true, trigger: "blur", message: "计划名称不能为空" },
],
deptId: [
{ required: true, trigger: "blur", message: "请选择所属部门" },
],
},
};
},
computed: {
// 获取课程类型
// ...mapGetters(["courseOptions"]),
},
created() {
if (this.bankId) {
this.getLessonById();
}
// 归属部门列表
// this.getTreeselect();
},
mounted() {
// this.jsonSelectNameList
// '[{"staffId":880,"staffName":"孙卓亚"},{"staffId":871,"staffName":"张玉宾"},{"staffId":869,"staffName":"李二朝"},{"staffId":870,"staffName":"盖永峰"},{"staffId":868,"staffName":"刘丽艳"},{"staffId":867,"staffName":"霍文俊"},{"staffId":866,"staffName":"刘志坚"},{"staffId":865,"staffName":"郝文权"},{"staffId":864,"staffName":"齐雪军"},{"staffId":852,"staffName":"刘江平"},{"staffId":853,"staffName":"谷建海"},{"staffId":851,"staffName":"丁振国"},{"staffId":850,"staffName":"齐江波"},{"staffId":849,"staffName":"周立新"},{"staffId":848,"staffName":"史志波"},{"staffId":847,"staffName":"王增波"},{"staffId":846,"staffName":"杨彦龙"},{"staffId":845,"staffName":"杨华国"},{"staffId":844,"staffName":"王青华"}]';
this.$refs.changePaple.changeNameList(this.jsonSelectNameList);
},
methods: {
// 添加课程
addLessons(data) {
if (!this.bankId) {
console.log(data);
return addBank(data);
} else {
console.log("修改");
return updateBank({ bankId: this.bankId, ...data });
}
},
// 复现
getLessonById() {
getPlan(this.bankId).then((res) => {
console.log("res", res);
if (res.code == 200) {
this.form = {
bankName: res.data.planName,
deptId: res.data.planId,
personnelType: res.data.personnelType,
};
// 人名复现
this.jsonSelectNameList = JSON.stringify(this.jsonData);
this.$refs.changePaple.changeNameList(this.jsonSelectNameList);
// const data = res.data;
// const { bankName, courseType, courseConent, video, enclosure } =
// data;
// this.form = {
// bankName,
// courseType,
// courseConent,
// video,
// enclosure,
// };
// this.fileListVideo = [
// {
// name: bankName + "视频",
// url: uploadfile,
// },
// ];
// this.fileListFile = [
// {
// name: bankName + "附件",
// url: uploadfile,
// },
// ];
}
});
},
// 获取参考人员的list
getPeopleList(list) {
console.log("参考人员", list);
this.peopleList = list;
},
savePlan() {
this.$refs.form.validate((valid) => {
if (valid) {
if (this.peopleList.length < 3) {
this.$message.error("请至少选择一个考试人员");
return;
}
//console.log(this.peopleList);
this.form.peopleList = this.peopleList.toString();
this.form.planName = this.form.bankName;
console.log(this.form);
if (this.bankId != null) {
this.form.planId = this.bankId;
return editPlan(this.form).then((res) => {
if (res.code == 200) {
this.$parent.$parent.$parent.getPlanList();
}
});
} else {
return addPlan(this.form).then((res) => {
if (res.code == 200) {
this.$parent.$parent.$parent.getPlanList();
}
});
}
}
});
},
save(num = 2) {
// 因为富文本编辑器会残留<p><br></p>,所以要清
// if (this.form.courseConent === "<p><br></p>") {
// this.form.courseConent = "";
// }
this.$refs.form.validate((valid) => {
if (valid) {
this.addLessons({ ...this.form }).then((res) => {
// 如果添加会传回来,就用传回来的,如果是修改本身就有,就用本身的
// console.log('res',res)
const bankId = this.bankId || res;
// if (res.code == 200) {
// 这样调比较纯函数一点
if (num == 2) {
this.$message({
message: "保存题库成功",
type: "success",
});
} else if (num == 3) {
this.$message({
message: "保存题库成功,请开始录入题目",
type: "success",
});
}
this.$parent.$parent.componentsNumChange(num);
this.$parent.$parent.changeCourseId(bankId);
this.$parent.$parent.$parent.getList();
return true;
// }
});
} else {
if (!this.form.deptId) {
document.querySelector(
".vue-treeselect__control"
).style.borderColor = "red";
} else {
document.querySelector(
".vue-treeselect__control"
).style.borderColor = "";
this.$refs.treeItem.clearValidate();
}
}
});
},
// 保存并进入题目
saveAndNext() {
this.save(3);
},
},
};
</script>
<style lang="scss" scoped>
.form-wrapper {
padding-top: 22px;
width: 100%;
height: 550px;
// overflow: hidden;
// padding-bottom: 10px;
margin-bottom: 20px;
// border-bottom: 1px solid #bbbbbb;
.top {
width: 100%;
justify-content: space-between;
}
}
</style>
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-16 17:07:30
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-12-28 15:04:15
* @FilePath: /danger-manage-web/src/views/trainingProgram/index.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="training-wrapper">
<div class="top-title flex">
<div class="item">
<div class="text">培训管理</div>
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="addClick"
>
新增
</el-button>
</div>
</div>
<div>
<Item
v-for="item in list"
:key="item.planId"
:infoData="item"
:personnelOptions="item.postIds"
@edit="edit"
@save="itemSave"
@deletePlan="deletePlan"
@cancel="itemCancel"
:isActiveId="isActiveId"
/>
</div>
<!-- <div v-for="item in list" :key="item.title">{{item.title}}</div> -->
<el-dialog
:title="dilogTitle"
:visible.sync="addOpen"
width="800px"
append-to-body
:close-on-click-modal="false"
>
<el-form ref="form" :rules="rules" :model="form" label-width="120px">
<el-form-item label="新增培训名称" prop="planName">
<el-input v-model="form.planName"></el-input>
</el-form-item>
<el-form-item label="参与培训人员" prop="postIds">
<el-checkbox-group v-model="form.postIds">
<el-checkbox
v-for="personnel in personnelOptions"
:label="personnel.postId"
:key="personnel.postId"
>{{ personnel.postName }}</el-checkbox
>
</el-checkbox-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="dialogSubmitForm">确 定</el-button>
<el-button @click="dialogCancel">取 消</el-button>
</div>
</el-dialog>
<Dia
ref="Dia"
:componentsNum.sync="componentsNum"
:bankId.sync="bankId"
:visible.sync="dilogFlag"
:jsonData='jsonData'
/>
</div>
</template>
<script>
import Dia from "./components/Dia";
import Item from "./components/Item";
import {
getPersonnel,
addPlan,
getPlanList,
} from "@/api/train/trainingProgram";
// 培训计划管理
const personnelOptions = [
"管理人员",
"主要负责人",
"入场新员工",
"值组组长",
"车间主任",
"承包商",
"实习学生",
"参观人员",
"专职应急救援人员",
];
export default {
name: "trainingProgram",
components: {
Item,Dia
},
data() {
return {
personnelOptions,
// 选人复显示
jsonData:null,
isActiveId: 999,
list: [],
// 当点击编辑的时候,会记录最初始的
oldInfoData: null,
addOpen: false,
dilogTitle: "新增培训",
form: {
planName: "",
postIds: [],
},
componentsNum: 2,
// 点击的id,如果是新增为空
bankId: null,
dilogFlag: false,
rules: {
planName: [
{
required: true,
message: "新增培训名称不能为空",
trigger: "change",
},
],
postIds: [
{
required: true,
message: "最少选择一种参与培训人员",
trigger: "change",
},
],
},
};
},
mounted() {
this.init();
},
methods: {
async init() {
await this.getPersonnel();
await this.getPlanList();
},
getPersonnel() {
getPersonnel().then((res) => {
this.personnelOptions = res.data.map((item) => {
return {
postId: item.postId,
postName: item.postName,
};
});
});
},
getPlanList() {
this.dilogFlag = false;
return getPlanList().then((res) => {
console.log(res.data);
this.list = res.data.map((item) => {
return {
planId: item.planId,
planName: item.planName,
personnelType:item.personnelType,
postIds: item.postList,
postList: item.postList
.filter((item) => item.ischeck)
.map((item) => item.postId),
};
});
console.log(this.list);
});
},
addPlan(plan) {
return addPlan(plan).then((res) => {
if (res.code == 200) {
console.log(res.data);
const planId = +res.data;
const obj = { planId, ...this.form };
this.list.push(obj);
this.addOpen = false;
this.formReset();
}
});
},
edit(e) {
// console.log(e);
// 如果已经记录过oldInfoData
if (this.oldInfoData) {
// 就让上一个的那个数据还原
this.itemCancel(this.oldInfoData, true);
}
// 然后记录一下
const data = JSON.parse(e);
this.oldInfoData = e;
// 编辑状态改变
console.log(e);
this.isActiveId = data.planId;
},
itemSave(newValue) {
// const data = JSON.parse(newValue);
// editPlan(data).
this.itemCancel(newValue);
},
// 删除
deletePlan(value) {
const data = JSON.parse(value);
const index = this.list.findIndex((item) => item.planId == data.planId);
this.list.splice(index, 1);
// 只删除,别的什么也不干
if(this.oldInfoData){
// 如果有正在编辑还未保存,就让他还原
// this.itemCancel(this.oldInfoData)
}
},
// 取消,第二个值用来判断是否让isActiveId=999;
itemCancel(value, isActiveIdChange = false) {
// console.log(e);
// 在这里转换,防止污染
const data = JSON.parse(value);
// 找到下标,然后改成初始值
const index = this.list.findIndex((item) => item.planId == data.planId);
this.list.splice(index, 1, data);
// 取消的时候清空这里存储的初始值
this.oldInfoData = null;
if (isActiveIdChange) return;
this.isActiveId = 999;
},
changeList() {},
addClick(form,json) {
this.$refs.Dia.title = "新增培训计划";
this.componentsNum = 2;
this.bankId = null;
this.dilogFlag = true;
if(form.planId!=undefined){
//console.log("=======")
this.$refs.Dia.title = "修改培训计划";
this.bankId = form.planId;
this.jsonData = json.map(item=>{
return {
peoPleId:item.postId,
peoPleName:item.postName,
}
})
}
//this.addOpen = true;
},
dialogSubmitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
console.log(this.form);
this.addPlan(this.form);
// alert("submit!");
// this.form.id = 10;
// this.list.push(this.form);
// this.addOpen = false;
// this.formReset();
} else {
console.log("error submit!!");
return false;
}
});
},
dialogCancel() {
this.addOpen = false;
// this.formReset();
},
formReset() {
this.form = {
planName: "",
postIds: [],
};
},
},
};
</script>
<style lang="scss" scoped>
.training-wrapper {
// width: 91.3%;
width: 100%;
height: calc(100vh - 50px);
// background-color: red;
overflow: auto;
.top-title {
padding-top: 14px;
padding-bottom: 14px;
width: 100%;
justify-content: center;
.item {
width: 93.2%;
max-width: 1600px;
.text {
margin-bottom: 10px;
}
}
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment