fix: 版本管理列表相关bug

This commit is contained in:
zhangdahai112 2022-01-23 22:47:24 +08:00 committed by jianxing
parent e84b0e98ac
commit 8c8940c994
9 changed files with 129 additions and 28 deletions

View File

@ -27,6 +27,8 @@ public class TestPlanScenarioRequest {
private Map<String, Object> combine; private Map<String, Object> combine;
private List<String> ids; private List<String> ids;
private String reviewId; private String reviewId;
private String versionId;
private String refId;
/** /**
* 是否选中所有数据 * 是否选中所有数据

View File

@ -24,20 +24,48 @@
</select> </select>
<select id="list" resultType="io.metersphere.api.dto.automation.ApiScenarioDTO"> <select id="list" resultType="io.metersphere.api.dto.automation.ApiScenarioDTO">
select SELECT
t.id, t.environment, t.create_time, t.update_time, t.last_result, t.pass_rate, t.report_id, c.scenario_definition, t.id,
c.id as case_id, c.user_id,c.api_scenario_module_id, c.module_path, c.name, c.level, t.environment,
c.status, c.principal, c.step_total, c.schedule, c.description, c.tags, t.create_user, c.project_id, t.create_time,
c.num, c.custom_num, t.environment_group_id, t.environment_type t.update_time,
from t.last_result,
test_plan_api_scenario t t.pass_rate,
inner join t.report_id,
api_scenario c c.scenario_definition,
on t.api_scenario_id = c.id and c.status != 'Trash' c.id AS case_id,
<if test="request.planId != null and request.planId!=''"> c.user_id,
and t.test_plan_id = #{request.planId} c.api_scenario_module_id,
</if> c.module_path,
where 1 c. NAME,
c. LEVEL,
c. STATUS,
c.principal,
c.step_total,
c. SCHEDULE,
c.description,
c.tags,
t.create_user,
c.project_id,
c.num,
c.custom_num,
t.environment_group_id,
t.environment_type,
project_version. NAME versionName,
project_version.id versionId
FROM
test_plan_api_scenario t
INNER JOIN api_scenario c ON t.api_scenario_id = c.id
INNER JOIN project_version ON c.project_id = project_version.project_id
AND c.version_id = project_version.id
AND c. STATUS != 'Trash'
<if test="request.planId != null and request.planId!=''">
and t.test_plan_id = #{request.planId}
</if>
WHERE 1
<include refid="queryVersionCondition">
<property name="versionTable" value="c"/>
</include>
<if test="request.scenarioIds != null and request.scenarioIds.size() > 0"> <if test="request.scenarioIds != null and request.scenarioIds.size() > 0">
and c.id in and c.id in
@ -72,7 +100,7 @@
</foreach> </foreach>
</if> </if>
<include refid="filers"/> <include refid="filters"/>
<if test="request.orders != null and request.orders.size() > 0"> <if test="request.orders != null and request.orders.size() > 0">
order by order by
<foreach collection="request.orders" separator="," item="order"> <foreach collection="request.orders" separator="," item="order">
@ -132,7 +160,7 @@
#{nodeId} #{nodeId}
</foreach> </foreach>
</if> </if>
<include refid="filers"/> <include refid="filters"/>
<if test="request.orders != null and request.orders.size() > 0"> <if test="request.orders != null and request.orders.size() > 0">
order by order by
<foreach collection="request.orders" separator="," item="order"> <foreach collection="request.orders" separator="," item="order">
@ -148,7 +176,7 @@
</if> </if>
</select> </select>
<sql id="filers"> <sql id="filters">
<if test="request.filters != null and request.filters.size() > 0"> <if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values"> <foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0"> <if test="values != null and values.size() > 0">
@ -165,6 +193,12 @@
#{value} #{value}
</foreach> </foreach>
</when> </when>
<when test="key == 'version_id'">
and c.version_id in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose> </choose>
</if> </if>
</foreach> </foreach>
@ -275,4 +309,16 @@
</if> </if>
order by `order` desc limit 1; order by `order` desc limit 1;
</select> </select>
<sql id="queryVersionCondition">
<if test="request.versionId != null">
and ${versionTable}.version_id = #{request.versionId}
</if>
<if test="request.refId != null">
and ${versionTable}.ref_id = #{request.refId}
</if>
<if test="request.versionId == null and request.refId == null and request.id == null">
AND ${versionTable}.latest = 1
</if>
</sql>
</mapper> </mapper>

View File

@ -24,7 +24,7 @@ export default {
data: {} data: {}
} }
}, },
props: ['title','tip'], props: ['title','tip', 'versionEnable'],
methods: { methods: {
open(item) { open(item) {
this.visible = true; this.visible = true;

View File

@ -4,6 +4,8 @@
<template v-slot:header> <template v-slot:header>
<test-plan-scenario-list-header <test-plan-scenario-list-header
:condition="condition" :condition="condition"
:projectId="projectId"
@changeVersion="changeVersion"
@refresh="search" @refresh="search"
@relevanceCase="$emit('relevanceCase', 'scenario')"/> @relevanceCase="$emit('relevanceCase', 'scenario')"/>
</template> </template>
@ -40,6 +42,18 @@
:label="$t('api_test.automation.scenario_name')" min-width="120px" :label="$t('api_test.automation.scenario_name')" min-width="120px"
sortable/> sortable/>
<ms-table-column
:field="item"
v-if="versionEnable"
prop="versionId"
:filters="versionFilters"
:label="$t('commons.version')"
min-width="120px">
<template v-slot:default="scope">
<span>{{ scope.row.versionName }}</span>
</template>
</ms-table-column>
<ms-table-column :field="item" <ms-table-column :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
prop="level" :label="$t('api_test.automation.case_level')" min-width="120px" prop="level" :label="$t('api_test.automation.case_level')" min-width="120px"
@ -177,7 +191,7 @@
import MsTableHeader from "@/business/components/common/components/MsTableHeader"; import MsTableHeader from "@/business/components/common/components/MsTableHeader";
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import MsTag from "../../../../../common/components/MsTag"; import MsTag from "../../../../../common/components/MsTag";
import {getCurrentProjectID, getUUID, strMapToObj} from "@/common/js/utils"; import {getCurrentProjectID, getUUID, hasLicense, strMapToObj} from "@/common/js/utils";
import MsApiReportDetail from "../../../../../api/automation/report/ApiReportDetail"; import MsApiReportDetail from "../../../../../api/automation/report/ApiReportDetail";
import MsTableMoreBtn from "../../../../../api/automation/scenario/TableMoreBtn"; import MsTableMoreBtn from "../../../../../api/automation/scenario/TableMoreBtn";
import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns"; import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns";
@ -229,7 +243,8 @@ export default {
selectNodeIds: Array, selectNodeIds: Array,
reviewId: String, reviewId: String,
planId: String, planId: String,
clickType: String clickType: String,
versionEnable: Boolean,
}, },
data() { data() {
return { return {
@ -288,6 +303,7 @@ export default {
}, },
planCaseIds: [], planCaseIds: [],
apiscenariofilters:{}, apiscenariofilters:{},
versionFilters: [],
} }
}, },
computed: { computed: {
@ -301,7 +317,7 @@ export default {
created() { created() {
this.apiscenariofilters = API_SCENARIO_FILTERS(); this.apiscenariofilters = API_SCENARIO_FILTERS();
this.search(); this.search();
this.getVersionOptions();
}, },
watch: { watch: {
selectNodeIds() { selectNodeIds() {
@ -551,6 +567,19 @@ export default {
}); });
} }
}, },
changeVersion(currentVersion) {
this.condition.versionId = currentVersion || null;
this.search();
},
getVersionOptions() {
if (hasLicense()) {
this.$get('/project/version/get-project-versions/' + getCurrentProjectID(), response => {
this.versionFilters = response.data.map(u => {
return {text: u.name, value: u.id};
});
});
}
},
} }
} }
</script> </script>

View File

@ -11,6 +11,7 @@
<ms-table-button v-permission="['PROJECT_TRACK_PLAN:READ+RELEVANCE_OR_CANCEL']" icon="el-icon-connection" <ms-table-button v-permission="['PROJECT_TRACK_PLAN:READ+RELEVANCE_OR_CANCEL']" icon="el-icon-connection"
:content="$t('test_track.plan_view.relevance_test_case')" :content="$t('test_track.plan_view.relevance_test_case')"
@click="$emit('relevanceCase')"/> @click="$emit('relevanceCase')"/>
<version-select v-xpack :project-id="projectId" @changeVersion="$emit('changeVersion', $event)" margin-left="10"/>
</template> </template>
</ms-table-header> </ms-table-header>
@ -20,11 +21,15 @@
import MsTableHeader from "../../../../../common/components/MsTableHeader"; import MsTableHeader from "../../../../../common/components/MsTableHeader";
import MsTableButton from "../../../../../common/components/MsTableButton"; import MsTableButton from "../../../../../common/components/MsTableButton";
import MsEnvironmentSelect from "../../../../../api/definition/components/case/MsEnvironmentSelect"; import MsEnvironmentSelect from "../../../../../api/definition/components/case/MsEnvironmentSelect";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
export default { export default {
name: "TestPlanScenarioListHeader", name: "TestPlanScenarioListHeader",
components: {MsEnvironmentSelect, MsTableButton, MsTableHeader}, components: {
props: ['condition', 'isReadOnly'], MsEnvironmentSelect, MsTableButton, MsTableHeader, 'VersionSelect': VersionSelect.default,
},
props: ['condition', 'isReadOnly', 'projectId'],
methods: {} methods: {}
}; };
</script> </script>

View File

@ -25,6 +25,7 @@
@nodeSelectEvent="nodeChange" @nodeSelectEvent="nodeChange"
@refreshTable="refreshTable" @refreshTable="refreshTable"
@setModuleOptions="setModuleOptions" @setModuleOptions="setModuleOptions"
:version-enable="versionEnable"
:is-read-only="true" :is-read-only="true"
:review-id="reviewId" :review-id="reviewId"
ref="scenarioNodeTree"> ref="scenarioNodeTree">
@ -41,6 +42,7 @@
v-if="model === 'api'" v-if="model === 'api'"
:current-protocol="currentProtocol" :current-protocol="currentProtocol"
:currentRow="currentRow" :currentRow="currentRow"
:version-enable="versionEnable"
:select-node-ids="selectNodeIds" :select-node-ids="selectNodeIds"
:trash-enable="trashEnable" :trash-enable="trashEnable"
:is-case-relevance="true" :is-case-relevance="true"
@ -88,6 +90,7 @@ import MsApiModule from "../../../../api/definition/components/module/ApiModule"
import TestReviewRelevanceApi from "@/business/components/track/review/view/components/TestReviewRelevanceApi"; import TestReviewRelevanceApi from "@/business/components/track/review/view/components/TestReviewRelevanceApi";
import TestReviewRelevanceScenario import TestReviewRelevanceScenario
from "@/business/components/track/review/view/components/TestReviewRelevanceScenario"; from "@/business/components/track/review/view/components/TestReviewRelevanceScenario";
import {getCurrentProjectID, hasLicense} from "@/common/js/utils";
export default { export default {
name: "TestReviewApi", name: "TestReviewApi",
@ -112,7 +115,8 @@ export default {
currentModule: null, currentModule: null,
selectNodeIds: [], selectNodeIds: [],
moduleOptions: {}, moduleOptions: {},
model: 'api' model: 'api',
versionEnable: false,
} }
}, },
props: [ props: [
@ -122,6 +126,7 @@ export default {
], ],
mounted() { mounted() {
this.checkRedirectCharType(); this.checkRedirectCharType();
this.checkVersionEnable();
}, },
watch: { watch: {
model() { model() {
@ -182,6 +187,16 @@ export default {
this.$refs.apiCaseRelevance.open(); this.$refs.apiCaseRelevance.open();
} }
}, },
checkVersionEnable() {
if (!getCurrentProjectID()) {
return;
}
if (hasLicense()) {
this.$get('/project/version/enable/' + getCurrentProjectID(), response => {
this.versionEnable = response.data;
});
}
},
} }
} }
</script> </script>

View File

@ -45,11 +45,13 @@
<test-review-relevance <test-review-relevance
@refresh="refresh" @refresh="refresh"
:review-id="reviewId" :review-id="reviewId"
:version-enable="versionEnable"
ref="testReviewRelevance"/> ref="testReviewRelevance"/>
<is-change-confirm <is-change-confirm
:title="'请保存脑图'" :title="'请保存脑图'"
:tip="'脑图未保存,确认保存脑图吗?'" :tip="'脑图未保存,确认保存脑图吗?'"
:version-enable="versionEnable"
@confirm="changeConfirm" @confirm="changeConfirm"
ref="isChangeConfirm"/> ref="isChangeConfirm"/>

View File

@ -49,7 +49,7 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
v-if="hasLicense()" v-if="versionEnable"
prop="versionName" prop="versionName"
:label="$t('test_track.case.version')" :label="$t('test_track.case.version')"
column-key="versionId" column-key="versionId"
@ -193,6 +193,10 @@ export default {
props: { props: {
reviewId: { reviewId: {
type: String type: String
},
versionEnable: {
type: Boolean,
default: false
} }
}, },
watch: { watch: {
@ -218,9 +222,6 @@ export default {
this.toggleSelection(this.testReviews); this.toggleSelection(this.testReviews);
}, },
methods: { methods: {
hasLicense() {
return hasLicense();
},
openTestReviewRelevanceDialog() { openTestReviewRelevanceDialog() {
this.getProject(); this.getProject();
this.dialogFormVisible = true; this.dialogFormVisible = true;

View File

@ -173,6 +173,7 @@ export let CUSTOM_TABLE_HEADER = {
TEST_PLAN_SCENARIO_CASE: [ TEST_PLAN_SCENARIO_CASE: [
{id: 'num', key: '1', label: 'commons.id'}, {id: 'num', key: '1', label: 'commons.id'},
{id: 'name', key: '2', label: 'api_test.automation.scenario_name'}, {id: 'name', key: '2', label: 'api_test.automation.scenario_name'},
{id: 'versionId', key: 'd', label: 'commons.version'},
{id: 'level', key: '3', label: 'api_test.automation.case_level'}, {id: 'level', key: '3', label: 'api_test.automation.case_level'},
{id: 'tagNames', key: '4', label: 'api_test.automation.tag'}, {id: 'tagNames', key: '4', label: 'api_test.automation.tag'},
{id: 'stepTotal', key: '7', label: 'api_test.automation.step'}, {id: 'stepTotal', key: '7', label: 'api_test.automation.step'},