问题页面,根父节点不能选,递归显示所有下级节点问题
This commit is contained in:
parent
f08bb2c98d
commit
c7ccd80b24
|
|
@ -1,7 +1,11 @@
|
|||
package com.ruoyi.exam.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.exam.domain.ExamQuestionCategory;
|
||||
import com.ruoyi.exam.service.IExamQuestionCategoryService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
|
@ -31,6 +35,9 @@ public class ExamQuestionController extends BaseController
|
|||
|
||||
@Autowired
|
||||
private IExamQuestionService examQuestionService;
|
||||
|
||||
@Autowired
|
||||
private IExamQuestionCategoryService examQuestionCategoryService;
|
||||
|
||||
@RequiresPermissions("exam:examQuestion:view")
|
||||
@GetMapping()
|
||||
|
|
@ -71,8 +78,28 @@ public class ExamQuestionController extends BaseController
|
|||
@ResponseBody
|
||||
public TableDataInfo list(ExamQuestion examQuestion)
|
||||
{
|
||||
List<ExamQuestion> list = examQuestionService.selectExamQuestionList(examQuestion);
|
||||
return getDataTable(list);
|
||||
ArrayList<ExamQuestion> objects = new ArrayList<>();
|
||||
List<ExamQuestion> listByIds = getListByIds(objects, examQuestion);
|
||||
return getDataTable(listByIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归找到所有下级的题目
|
||||
* @param list
|
||||
* @param examQuestion
|
||||
* @return
|
||||
*/
|
||||
private List<ExamQuestion> getListByIds(List<ExamQuestion> list,ExamQuestion examQuestion){
|
||||
list.addAll(examQuestionService.selectExamQuestionList(examQuestion));
|
||||
String categoryId = examQuestion.getCategoryId();
|
||||
ExamQuestionCategory examQuestionCategory = new ExamQuestionCategory();
|
||||
examQuestionCategory.setParentId(Long.parseLong(categoryId));
|
||||
List<ExamQuestionCategory> examQuestionCategories = examQuestionCategoryService.selectList(examQuestionCategory);
|
||||
for (ExamQuestionCategory questionCategory : examQuestionCategories) {
|
||||
examQuestion.setCategoryId(questionCategory.getId().toString());
|
||||
getListByIds(list,examQuestion);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
<div class="row">
|
||||
<div class="col-sm-12 search-collapse">
|
||||
<form id="formId">
|
||||
<input type="hidden" id="categoryId" name="categoryId" >
|
||||
<input type="hidden" id="categoryId" name="categoryId" value="1">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
|
|
@ -97,9 +97,9 @@
|
|||
|
||||
$(function () {
|
||||
$('body').layout({west__size: 185});
|
||||
$("#categoryId").val(0);
|
||||
queryExamQuestionList();
|
||||
// $.table.search();
|
||||
$("#categoryId").val(1);
|
||||
$.table.search();
|
||||
queryExamQuestionCategoryTree();
|
||||
});
|
||||
|
||||
|
|
@ -116,21 +116,11 @@
|
|||
columns: [{
|
||||
checkbox: true
|
||||
},
|
||||
{
|
||||
field: 'id',
|
||||
title: 'ID',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'title',
|
||||
title: '问题标题',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'answer',
|
||||
title: '问题答案',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'type',
|
||||
title: '问题类型',
|
||||
|
|
@ -151,19 +141,9 @@
|
|||
title: '创建时间',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'updateBy',
|
||||
title: '更新者',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'updateDate',
|
||||
title: '更新时间',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'remarks',
|
||||
title: '备注信息',
|
||||
title: '答案解析',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
|
|
@ -190,9 +170,6 @@
|
|||
$.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();
|
||||
}
|
||||
|
|
@ -222,27 +199,24 @@
|
|||
}
|
||||
|
||||
function addChoiceQuestion(){
|
||||
if($("#categoryId").val() == null||$("#categoryId").val() == ''||$("#categoryId").val() == 1 || $("#categoryId").val() == 0 ){
|
||||
alert("请选择题库!")
|
||||
return;
|
||||
if(!$.tree.notAllowParents($._tree)){
|
||||
return ;
|
||||
}
|
||||
var url = prefix + "/choiceadd/"+$("#categoryId").val();
|
||||
$.operate.jumpModeltoUrl("添加单选题",url);
|
||||
}
|
||||
|
||||
function addMoreChoiceQuestion(){
|
||||
if($("#categoryId").val() == null||$("#categoryId").val() == ''||$("#categoryId").val() == 1 || $("#categoryId").val() == 0 ){
|
||||
alert("请选择题库!")
|
||||
return;
|
||||
if(!$.tree.notAllowParents($._tree)){
|
||||
return ;
|
||||
}
|
||||
var url = prefix + "/morechoiceadd/"+$("#categoryId").val();
|
||||
$.operate.jumpModeltoUrl("添加多选题",url);
|
||||
}
|
||||
|
||||
function addJudgeQuestion(){
|
||||
if($("#categoryId").val() == null||$("#categoryId").val() == ''||$("#categoryId").val() == 1 || $("#categoryId").val() == 0 ){
|
||||
alert("请选择题库!")
|
||||
return;
|
||||
if(!$.tree.notAllowParents($._tree)){
|
||||
return ;
|
||||
}
|
||||
var url = prefix + "/judgeadd/"+$("#categoryId").val();
|
||||
$.operate.jumpModeltoUrl("添加多选题",url);
|
||||
|
|
|
|||
Loading…
Reference in New Issue