Commit aa08a383 authored by 吴卿华's avatar 吴卿华

化工巡检

parent 61db080f
...@@ -16,7 +16,11 @@ ...@@ -16,7 +16,11 @@
</description> </description>
<dependencies> <dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.1.1</version>
</dependency>
<!-- spring-boot-devtools --> <!-- spring-boot-devtools -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -211,4 +215,4 @@ ...@@ -211,4 +215,4 @@
</build> </build>
</project> </project>
\ No newline at end of file
package com.zehong.web.controller.system; package com.zehong.web.controller.system;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zehong.common.exception.CustomException;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.Answer;
import com.zehong.system.domain.TBankSubject; import com.zehong.system.domain.TBankSubject;
import com.zehong.system.domain.TDeviceInfo;
import com.zehong.system.service.ITBankSubjectService; import com.zehong.system.service.ITBankSubjectService;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -19,9 +37,12 @@ import com.zehong.common.core.domain.AjaxResult; ...@@ -19,9 +37,12 @@ import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType; import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil; import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo; import com.zehong.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
import javax.xml.crypto.Data;
/** /**
* 题库题目Controller * 题目Controller
* *
* @author zehong * @author zehong
* @date 2022-12-15 * @date 2022-12-15
...@@ -100,4 +121,101 @@ public class TBankSubjectController extends BaseController ...@@ -100,4 +121,101 @@ public class TBankSubjectController extends BaseController
{ {
return toAjax(tBankSubjectService.deleteTBankSubjectByIds(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<=2){
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())){
successNum++;
/**题库id*/
excelEntity.setBankId(bankId);
/**题目*/
excelEntity.setTopicTitle(row.getCell(0).toString());
/**选项*/
for (int s=1;s<=8;s++){
JSONObject jsonObject=new JSONObject();
jsonObject.put("value",row.getCell(s).toString());
jsonArray.add(jsonObject);
}
/**答案*/
if ("A".equals(row.getCell(9).toString())){
excelEntity.setAnswer(1);
}else if ("b".equals(row.getCell(9).toString())){
excelEntity.setAnswer(2);
}else if ("C".equals(row.getCell(9).toString())){
excelEntity.setAnswer(3);
}else if ("D".equals(row.getCell(9).toString())){
excelEntity.setAnswer(4);
}else if ("E".equals(row.getCell(9).toString())){
excelEntity.setAnswer(5);
}else if ("F".equals(row.getCell(9).toString())){
excelEntity.setAnswer(6);
}else if ("G".equals(row.getCell(9).toString())){
excelEntity.setAnswer(7);
}else if ("H".equals(row.getCell(9).toString())){
excelEntity.setAnswer(8);
}
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 + " 条");
}
/**数据添加方法*/
tBankSubjectService.insertBank(list);
// String message = tBankSubjectService.importDevice(file, updateSupport);
return AjaxResult.success(successMsg.toString());
}
} }
...@@ -22,7 +22,7 @@ import com.zehong.common.core.page.TableDataInfo; ...@@ -22,7 +22,7 @@ import com.zehong.common.core.page.TableDataInfo;
/** /**
* bankController * bankController
* * 题库管理
* @author zehong * @author zehong
* @date 2022-12-14 * @date 2022-12-14
*/ */
...@@ -34,7 +34,7 @@ public class TTrainCourseBankController extends BaseController ...@@ -34,7 +34,7 @@ public class TTrainCourseBankController extends BaseController
private ITTrainCourseBankService tTrainCourseBankService; private ITTrainCourseBankService tTrainCourseBankService;
/** /**
* 查询bank列表 * 查询题库列表
*/ */
//@PreAuthorize("@ss.hasPermi('system:bank:list')") //@PreAuthorize("@ss.hasPermi('system:bank:list')")
@GetMapping("/list") @GetMapping("/list")
...@@ -46,7 +46,7 @@ public class TTrainCourseBankController extends BaseController ...@@ -46,7 +46,7 @@ public class TTrainCourseBankController extends BaseController
} }
/** /**
* 导出bank列表 * 导出题库列表
*/ */
//@PreAuthorize("@ss.hasPermi('system:bank:export')") //@PreAuthorize("@ss.hasPermi('system:bank:export')")
@Log(title = "bank", businessType = BusinessType.EXPORT) @Log(title = "bank", businessType = BusinessType.EXPORT)
...@@ -69,7 +69,7 @@ public class TTrainCourseBankController extends BaseController ...@@ -69,7 +69,7 @@ public class TTrainCourseBankController extends BaseController
} }
/** /**
* 新增bank * 新增题库
*/ */
//@PreAuthorize("@ss.hasPermi('system:bank:add')") //@PreAuthorize("@ss.hasPermi('system:bank:add')")
@Log(title = "bank", businessType = BusinessType.INSERT) @Log(title = "bank", businessType = BusinessType.INSERT)
......
...@@ -26,7 +26,13 @@ ...@@ -26,7 +26,13 @@
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel-core</artifactId>
<version>3.1.1</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
package com.zehong.system.domain; package com.zehong.system.domain;
import java.util.Date; import java.util.Date;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
...@@ -9,7 +11,7 @@ import com.zehong.common.core.domain.BaseEntity; ...@@ -9,7 +11,7 @@ import com.zehong.common.core.domain.BaseEntity;
/** /**
* 题库题目对象 t_bank_subject * 题库题目对象 t_bank_subject
* *
* @author zehong * @author zehong
* @date 2022-12-15 * @date 2022-12-15
*/ */
...@@ -25,7 +27,7 @@ public class TBankSubject extends BaseEntity ...@@ -25,7 +27,7 @@ public class TBankSubject extends BaseEntity
private Long bankId; private Long bankId;
/** 题目内容 */ /** 题目内容 */
@Excel(name = "题目内容") @ExcelProperty(value = "题干(必填)")
private String topicTitle; private String topicTitle;
/** 题目选项(json) */ /** 题目选项(json) */
...@@ -33,65 +35,69 @@ public class TBankSubject extends BaseEntity ...@@ -33,65 +35,69 @@ public class TBankSubject extends BaseEntity
private String topicOption; private String topicOption;
/** 答案 */ /** 答案 */
@Excel(name = "答案") @Excel(name = "正确答案(必填)")
private Integer answer; private int answer;
/** 创建时间 */ /** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date datetime; private Date datetime;
public void setSubjectId(Long subjectId) public void setSubjectId(Long subjectId)
{ {
this.subjectId = subjectId; this.subjectId = subjectId;
} }
public Long getSubjectId() public Long getSubjectId()
{ {
return subjectId; return subjectId;
} }
public void setBankId(Long bankId) public void setBankId(Long bankId)
{ {
this.bankId = bankId; this.bankId = bankId;
} }
public Long getBankId() public Long getBankId()
{ {
return bankId; return bankId;
} }
public void setTopicTitle(String topicTitle) public void setTopicTitle(String topicTitle)
{ {
this.topicTitle = topicTitle; this.topicTitle = topicTitle;
} }
public String getTopicTitle() public String getTopicTitle()
{ {
return topicTitle; return topicTitle;
} }
public void setTopicOption(String topicOption) public void setTopicOption(String topicOption)
{ {
this.topicOption = topicOption; this.topicOption = topicOption;
} }
public String getTopicOption() public String getTopicOption()
{ {
return topicOption; return topicOption;
} }
public void setAnswer(Integer answer)
{ public static long getSerialVersionUID() {
this.answer = answer; return serialVersionUID;
} }
public Integer getAnswer() public int getAnswer() {
{
return answer; return answer;
} }
public void setDatetime(Date datetime)
public void setAnswer(int answer) {
this.answer = answer;
}
public void setDatetime(Date datetime)
{ {
this.datetime = datetime; this.datetime = datetime;
} }
public Date getDatetime() public Date getDatetime()
{ {
return datetime; return datetime;
} }
......
...@@ -61,6 +61,9 @@ public class TEmergencyDrill extends BaseEntity ...@@ -61,6 +61,9 @@ public class TEmergencyDrill extends BaseEntity
@Excel(name = "评估") @Excel(name = "评估")
private String assessment; private String assessment;
/**演练总人数*/
private String numberDrillers;
/**评价*/ /**评价*/
private String evaluate; private String evaluate;
...@@ -70,6 +73,14 @@ public class TEmergencyDrill extends BaseEntity ...@@ -70,6 +73,14 @@ public class TEmergencyDrill extends BaseEntity
/** 删除 0否 1是 */ /** 删除 0否 1是 */
private Integer isDel; private Integer isDel;
public String getNumberDrillers() {
return numberDrillers;
}
public void setNumberDrillers(String numberDrillers) {
this.numberDrillers = numberDrillers;
}
public static long getSerialVersionUID() { public static long getSerialVersionUID() {
return serialVersionUID; return serialVersionUID;
} }
...@@ -201,21 +212,22 @@ public class TEmergencyDrill extends BaseEntity ...@@ -201,21 +212,22 @@ public class TEmergencyDrill extends BaseEntity
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return "TEmergencyDrill{" +
.append("drillId", getDrillId()) "drillId=" + drillId +
.append("drillName", getDrillName()) ", drillName='" + drillName + '\'' +
.append("drillAddress", getDrillAddress()) ", drillAddress='" + drillAddress + '\'' +
.append("drillUnit", getDrillUnit()) ", drillUnit='" + drillUnit + '\'' +
.append("drillTime", getDrillTime()) ", drillTime=" + drillTime +
.append("drillType", getDrillType()) ", drillType=" + drillType +
.append("drillForm", getDrillForm()) ", drillForm=" + drillForm +
.append("drillObjective", getDrillObjective()) ", drillObjective='" + drillObjective + '\'' +
.append("drillPeople", getDrillPeople()) ", drillPeople='" + drillPeople + '\'' +
.append("drillContent", getDrillContent()) ", drillContent='" + drillContent + '\'' +
.append("assessment", getAssessment()) ", assessment='" + assessment + '\'' +
.append("createTime", getCreateTime()) ", numberDrillers='" + numberDrillers + '\'' +
.append("createBy", getCreateBy()) ", evaluate='" + evaluate + '\'' +
.append("isDel", getIsDel()) ", measures='" + measures + '\'' +
.toString(); ", isDel=" + isDel +
'}';
} }
} }
...@@ -7,7 +7,7 @@ import com.zehong.common.core.domain.BaseEntity; ...@@ -7,7 +7,7 @@ import com.zehong.common.core.domain.BaseEntity;
/** /**
* bank对象 t_train_course_bank * bank对象 t_train_course_bank
* *
* @author zehong * @author zehong
* @date 2022-12-14 * @date 2022-12-14
*/ */
...@@ -25,57 +25,69 @@ public class TTrainCourseBank extends BaseEntity ...@@ -25,57 +25,69 @@ public class TTrainCourseBank extends BaseEntity
@Excel(name = "题库名称") @Excel(name = "题库名称")
private String bankName; private String bankName;
/**下级题目数量*/
private String numberQuestions;
/** 是否删除 0未删除 1删除 */ /** 是否删除 0未删除 1删除 */
private Integer isDel; private Integer isDel;
public void setBankId(Long bankId) 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; this.bankId = bankId;
} }
public Long getBankId() public Long getBankId()
{ {
return bankId; return bankId;
} }
public void setDeptId(Long deptId) public void setDeptId(Long deptId)
{ {
this.deptId = deptId; this.deptId = deptId;
} }
public Long getDeptId() public Long getDeptId()
{ {
return deptId; return deptId;
} }
public void setBankName(String bankName) public void setBankName(String bankName)
{ {
this.bankName = bankName; this.bankName = bankName;
} }
public String getBankName() public String getBankName()
{ {
return bankName; return bankName;
} }
public void setIsDel(Integer isDel) public void setIsDel(Integer isDel)
{ {
this.isDel = isDel; this.isDel = isDel;
} }
public Integer getIsDel() public Integer getIsDel()
{ {
return isDel; return isDel;
} }
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return "TTrainCourseBank{" +
.append("bankId", getBankId()) "bankId=" + bankId +
.append("deptId", getDeptId()) ", deptId=" + deptId +
.append("bankName", getBankName()) ", bankName='" + bankName + '\'' +
.append("isDel", getIsDel()) ", numberQuestions='" + numberQuestions + '\'' +
.append("createBy", getCreateBy()) ", isDel=" + isDel +
.append("createTime", getCreateTime()) '}';
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
} }
} }
...@@ -5,15 +5,15 @@ import com.zehong.system.domain.TBankSubject; ...@@ -5,15 +5,15 @@ import com.zehong.system.domain.TBankSubject;
/** /**
* 题库题目Mapper接口 * 题库题目Mapper接口
* *
* @author zehong * @author zehong
* @date 2022-12-15 * @date 2022-12-15
*/ */
public interface TBankSubjectMapper public interface TBankSubjectMapper
{ {
/** /**
* 查询题库题目 * 查询题库题目
* *
* @param subjectId 题库题目ID * @param subjectId 题库题目ID
* @return 题库题目 * @return 题库题目
*/ */
...@@ -21,7 +21,7 @@ public interface TBankSubjectMapper ...@@ -21,7 +21,7 @@ public interface TBankSubjectMapper
/** /**
* 查询题库题目列表 * 查询题库题目列表
* *
* @param tBankSubject 题库题目 * @param tBankSubject 题库题目
* @return 题库题目集合 * @return 题库题目集合
*/ */
...@@ -29,7 +29,7 @@ public interface TBankSubjectMapper ...@@ -29,7 +29,7 @@ public interface TBankSubjectMapper
/** /**
* 新增题库题目 * 新增题库题目
* *
* @param tBankSubject 题库题目 * @param tBankSubject 题库题目
* @return 结果 * @return 结果
*/ */
...@@ -37,7 +37,7 @@ public interface TBankSubjectMapper ...@@ -37,7 +37,7 @@ public interface TBankSubjectMapper
/** /**
* 修改题库题目 * 修改题库题目
* *
* @param tBankSubject 题库题目 * @param tBankSubject 题库题目
* @return 结果 * @return 结果
*/ */
...@@ -45,7 +45,7 @@ public interface TBankSubjectMapper ...@@ -45,7 +45,7 @@ public interface TBankSubjectMapper
/** /**
* 删除题库题目 * 删除题库题目
* *
* @param subjectId 题库题目ID * @param subjectId 题库题目ID
* @return 结果 * @return 结果
*/ */
...@@ -53,9 +53,15 @@ public interface TBankSubjectMapper ...@@ -53,9 +53,15 @@ public interface TBankSubjectMapper
/** /**
* 批量删除题库题目 * 批量删除题库题目
* *
* @param subjectIds 需要删除的数据ID * @param subjectIds 需要删除的数据ID
* @return 结果 * @return 结果
*/ */
public int deleteTBankSubjectByIds(Long[] subjectIds); public int deleteTBankSubjectByIds(Long[] subjectIds);
/**
* Excel导入
* @param list
*/
void insertBank(List<TBankSubject> list);
} }
package com.zehong.system.service; package com.zehong.system.service;
import java.io.IOException;
import java.util.List; import java.util.List;
import com.zehong.system.domain.TBankSubject; import com.zehong.system.domain.TBankSubject;
import org.springframework.web.multipart.MultipartFile;
/** /**
* 题库题目Service接口 * 题库题目Service接口
* *
* @author zehong * @author zehong
* @date 2022-12-15 * @date 2022-12-15
*/ */
public interface ITBankSubjectService public interface ITBankSubjectService
{ {
/** /**
* 查询题库题目 * 查询题库题目
* *
* @param subjectId 题库题目ID * @param subjectId 题库题目ID
* @return 题库题目 * @return 题库题目
*/ */
...@@ -21,7 +23,7 @@ public interface ITBankSubjectService ...@@ -21,7 +23,7 @@ public interface ITBankSubjectService
/** /**
* 查询题库题目列表 * 查询题库题目列表
* *
* @param tBankSubject 题库题目 * @param tBankSubject 题库题目
* @return 题库题目集合 * @return 题库题目集合
*/ */
...@@ -29,7 +31,7 @@ public interface ITBankSubjectService ...@@ -29,7 +31,7 @@ public interface ITBankSubjectService
/** /**
* 新增题库题目 * 新增题库题目
* *
* @param tBankSubject 题库题目 * @param tBankSubject 题库题目
* @return 结果 * @return 结果
*/ */
...@@ -37,7 +39,7 @@ public interface ITBankSubjectService ...@@ -37,7 +39,7 @@ public interface ITBankSubjectService
/** /**
* 修改题库题目 * 修改题库题目
* *
* @param tBankSubject 题库题目 * @param tBankSubject 题库题目
* @return 结果 * @return 结果
*/ */
...@@ -45,7 +47,7 @@ public interface ITBankSubjectService ...@@ -45,7 +47,7 @@ public interface ITBankSubjectService
/** /**
* 批量删除题库题目 * 批量删除题库题目
* *
* @param subjectIds 需要删除的题库题目ID * @param subjectIds 需要删除的题库题目ID
* @return 结果 * @return 结果
*/ */
...@@ -53,9 +55,23 @@ public interface ITBankSubjectService ...@@ -53,9 +55,23 @@ public interface ITBankSubjectService
/** /**
* 删除题库题目信息 * 删除题库题目信息
* *
* @param subjectId 题库题目ID * @param subjectId 题库题目ID
* @return 结果 * @return 结果
*/ */
public int deleteTBankSubjectById(Long subjectId); 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.impl; package com.zehong.system.service.impl;
import java.io.IOException;
import java.io.InputStream;
import java.util.List; import java.util.List;
import com.alibaba.excel.EasyExcel;
import com.zehong.common.exception.CustomException;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.TDeviceInfo;
import org.apache.poi.ss.usermodel.Row;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TBankSubjectMapper; import com.zehong.system.mapper.TBankSubjectMapper;
import com.zehong.system.domain.TBankSubject; import com.zehong.system.domain.TBankSubject;
import com.zehong.system.service.ITBankSubjectService; import com.zehong.system.service.ITBankSubjectService;
import org.springframework.web.multipart.MultipartFile;
/** /**
* 题库题目Service业务层处理 * 题库题目Service业务层处理
* *
* @author zehong * @author zehong
* @date 2022-12-15 * @date 2022-12-15
*/ */
@Service @Service
public class TBankSubjectServiceImpl implements ITBankSubjectService public class TBankSubjectServiceImpl implements ITBankSubjectService
{ {
@Autowired @Autowired
private TBankSubjectMapper tBankSubjectMapper; private TBankSubjectMapper tBankSubjectMapper;
/** /**
* 查询题库题目 * 查询题库题目
* *
* @param subjectId 题库题目ID * @param subjectId 题库题目ID
* @return 题库题目 * @return 题库题目
*/ */
...@@ -33,7 +42,7 @@ public class TBankSubjectServiceImpl implements ITBankSubjectService ...@@ -33,7 +42,7 @@ public class TBankSubjectServiceImpl implements ITBankSubjectService
/** /**
* 查询题库题目列表 * 查询题库题目列表
* *
* @param tBankSubject 题库题目 * @param tBankSubject 题库题目
* @return 题库题目 * @return 题库题目
*/ */
...@@ -45,7 +54,7 @@ public class TBankSubjectServiceImpl implements ITBankSubjectService ...@@ -45,7 +54,7 @@ public class TBankSubjectServiceImpl implements ITBankSubjectService
/** /**
* 新增题库题目 * 新增题库题目
* *
* @param tBankSubject 题库题目 * @param tBankSubject 题库题目
* @return 结果 * @return 结果
*/ */
...@@ -57,7 +66,7 @@ public class TBankSubjectServiceImpl implements ITBankSubjectService ...@@ -57,7 +66,7 @@ public class TBankSubjectServiceImpl implements ITBankSubjectService
/** /**
* 修改题库题目 * 修改题库题目
* *
* @param tBankSubject 题库题目 * @param tBankSubject 题库题目
* @return 结果 * @return 结果
*/ */
...@@ -69,7 +78,7 @@ public class TBankSubjectServiceImpl implements ITBankSubjectService ...@@ -69,7 +78,7 @@ public class TBankSubjectServiceImpl implements ITBankSubjectService
/** /**
* 批量删除题库题目 * 批量删除题库题目
* *
* @param subjectIds 需要删除的题库题目ID * @param subjectIds 需要删除的题库题目ID
* @return 结果 * @return 结果
*/ */
...@@ -81,7 +90,7 @@ public class TBankSubjectServiceImpl implements ITBankSubjectService ...@@ -81,7 +90,7 @@ public class TBankSubjectServiceImpl implements ITBankSubjectService
/** /**
* 删除题库题目信息 * 删除题库题目信息
* *
* @param subjectId 题库题目ID * @param subjectId 题库题目ID
* @return 结果 * @return 结果
*/ */
...@@ -90,4 +99,60 @@ public class TBankSubjectServiceImpl implements ITBankSubjectService ...@@ -90,4 +99,60 @@ public class TBankSubjectServiceImpl implements ITBankSubjectService
{ {
return tBankSubjectMapper.deleteTBankSubjectById(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);
}
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zehong.system.mapper.TBankSubjectMapper"> <mapper namespace="com.zehong.system.mapper.TBankSubjectMapper">
<resultMap type="TBankSubject" id="TBankSubjectResult"> <resultMap type="TBankSubject" id="TBankSubjectResult">
<result property="subjectId" column="subject_id" /> <result property="subjectId" column="subject_id" />
<result property="bankId" column="bank_id" /> <result property="bankId" column="bank_id" />
...@@ -19,20 +19,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -19,20 +19,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectTBankSubjectList" parameterType="TBankSubject" resultMap="TBankSubjectResult"> <select id="selectTBankSubjectList" parameterType="TBankSubject" resultMap="TBankSubjectResult">
<include refid="selectTBankSubjectVo"/> <include refid="selectTBankSubjectVo"/>
<where> <where>
<if test="bankId != null "> and bank_id = #{bankId}</if> <if test="bankId != null "> and bank_id = #{bankId}</if>
<if test="topicTitle != null and topicTitle != ''"> and topic_title = #{topicTitle}</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="topicOption != null and topicOption != ''"> and topic_option = #{topicOption}</if>-->
<if test="answer != null "> and answer = #{answer}</if> <!-- <if test="answer != null "> and answer = #{answer}</if>-->
<if test="datetime != null "> and datetime = #{datetime}</if> <!-- <if test="datetime != null "> and datetime = #{datetime}</if>-->
</where> </where>
</select> </select>
<select id="selectTBankSubjectById" parameterType="Long" resultMap="TBankSubjectResult"> <select id="selectTBankSubjectById" parameterType="Long" resultMap="TBankSubjectResult">
<include refid="selectTBankSubjectVo"/> <include refid="selectTBankSubjectVo"/>
where subject_id = #{subjectId} where subject_id = #{subjectId}
</select> </select>
<insert id="insertTBankSubject" parameterType="TBankSubject" useGeneratedKeys="true" keyProperty="subjectId"> <insert id="insertTBankSubject" parameterType="TBankSubject" useGeneratedKeys="true" keyProperty="subjectId">
insert into t_bank_subject insert into t_bank_subject
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
...@@ -68,9 +68,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -68,9 +68,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<delete id="deleteTBankSubjectByIds" parameterType="String"> <delete id="deleteTBankSubjectByIds" parameterType="String">
delete from t_bank_subject where subject_id in delete from t_bank_subject where subject_id in
<foreach item="subjectId" collection="array" open="(" separator="," close=")"> <foreach item="subjectId" collection="array" open="(" separator="," close=")">
#{subjectId} #{subjectId}
</foreach> </foreach>
</delete> </delete>
</mapper>
\ No newline at end of file <!--excel导入-->
<insert id="insertBank">
insert into t_bank_subject (bank_id,topic_title,topic_option,answer,datetime)
values
<foreach collection="list" item="item" index= "index" separator =",">
( #{item.bankId},#{item.topicTitle},#{item.topicOption},#{item.answer},#{item.datetime})
</foreach>
</insert>
</mapper>
...@@ -18,11 +18,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -18,11 +18,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="assessment" column="assessment" /> <result property="assessment" column="assessment" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="numberDrillers" column="number_drillers" />
<result property="isDel" column="is_del" /> <result property="isDel" column="is_del" />
</resultMap> </resultMap>
<sql id="selectTEmergencyDrillVo"> <sql id="selectTEmergencyDrillVo">
select drill_id, drill_name, drill_address, drill_unit, drill_time, drill_type, drill_form, drill_objective, drill_people, drill_content, assessment, evaluate,measures,create_time, create_by, is_del from t_emergency_drill select drill_id, drill_name, drill_address, drill_unit, drill_time, drill_type, drill_form, drill_objective, drill_people, drill_content, assessment, evaluate,measures,create_time, create_by,number_drillers, is_del from t_emergency_drill
</sql> </sql>
<select id="selectTEmergencyDrillList" parameterType="TEmergencyDrill" resultMap="TEmergencyDrillResult"> <select id="selectTEmergencyDrillList" parameterType="TEmergencyDrill" resultMap="TEmergencyDrillResult">
...@@ -55,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -55,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="assessment != null">assessment,</if> <if test="assessment != null">assessment,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="numberDrillers != null">number_drillers,</if>
<if test="isDel != null">is_del,</if> <if test="isDel != null">is_del,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
...@@ -70,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -70,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="assessment != null">#{assessment},</if> <if test="assessment != null">#{assessment},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="numberDrillers != null">#{numberDrillers},</if>
<if test="isDel != null">#{isDel},</if> <if test="isDel != null">#{isDel},</if>
</trim> </trim>
</insert> </insert>
...@@ -90,6 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -90,6 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>
<if test="evaluate != null">evaluate = #{evaluate},</if> <if test="evaluate != null">evaluate = #{evaluate},</if>
<if test="numberDrillers != null">number_drillers = #{numberDrillers},</if>
<if test="measures != null">measures = #{measures},</if> <if test="measures != null">measures = #{measures},</if>
<if test="isDel != null">is_del = #{isDel},</if> <if test="isDel != null">is_del = #{isDel},</if>
</trim> </trim>
...@@ -110,7 +114,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -110,7 +114,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!--应急演练统计查询--> <!--应急演练统计查询-->
<select id="countList" resultType="com.zehong.system.domain.DrillStatistics"> <select id="countList" resultType="com.zehong.system.domain.DrillStatistics">
select * from ( select * from (
select date_format(create_time, '%Y-%m') mont , count(*)as totalNumberDrills select date_format(create_time, '%Y-%m') mont , count(*)as totalNumberDrills,
sum(number_drillers) as numberParticipants
from t_emergency_drill from t_emergency_drill
group by date_format(create_time, '%Y-%m') ) t group by date_format(create_time, '%Y-%m') ) t
<if test="mont != null and mont != ''"> <if test="mont != null and mont != ''">
......
...@@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="numberQuestions" column="numberQuestions" />
</resultMap> </resultMap>
<sql id="selectTTrainCourseBankVo"> <sql id="selectTTrainCourseBankVo">
...@@ -20,9 +21,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -20,9 +21,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql> </sql>
<select id="selectTTrainCourseBankList" parameterType="TTrainCourseBank" resultMap="TTrainCourseBankResult"> <select id="selectTTrainCourseBankList" parameterType="TTrainCourseBank" resultMap="TTrainCourseBankResult">
<include refid="selectTTrainCourseBankVo"/> 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> <where>
<if test="bankName != null and bankName != ''"> and bank_name like concat('%', #{bankName}, '%')</if> <if test="bankName != null and bankName != ''"> and a.bank_name like concat('%', #{bankName}, '%')</if>
</where> </where>
group by bank_id desc group by bank_id desc
</select> </select>
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading" :loading="exportLoading"
@click="handleExport" @click="handleExport"
>导出</el-button> >导出</el-button>
</el-col> </el-col>
......
...@@ -16,6 +16,18 @@ ...@@ -16,6 +16,18 @@
</div> </div>
<div class="right">{{ courseName }}</div> <div class="right">{{ courseName }}</div>
</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="table flex" v-loading="loading">
<div class="th flex"> <div class="th flex">
<div class="left">序号</div> <div class="left">序号</div>
...@@ -73,8 +85,46 @@ ...@@ -73,8 +85,46 @@
type="success" type="success"
>保存</el-button >保存</el-button
> >
</div> </div>
</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> </div>
</template> </template>
...@@ -87,7 +137,7 @@ import { ...@@ -87,7 +137,7 @@ import {
} from "@/api/educationPlanExam/lessonsProgram"; } from "@/api/educationPlanExam/lessonsProgram";
import { listSubject, delSubject } from "@/api/educationPlanExam/subject"; import { listSubject, delSubject } from "@/api/educationPlanExam/subject";
import { getBank } from "@/api/educationPlanExam/questionBank"; import { getBank } from "@/api/educationPlanExam/questionBank";
import { getToken } from "@/utils/auth";
export default { export default {
name: "AnswerLesson", name: "AnswerLesson",
props: { props: {
...@@ -105,6 +155,25 @@ export default { ...@@ -105,6 +155,25 @@ export default {
questionList: [], questionList: [],
loading: false, loading: false,
courseName: "", 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"
},
}; };
}, },
// watch: { // watch: {
...@@ -126,6 +195,47 @@ export default { ...@@ -126,6 +195,47 @@ export default {
} }
}, },
methods: { 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/kaoshibao.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.getList();
},
/** 下载模板操作 */
importTemplate() {
importTemplate().then(response => {
this.download(response.msg);
});
},
// 提交上传文件
submitFileForm() {
this.$refs.upload.submit();
},
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
save() { save() {
console.log("QuestionList"); console.log("QuestionList");
}, },
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
ref="queryForm" ref="queryForm"
:inline="true" :inline="true"
label-width="68px" label-width="68px"
> >
<!-- <el-form-item label="课件类别" prop="courseType"> <!-- <el-form-item label="课件类别" prop="courseType">
<el-select <el-select
...@@ -131,9 +131,9 @@ ...@@ -131,9 +131,9 @@
prop="topicNum" prop="topicNum"
width="180" width="180"
> >
<template v-slot="{ row: { topicNum, bankId } }"> <template v-slot="{ row: { numberQuestions, bankId } }">
<div @click="checkQuestion(bankId)" class="timuNum"> <div @click="checkQuestion(bankId)" class="timuNum">
<div v-if="topicNum > 0">{{ `已录入${topicNum}题` }}</div> <div v-if="numberQuestions > 0">{{ `已录入${numberQuestions}题` }}</div>
<div v-else>未录入</div> <div v-else>未录入</div>
</div> </div>
</template> </template>
...@@ -230,6 +230,7 @@ export default { ...@@ -230,6 +230,7 @@ export default {
// 题库名称 // 题库名称
bankName: null, bankName: null,
releaseTime: "", releaseTime: "",
numberQuestions:0
}, },
// 表单参数 // 表单参数
form: {}, form: {},
...@@ -338,7 +339,6 @@ export default { ...@@ -338,7 +339,6 @@ export default {
checkQuestion(bankId) { checkQuestion(bankId) {
// 要查看考题的id // 要查看考题的id
this.bankId = bankId; this.bankId = bankId;
console.log(this.bankId);
// 2代表列表组件 // 2代表列表组件
this.componentsNum = 2; this.componentsNum = 2;
this.dilogFlag = true; this.dilogFlag = true;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
ref="queryForm" ref="queryForm"
:inline="true" :inline="true"
label-width="68px" label-width="68px"
> >
<!-- <el-form-item label="课件类别" prop="courseType"> <!-- <el-form-item label="课件类别" prop="courseType">
<el-select <el-select
...@@ -175,7 +175,7 @@ ...@@ -175,7 +175,7 @@
@click="changeBank(bankId)" @click="changeBank(bankId)"
>发布考试</el-button >发布考试</el-button
> >
<!-- <el-button <!-- <el-button
v-if="status == 0" v-if="status == 0"
size="mini" size="mini"
......
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
</template> </template>
<script> <script>
import { listBank, getBank, delBank, addBank, updateBank, exportBank } from "@/api/system/bank"; // import { listBank, getBank, delBank, addBank, updateBank, exportBank } from "@/api/system/bank";
import { treeselect } from "@/api/system/dept"; import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import "@riophae/vue-treeselect/dist/vue-treeselect.css";
......
...@@ -90,6 +90,7 @@ ...@@ -90,6 +90,7 @@
<el-table-column label="演练形式" align="center" prop="drillForm" :formatter="drillFormFormat" /> <el-table-column label="演练形式" align="center" prop="drillForm" :formatter="drillFormFormat" />
<el-table-column label="演练地址" align="center" prop="drillAddress" /> <el-table-column label="演练地址" align="center" prop="drillAddress" />
<el-table-column label="主办单位" align="center" prop="drillUnit" /> <el-table-column label="主办单位" align="center" prop="drillUnit" />
<el-table-column label="参演总人数" align="center" prop="numberDrillers" />
<el-table-column label="演练时间" align="center" prop="drillTime" width="180"/> <el-table-column label="演练时间" align="center" prop="drillTime" width="180"/>
<!--<el-table-column label="演练目的" align="center" prop="drillObjective" />--> <!--<el-table-column label="演练目的" align="center" prop="drillObjective" />-->
<!--<el-table-column label="参演人员" align="center" prop="drillPeople" />--> <!--<el-table-column label="参演人员" align="center" prop="drillPeople" />-->
...@@ -142,10 +143,10 @@ ...@@ -142,10 +143,10 @@
/> />
<!-- 添加或修改应急演练对话框 --> <!-- 添加或修改应急演练对话框 -->
<el-dialog :title="title" :visible.sync="open" width="1600px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="1800px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="90px"> <el-form ref="form" :model="form" :rules="rules" label-width="90px">
<div class="division"> <div class="division">
<div class="div-kuang" style="width: 40%;"> <div class="div-kuang" style="width: 50%;">
<el-form-item label="演练名称" prop="drillName"> <el-form-item label="演练名称" prop="drillName">
<el-input v-model="form.drillName" placeholder="请输入演练名称" /> <el-input v-model="form.drillName" placeholder="请输入演练名称" />
</el-form-item> </el-form-item>
...@@ -188,7 +189,8 @@ ...@@ -188,7 +189,8 @@
<el-input type="textarea" v-model="form.drillObjective" placeholder="请输入演练目的" /> <el-input type="textarea" v-model="form.drillObjective" placeholder="请输入演练目的" />
</el-form-item> </el-form-item>
</div> </div>
<div class="div-kuang" style="width: 68%;margin-left: 2%">
<div class="div-kuang" style="width: 58%;margin-left: 2%">
<!-- <el-form-item label="参演人员" prop="drillPeople">--> <!-- <el-form-item label="参演人员" prop="drillPeople">-->
<!-- <el-input v-model="form.drillPeople" type="textarea" placeholder="请输入内容" />--> <!-- <el-input v-model="form.drillPeople" type="textarea" placeholder="请输入内容" />-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
...@@ -196,21 +198,22 @@ ...@@ -196,21 +198,22 @@
<editor v-model="form.drillContent" :min-height="240"/> <editor v-model="form.drillContent" :min-height="240"/>
</el-form-item> </el-form-item>
</div> </div>
<div class="div-kuang" style="width: 95%;margin-left: 2%"> <div class="div-kuang" style="width: 95%;margin-left: 2%">
<el-form-item label="参演人员" prop="drillPeople"> <el-form-item label="选择人员" prop="releaseTime">
<el-transfer <!-- table -->
filterable <!-- jsonSelectNameList就是呗选中的人员的json -->
:filter-method="filterMethod" <!-- getPeopleList 是每次选中或者删除人员都会返回 一个所有人员列表的json串,[{staffId:staffId,staffName:staffName},{staffId:staffId,staffName:staffName}] -->
filter-placeholder="请输入参演人员姓名" <!-- 要在jsonSelectNameList赋值完毕之后 调用一下 this.$refs.changePaple.changeNameList 135行 -->
v-model="value" <ChangePapel
:titles="['员工信息', '参演人员']" ref="changePaple"
:data="data" :jsonSelectNameList="jsonSelectNameList"
@change="handleChange"> @getPeopleList="getPeopleList"
</el-transfer> />
</el-form-item> </el-form-item>
</div> </div>
</div> </div>
...@@ -249,6 +252,9 @@ ...@@ -249,6 +252,9 @@
<el-form-item label="演练目的:" prop="drillObjective"> <el-form-item label="演练目的:" prop="drillObjective">
<span>{{form.drillObjective}}</span> <span>{{form.drillObjective}}</span>
</el-form-item> </el-form-item>
<el-form-item label="参演人数:" prop="drillObjective">
<span>{{form.numberDrillers}}</span>
</el-form-item>
</div> </div>
<div class="div-kuang" style="width: 58%;margin-left: 2%"> <div class="div-kuang" style="width: 58%;margin-left: 2%">
<el-form-item label="参演人员:" prop="drillPeople"> <el-form-item label="参演人员:" prop="drillPeople">
...@@ -293,17 +299,25 @@ ...@@ -293,17 +299,25 @@
</template> </template>
<script> <script>
import ChangePapel from "@/components/PeopleChange";
import { listDrill, getDrill, delDrill, addDrill, updateDrill, exportDrill } from "@/api/system/drill"; import { listDrill, getDrill, delDrill, addDrill, updateDrill, exportDrill } from "@/api/system/drill";
import { TStaffList } from "@/api/safetyManagement/staff"; import { TStaffList } from "@/api/safetyManagement/staff";
import Editor from '@/components/Editor'; import Editor from '@/components/Editor';
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default { export default {
name: "Drill", name: "Drill",
components: { components: {
Editor, Editor,
ChangePapel
}, },
data() { data() {
return { return {
// 参考人员
jsonSelectNameList: null,
//参演人员
data: [], data: [],
//参演人数
numberPersonnel:null,
value: [], value: [],
//选中下标 //选中下标
check:[], check:[],
...@@ -370,6 +384,9 @@ export default { ...@@ -370,6 +384,9 @@ export default {
}; };
}, },
created() { created() {
if (this.bankId) {
this.getLessonById();
}
this.getList(); this.getList();
this.getDicts("t_drill_type").then(response => { this.getDicts("t_drill_type").then(response => {
this.drillTypeOptions = response.data; this.drillTypeOptions = response.data;
...@@ -378,20 +395,48 @@ export default { ...@@ -378,20 +395,48 @@ export default {
this.drillFormOptions = response.data; this.drillFormOptions = response.data;
}); });
}, },
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: { methods: {
// 获取参考人员的list
getPeopleList(list) {
//参演人员数量
//this.numberPersonnel=JSON.parse(list).length
//参演人员
//this.data=list;
this.form.drillPeople=list;
this.form.numberDrillers=JSON.parse(list).length
},
// 复现
getLessonById() {
getBank(this.bankId).then((res) => {
console.log("res", res);
if (res.code == 200) {
this.form = {
bankName: res.data.bankName,
deptId: res.data.deptId,
};
}
});
},
/**穿梭框数据查询*/ /**穿梭框数据查询*/
generateData(){ generateData(){
const data = []; const data = [];
TStaffList(this.addDateRange(this.queryParams, this.dateRange)).then(response => { TStaffList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
response.rows.forEach((city, index) => { this.jsonSelectNameList=response;
data.push({ // response.rows.forEach((city, index) => {
label: city.staffName, // data.push({
key: index, // label: city.staffName,
pinyin: city.staffName // key: index,
}); // pinyin: city.staffName
}) // });
// })
}); });
this.value=['孙卓亚']
this.data=data; this.data=data;
}, },
/**参演人员选中信息方法 获取数组下标*/ /**参演人员选中信息方法 获取数组下标*/
...@@ -439,6 +484,7 @@ export default { ...@@ -439,6 +484,7 @@ export default {
isDel: null, isDel: null,
evaluate:null, evaluate:null,
measures:null, measures:null,
numberDrillers:0,
}; };
this.resetForm("form"); this.resetForm("form");
}, },
...@@ -465,7 +511,8 @@ export default { ...@@ -465,7 +511,8 @@ export default {
// this.cities = response.rows.staffName; // this.cities = response.rows.staffName;
// generateData.cities=['shanghai', 'beijing', 'guangzhou', 'shenzhen', 'nanjing', 'xian', 'chengdu'] // generateData.cities=['shanghai', 'beijing', 'guangzhou', 'shenzhen', 'nanjing', 'xian', 'chengdu']
// }); // });
this.generateData();
this.generateData();
this.reset(); this.reset();
this.open = true; this.open = true;
this.title = "添加应急演练"; this.title = "添加应急演练";
...@@ -496,7 +543,6 @@ export default { ...@@ -496,7 +543,6 @@ export default {
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
console.log(this.form.drillId)
if (valid) { if (valid) {
if (this.form.drillId != null) { if (this.form.drillId != null) {
updateDrill(this.form).then(response => { updateDrill(this.form).then(response => {
...@@ -506,16 +552,11 @@ export default { ...@@ -506,16 +552,11 @@ export default {
this.getList(); this.getList();
}); });
} else { } else {
this.check.forEach((city, index) => { addDrill(this.form).then(response => {
this.test=this.data[index] this.msgSuccess("新增成功");
console.log(this.test.label) this.open = false;
}) this.getList();
});
// addDrill(this.form).then(response => {
// this.msgSuccess("新增成功");
// this.open = false;
// this.getList();
// });
} }
} }
}); });
......
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