新增选择题

This commit is contained in:
flower 2018-12-10 03:08:09 +08:00
parent c2c95058ff
commit be93d9489e
15 changed files with 756 additions and 436 deletions

View File

@ -477,6 +477,10 @@
add: function(id) {
var url = $.common.isEmpty(id) ? $.table._option.createUrl : $.table._option.createUrl.replace("{id}", id);
$.modal.open("添加" + $.table._option.modalName, url);
},
//跳转自定义
jumpModeltoUrl: function(modelName,url) {
$.modal.open(modelName, url);
},
// 修改信息
edit: function(id) {

View File

@ -1,6 +1,11 @@
package com.ruoyi.web.controller.exam;
package com.ruoyi.exam.controller;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.ruoyi.framework.web.util.ShiroUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -41,17 +46,19 @@ public class ExamQuestionCategoryController extends BaseController
return prefix + "/examQuestionCategory";
}
/**
* 查询试题分类列表
*/
@RequiresPermissions("exam:examQuestionCategory:list")
@PostMapping("/list")
@GetMapping("/list")
@ResponseBody
public TableDataInfo list(ExamQuestionCategory examQuestionCategory)
public List<ExamQuestionCategory> list(ExamQuestionCategory examQuestionCategory)
{
List<ExamQuestionCategory> list = examQuestionCategoryService.selectExamQuestionCategoryList(examQuestionCategory);
return getDataTable(list);
return list;
}
@ -71,9 +78,10 @@ public class ExamQuestionCategoryController extends BaseController
/**
* 新增试题分类
*/
@GetMapping("/add")
public String add()
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") String parentId, ModelMap mmap)
{
mmap.put("examQuestionCategory", examQuestionCategoryService.selectExamQuestionCategoryById(parentId));
return prefix + "/add";
}
@ -86,6 +94,8 @@ public class ExamQuestionCategoryController extends BaseController
@ResponseBody
public AjaxResult addSave(ExamQuestionCategory examQuestionCategory)
{
examQuestionCategory.setCreateBy(ShiroUtils.getLoginName());
examQuestionCategory.setCreateDate(new Date());
return toAjax(examQuestionCategoryService.insertExamQuestionCategory(examQuestionCategory));
}
@ -124,4 +134,48 @@ public class ExamQuestionCategoryController extends BaseController
return toAjax(examQuestionCategoryService.deleteExamQuestionCategoryByIds(ids));
}
/**
* 选择部门树
*/
@GetMapping("/selectExamQuestionCategoryTree/{examQuestionCategoryId}")
public String selectDeptTree(@PathVariable("examQuestionCategoryId") String examQuestionCategoryId, ModelMap mmap)
{
mmap.put("examQuestionCategory", examQuestionCategoryService.selectExamQuestionCategoryById(examQuestionCategoryId));
return prefix + "/tree";
}
/**
* 加载列表树
*/
@GetMapping("/treeData")
@ResponseBody
public List<Map<String, Object>> treeData()
{
List<Map<String, Object>> tree = examQuestionCategoryService.selectDeptTree();
return tree;
}
/**
* 选择部门树
*/
@GetMapping("/treeDataForAdd")
@ResponseBody
public List<Map<String, Object>> treeDataForAdd()
{
List<Map<String, Object>> tree = examQuestionCategoryService.selectDeptTree();
List<Map<String, Object>> res = new ArrayList<>();
for (Map<String, Object> stringObjectMap : tree) {
String pId = stringObjectMap.get("pId").toString();
if(pId.equals("0")||pId.equals("1")){
res.add(stringObjectMap);
}
}
return res;
}
}

View File

