From 6d2d338e74938214a7ebab5a48a965b7acb0ecf5 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Fri, 18 Feb 2022 11:58:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=A8=E4=BE=8B=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC=E5=AF=B9=E8=84=91=E5=9B=BE=E4=B8=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?=20--bug=3D1010305=20--user=3D=E9=99=88=E5=BB=BA=E6=98=9F=20?= =?UTF-8?q?=E3=80=90=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E3=80=91=20#10607?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AD=97=E6=AE=B5=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E9=BB=98=E8=AE=A4=E6=94=B9=E4=B8=BAP2?= =?UTF-8?q?=EF=BC=8C=E8=84=91=E5=9B=BE=E7=BC=96=E8=BE=91=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E4=BF=9D=E5=AD=98=E4=B8=8D=E7=94=9F=E6=95=88[BUG]=20h?= =?UTF-8?q?ttps://www.tapd.cn/55049933/s/1105527?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/TestCaseTemplateService.java | 20 ++++--------------- .../track/service/TestCaseService.java | 4 +++- .../track/case/components/TestCaseList.vue | 14 +++++++++++++ .../track/common/minder/TestCaseMinder.vue | 14 ++++++++++--- frontend/src/store/index.js | 3 ++- frontend/src/store/mutations.js | 1 + 6 files changed, 35 insertions(+), 21 deletions(-) diff --git a/backend/src/main/java/io/metersphere/service/TestCaseTemplateService.java b/backend/src/main/java/io/metersphere/service/TestCaseTemplateService.java index 497fdfdaaa..d5d633cd7d 100644 --- a/backend/src/main/java/io/metersphere/service/TestCaseTemplateService.java +++ b/backend/src/main/java/io/metersphere/service/TestCaseTemplateService.java @@ -184,23 +184,11 @@ public class TestCaseTemplateService extends TemplateBaseService { } public Map> getCaseLevelAndStatusMapByProjectId(String projectId){ - Project project = projectService.getProjectById(projectId); - String caseTemplateId = project.getCaseTemplateId(); - TestCaseTemplateWithBLOBs caseTemplate = null; - TestCaseTemplateDao caseTemplateDao = new TestCaseTemplateDao(); - if (StringUtils.isNotBlank(caseTemplateId)) { - caseTemplate = testCaseTemplateMapper.selectByPrimaryKey(caseTemplateId); - if (caseTemplate == null) { - caseTemplate = getDefaultTemplate(project.getWorkspaceId()); - } - } else { - caseTemplate = getDefaultTemplate(project.getWorkspaceId()); - } - BeanUtils.copyBean(caseTemplateDao, caseTemplate); - List result = customFieldService.getCustomFieldByTemplateId(caseTemplate.getId()); + TestCaseTemplateDao template = getTemplate(projectId); + List result = template.getCustomFields(); Map> returnMap = new HashMap<>(); - for (CustomFieldDao field:result) { + for (CustomFieldDao field : result) { if(StringUtils.equalsAnyIgnoreCase(field.getScene(),"TEST_CASE")){ if(StringUtils.equalsAnyIgnoreCase(field.getName(),"用例等级")){ try { @@ -231,7 +219,7 @@ public class TestCaseTemplateService extends TemplateBaseService { public TestCaseTemplateDao getTemplate(String projectId) { Project project = projectService.getProjectById(projectId); String caseTemplateId = project.getCaseTemplateId(); - TestCaseTemplateWithBLOBs caseTemplate = null; + TestCaseTemplateWithBLOBs caseTemplate; TestCaseTemplateDao caseTemplateDao = new TestCaseTemplateDao(); if (StringUtils.isNotBlank(caseTemplateId)) { caseTemplate = testCaseTemplateMapper.selectByPrimaryKey(caseTemplateId); diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index c95b1a7b06..c7da62d66c 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -1851,7 +1851,9 @@ public class TestCaseService { editTestCase(editRequest); changeOrder(item, request.getProjectId()); } else { - item.setMaintainer(SessionUtils.getUserId()); + if (StringUtils.isBlank(item.getMaintainer())) { + item.setMaintainer(SessionUtils.getUserId()); + } EditTestCaseRequest editTestCaseRequest = new EditTestCaseRequest(); BeanUtils.copyBean(editTestCaseRequest, item); addTestCase(editTestCaseRequest); diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index 6ebda9da19..3948286ae1 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -621,6 +621,7 @@ export default { this.page.result.loading = true; this.testCaseTemplate = template; this.fields = getTableHeaderWithCustomFields('TRACK_TEST_CASE', this.testCaseTemplate.customFields); + this.setTestCaseDefaultValue(template); this.page.result.loading = false; if (this.$refs.table) { this.$refs.table.reloadTable(); @@ -629,6 +630,19 @@ export default { getCustomFieldBatchEditOption(template.customFields, this.typeArr, this.valueArr, this.members); }); }, + setTestCaseDefaultValue(template) { + let testCaseDefaultValue = {}; + template.customFields.forEach(item => { + if (item.system) { + if (item.defaultValue) { + testCaseDefaultValue[item.name] = JSON.parse(item.defaultValue); + } else { + testCaseDefaultValue[item.name] = ""; + } + } + }); + this.$store.commit('setTestCaseDefaultValue', testCaseDefaultValue); + }, getCustomFieldValue(row, field) { let value = getCustomFieldValue(row, field, this.members); if (!value) { diff --git a/frontend/src/business/components/track/common/minder/TestCaseMinder.vue b/frontend/src/business/components/track/common/minder/TestCaseMinder.vue index 287f7773d0..2a96f739b5 100644 --- a/frontend/src/business/components/track/common/minder/TestCaseMinder.vue +++ b/frontend/src/business/components/track/common/minder/TestCaseMinder.vue @@ -98,6 +98,9 @@ name: "TestCaseMinder", moduleOptions() { return this.$store.state.testCaseModuleOptions; }, + testCaseDefaultValue() { + return this.$store.state.testCaseDefaultValue; + }, disabled() { return !hasPermission('PROJECT_TRACK_CASE:READ+EDIT'); }, @@ -129,7 +132,7 @@ name: "TestCaseMinder", methods: { handleAfterMount() { listenNodeSelected(() => { - // 展开模块下的用例 + // 点击模块,加载模块下的用例 loadSelectNodes(this.getParam(), getTestCasesForMinder, null, getMinderExtraNode); }); @@ -338,6 +341,10 @@ name: "TestCaseMinder", let isChange = false; let nodeId = parent ? (parent.newId ? parent.newId : parent.id) : ""; + let priorityDefaultValue = (data.priority ? 'P' + data.priority - 1 : + (this.testCaseDefaultValue['用例等级'] ? this.testCaseDefaultValue['用例等级'] : 'P' + 0) + ); + let testCase = { id: data.id, name: data.text, @@ -345,12 +352,13 @@ name: "TestCaseMinder", nodePath: getNodePath(nodeId, this.moduleOptions), type: data.type ? data.type : 'functional', method: data.method ? data.method: 'manual', - maintainer: data.maintainer, - priority: 'P' + (data.priority ? data.priority - 1 : 0), + maintainer: this.testCaseDefaultValue['责任人'] ? this.testCaseDefaultValue['责任人'] : data.maintainer, + priority: priorityDefaultValue, prerequisite: "", remark: "", stepDescription: "", expectedResult: "", + status: this.testCaseDefaultValue['用例状态'], steps: "[]" }; if (data.changed) isChange = true; diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index acfb9158d0..aaec873439 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -33,7 +33,8 @@ const state = { apiMap: new Map(), apiStatus: new Map(), testCaseMap: new Map(), - curTabId: null + curTabId: null, + testCaseDefaultValue: {} } const store = new Vuex.Store({ diff --git a/frontend/src/store/mutations.js b/frontend/src/store/mutations.js index 5d439b569c..14cd00afc4 100644 --- a/frontend/src/store/mutations.js +++ b/frontend/src/store/mutations.js @@ -18,6 +18,7 @@ const mutations = { setCurrentProjectIsCustomNum: (state, value) => state.currentProjectIsCustomNum = value, setTestCaseTemplate: (state, value) => state.testCaseTemplate = value, setCurTabId: (state, value) => state.curTabId = value, + setTestCaseDefaultValue: (state, value) => state.testCaseDefaultValue = value, } export default mutations;