This commit is contained in:
fit2-zhao 2021-03-17 11:41:44 +08:00
commit 816cb4780c
6 changed files with 83 additions and 65 deletions

View File

@ -49,6 +49,12 @@ public class TestReviewTestCaseController {
testReviewTestCaseService.editTestCaseBatchStatus(request); testReviewTestCaseService.editTestCaseBatchStatus(request);
} }
@PostMapping("/minder/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void editTestCaseForMinder(@RequestBody List<TestCaseReviewTestCase> testCases) {
testReviewTestCaseService.editTestCaseForMinder(testCases);
}
@PostMapping("/list/all") @PostMapping("/list/all")
public List<TestReviewCaseDTO> getTestReviewCases(@RequestBody QueryCaseReviewRequest request) { public List<TestReviewCaseDTO> getTestReviewCases(@RequestBody QueryCaseReviewRequest request) {
return testReviewTestCaseService.list(request); return testReviewTestCaseService.list(request);

View File

@ -163,4 +163,18 @@ public class TestReviewTestCaseService {
MSException.throwException("非此用例的评审人员!"); MSException.throwException("非此用例的评审人员!");
} }
} }
public void editTestCaseForMinder(List<TestCaseReviewTestCase> testCaseReviewTestCases) {
if (!CollectionUtils.isEmpty(testCaseReviewTestCases)) {
List<TestCaseWithBLOBs> testCaseList = new ArrayList<>();
testCaseReviewTestCases.forEach((item) -> {
TestCaseWithBLOBs testCase = new TestCaseWithBLOBs();
testCase.setId(item.getCaseId());
testCase.setReviewStatus(item.getStatus());
testCaseList.add(testCase);
testCaseReviewTestCaseMapper.updateByPrimaryKeySelective(item);
});
testCaseList.forEach(testCaseMapper::updateByPrimaryKeySelective);
}
}
} }

View File