@ -1,15 +1,12 @@
package com.ruoyi.web.controller.exam;
package com.ruoyi.exam.controller;
import java.util.Enumeration;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.exam.domain.ExamQuestion;
@ -19,6 +16,8 @@ import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.ExcelUtil;
import javax.servlet.http.HttpServletRequest;
/**
* 问题 信息操作处理
*
@ -40,6 +39,14 @@ public class ExamQuestionController extends BaseController
{
return prefix + "/examQuestion";
}
@GetMapping("/choiceadd/{id}")
public String addChoiceUrl(@PathVariable("id") String id, ModelMap mmap)
{
mmap.put("categoryId",id);
mmap.put("type",1);
return prefix + "/choiceadd";
}
/**
* 查询问题列表
@ -83,9 +90,11 @@ public class ExamQuestionController extends BaseController
@Log(title = "问题", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(ExamQuestion examQuestion)
{
return toAjax(examQuestionService.insertExamQuestion(examQuestion));
public AjaxResult addSave(ExamQuestion examQuestion,@RequestParam(value = "number", required = true) String[] number,
@RequestParam(value = "content", required = true) String[] content)
{
return toAjax(examQuestionService.insertQuestion(examQuestion,number,content));
}
/**

View File

@ -16,11 +16,11 @@ public class ExamQuestionCategory
private static final long serialVersionUID = 1L;
/** */
private String id;
private Long id;
/** 分类 */
private String name;
/** */
private String parentId;
private Long parentId;
/** */
private String parentIds;
/** 创建者 */
@ -36,12 +36,22 @@ public class ExamQuestionCategory
/** 删除标记 */
private String delFlag;
public void setId(String id)
private String orderNum;
public String getOrderNum() {
return orderNum;
}
public void setOrderNum(String orderNum) {
this.orderNum = orderNum;
}
public void setId(Long id)
{
this.id = id;
}
public String getId()
public Long getId()
{
return id;
}
@ -54,12 +64,12 @@ public class ExamQuestionCategory
{
return name;
}
public void setParentId(String parentId)
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
public String getParentId()
public Long getParentId()
{
return parentId;
}

View File

@ -2,6 +2,8 @@ package com.ruoyi.exam.service;
import com.ruoyi.exam.domain.ExamQuestionCategory;
import java.util.List;
import java.util.Map;
import com.ruoyi.framework.web.base.AbstractBaseService;
/**
* 试题分类 服务层
@ -50,5 +52,6 @@ public interface IExamQuestionCategoryService extends AbstractBaseService<ExamQu
* @return 结果
*/
public int deleteExamQuestionCategoryByIds(String ids);
List<Map<String,Object>> selectDeptTree();
}

View File

@ -50,5 +50,6 @@ public interface IExamQuestionService extends AbstractBaseService<ExamQuestion>
* @return 结果
*/
public int deleteExamQuestionByIds(String ids);
int insertQuestion(ExamQuestion examQuestion, String[] number, String[] content);
}

View File

