15 changed files with 488 additions and 149 deletions
@ -1,38 +1,125 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > |
|||
<html lang="zh" xmlns:th="http://www.thymeleaf.org"> |
|||
<head> |
|||
<th:block th:include="include :: header('场景题目绑定')" /> |
|||
<th:block th:include="zdxtInclude :: header('场景题目绑定')"/> |
|||
</head> |
|||
<body class="white-bg"> |
|||
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
|||
<form class="form-horizontal m" id="form-question-detail" th:object="${sceneQuestion}"> |
|||
<h2 th:value="*{name}"></h2> |
|||
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
|||
<form class="form-horizontal m" id="form-question-bind" th:object="${sceneQuestion}"> |
|||
<h2 th:text="*{name}" style="margin-bottom: 30px;"></h2> |
|||
<input name="id" th:field="*{id}" type="hidden"> |
|||
<div class="form-group"> |
|||
<div class="col-sm-8"> |
|||
<input name="name" class="form-control" type="text" placeholder="A:..."> |
|||
<div class="col-sm-6"> |
|||
<input name="answer" class="form-control" type="text" placeholder="A..."> |
|||
</div> |
|||
<div class="col-sm-2" style="width: 12%"> |
|||
<input type="checkbox" name="check" onclick="inputCheck(this)"> |
|||
<span>正确</span> |
|||
</div> |
|||
<div class="col-sm-4" style="display: none"> |
|||
<select th:each="li:${list}" class="form-control"> |
|||
<option th:value="${li.id}" th:text="${li.name}"></option> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
<div class="form-group"> |
|||
<div class="col-sm-8"> |
|||
<input name="groupId" class="form-control" type="text" placeholder="B:..."> |
|||
<div class="col-sm-6"> |
|||
<input name="answer" class="form-control" type="text" placeholder="B..."> |
|||
</div> |
|||
<div class="col-sm-2" style="width: 12%"> |
|||
<input type="checkbox" name="check" onclick="inputCheck(this)"> |
|||
<span>正确</span> |
|||
</div> |
|||
<div class="col-sm-4" style="display: none"> |
|||
<select th:each="li:${list}" class="form-control"> |
|||
<option th:value="${li.id}" th:text="${li.name}"></option> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
<div class="form-group"> |
|||
<div class="col-sm-8"> |
|||
<input name="roleId" class="form-control" type="text" placeholder="C:..."> |
|||
<div class="col-sm-6"> |
|||
<input name="answer" class="form-control" type="text" placeholder="C..."> |
|||
</div> |
|||
<div class="col-sm-2" style="width: 12%"> |
|||
<input type="checkbox" name="check" onclick="inputCheck(this)"> |
|||
<span>正确</span> |
|||
</div> |
|||
<div class="col-sm-4" style="display: none"> |
|||
<select th:each="li:${list}" class="form-control"> |
|||
<option th:value="${li.id}" th:text="${li.name}"></option> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
<div class="form-group"> |
|||
<div class="col-sm-8"> |
|||
<input name="roleId" class="form-control" type="text" placeholder="D:..."> |
|||
<div class="col-sm-6"> |
|||
<input name="answer" class="form-control" type="text" placeholder="D..."> |
|||
</div> |
|||
<div class="col-sm-2" style="width: 12%"> |
|||
<input type="checkbox" name="check" onclick="inputCheck(this)"> |
|||
<span>正确</span> |
|||
</div> |
|||
<div class="col-sm-4" style="display: none"> |
|||
<select th:each="li:${list}" class="form-control"> |
|||
<option th:value="${li.id}" th:text="${li.name}"></option> |
|||
</select> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
<th:block th:include="include :: footer" /> |
|||
<script type="text/javascript"> |
|||
</form> |
|||
</div> |
|||
<th:block th:include="zdxtInclude :: footer"/> |
|||
<script th:inline="javascript"> |
|||
var prefix = ctx + "project/question" |
|||
$("#form-question-add").validate({ |
|||
focusCleanup: true |
|||
}); |
|||
|
|||
function inputCheck(obj) { |
|||
if ($(obj).prop('checked')) { |
|||
// 还原之前样式 |
|||
$("[name='check']").prop('checked', false); |
|||
// $("[name='select']").val(""); |
|||
$(".col-sm-4").hide(); |
|||
//选中当前样式 |
|||
$(obj).prop('checked', true) |
|||
$(obj).parent().next().show(); |
|||
} else { |
|||
$(obj).parent().next().hide(); |
|||
} |
|||
} |
|||
|
|||
</script> |
|||
function submitHandler() { |
|||
if ($.validate.form()) { |
|||
var reqData = {}; |
|||
var nextQuestionId; |
|||
var reqList = new Array(); |
|||
var checkFlag = false; |
|||
var elements = document.getElementsByName("answer"); |
|||
for (let i = 0; i < document.getElementsByName("answer").length; i++) { |
|||
if (elements[i].value === "") { |
|||
$.modal.alertWarning("请将选项填写完整"); |
|||
return; |
|||
} |
|||
var req = {}; |
|||
req.answer = elements[i].value; |
|||
req.check = elements[i].parentElement.nextElementSibling.firstElementChild.checked; |
|||
checkFlag = checkFlag === true ? true : req.check; |
|||
reqList.push(req); |
|||
debugger |
|||
if (req.check) { |
|||
let divData = elements[i].parentElement.nextElementSibling.nextElementSibling; |
|||
nextQuestionId = $(divData).find("select").val(); |
|||
} |
|||
} |
|||
if (!checkFlag) { |
|||
$.modal.alertWarning("请勾选一个正确选项"); |
|||
return; |
|||
} |
|||
reqData.id = $("[name = 'id']").val(); |
|||
reqData.nextQuestionId = nextQuestionId; |
|||
reqData.answer = JSON.stringify(reqList); |
|||
$.operate.save(prefix + "/bindAnswer", reqData); |
|||
} |
|||
} |
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,39 @@ |
|||
package com.zdxt.knowledge.domain; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 场景题目对象 scene_question |
|||
* |
|||
* @author ruoyi |
|||
* @date 2023-12-26 |
|||
*/ |
|||
@Data |
|||
public class SceneQuestionBindRequest implements Serializable { |
|||
|
|||
/** |
|||
* 主键 |
|||
*/ |
|||
private Long id; |
|||
|
|||
/** |
|||
* 答案 |
|||
*/ |
|||
private List<QuestionAnswer> answerList; |
|||
|
|||
/** |
|||
* 下一个答案 |
|||
*/ |
|||
private Long nextQuestionId; |
|||
|
|||
@Data |
|||
public static class QuestionAnswer { |
|||
public String answerEle; |
|||
public boolean checkFlag; |
|||
} |
|||
|
|||
|
|||
} |
|||
Loading…
Reference in new issue