提交 b9c369ec 编写于 作者: S shiziyuan9527

feat: 关联测试用例页面添加高级搜索

上级 b2d036a8
......@@ -2,13 +2,120 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="io.metersphere.base.mapper.ext.ExtTestCaseMapper">
<sql id="condition">
<choose>
<when test='${object}.operator == "like"'>
like CONCAT('%', #{${object}.value},'%')
</when>
<when test='${object}.operator == "not like"'>
not like CONCAT('%', #{${object}.value},'%')
</when>
<when test='${object}.operator == "in"'>
in
<foreach collection="${object}.value" item="v" separator="," open="(" close=")">
#{v}
</foreach>
</when>
<when test='${object}.operator == "not in"'>
not in
<foreach collection="${object}.value" item="v" separator="," open="(" close=")">
#{v}
</foreach>
</when>
<when test='${object}.operator == "between"'>
between #{${object}.value[0]} and #{${object}.value[1]}
</when>
<when test='${object}.operator == "gt"'>
&gt; #{${object}.value}
</when>
<when test='${object}.operator == "lt"'>
&lt; #{${object}.value}
</when>
<when test='${object}.operator == "ge"'>
&gt;= #{${object}.value}
</when>
<when test='${object}.operator == "le"'>
&lt;= #{${object}.value}
</when>
<when test='${object}.operator == "current user"'>
= '${@io.metersphere.commons.utils.SessionUtils@getUserId()}'
</when>
<otherwise>
= #{${object}.value}
</otherwise>
</choose>
</sql>
<sql id="combine">
<if test="${condition}.name != null">
and test_case.name
<include refid="condition">
<property name="object" value="${condition}.name"/>
</include>
</if>
<if test="${condition}.module != null">
and test_case.node_path
<include refid="condition">
<property name="object" value="${condition}.module"/>
</include>
</if>
<if test="${condition}.priority != null">
and test_case.priority
<include refid="condition">
<property name="object" value="${condition}.priority"/>
</include>
</if>
<if test="${condition}.createTime != null">
and test_case.create_time
<include refid="condition">
<property name="object" value="${condition}.createTime"/>
</include>
</if>
<if test="${condition}.type != null">
and test_case.type
<include refid="condition">
<property name="object" value="${condition}.type"/>
</include>
</if>
<if test="${condition}.updateTime != null">
and test_case.update_time
<include refid="condition">
<property name="object" value="${condition}.updateTime"/>
</include>
</if>
<if test="${condition}.method != null">
and test_case.method
<include refid="condition">
<property name="object" value="${condition}.method"/>
</include>
</if>
<if test="${condition}.creator != null">
and test_case.maintainer
<include refid="condition">
<property name="object" value="${condition}.creator"/>
</include>
</if>
</sql>
<select id="getTestCaseNames" resultType="io.metersphere.base.domain.TestCase">
select test_case.id, test_case.name, test_case.priority, test_case.type
from test_case
<where>
<if test="request.name != null">
and test_case.name like CONCAT('%', #{request.name},'%')
</if>
<choose>
<!--高级-->
<when test="request.combine != null">
<include refid="combine">
<property name="condition" value="request.combine"/>
</include>
</when>
<!--普通-->
<otherwise>
<if test="request.name != null">
and test_case.name like CONCAT('%', #{request.name},'%')
</if>
</otherwise>
</choose>
<if test="request.projectId != null">
AND test_case.project_id = #{request.projectId}
</if>
......
......@@ -23,4 +23,6 @@ public class QueryTestCaseRequest extends TestCase {
private String planId;
private String workspaceId;
private Map<String, Object> combine;
}
<template>
<span class="adv-search-bar">
<el-link type="primary" @click="open">{{$t('commons.adv_search.title')}}</el-link>
<el-dialog :title="$t('commons.adv_search.combine')" :visible.sync="visible" width="70%">
<el-dialog :title="$t('commons.adv_search.combine')" :visible.sync="visible" width="70%" :append-to-body="true">
<div>
<!-- 如果有需求再加上-->
<!-- <div class="search-label">{{$t('commons.adv_search.combine')}}: </div>-->
......
......@@ -161,6 +161,67 @@ export const TRIGGER_MODE = {
}
}
export const PRIORITY = {
key: "priority",
name: 'MsTableSearchSelect',
label: i18n.t("test_track.case.priority"),
operator: {
options: [OPERATORS.IN, OPERATORS.NOT_IN]
},
options: [
{label: "P0", value: "P0"},
{label: "P1", value: "P1"},
{label: "P2", value: "P2"},
{label: "P3", value: "P3"},
],
props: {
multiple: true
}
}
export const TYPE = {
key: "type",
name: 'MsTableSearchSelect',
label: i18n.t("test_track.case.type"),
operator: {
options: [OPERATORS.IN, OPERATORS.NOT_IN]
},
options: [
{label: i18n.t('commons.functional'), value: 'functional'},
{label: i18n.t('commons.performance'), value: 'performance'},
{label: i18n.t('commons.api'), value: 'api'}
],
props: {
multiple: true
}
}
export const METHOD = {
key: "method",
name: 'MsTableSearchSelect',
label: i18n.t("test_track.case.method"),
operator: {
options: [OPERATORS.IN, OPERATORS.NOT_IN]
},
options: [
{label: i18n.t('test_track.case.manual'), value: 'manual'},
{label: i18n.t('test_track.case.auto'), value: 'auto'}
],
props: {
multiple: true
}
}
export const MODULE = {
key: "module",
name: 'MsTableSearchInput',
label: i18n.t("test_track.case.module"),
operator: {
value: OPERATORS.LIKE.value, // 如果未设置value初始值,则value初始值为options[0]
options: [OPERATORS.LIKE, OPERATORS.NOT_LIKE] // 运算符候选项
},
}
export const getTestConfigs = () => {
return _.cloneDeep([NAME, UPDATE_TIME, PROJECT_NAME, CREATE_TIME, STATUS, CREATOR]);
}
......@@ -168,3 +229,7 @@ export const getTestConfigs = () => {
export const getReportConfigs = () => {
return _.cloneDeep([NAME, TEST_NAME, PROJECT_NAME, CREATE_TIME, STATUS, CREATOR, TRIGGER_MODE]);
}
export const getTestCaseConfigs = () => {
return _.cloneDeep([NAME, MODULE, PRIORITY, CREATE_TIME, TYPE, UPDATE_TIME, METHOD, CREATOR]);
}
......@@ -19,11 +19,7 @@
<el-container>
<el-main class="case-content" v-loading="result.loading">
<el-row>
<el-col :offset="16" :span="8">
<ms-table-search-bar :condition.sync="condition" @change="initData"/>
</el-col>
</el-row>
<ms-table-header :condition.sync="condition" @search="getCaseNames" title="" :show-create="false"/>
<el-table
:data="testCases"
@filter-change="filter"
......@@ -86,10 +82,21 @@
import TypeTableItem from "../../../common/tableItems/planview/TypeTableItem";
import {_filter} from "../../../../../../common/js/utils";
import MsTableSearchBar from "../../../../common/components/MsTableSearchBar";
import MsTableAdvSearchBar from "../../../../common/components/search/MsTableAdvSearchBar";
import MsTableHeader from "../../../../common/components/MsTableHeader";
import {getTestCaseConfigs} from "../../../../common/components/search/search-components";
export default {
name: "TestCaseRelevance",
components: {NodeTree, MsDialogFooter, PriorityTableItem, TypeTableItem, MsTableSearchBar},
components: {
NodeTree,
MsDialogFooter,
PriorityTableItem,
TypeTableItem,
MsTableSearchBar,
MsTableAdvSearchBar,
MsTableHeader
},
data() {
return {
result: {},
......@@ -100,7 +107,9 @@
treeNodes: [],
selectNodeIds: [],
selectNodeNames: [],
condition: {},
condition: {
components: getTestCaseConfigs()
},
priorityFilters: [
{text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'},
......@@ -143,17 +152,19 @@
this.$emit('refresh');
});
},
getCaseNames() {
getCaseNames(combine) {
let param = {};
// 只有在点击高级搜索的查询按钮时combine才有值
let condition = combine ? {combine: combine} : this.condition;
if (this.planId) {
// param.planId = this.planId;
this.condition.planId = this.planId;
condition.planId = this.planId;
}
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
// param.nodeIds = this.selectNodeIds;
this.condition.nodeIds = this.selectNodeIds;
condition.nodeIds = this.selectNodeIds;
}
this.result = this.$post('/test/case/name', this.condition, response => {
this.result = this.$post('/test/case/name', condition, response => {
this.testCases = response.data;
this.testCases.forEach(item => {
item.checked = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册