@ -1,6 +1,12 @@
package com.ruoyi.exam.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.system.domain.SysDept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.exam.mapper.ExamQuestionCategoryMapper;
@ -8,77 +14,99 @@ import com.ruoyi.exam.domain.ExamQuestionCategory;
import com.ruoyi.exam.service.IExamQuestionCategoryService;
import com.ruoyi.common.support.Convert;
import com.ruoyi.framework.web.base.AbstractBaseServiceImpl;
/**
* 试题分类 服务层实现
*
*
* @author zhujj
* @date 2018-12-06
*/
@Service
public class ExamQuestionCategoryServiceImpl extends AbstractBaseServiceImpl<ExamQuestionCategoryMapper,ExamQuestionCategory> implements IExamQuestionCategoryService
{
@Autowired
private ExamQuestionCategoryMapper examQuestionCategoryMapper;
public class ExamQuestionCategoryServiceImpl extends AbstractBaseServiceImpl<ExamQuestionCategoryMapper, ExamQuestionCategory> implements IExamQuestionCategoryService {
@Autowired
private ExamQuestionCategoryMapper examQuestionCategoryMapper;
/**
/**
* 查询试题分类信息
*
*
* @param id 试题分类ID
* @return 试题分类信息
*/
@Override
public ExamQuestionCategory selectExamQuestionCategoryById(String id)
{
return examQuestionCategoryMapper.selectExamQuestionCategoryById(id);
}
/**
public ExamQuestionCategory selectExamQuestionCategoryById(String id) {
return examQuestionCategoryMapper.selectExamQuestionCategoryById(id);
}
/**
* 查询试题分类列表
*
*
* @param examQuestionCategory 试题分类信息
* @return 试题分类集合
*/
@Override
public List<ExamQuestionCategory> selectExamQuestionCategoryList(ExamQuestionCategory examQuestionCategory)
{
startPage();
return examQuestionCategoryMapper.selectExamQuestionCategoryList(examQuestionCategory);
}
@Override
public List<ExamQuestionCategory> selectExamQuestionCategoryList(ExamQuestionCategory examQuestionCategory) {
startPage();
return examQuestionCategoryMapper.selectExamQuestionCategoryList(examQuestionCategory);
}
/**
* 新增试题分类
*
*
* @param examQuestionCategory 试题分类信息
* @return 结果
*/
@Override
public int insertExamQuestionCategory(ExamQuestionCategory examQuestionCategory)
{
return examQuestionCategoryMapper.insertExamQuestionCategory(examQuestionCategory);
}
/**
* 修改试题分类
*
* @param examQuestionCategory 试题分类信息
* @return 结果
*/
@Override
public int updateExamQuestionCategory(ExamQuestionCategory examQuestionCategory)
{
return examQuestionCategoryMapper.updateExamQuestionCategory(examQuestionCategory);
}
@Override
public int insertExamQuestionCategory(ExamQuestionCategory examQuestionCategory) {
return examQuestionCategoryMapper.insertExamQuestionCategory(examQuestionCategory);
}
/**
/**
* 修改试题分类
*
* @param examQuestionCategory 试题分类信息
* @return 结果
*/
@Override
public int updateExamQuestionCategory(ExamQuestionCategory examQuestionCategory) {
return examQuestionCategoryMapper.updateExamQuestionCategory(examQuestionCategory);
}
/**
* 删除试题分类对象
*
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteExamQuestionCategoryByIds(String ids)
{
return examQuestionCategoryMapper.deleteExamQuestionCategoryByIds(Convert.toStrArray(ids));
}
@Override
public int deleteExamQuestionCategoryByIds(String ids) {
return examQuestionCategoryMapper.deleteExamQuestionCategoryByIds(Convert.toStrArray(ids));
}
@Override
public List<Map<String, Object>> selectDeptTree() {
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
List<ExamQuestionCategory> deptList = selectExamQuestionCategoryList(new ExamQuestionCategory());
trees = getTrees(deptList, false, null);
return trees;
}
private List<Map<String, Object>> getTrees(List<ExamQuestionCategory> deptList, boolean isCheck, List<String> roleDeptList) {
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
for (ExamQuestionCategory dept : deptList) {
Map<String, Object> deptMap = new HashMap<String, Object>();
deptMap.put("id", dept.getId());
deptMap.put("pId", dept.getParentId());
deptMap.put("name", dept.getName());
deptMap.put("title", dept.getName());
if (isCheck) {
deptMap.put("checked", roleDeptList.contains(dept.getId() + dept.getName()));
} else {
deptMap.put("checked", false);
}
trees.add(deptMap);
}
return trees;
}
}

View File

@ -1,6 +1,12 @@
package com.ruoyi.exam.service.impl;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import com.ruoyi.exam.domain.ExamQuestionItem;
import com.ruoyi.exam.mapper.ExamQuestionItemMapper;
import com.ruoyi.framework.web.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.exam.mapper.ExamQuestionMapper;
@ -20,6 +26,9 @@ public class ExamQuestionServiceImpl extends AbstractBaseServiceImpl<ExamQuestio
@Autowired
private ExamQuestionMapper examQuestionMapper;
@Autowired
private ExamQuestionItemMapper examQuestionItemMapper;
/**
* 查询问题信息
*
@ -80,5 +89,29 @@ public class ExamQuestionServiceImpl extends AbstractBaseServiceImpl<ExamQuestio
{
return examQuestionMapper.deleteExamQuestionByIds(Convert.toStrArray(ids));
}
@Override
public int insertQuestion(ExamQuestion examQuestion, String[] number, String[] content) {
Date date = new Date();
examQuestion.setCreateDate(date);
examQuestion.setCreateBy(ShiroUtils.getLoginName());
int i = examQuestionMapper.insertExamQuestion(examQuestion);
examQuestion.setCreateDate(null);
List<ExamQuestion> select = examQuestionMapper.selectExamQuestionList(examQuestion);
ExamQuestionItem examQuestionItem = new ExamQuestionItem();
for (int i1 = 0; i1 < number.length; i1++) {
examQuestionItem.setContent(content[i1]);
examQuestionItem.setNumber(number[i1]);
examQuestionItem.setExamQuestionId(select.get(0).getId()+"");
examQuestionItem.setCreateDate(date);
examQuestionItem.setCreateBy(ShiroUtils.getLoginName());
examQuestionItemMapper.insertExamQuestionItem(examQuestionItem);
}
return i ;
}
}

View File

@ -15,10 +15,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateDate" column="update_date" />
<result property="remarks" column="remarks" />
<result property="delFlag" column="del_flag" />
<result property="orderNum" column="order_num" />
</resultMap>
<sql id="selectExamQuestionCategoryVo">
select id, name, parent_id, parent_ids, create_by, create_date, update_by, update_date, remarks, del_flag from exam_question_category
select id, name, parent_id, parent_ids, create_by, create_date, update_by, update_date, remarks, del_flag,order_num from exam_question_category
</sql>
<select id="selectExamQuestionCategoryList" parameterType="ExamQuestionCategory" resultMap="ExamQuestionCategoryResult">

View File

@ -0,0 +1,135 @@
<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-examQuestion-add">
<div class="form-group">
<input type="hidden" id="categoryId" name="categoryId" th:value="${categoryId}">
<input type="hidden" id="type" name="type" th:value="${type}">
<label class="col-sm-3 control-label">问题标题:</label>
<div class="col-sm-8">
<input id="title" name="title" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">问题答案:</label>
<div class="col-sm-8">
<input id="answer" name="answer" class="form-control" type="text">
</div>
</div>
<div class="form-group" >
<label class="col-sm-3 control-label">问题选项:</label>
<div class="col-sm-1">
<input style="padding: 6px 10px" id="number1" name="number" class="form-control" type="text" value="A" readonly>
</div>
<div class="col-sm-7">
<input id="content1" name="content" class="form-control" type="text">
</div>
</div>
<div class="form-group" >
<label class="col-sm-3 control-label"></label>
<div class="col-sm-1">
<input style="padding: 6px 10px" id="number2" name="number" class="form-control" type="text" value="B" readonly>
</div>
<div class="col-sm-7">
<input id="content2" name="content" class="form-control" type="text">
</div>
</div>
<div class="form-group" id="addOption">
<label class="col-sm-4 control-label"></label>
<div class="col-sm-7">
<a style="text-align: center;color: #999;border: 1px #ccc dashed;display:block;height: 34px
;line-height: 34px" href="javascript:addOption();">添加选项</a>
</div>
</div>
<!--</div>-->
<!--<div class="form-group">-->
<!--<label class="col-sm-3 control-label">标签:</label>-->
<!--<div class="col-sm-8">-->
<!--<input id="label" name="label" class="form-control" type="text">-->
<!--</div>-->
<!--</div>-->
<div class="form-group">
<label class="col-sm-3 control-label">备注信息:</label>
<div class="col-sm-8">
<input id="remarks" name="remarks" class="form-control" type="text">
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
$(function () {
if ($.validator) {
$.validator.prototype.elements = function () {
var validator = this,
rulesCache = {};
return $([]).add(this.currentForm.elements)
.filter(":input")
.not(":submit, :reset, :image, [disabled]")
.not(this.settings.ignore)
.filter(function () {
var elementIdentification = this.id || this.name;
!elementIdentification && validator.settings.debug && window.console && console.error("%o has no id nor name assigned", this);
if (elementIdentification in rulesCache || !validator.objectLength($(this).rules()))
return false;
rulesCache[elementIdentification] = true;
return true;
});
};
}
});
var item = ["C","D","E","F","G","H","I","G","K","L","M","N"];
var index = 0;
var prefix = ctx + "exam/examQuestion"
$("#form-examQuestion-add").validate({
rules:{
title:{
required:true,
},
content:{
required:true,
},
}
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-examQuestion-add').serialize());
}
}
function addOption(){
$("#addOption").before(' <div class="form-group update1" id="div'+item[index]+'"> <label class="col-sm-3 control-label"></label> <div class="col-sm-1"> ' +
'<input style="padding: 6px 10px" id="number'+item[index]+'" name="number" class="form-control update2" type="text" value="'+item[index]+'" readonly> ' +
'</div> <div class="col-sm-7"> <input name="content" class="form-control" type="text"> </div> <div class="col-sm-1"> <a style="text-align: center;color: #999;border: 1px #ccc dashed;display:block;height: 34px;line-height: 34px" href="javascript:deleteOption(\''+item[index++]+'\');">X</a> </div></div>')
}
function deleteOption(id){
debugger
$("#div"+id).remove();
index--;
var index1 = 0;
var index2 = 0;
$(".update1").each(function(){
$(this).attr("id","div"+item[index1++])
})
$(".update2").each(function(){
$(this).attr("value",item[index2++])
})
}
</script>
</body>
</html>

View File

@ -2,178 +2,225 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<li>
问题标题:<input type="text" name="title"/>
</li>
<div class="ui-layout-west">
<div class="main-content">
<div class="box box-main">
<div class="box-header">
<div class="box-title">
<i class="fa icon-grid"></i> 题库
</div>
<div class="box-tools pull-right">
<a type="button" class="btn btn-box-tool menuItem" href="#" onclick="examQuestionCategory()"
title="题库管理"><i
class="fa fa-edit"></i></a>
<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i
class="fa fa-chevron-up"></i></button>
<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i
class="fa fa-chevron-down"></i></button>
<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新题库"><i
class="fa fa-refresh"></i></button>
</div>
</div>
<div class="ui-layout-content">
<div id="tree" class="ztree"></div>
</div>
</div>
</div>
</div>
<li>
问题答案:<input type="text" name="answer"/>
</li>
<li>
问题类型:<input type="text" name="type"/>
</li>
<div class="container-div ui-layout-center">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<input type="hidden" id="categoryId" name="categoryId">
<div class="select-list">
<ul>
<li>
问题标题:<input type="text" name="title"/>
</li>
<li>
标签:<input type="text" name="label"/>
</li>
<li>
问题类型:<select name="type" th:with="type=${@dict.getType('exam_question_type')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
<li>
类别:<input type="text" name="categoryId"/>
</li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<li>
创建者:<input type="text" name="createBy"/>
</li>
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
<a class="btn btn-success" onclick="addChoiceQuestion()" shiro:hasPermission="exam:examQuestion:add">
<i class="fa fa-plus"></i> 添加选择题
</a>
<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()"
shiro:hasPermission="exam:examQuestion:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"
shiro:hasPermission="exam:examQuestion:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="exam:examQuestion:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table" data-mobile-responsive="true"></table>
</div>
</div>
</div>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('exam:examQuestion:edit')}]];
var removeFlag = [[${@permission.hasPermi('exam:examQuestion:remove')}]];
var prefix = ctx + "exam/examQuestion";
<li>
创建时间:<input type="text" name="createDate"/>
</li>
$(function () {
$('body').layout({west__size: 185});
queryExamQuestionList();
queryExamQuestionCategoryTree();
});
<li>
更新者:<input type="text" name="updateBy"/>
</li>
<li>
更新时间:<input type="text" name="updateDate"/>
</li>
<li>
备注信息:<input type="text" name="remarks"/>
</li>
<li>
删除标记:<input type="text" name="delFlag"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="exam:examQuestion:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="exam:examQuestion:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="exam:examQuestion:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="exam:examQuestion:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table" data-mobile-responsive="true"></table>
</div>
</div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('exam:examQuestion:edit')}]];
var removeFlag = [[${@permission.hasPermi('exam:examQuestion:remove')}]];
var prefix = ctx + "exam/examQuestion";
$(function() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "问题",
search: false,
showExport: true,
columns: [{
checkbox: true
},
{
field : 'id',
title : '',
visible: false
},
{
field : 'title',
title : '问题标题',
sortable: true
},
{
field : 'answer',
title : '问题答案',
sortable: true
},
{
field : 'type',
title : '问题类型',
sortable: true
},
{
field : 'label',
title : '标签',
sortable: true
},
{
field : 'categoryId',
title : '类别',
sortable: true
},
{
field : 'createBy',
title : '创建者',
sortable: true
},
{
field : 'createDate',
title : '创建时间',
sortable: true
},
{
field : 'updateBy',
title : '更新者',
sortable: true
},
{
field : 'updateDate',
title : '更新时间',
sortable: true
},
{
field : 'remarks',
title : '备注信息',
sortable: true
},
{
field : 'delFlag',
title : '删除标记',
sortable: true
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
function queryExamQuestionList() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "问题",
search: false,
showExport: true,
columns: [{
checkbox: true
},
{
field: 'id',
title: 'ID',
sortable: true
},
{
field: 'title',
title: '问题标题',
sortable: true
},
{
field: 'answer',
title: '问题答案',
sortable: true
},
{
field: 'type',
title: '问题类型',
sortable: true
},
{
field: 'label',
title: '标签',
sortable: true
},
{
field: 'createBy',
title: '创建者',
sortable: true
},
{
field: 'createDate',
title: '创建时间',
sortable: true
},
{
field: 'updateBy',
title: '更新者',
sortable: true
},
{
field: 'updateDate',
title: '更新时间',
sortable: true
},
{
field: 'remarks',
title: '备注信息',
sortable: true
},
{
title: '操作',
align: 'center',
formatter: function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
};
$.table.init(options);
});
</script>
return actions.join('');
}
}]
};
$.table.init(options);
};
function queryExamQuestionCategoryTree() {
var url = ctx + "exam/examQuestionCategory/treeData";
var options = {
url: url,
expandLevel: 2,
onClick: zOnClick
};
$.tree.init(options);
function zOnClick(event, treeId, treeNode) {
if(treeNode.pId == 1 || treeNode.pId == 0 ||treeNode.pId == null) {
return;
}
$("#categoryId").val(treeNode.id);
$.table.search();
}
}
$('#btnExpand').click(function () {
$._tree.expandAll(true);
$(this).hide();
$('#btnCollapse').show();
});
$('#btnCollapse').click(function () {
$._tree.expandAll(false);
$(this).hide();
$('#btnExpand').show();
});
$('#btnRefresh').click(function () {
queryExamQuestionCategoryTree();
});
/*用户管理-部门*/
function examQuestionCategory() {
var url = ctx + "exam/examQuestionCategory";
createMenuItem(url, "题库管理");
}
function addChoiceQuestion(){
if($("#categoryId").val() == null||$("#categoryId").val() == ''){
alert("请选择题库!")
return;
}
var url = prefix + "/choiceadd/"+$("#categoryId").val();
$.operate.jumpModeltoUrl("添加选择题",url);
}
</script>
</body>
</html>

View File

@ -5,60 +5,26 @@
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-examQuestionCategory-add">
<div class="form-group">
<label class="col-sm-3 control-label">分类:</label>
<input id="treeId" name="parentId" type="hidden" th:value="${examQuestionCategory.id}" />
<div class="form-group">
<label class="col-sm-3 control-label ">上级名称:</label>
<div class="col-sm-8">
<input class="form-control" type="text" onclick="selectExamQuestionCategoryTree()" id="treeName" readonly="true" th:value="${examQuestionCategory.name}"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">名称:</label>
<div class="col-sm-8">
<input id="name" name="name" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-8">
<input id="parentId" name="parentId" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-8">
<input id="parentIds" name="parentIds" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">创建者:</label>
<div class="col-sm-8">
<input id="createBy" name="createBy" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">创建时间:</label>
<div class="col-sm-8">
<input id="createDate" name="createDate" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">更新者:</label>
<div class="col-sm-8">
<input id="updateBy" name="updateBy" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">更新时间:</label>
<div class="col-sm-8">
<input id="updateDate" name="updateDate" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<div class="form-group">
<label class="col-sm-3 control-label">备注信息:</label>
<div class="col-sm-8">
<input id="remarks" name="remarks" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">删除标记:</label>
<div class="col-sm-8">
<input id="delFlag" name="delFlag" class="form-control" type="text">
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
@ -66,7 +32,7 @@
var prefix = ctx + "exam/examQuestionCategory"
$("#form-examQuestionCategory-add").validate({
rules:{
xxxx:{
name:{
required:true,
},
}
@ -77,6 +43,23 @@
$.operate.save(prefix + "/add", $('#form-examQuestionCategory-add').serialize());
}
}
function selectExamQuestionCategoryTree() {
var options = {
title: '分类选择',
width: "380",
url: prefix + "/selectExamQuestionCategoryTree/" + $("#treeId").val(),
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var body = layer.getChildFrame('body', index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
layer.close(index);
}
</script>
</body>
</html>

View File

@ -12,19 +12,19 @@
<input id="name" name="name" th:field="*{name}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-8">
<input id="parentId" name="parentId" th:field="*{parentId}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-8">
<input id="parentIds" name="parentIds" th:field="*{parentIds}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<!--<div class="form-group"> -->
<!--<label class="col-sm-3 control-label"></label>-->
<!--<div class="col-sm-8">-->
<!--<input id="parentId" name="parentId" th:field="*{parentId}" class="form-control" type="text">-->
<!--</div>-->
<!--</div>-->
<!--<div class="form-group"> -->
<!--<label class="col-sm-3 control-label"></label>-->
<!--<div class="col-sm-8">-->
<!--<input id="parentIds" name="parentIds" th:field="*{parentIds}" class="form-control" type="text">-->
<!--</div>-->
<!--</div>-->
<!--<div class="form-group">
<label class="col-sm-3 control-label">创建者:</label>
<div class="col-sm-8">
<input id="createBy" name="createBy" th:field="*{createBy}" class="form-control" type="text">
@ -47,19 +47,19 @@
<div class="col-sm-8">
<input id="updateDate" name="updateDate" th:field="*{updateDate}" class="form-control" type="text">
</div>
</div>
</div>-->
<div class="form-group">
<label class="col-sm-3 control-label">备注信息:</label>
<div class="col-sm-8">
<input id="remarks" name="remarks" th:field="*{remarks}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">删除标记:</label>
<div class="col-sm-8">
<input id="delFlag" name="delFlag" th:field="*{delFlag}" class="form-control" type="text">
</div>
</div>
<!--<div class="form-group"> -->
<!--<label class="col-sm-3 control-label">删除标记:</label>-->
<!--<div class="col-sm-8">-->
<!--<input id="delFlag" name="delFlag" th:field="*{delFlag}" class="form-control" type="text">-->
<!--</div>-->
<!--</div>-->
</form>
</div>
<div th:include="include::footer"></div>

View File

@ -3,159 +3,123 @@
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<li>
分类:<input type="text" name="name"/>
</li>
<li>
<input type="text" name="parentId"/>
</li>
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<li>
分类:<input type="text" name="name"/>
</li>
<li>
<input type="text" name="parentIds"/>
</li>
<li>
创建者:<input type="text" name="createBy"/>
</li>
<li>
创建时间:<input type="text" name="createDate"/>
</li>
<li>
更新者:<input type="text" name="updateBy"/>
</li>
<li>
更新时间:<input type="text" name="updateDate"/>
</li>
<li>
备注信息:<input type="text" name="remarks"/>
</li>
<li>
删除标记:<input type="text" name="delFlag"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="exam:examQuestionCategory:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="exam:examQuestionCategory:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="exam:examQuestionCategory:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="exam:examQuestionCategory:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table" data-mobile-responsive="true"></table>
</div>
</div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('exam:examQuestionCategory:edit')}]];
var removeFlag = [[${@permission.hasPermi('exam:examQuestionCategory:remove')}]];
var prefix = ctx + "exam/examQuestionCategory";
$(function() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "试题分类",
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i
class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add(1)" shiro:hasPermission="exam:examQuestionCategory:add">
<i class="fa fa-plus"></i> 添加
</a>
<!--<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()"-->
<!--shiro:hasPermission="exam:examQuestionCategory:edit">-->
<!--<i class="fa fa-edit"></i> 修改-->
<!--</a>-->
<!--<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"-->
<!--shiro:hasPermission="exam:examQuestionCategory:remove">-->
<!--<i class="fa fa-remove"></i> 删除-->
<!--</a>-->
<!--<a class="btn btn-warning" onclick="$.table.exportExcel()"-->
<!--shiro:hasPermission="exam:examQuestionCategory:export">-->
<!--<i class="fa fa-download"></i> 导出-->
<!--</a>-->
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-tree-table" data-mobile-responsive="true"></table>
</div>
</div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('exam:examQuestionCategory:edit')}]];
var removeFlag = [[${@permission.hasPermi('exam:examQuestionCategory:remove')}]];
var prefix = ctx + "exam/examQuestionCategory";
debugger
$(function () {
var options = {
code: "id",
parentCode: "parentId",
uniqueId: "id",
url: prefix + "/list",
createUrl: prefix + "/add/{id}",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "试题分类",
search: false,
showExport: true,
columns: [{
checkbox: true
},
columns: [{
field: 'selectItem',
radio: true
},
{
field: 'name',
title: '分类',
align: "left"
},
{
field: 'orderNum',
title: '排序',
align: "left"
},
{
field : 'id',
title : '',
visible: false
},
{
field : 'name',
title : '分类',
sortable: true
},
{
field : 'parentId',
title : '',
sortable: true
},
{
field : 'parentIds',
title : '',
sortable: true
},
{
field : 'createBy',
field : 'createBy',
title : '创建者',
sortable: true
align: "left"
},
{
field : 'createDate',
field : 'createDate',
title : '创建时间',
sortable: true
align: "left"
},
{
field : 'updateBy',
field : 'updateBy',
title : '更新者',
sortable: true
align: "left"
},
{
field : 'updateDate',
field : 'updateDate',
title : '更新时间',
sortable: true
align: "left"
},
{
field : 'remarks',
field : 'remarks',
title : '备注信息',
sortable: true
align: "left"
},
{
field : 'delFlag',
title : '删除标记',
sortable: true
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
{
title: '操作',
align: 'left',
formatter: function (value, row, index) {
if(row.id == 1){
return '';
}
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
};
$.table.init(options);
});
</script>
return actions.join('');
}
}]
};
$.treeTable.init(options);
});
</script>
</body>
</html>

