Browse Source

场景管理答案绑定

master
yanyan 3 years ago
parent
commit
e5ea4469c4
  1. 143
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/bindNew.html
  2. 5
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/view.html
  3. 4
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneManageController.java
  4. 13
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneQuestionController.java
  5. 7
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/SceneImportDataModel.java
  6. 4
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/SceneQuestionMapper.xml

143
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/bindNew.html

@ -0,0 +1,143 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Tree Diagram with Tooltips</title>
<style>
.card {
fill: #fff;
stroke: steelblue;
stroke-width: 3px;
width: 120px;
height: 50px;
cursor: pointer;
}
.card text {
font-size: 14px;
font-family: sans-serif;
}
.tooltip {
position: absolute;
text-align: center;
padding: 10px;
font-size: 14px;
font-family: sans-serif;
background-color: #f0f0f0;
border: 1px solid #ccc;
border-radius: 5px;
pointer-events: none;
visibility: hidden;
}
.link {
fill: none;
stroke: #ccc;
stroke-width: 2px;
}
</style>
</head>
<body>
<div id="tree"></div>
<script src="https://d3js.org/d3.v5.min.js"></script>
<script>
// 树形结构数据
// var treeData = {
// "name": "Root",
// "children": [
// {
// "name": "Node 1",
// "children": [
// {"name": "Leaf 1"},
// ]
// },
// {
// "name": "Node 2",
// "children": [
// {"name": "Leaf 1"}
// ]
// }
// ]
// };
var treeData = {
"name": "Root",
"children": [
{
"name": "Node 1",
"children": [
{"name": "Leaf 1"},
]
}
]
};
// 定义画布大小和边距
var margin = {top: 20, right: 120, bottom: 20, left: 120},
width = 600 - margin.right - margin.left,
height = 300 - margin.top - margin.bottom;
// 定义树形布局
var treemap = d3.tree()
.size([height, width]);
// 为数据设置层级关系
var root = d3.hierarchy(treeData);
// 计算节点位置
treemap(root);
// 创建SVG画布
var svg = d3.select("#tree")
.append("svg")
.attr("width", width + margin.right + margin.left)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
// 添加节点组
var node = svg.selectAll(".node")
.data(root.descendants())
.enter()
.append("g")
.attr("class", "node")
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; })
.on("mouseover", function(d) {
tooltip.style("visibility", "visible");
tooltip.text(d.data.name);
})
.on("mousemove", function(d) {
tooltip.style("top", (d3.event.pageY-10)+"px").style("left",(d3.event.pageX+10)+"px");
})
.on("mouseout", function(d) {
tooltip.style("visibility", "hidden");
});
// 添加节点卡片
node.append("rect")
.attr("class", "card");
// 添加节点标签
node.append("text")
.attr("dy", 20)
.attr("dx", 6)
.text(function(d) { return d.data.name; });
// 添加连线
var link = svg.selectAll(".link")
.data(root.links())
.enter()
.append("path")
.attr("class", "link")
.attr("d", d3.linkHorizontal()
.x(function(d) { return d.y; })
.y(function(d) { return d.x; }));
// 添加提示框
var tooltip = d3.select("body")
.append("div")
.attr("class", "tooltip");
</script>
</body>
</html>

5
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/view.html

@ -103,6 +103,7 @@
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
actions.push('<a class="btn btn-primary btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.id + '\',800,450)"><i class="fa fa-eye"></i>查看</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + bindFlag + '" href="javascript:void(0)" onclick="bind(\'' + row.id + '\',800,450)"><i class="fa fa-eject"></i>绑定</a>');
actions.push('<a class="btn btn-danger btn-xs ' + bindFlag + '" href="javascript:void(0)" onclick="bindNew(\'' + row.id + '\',800,450)"><i class="fa fa-eject"></i>绑定新</a>');
return actions.join('');
}
}]
@ -122,6 +123,10 @@
$.modal.open("", ctx + "project/question/bind/" + id, width, height);
}
function bindNew(id, width, height) {
$.modal.open("", ctx + "project/question/bindNew/" + id, width, height);
}
function reset() {
$("[name='name']").val("");
$("[name='createTime']").val("");

4
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneManageController.java

@ -116,7 +116,7 @@ public class SceneManageController extends BaseController {
}
/**
* 删除
* 导出记录
*/
@PostMapping("/export")
@ApiOperation("导出记录")
@ -125,7 +125,7 @@ public class SceneManageController extends BaseController {
}
/**
* 删除
* 导入记录
*/
@PostMapping("/importData")
@ResponseBody

13
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneQuestionController.java

@ -82,6 +82,19 @@ public class SceneQuestionController extends BaseController {
return prefix + "/bind";
}
@RequiresPermissions("project:question:bind")
@GetMapping("/bindNew/{id}")
public String bindNew(@PathVariable("id") Long id, ModelMap mmap) {
SceneQuestion sceneQuestion = sceneQuestionService.selectSceneQuestionById(id);
List<SceneQuestion> list = sceneQuestionService.selectSceneQuestionList(new SceneQuestion());
if (CollectionUtils.isNotEmpty(list)) {
list = list.stream().filter(item -> !Objects.equals(item.getId(), id)).collect(Collectors.toList());
}
mmap.put("sceneQuestion", sceneQuestion);
mmap.put("list", list);
return prefix + "/bindNew";
}
// /**
// * 导出场景题目列表
// */

7
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/SceneImportDataModel.java

@ -95,4 +95,11 @@ public class SceneImportDataModel {
public void setDescribe(String describe) {
this.describe = describe;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
}

4
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/SceneQuestionMapper.xml

@ -11,12 +11,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="roleId" column="role_id" />
<result property="status" column="status" />
<result property="creator" column="creator" />
<result property="answer" column="answer" />
<result property="nextQuestionId" column="next_question_id" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectSceneQuestionVo">
select id, name, parent_id, role_id, status, creator, create_time, update_time from scene_question
select id, name, parent_id, role_id, status, creator, create_time, answer, next_question_id, update_time from scene_question
</sql>
<select id="selectSceneQuestionList" parameterType="SceneQuestion" resultMap="SceneQuestionResult">

Loading…
Cancel
Save