From e9e2f1e5ce906d8e4d40eef2a5db40394641ccda Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Tue, 22 Aug 2023 11:37:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=85=A8?= =?UTF-8?q?=E9=80=89UI=E7=94=A8=E4=BE=8B=E7=8E=AF=E5=A2=83=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=A2=E5=A4=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1029146 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001029146 --- .../comonents/ui/RelevanceUiScenarioList.vue | 43 +++++++++++++++---- .../ui/TestCaseUiScenarioRelevance.vue | 29 +++++-------- 2 files changed, 44 insertions(+), 28 deletions(-) diff --git a/test-track/frontend/src/business/plan/view/comonents/ui/RelevanceUiScenarioList.vue b/test-track/frontend/src/business/plan/view/comonents/ui/RelevanceUiScenarioList.vue index a6d988a810..a6e2515c81 100644 --- a/test-track/frontend/src/business/plan/view/comonents/ui/RelevanceUiScenarioList.vue +++ b/test-track/frontend/src/business/plan/view/comonents/ui/RelevanceUiScenarioList.vue @@ -125,7 +125,10 @@ import {TEST_PLAN_RELEVANCE_UI_SCENARIO_CONFIGS} from "metersphere-frontend/src/ import {ENV_TYPE} from "metersphere-frontend/src/utils/constants"; import MsTable from "metersphere-frontend/src/components/table/MsTable"; import {getOwnerProjects, getVersionFilters} from "@/business/utils/sdk-utils"; -import {testPlanUiScenarioRelevanceList} from "@/api/remote/ui/test-plan-ui-scenario-case"; +import { + testPlanUiScenarioRelevanceList, + testPlanUiScenarioRelevanceListIds +} from "@/api/remote/ui/test-plan-ui-scenario-case"; import {getCustomTableWidth} from "metersphere-frontend/src/utils/tableUtils"; import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn"; import EnvGroupPopover from "@/business/plan/env/EnvGroupPopover"; @@ -165,6 +168,7 @@ export default { currentScenario: {}, schedule: {}, selectAll: false, + selectAllIds: [], tableData: [], currentPage: 1, pageSize: 10, @@ -290,25 +294,46 @@ export default { }, selectCountChange(data) { this.selectRows = this.$refs.scenarioTable.selectRows; + this.selectAll = this.$refs.scenarioTable.showSelectAll; this.$emit("selectCountChange", data); this.initProjectIds(); }, showReport() { }, - initProjectIds() { + async initProjectIds() { this.projectIds.clear(); this.map.clear(); - this.selectRows.forEach((row) => { - getUiScenarioEnvByProjectId(row.id).then((res) => { - let data = res.data; - data.projectIds.forEach((d) => this.projectIds.add(d)); - this.map.set(row.id, data.projectIds); + if (!this.selectAll) { + this.selectRows.forEach((row) => { + getUiScenarioEnvByProjectId(row.id).then((res) => { + let data = res.data; + data.projectIds.forEach((d) => this.projectIds.add(d)); + this.map.set(row.id, data.projectIds); + }); + }); + } else { + this.selectAllIds = await this.getAllId(this.condition); + this.selectAllIds.forEach((row) => { + getUiScenarioEnvByProjectId(row).then((res) => { + let data = res.data; + data.projectIds.forEach((d) => this.projectIds.add(d)); + this.map.set(row, data.projectIds); + }); + }); + } + }, + getAllId(param) { + return new Promise((resolve) => { + testPlanUiScenarioRelevanceListIds(param).then((r) => { + resolve(r.data); }); }); }, - closeEnv(){ - this.$refs.envPopover.close(); + closeEnv() { + if (this.$refs.envPopover) { + this.$refs.envPopover.close(); + } } } }; diff --git a/test-track/frontend/src/business/plan/view/comonents/ui/TestCaseUiScenarioRelevance.vue b/test-track/frontend/src/business/plan/view/comonents/ui/TestCaseUiScenarioRelevance.vue index dfb9056922..f033b527e3 100644 --- a/test-track/frontend/src/business/plan/view/comonents/ui/TestCaseUiScenarioRelevance.vue +++ b/test-track/frontend/src/business/plan/view/comonents/ui/TestCaseUiScenarioRelevance.vue @@ -38,7 +38,6 @@ import {strMapToObj} from "metersphere-frontend/src/utils"; import {ENV_TYPE} from "metersphere-frontend/src/utils/constants"; import RelevanceUiScenarioList from "@/business/plan/view/comonents/ui/RelevanceUiScenarioList"; import {testPlanAutoCheck} from "@/api/remote/plan/test-plan"; -import {testPlanUiScenarioRelevanceListIds} from "@/api/remote/ui/test-plan-ui-scenario-case"; import UiScenarioModule from "@/business/plan/view/comonents/ui/UiScenarioModule"; import {uiAutomationRelevance} from "@/api/remote/ui/api-scenario"; @@ -139,14 +138,8 @@ export default { this.$refs.baseRelevance.close(); }); }, - getAllId(param) { - return new Promise((resolve) => { - testPlanUiScenarioRelevanceListIds(param).then((r) => { - resolve(r.data); - }); - }); - }, - async saveCaseRelevance() { + + saveCaseRelevance() { this.isSaving = true; let selectIds = []; let selectRows = this.$refs.apiScenarioList.selectRows; @@ -154,9 +147,14 @@ export default { let map = this.$refs.apiScenarioList.map; let envGroupId = this.$refs.apiScenarioList.envGroupId; - selectRows.forEach((row) => { - selectIds.push(row.id); - }); + if (!this.$refs.apiScenarioList.selectAll) { + selectRows.forEach((row) => { + selectIds.push(row.id); + }); + } else { + selectIds = this.$refs.apiScenarioList.selectAllIds; + } + if (selectIds.length < 1) { this.isSaving = false; this.$warning(this.$t("test_track.plan_view.please_choose_test_case")); @@ -169,13 +167,6 @@ export default { param.envMap = strMapToObj(envMap); param.envGroupId = envGroupId; param.selectIds = selectIds; - - //查找所有数据 - let params = this.$refs.apiScenarioList.condition; - if (params.selectAll) { - let result = await this.getAllId(params); - param.selectIds = result; - } this.loading = true; uiAutomationRelevance(param) .then(() => {