View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>
<style>
body{height:auto;font-family: "Microsoft YaHei";}
button{font-family: "SimSun","Helvetica Neue",Helvetica,Arial;}
</style>
<body class="hold-transition box box-main">
<input id="treeId" name="treeId" type="hidden" th:value="${examQuestionCategory.id}"/>
<input id="treeName" name="treeName" type="hidden" th:value="${examQuestionCategory.name}"/>
<div class="wrapper"><div class="treeShowHideButton" onclick="$.tree.toggleSearch();">
<label id="btnShow" title="显示搜索" style="display:none;"></label>
<label id="btnHide" title="隐藏搜索"></label>
</div>
<div class="treeSearchInput" id="search">
<label for="keyword">关键字:</label><input type="text" class="empty" id="keyword" maxlength="50">
<button class="btn" id="btn" onclick="$.tree.searchNode()"> 搜索 </button>
</div>
<div class="treeExpandCollapse">
<a href="#" onclick="$.tree.expand()">展开</a> /
<a href="#" onclick="$.tree.collapse()">折叠</a>
</div>
<div id="tree" class="ztree treeselect"></div>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
$(function() {
var url = ctx + "exam/examQuestionCategory/treeDataForAdd";
var options = {
url: url,
expandLevel: 2,
onClick : zOnClick
};
$.tree.init(options);
});
function zOnClick(event, treeId, treeNode) {
var treeId = treeNode.id;
var treeName = treeNode.name;
$("#treeId").val(treeId);
$("#treeName").val(treeName);
}
</script>
</body>
</html>