fix:编辑用例后新建用例无法保存
This commit is contained in:
parent
4ff1edd870
commit
b6e3a71176
|
@ -966,9 +966,7 @@ public class TestCaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String save(EditTestCaseRequest request, List<MultipartFile> files) {
|
public String save(EditTestCaseRequest request, List<MultipartFile> files) {
|
||||||
if (files == null) {
|
|
||||||
throw new IllegalArgumentException(Translator.get("file_cannot_be_null"));
|
|
||||||
}
|
|
||||||
|
|
||||||
final TestCaseWithBLOBs testCaseWithBLOBs = addTestCase(request);
|
final TestCaseWithBLOBs testCaseWithBLOBs = addTestCase(request);
|
||||||
//插入测试与用例关系表
|
//插入测试与用例关系表
|
||||||
|
@ -996,14 +994,16 @@ public class TestCaseService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (files != null) {
|
||||||
|
files.forEach(file -> {
|
||||||
|
final FileMetadata fileMetadata = fileService.saveFile(file, testCaseWithBLOBs.getProjectId());
|
||||||
|
TestCaseFile testCaseFile = new TestCaseFile();
|
||||||
|
testCaseFile.setCaseId(testCaseWithBLOBs.getId());
|
||||||
|
testCaseFile.setFileId(fileMetadata.getId());
|
||||||
|
testCaseFileMapper.insert(testCaseFile);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
files.forEach(file -> {
|
|
||||||
final FileMetadata fileMetadata = fileService.saveFile(file, testCaseWithBLOBs.getProjectId());
|
|
||||||
TestCaseFile testCaseFile = new TestCaseFile();
|
|
||||||
testCaseFile.setCaseId(testCaseWithBLOBs.getId());
|
|
||||||
testCaseFile.setFileId(fileMetadata.getId());
|
|
||||||
testCaseFileMapper.insert(testCaseFile);
|
|
||||||
});
|
|
||||||
return testCaseWithBLOBs.getId();
|
return testCaseWithBLOBs.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<!--操作按钮-->
|
<!--操作按钮-->
|
||||||
<div class="ms-opt-btn">
|
<div class="ms-opt-btn">
|
||||||
<el-link type="primary" style="margin-right: 20px" @click="openHis" v-if="form.id">{{$t('operating_log.change_history')}}</el-link>
|
<el-link type="primary" style="margin-right: 20px" @click="openHis" v-if="form.id">{{$t('operating_log.change_history')}}</el-link>
|
||||||
<ms-table-button v-if="type!='add'"
|
<ms-table-button v-if="this.path!='/test/case/add'"
|
||||||
id="inputDelay"
|
id="inputDelay"
|
||||||
type="primary"
|
type="primary"
|
||||||
:content="$t('commons.save')"
|
:content="$t('commons.save')"
|
||||||
|
@ -173,6 +173,7 @@
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
path: "/test/case/add",
|
||||||
testCaseTemplate: {},
|
testCaseTemplate: {},
|
||||||
// sysList: [],//一级选择框的数据
|
// sysList: [],//一级选择框的数据
|
||||||
options: REVIEW_STATUS,
|
options: REVIEW_STATUS,
|
||||||
|
@ -501,17 +502,33 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getTestCase(index) {
|
getTestCase(index) {
|
||||||
|
let id = "";
|
||||||
this.showInputTag = false;
|
this.showInputTag = false;
|
||||||
let testCase = this.testCases[index];
|
let testCase = this.testCases[index];
|
||||||
this.result = this.$get('/test/case/get/' + testCase.id, response => {
|
if (typeof (index) == "undefined") {
|
||||||
|
id = this.currentTestCaseInfo.id;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
id = testCase.id;
|
||||||
|
}
|
||||||
|
this.result = this.$get('/test/case/get/' + id, response => {
|
||||||
|
if (response.data) {
|
||||||
|
this.path = "/test/case/edit";
|
||||||
|
if (this.currentTestCaseInfo.isCopy) {
|
||||||
|
this.path = "/test/case/add";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.path = "/test/case/add";
|
||||||
|
}
|
||||||
let testCase = response.data;
|
let testCase = response.data;
|
||||||
this.setFormData(testCase);
|
this.setFormData(testCase);
|
||||||
this.setTestCaseExtInfo(testCase);
|
this.setTestCaseExtInfo(testCase);
|
||||||
this.getSelectOptions();
|
this.getSelectOptions();
|
||||||
this.reload();
|
this.reload();
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.showInputTag = true
|
this.showInputTag = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async setFormData(testCase) {
|
async setFormData(testCase) {
|
||||||
|
@ -578,12 +595,14 @@
|
||||||
let option = this.getOption(param);
|
let option = this.getOption(param);
|
||||||
this.result = this.$request(option, (response) => {
|
this.result = this.$request(option, (response) => {
|
||||||
this.$success(this.$t('commons.save_success'));
|
this.$success(this.$t('commons.save_success'));
|
||||||
this.operationType = "edit"
|
this.path = "/test/case/edit";
|
||||||
|
// this.operationType = "edit"
|
||||||
this.form.id = response.id;
|
this.form.id = response.id;
|
||||||
this.$emit("refreshTestCase",)
|
this.$emit("refreshTestCase",);
|
||||||
this.tableType = 'edit';
|
//this.tableType = 'edit';
|
||||||
this.$emit("refresh", this.form);
|
this.$emit("refresh", this.form);
|
||||||
this.form.id = response.data
|
this.form.id = response.data;
|
||||||
|
|
||||||
if (this.type === 'add' || this.type === 'copy') {
|
if (this.type === 'add' || this.type === 'copy') {
|
||||||
param.id = response.data;
|
param.id = response.data;
|
||||||
this.$emit("caseCreate", param);
|
this.$emit("caseCreate", param);
|
||||||
|
@ -599,15 +618,16 @@
|
||||||
buildParam() {
|
buildParam() {
|
||||||
let param = {};
|
let param = {};
|
||||||
Object.assign(param, this.form);
|
Object.assign(param, this.form);
|
||||||
|
console.log(param);
|
||||||
param.steps = JSON.stringify(this.form.steps);
|
param.steps = JSON.stringify(this.form.steps);
|
||||||
param.nodeId = this.form.module;
|
param.nodeId = this.form.module;
|
||||||
param.nodePath = getNodePath(this.form.module, this.moduleOptions);
|
param.nodePath = getNodePath(this.form.module, this.moduleOptions);
|
||||||
if (this.projectId) {
|
if (this.projectId) {
|
||||||
param.projectId = this.projectId;
|
param.projectId = this.projectId;
|
||||||
}
|
}
|
||||||
if (this.type === 'copy') {
|
/* if (this.type === 'copy') {
|
||||||
param.num = "";
|
param.num = "";
|
||||||
}
|
}*/
|
||||||
param.name = param.name.trim();
|
param.name = param.name.trim();
|
||||||
|
|
||||||
if (this.form.tags instanceof Array) {
|
if (this.form.tags instanceof Array) {
|
||||||
|
@ -638,17 +658,17 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getOption(param) {
|
getOption(param) {
|
||||||
let type = {}
|
/* let type = {}
|
||||||
if (this.tableType === 'edit') {
|
if (this.tableType === 'edit') {
|
||||||
type = 'edit'
|
type = 'edit'
|
||||||
} else if (this.type === 'copy') {
|
} else if (this.type === 'copy') {
|
||||||
type = 'add'
|
type = 'add'
|
||||||
} else {
|
} else {
|
||||||
type = this.type
|
type = this.type
|
||||||
}
|
}*/
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
let url = '/test/case/' + type;
|
//let url = '/test/case/' + type;
|
||||||
|
console.log(this.$refs.otherInfo);
|
||||||
if (this.$refs.otherInfo && this.$refs.otherInfo.uploadList) {
|
if (this.$refs.otherInfo && this.$refs.otherInfo.uploadList) {
|
||||||
this.$refs.otherInfo.uploadList.forEach(f => {
|
this.$refs.otherInfo.uploadList.forEach(f => {
|
||||||
formData.append("file", f);
|
formData.append("file", f);
|
||||||
|
@ -673,10 +693,9 @@
|
||||||
formData.append('request', new Blob([requestJson], {
|
formData.append('request', new Blob([requestJson], {
|
||||||
type: "application/json"
|
type: "application/json"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: url,
|
url: this.path,
|
||||||
data: formData,
|
data: formData,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': undefined
|
'Content-Type': undefined
|
||||||
|
|
Loading…
Reference in New Issue