重命名节点更新模块字段
This commit is contained in:
parent
d569ef8582
commit
2b3e148463
|
@ -37,7 +37,7 @@ public class TestCaseNodeController {
|
|||
}
|
||||
|
||||
@PostMapping("/edit")
|
||||
public int editNode(@RequestBody TestCaseNode node){
|
||||
public int editNode(@RequestBody DragNodeRequest node){
|
||||
return testCaseNodeService.editNode(node);
|
||||
}
|
||||
|
||||
|
|
|
@ -115,9 +115,25 @@ public class TestCaseNodeService {
|
|||
return nodeTree;
|
||||
}
|
||||
|
||||
public int editNode(TestCaseNode node) {
|
||||
node.setUpdateTime(System.currentTimeMillis());
|
||||
return testCaseNodeMapper.updateByPrimaryKeySelective(node);
|
||||
public int editNode(DragNodeRequest request) {
|
||||
request.setUpdateTime(System.currentTimeMillis());
|
||||
|
||||
List<TestCaseDTO> testCases = QueryTestCaseByNodeIds(request.getNodeIds());
|
||||
|
||||
testCases.forEach(testCase -> {
|
||||
StringBuilder path = new StringBuilder(testCase.getNodePath());
|
||||
List<String> list = Arrays.asList(path.toString().split("/"));
|
||||
list.set(request.getLevel(), request.getName());
|
||||
path.delete( 0, path.length());
|
||||
for (int i = 1; i < list.size(); i++) {
|
||||
path = path.append("/").append(list.get(i));
|
||||
}
|
||||
testCase.setNodePath(path.toString());
|
||||
});
|
||||
|
||||
batchUpdateTestCase(testCases);
|
||||
|
||||
return testCaseNodeMapper.updateByPrimaryKeySelective(request);
|
||||
}
|
||||
|
||||
public int deleteNode(List<String> nodeIds) {
|
||||
|
@ -357,16 +373,16 @@ public class TestCaseNodeService {
|
|||
|
||||
editNode(request);
|
||||
|
||||
QueryTestCaseRequest testCaseRequest = new QueryTestCaseRequest();
|
||||
testCaseRequest.setNodeIds(request.getNodeIds());
|
||||
|
||||
List<TestCaseDTO> testCases = extTestCaseMapper.list(testCaseRequest);
|
||||
List<TestCaseDTO> testCases = QueryTestCaseByNodeIds(request.getNodeIds());
|
||||
|
||||
TestCaseNodeDTO nodeTree = request.getNodeTree();
|
||||
|
||||
request.getId();
|
||||
buildUpdateTestCase(nodeTree, testCases, "/");
|
||||
|
||||
batchUpdateTestCase(testCases);
|
||||
}
|
||||
|
||||
private void batchUpdateTestCase(List<TestCaseDTO> testCases) {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
TestCaseMapper testCaseMapper = sqlSession.getMapper(TestCaseMapper.class);
|
||||
testCases.forEach((value) -> {
|
||||
|
@ -375,6 +391,12 @@ public class TestCaseNodeService {
|
|||
sqlSession.flushStatements();
|
||||
}
|
||||
|
||||
private List<TestCaseDTO> QueryTestCaseByNodeIds(List<String> nodeIds) {
|
||||
QueryTestCaseRequest testCaseRequest = new QueryTestCaseRequest();
|
||||
testCaseRequest.setNodeIds(nodeIds);
|
||||
return extTestCaseMapper.list(testCaseRequest);
|
||||
}
|
||||
|
||||
private void buildUpdateTestCase(TestCaseNodeDTO rootNode, List<TestCaseDTO> testCases, String rootPath) {
|
||||
|
||||
rootPath = rootPath + rootNode.getName();
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
},
|
||||
type: '',
|
||||
node: {},
|
||||
nodeIds: [],
|
||||
formLabelWidth: '80px',
|
||||
dialogFormVisible: false,
|
||||
}
|
||||
|
@ -59,9 +60,10 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
open(type, data) {
|
||||
open(type, data, nodeIds) {
|
||||
this.type = type;
|
||||
this.node = data;
|
||||
this.nodeIds = nodeIds;
|
||||
this.dialogFormVisible = true;
|
||||
},
|
||||
saveNode() {
|
||||
|
@ -97,6 +99,7 @@
|
|||
url = '/case/node/edit';
|
||||
param.id = this.node.id;
|
||||
param.level = this.node.level;
|
||||
param.nodeIds = this.nodeIds;
|
||||
}
|
||||
param.name = this.form.name.trim();
|
||||
param.label = this.form.name;
|
||||
|
|
|
@ -110,7 +110,7 @@ export default {
|
|||
}
|
||||
}
|
||||
let nodeIds = [];
|
||||
this.getChildNodeId(draggingNode, nodeIds);
|
||||
this.getChildNodeId(draggingNode.data, nodeIds);
|
||||
if (dropNode.level == 1 && dropType != "inner") {
|
||||
param.nodeTree = draggingNode.data;
|
||||
} else {
|
||||
|
@ -123,9 +123,12 @@ export default {
|
|||
}
|
||||
param.nodeIds = nodeIds;
|
||||
this.$post("/case/node/drag", param, () => {
|
||||
this.$emit('refreshTable');
|
||||
this.refreshTable();
|
||||
});
|
||||
},
|
||||
refreshTable() {
|
||||
this.$emit('refreshTable');
|
||||
},
|
||||
findTreeByNodeId(rootNode, nodeId) {
|
||||
if (rootNode.id == nodeId) {
|
||||
return rootNode;
|
||||
|
@ -151,7 +154,7 @@ export default {
|
|||
callback: action => {
|
||||
if (action === "confirm") {
|
||||
let nodeIds = [];
|
||||
this.getChildNodeId(node, nodeIds);
|
||||
this.getChildNodeId(node.data, nodeIds);
|
||||
this.$post("/case/node/delete", nodeIds, () => {
|
||||
const parent = node.parent;
|
||||
const children = parent.data.children || parent.data;
|
||||
|
@ -168,16 +171,18 @@ export default {
|
|||
handleNodeSelect(node) {
|
||||
let nodeIds = [];
|
||||
let pNodes = [];
|
||||
this.getChildNodeId(node, nodeIds);
|
||||
this.getChildNodeId(node.data, nodeIds);
|
||||
this.getParentNodes(node, pNodes);
|
||||
this.$emit("nodeSelectEvent", nodeIds, pNodes);
|
||||
this.$emit("update:selectNode", node);
|
||||
},
|
||||
getChildNodeId(rootNode, nodeIds) {
|
||||
//递归获取所有子节点ID
|
||||
nodeIds.push(rootNode.data.id);
|
||||
for (let i = 0; i < rootNode.childNodes.length; i++) {
|
||||
this.getChildNodeId(rootNode.childNodes[i], nodeIds);
|
||||
nodeIds.push(rootNode.id);
|
||||
if (rootNode.children) {
|
||||
for (let i = 0; i < rootNode.children.length; i++) {
|
||||
this.getChildNodeId(rootNode.children[i], nodeIds);
|
||||
}
|
||||
}
|
||||
},
|
||||
getParentNodes(rootNode, pNodes) {
|
||||
|
@ -193,7 +198,11 @@ export default {
|
|||
return data.label.indexOf(value) !== -1;
|
||||
},
|
||||
openEditNodeDialog(type, data) {
|
||||
this.$refs.nodeEdit.open(type, data);
|
||||
let nodeIds = [];
|
||||
if (type == 'edit') {
|
||||
this.getChildNodeId(data, nodeIds);
|
||||
}
|
||||
this.$refs.nodeEdit.open(type, data, nodeIds);
|
||||
},
|
||||
refreshNode() {
|
||||
this.$emit("refresh");
|
||||
|
|
Loading…
Reference in New Issue