@ -49,7 +49,7 @@
"xml-js": "^1.6.11", "xml-js": "^1.6.11",
"yan-progress": "^1.0.3", "yan-progress": "^1.0.3",
"jsonpath": "^1.1.0", "jsonpath": "^1.1.0",
"vue-minder-editor-plus": "^1.0.16", "vue-minder-editor-plus": "^1.0.17",
"jsencrypt": "^3.1.0" "jsencrypt": "^3.1.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -6,6 +6,7 @@
:import-json="importJson" :import-json="importJson"
:height="700" :height="700"
:progress-enable="false" :progress-enable="false"
:tags="tags"
@save="save" @save="save"
/> />
</div> </div>
@ -28,7 +29,13 @@ export default {
default() { default() {
return new Map(); return new Map();
} }
} },
tags: {
type: Array,
default() {
return []
}
},
}, },
data() { data() {
return { return {

View File

@ -3,6 +3,7 @@
v-loading="result.loading" v-loading="result.loading"
:tree-nodes="treeNodes" :tree-nodes="treeNodes"
:data-map="dataMap" :data-map="dataMap"
:tags="tags"
@save="save" @save="save"
/> />
</template> </template>
@ -17,6 +18,7 @@ name: "TestReviewMinder",
return{ return{
testCase: [], testCase: [],
dataMap: new Map(), dataMap: new Map(),
tags: ['通过', '不通过'],
result: {} result: {}
} }
}, },
@ -44,27 +46,32 @@ name: "TestReviewMinder",
getTestCases() { getTestCases() {
if (this.projectId) { if (this.projectId) {
this.result = this.$post('/test/review/case/list/all', {reviewId: this.reviewId}, response => { this.result = this.$post('/test/review/case/list/all', {reviewId: this.reviewId}, response => {
this.testCase = response.data; this.dataMap = getTestCaseDataMap(response.data, true, (data, item) => {
this.dataMap = getTestCaseDataMap(this.testCase); if (item.reviewStatus === 'Pass') {
data.resource.push("通过");
} else if (item.reviewStatus === 'UnPass') {
data.resource.push("不通过");
} else {
data.resource.push("未开始");
}
data.caseId = item.caseId;
});
}); });
} }
}, },
save(data) { save(data) {
// let saveCases = []; console.log(data);
// this.buildSaveCase(data.root, saveCases, undefined); let saveCases = [];
// console.log(saveCases); this.buildSaveCase(data.root, saveCases);
// let param = { console.log(saveCases);
// projectId: this.projectId, this.result = this.$post('/test/review/case/minder/edit', saveCases, () => {
// data: saveCases this.$success(this.$t('commons.save_success'));
// } });
// this.result = this.$post('/test/case/minder/edit', param, () => {
// this.$success(this.$t('commons.save_success'));
// });
}, },
buildSaveCase(root, saveCases, parent) { buildSaveCase(root, saveCases) {
let data = root.data; let data = root.data;
if (data.resource && data.resource.indexOf("用例") > -1) { if (data.resource && data.resource.indexOf("用例") > -1) {
this._buildSaveCase(root, saveCases, parent); this._buildSaveCase(root, saveCases);
} else { } else {
if (root.children) { if (root.children) {
root.children.forEach((childNode) => { root.children.forEach((childNode) => {
@ -73,51 +80,24 @@ name: "TestReviewMinder",
} }
} }
}, },
_buildSaveCase(node, saveCases, parent) { _buildSaveCase(node, saveCases) {
let data = node.data; let data = node.data;
let isChange = false; if (!data.changed) {
return;
}
let testCase = { let testCase = {
id: data.id, caseId: data.caseId,
name: data.text, id: data.id
nodeId: parent ? parent.id : "", // name: data.text,
nodePath: parent ? parent.path : "",
type: data.type ? data.type : 'functional',
method: data.method ? data.method : 'manual',
maintainer: data.maintainer,
priority: 'P' + data.priority,
}; };
if (data.changed) isChange = true; if (data.resource.length > 1) {
let steps = []; if (data.resource.indexOf('不通过')) {
let stepNum = 1; testCase.status = 'UnPass';
if (node.children) { } else if (data.resource.indexOf('通过')) {
node.children.forEach((childNode) => { testCase.status = 'Pass';
let childData = childNode.data; }
if (childData.resource && childData.resource.indexOf('前置条件') > -1) {
testCase.prerequisite = childData.text;
} else if (childData.resource && childData.resource.indexOf('备注') > -1) {
testCase.remark = childData.text;
} else {
//
let step = {};
step.num = stepNum++;
step.desc = childData.text;
if (childNode.children) {
let result = "";
childNode.children.forEach((child) => {
result += child.data.text;
if (child.data.changed) isChange = true;
})
step.result = result;
}
steps.push(step);
}
if (childData.changed) isChange = true;
})
}
testCase.steps = JSON.stringify(steps);
if (isChange) {
saveCases.push(testCase);
} }
saveCases.push(testCase);
}, },
} }
} }

View File

@ -1,4 +1,4 @@
export function getTestCaseDataMap(testCase) { export function getTestCaseDataMap(testCase, isDisable, setParamCallback) {
let dataMap = new Map(); let dataMap = new Map();
testCase.forEach(item => { testCase.forEach(item => {
item.steps = JSON.parse(item.steps); item.steps = JSON.parse(item.steps);
@ -17,7 +17,15 @@ export function getTestCaseDataMap(testCase) {
maintainer: item.maintainer maintainer: item.maintainer
} }
} }
parseChildren(nodeItem, item); if (setParamCallback) {
setParamCallback(nodeItem.data, item);
}
if (isDisable) {
nodeItem.data.disable = true;
// 用例节点可以打标签
nodeItem.data.allowDisabledTag = true;
}
parseChildren(nodeItem, item, isDisable);
if (mapItem) { if (mapItem) {
mapItem.push(nodeItem); mapItem.push(nodeItem);
} else { } else {
@ -29,23 +37,23 @@ export function getTestCaseDataMap(testCase) {
return dataMap; return dataMap;
} }
function parseChildren(nodeItem, item) { function parseChildren(nodeItem, item, isDisable) {
nodeItem.children = []; nodeItem.children = [];
let children = []; let children = [];
_parseChildren(children, item.prerequisite, "前置条件"); _parseChildren(children, item.prerequisite, "前置条件", isDisable);
item.steps.forEach((step) => { item.steps.forEach((step) => {
let descNode = _parseChildren(children, step.desc, "测试步骤"); let descNode = _parseChildren(children, step.desc, "测试步骤", isDisable);
if (descNode) { if (descNode) {
descNode.data.num = step.num; descNode.data.num = step.num;
descNode.children = []; descNode.children = [];
_parseChildren(descNode.children, step.result, "预期结果"); _parseChildren(descNode.children, step.result, "预期结果", isDisable);
} }
}); });
_parseChildren(children, item.remark, "备注"); _parseChildren(children, item.remark, "备注", isDisable);
nodeItem.children = children; nodeItem.children = children;
} }
function _parseChildren(children, k, v) { function _parseChildren(children, k, v, isDisable) {
if (k) { if (k) {
let node = { let node = {
data: { data: {
@ -53,6 +61,9 @@ function _parseChildren(children, k, v) {
resource: [v] resource: [v]
} }
} }
if (isDisable) {
node.data.disable = true;
}
children.push(node); children.push(node);
return node; return node;
} }