From bd911136d8867139fcc72f3a34c80571d09e8e4a Mon Sep 17 00:00:00 2001 From: wenyann Date: Thu, 8 Apr 2021 11:43:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92?= =?UTF-8?q?=EF=BC=8C=E5=85=B3=E8=81=94=E6=B5=8B=E8=AF=95=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E9=97=AE=E9=A2=98,=E6=96=B0=E5=BB=BA=E7=94=A8=E4=BE=8B-?= =?UTF-8?q?=E7=BC=96=E8=BE=91=EF=BC=8C=E6=97=A0=E6=B3=95=E7=BB=99=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E6=AD=A5=E9=AA=A4?= =?UTF-8?q?,=E6=89=A7=E8=A1=8C=E7=94=A8=E4=BE=8B=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=EF=BC=8C=E5=BA=94=E5=85=81=E8=AE=B8=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=A4=87=E6=B3=A8=E5=92=8C=E9=99=84=E4=BB=B6,=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/definition/ApiDefinition.vue | 4 + .../functional/FunctionalTestCaseEdit.vue | 167 +++++++++++++++--- 2 files changed, 149 insertions(+), 22 deletions(-) diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index 9f1fcbda0d..9842ccc0d5 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -221,6 +221,10 @@ } }, created() { + let dataRange = this.$route.params.dataSelectRange; + if (dataRange.length > 0) { + this.activeDom = 'middle'; + } if (this.activeDom === 'left') { getLabel(this, API_LIST); } else if (this.activeDom === 'right') { diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseEdit.vue b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseEdit.vue index 8c318cd2cd..62861f34c4 100644 --- a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseEdit.vue +++ b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseEdit.vue @@ -291,31 +291,46 @@ - + + + {{ $t('commons.remark') }}:
- {{ $t('commons.remark') }}: - {{ $t('commons.not_filled') }} -
-
- + :rows="3" + :placeholder="$t('commons.input_content')">
- - -
- {{ $t('test_track.case.attachment') }}: -
+ + {{ $t('test_track.case.attachment') }}: + + + {{ $t('test_track.case.upload_tip') }} + + +
+ +
@@ -327,7 +342,16 @@
- + + + + + @@ -353,10 +377,12 @@ import {getUUID, listenGoBack, removeGoBackListener} from "@/common/js/utils"; import TestCaseAttachment from "@/business/components/track/case/components/TestCaseAttachment"; import CaseComment from "@/business/components/track/case/components/CaseComment"; import MsPreviousNextButton from "../../../../../common/components/MsPreviousNextButton"; +import ReviewComment from "@/business/components/track/review/commom/ReviewComment"; export default { name: "FunctionalTestCaseEdit", components: { + ReviewComment, MsPreviousNextButton, CaseComment, PerformanceTestResult, @@ -391,6 +417,9 @@ export default { hasTapdId: false, hasZentaoId: false, tableData: [], + fileList: [], + uploadList: [], + comments: [], }; }, props: { @@ -405,7 +434,55 @@ export default { default: false } }, + computed: { + projectId() { + return this.$store.state.projectId; + }, + }, methods: { + getComments(testCase) { + let id = ''; + if (testCase) { + id = testCase.caseId; + } else { + id = this.testCase.caseId; + } + this.result = this.$get('/test/case/comment/list/' + id, res => { + this.comments = res.data; + }) + }, + fileValidator(file) { + /// todo: 是否需要对文件内容和大小做限制 + return file.size > 0; + }, + handleExceed() { + this.$error(this.$t('load_test.file_size_limit')); + }, + beforeUpload(file) { + if (!this.fileValidator(file)) { + /// todo: 显示错误信息 + return false; + } + + if (this.tableData.filter(f => f.name === file.name).length > 0) { + this.$error(this.$t('load_test.delete_file') + ', name: ' + file.name); + return false; + } + + let type = file.name.substring(file.name.lastIndexOf(".") + 1); + + this.tableData.push({ + name: file.name, + size: file.size + ' Bytes', /// todo: 按照大小显示Byte、KB、MB等 + type: type.toUpperCase(), + updateTime: new Date().getTime(), + }); + + return true; + }, + handleUpload(uploadResources) { + this.uploadList.push(uploadResources.file); + }, handleClose() { removeGoBackListener(this.handleClose); this.showDialog = false; @@ -420,12 +497,38 @@ export default { this.testCase.status = status; this.saveCase(); }, + getOption(param) { + let formData = new FormData(); + let url = '/test/case/edit/testPlan'; + this.uploadList.forEach(f => { + formData.append("file", f); + }); + param.updatedFileList = this.fileList; + let requestJson = JSON.stringify(param, function (key, value) { + return key === "file" ? undefined : value; + }); + + formData.append('request', new Blob([requestJson], { + type: "application/json "; + })); + + return { + method: 'POST', + url: url, + data: formData, + headers: { + 'Content-Type': undefined; + } + }; + }, saveCase() { let param = {}; param.id = this.testCase.id; param.status = this.testCase.status; param.results = []; - + param.remark = this.testCase.remark; + param.projectId = this.projectId; + let option = this.getOption(param); for (let i = 0; i < this.testCase.steptResults.length; i++) { let result = {}; result.actualResult = this.testCase.steptResults[i].actualResult; @@ -437,9 +540,11 @@ export default { } param.results.push(result); } - param.results = JSON.stringify(param.results); this.$post('/test/plan/case/edit', param, () => { + this.$request(option, (response) => { + + }); this.$success(this.$t('commons.save_success')); this.updateTestCases(param); this.setPlanStatus(this.testCase.planId); @@ -495,15 +600,18 @@ export default { this.getIssues(item.caseId); this.stepResultChange(); this.getFileMetaData(item); + this.getComments(item); }) }, getFileMetaData(testCase) { + this.fileList = []; this.tableData = []; this.result = this.$get("test/case/file/metadata/" + testCase.caseId, response => { let files = response.data; if (!files) { return; } + this.fileList = JSON.parse(JSON.stringify(files)); this.tableData = JSON.parse(JSON.stringify(files)); this.tableData.map(f => { f.size = f.size + ' Bytes'; @@ -699,9 +807,24 @@ export default { this.$success(this.$t('commons.delete_success')); }) }, - handleDelete() { - - } + handleDelete(file, index) { + this.$alert(this.$t('load_test.delete_file_confirm') + file.name + "?", '', { + confirmButtonText: this.$t('commons.confirm'), + callback: (action) => { + if (action === 'confirm') { + this._handleDelete(file, index); + } + } + }); + }, + _handleDelete(file, index) { + this.fileList.splice(index, 1); + this.tableData.splice(index, 1); + let i = this.uploadList.findIndex(upLoadFile => upLoadFile.name === file.name); + if (i > -1) { + this.uploadList.splice(i, 1); + } + }, } }