提交 c715a96c 编写于 作者: Q q4speed

高级查询

上级 c98c8bd3
......@@ -18,4 +18,5 @@ public class QueryAPIReportRequest {
private boolean recent = false;
private List<OrderRequest> orders;
private Map<String, List<String>> filters;
private Map<String, Object> combine;
}
......@@ -18,5 +18,5 @@ public class QueryAPITestRequest {
private boolean recent = false;
private List<OrderRequest> orders;
private Map<String, List<String>> filters;
private Map<String, Object> combine;
}
......@@ -33,11 +33,9 @@ import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.*;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
@Service
......@@ -189,7 +187,7 @@ public class APITestService {
ApiTestExample example = new ApiTestExample();
example.createCriteria().andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId()).andIdNotEqualTo(request.getId());
if (apiTestMapper.countByExample(example) > 0) {
return true;
return true;
}
return false;
}
......@@ -292,7 +290,7 @@ public class APITestService {
}
private SaveAPITestRequest getImportApiTest(MultipartFile file, ApiImport apiImport) {
SaveAPITestRequest request = new SaveAPITestRequest();
SaveAPITestRequest request = new SaveAPITestRequest();
request.setName(file.getOriginalFilename());
request.setProjectId("");
request.setScenarioDefinition(apiImport.getScenarios());
......@@ -304,7 +302,8 @@ public class APITestService {
if (name.endsWith(suffix)) {
request.setName(name.substring(0, name.length() - suffix.length()));
}
};
}
;
if (isNameExist(request)) {
request.setName(request.getName() + "_" + request.getId().substring(0, 5));
}
......
......@@ -8,15 +8,109 @@
<result column="user_name" property="userName"/>
</resultMap>
<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 api_test.name
<include refid="condition">
<property name="object" value="${condition}.name"/>
</include>
</if>
<if test="${condition}.updateTime != null">
and api_test.update_time
<include refid="condition">
<property name="object" value="${condition}.updateTime"/>
</include>
</if>
<if test="${condition}.projectName != null">
and project.name
<include refid="condition">
<property name="object" value="${condition}.projectName"/>
</include>
</if>
<if test="${condition}.createTime != null">
and api_test.create_time
<include refid="condition">
<property name="object" value="${condition}.createTime"/>
</include>
</if>
<if test="${condition}.status != null">
and api_test.status
<include refid="condition">
<property name="object" value="${condition}.status"/>
</include>
</if>
<if test="${condition}.creator != null">
and api_test.user_id
<include refid="condition">
<property name="object" value="${condition}.creator"/>
</include>
</if>
</sql>
<select id="list" resultMap="BaseResultMap" parameterType="io.metersphere.api.dto.APITestResult">
select api_test.*, project.name as project_name, user.name as user_name
from api_test
left join project on api_test.project_id = project.id
left join user on api_test.user_id = user.id
<where>
<if test="request.name != null">
and api_test.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 api_test.name like CONCAT('%', #{request.name},'%')
</if>
</otherwise>
</choose>
<if test="request.workspaceId != null">
AND project.workspace_id = #{request.workspaceId}
</if>
......
......@@ -9,6 +9,55 @@
<result column="user_name" property="userName"/>
</resultMap>
<sql id="condition">
<include refid="io.metersphere.base.mapper.ext.ExtApiTestMapper.condition"/>
</sql>
<sql id="combine">
<if test="${condition}.name != null">
and r.name
<include refid="condition">
<property name="object" value="${condition}.name"/>
</include>
</if>
<if test="${condition}.testName != null">
and t.name
<include refid="condition">
<property name="object" value="${condition}.testName"/>
</include>
</if>
<if test="${condition}.projectName != null">
and project.name
<include refid="condition">
<property name="object" value="${condition}.projectName"/>
</include>
</if>
<if test="${condition}.createTime != null">
and r.create_time
<include refid="condition">
<property name="object" value="${condition}.createTime"/>
</include>
</if>
<if test="${condition}.status != null">
and r.status
<include refid="condition">
<property name="object" value="${condition}.status"/>
</include>
</if>
<if test="${condition}.triggerMode != null">
and r.trigger_mode
<include refid="condition">
<property name="object" value="${condition}.triggerMode"/>
</include>
</if>
<if test="${condition}.creator != null">
and r.user_id
<include refid="condition">
<property name="object" value="${condition}.creator"/>
</include>
</if>
</sql>
<select id="list" resultMap="BaseResultMap">
SELECT t.name AS test_name,
r.name, r.description, r.id, r.test_id, r.create_time, r.update_time, r.status, r.trigger_mode,
......@@ -17,9 +66,20 @@
LEFT JOIN project ON project.id = t.project_id
LEFT JOIN user ON user.id = r.user_id
<where>
<if test="request.name != null">
AND r.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 r.name like CONCAT('%', #{request.name},'%')
</if>
</otherwise>
</choose>
<if test="request.projectId != null">
AND project.id = #{request.projectId}
</if>
......
......@@ -8,15 +8,69 @@
<result column="user_name" property="userName"/>
</resultMap>
<sql id="condition">
<include refid="io.metersphere.base.mapper.ext.ExtApiTestMapper.condition"/>
</sql>
<sql id="combine">
<if test="${condition}.name != null">
and load_test.name
<include refid="condition">
<property name="object" value="${condition}.name"/>
</include>
</if>
<if test="${condition}.updateTime != null">
and load_test.update_time
<include refid="condition">
<property name="object" value="${condition}.updateTime"/>
</include>
</if>
<if test="${condition}.projectName != null">
and project.name
<include refid="condition">
<property name="object" value="${condition}.projectName"/>
</include>
</if>
<if test="${condition}.createTime != null">
and load_test.create_time
<include refid="condition">
<property name="object" value="${condition}.createTime"/>
</include>
</if>
<if test="${condition}.status != null">
and load_test.status
<include refid="condition">
<property name="object" value="${condition}.status"/>
</include>
</if>
<if test="${condition}.creator != null">
and load_test.user_id
<include refid="condition">
<property name="object" value="${condition}.creator"/>
</include>
</if>
</sql>
<select id="list" resultMap="BaseResultMap" parameterType="io.metersphere.track.request.testplan.QueryTestPlanRequest">
select load_test.*, project.name as project_name, user.name as user_name
from load_test
left join project on load_test.project_id = project.id
left join user on load_test.user_id = user.id
<where>
<if test="request.name != null">
and load_test.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 load_test.name like CONCAT('%', #{request.name},'%')
</if>
</otherwise>
</choose>
<if test="request.workspaceId != null">
AND project.workspace_id = #{request.workspaceId}
</if>
......
......@@ -15,6 +15,55 @@
id, test_id, name, create_time, update_time, status
</sql>
<sql id="condition">
<include refid="io.metersphere.base.mapper.ext.ExtApiTestMapper.condition"/>
</sql>
<sql id="combine">
<if test="${condition}.name != null">
and ltr.name
<include refid="condition">
<property name="object" value="${condition}.name"/>
</include>
</if>
<if test="${condition}.testName != null">
and lt.name
<include refid="condition">
<property name="object" value="${condition}.testName"/>
</include>
</if>
<if test="${condition}.projectName != null">
and project.name
<include refid="condition">
<property name="object" value="${condition}.projectName"/>
</include>
</if>
<if test="${condition}.createTime != null">
and ltr.create_time
<include refid="condition">
<property name="object" value="${condition}.createTime"/>
</include>
</if>
<if test="${condition}.status != null">
and ltr.status
<include refid="condition">
<property name="object" value="${condition}.status"/>
</include>
</if>
<if test="${condition}.triggerMode != null">
and ltr.trigger_mode
<include refid="condition">
<property name="object" value="${condition}.triggerMode"/>
</include>
</if>
<if test="${condition}.creator != null">
and ltr.user_id
<include refid="condition">
<property name="object" value="${condition}.creator"/>
</include>
</if>
</sql>
<select id="getReportList" resultType="io.metersphere.dto.ReportDTO">
select ltr.id, ltr.name, ltr.test_id as testId, ltr.description, user.name as userName, project.name as
projectName, ltr.trigger_mode,
......@@ -26,9 +75,20 @@
JOIN project on project.id = lt.project_id
</if>
<where>
<if test="reportRequest.name != null">
AND ltr.name like CONCAT('%', #{reportRequest.name},'%')
</if>
<choose>
<!--高级-->
<when test="reportRequest.combine != null">
<include refid="combine">
<property name="condition" value="reportRequest.combine"/>
</include>
</when>
<!--普通-->
<otherwise>
<if test="reportRequest.name != null">
AND ltr.name like CONCAT('%', #{reportRequest.name},'%')
</if>
</otherwise>
</choose>
<if test="reportRequest.workspaceId != null">
AND workspace_id = #{reportRequest.workspaceId,jdbcType=VARCHAR}
</if>
......
......@@ -5,12 +5,17 @@ import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import java.util.Objects;
import java.util.Optional;
import static io.metersphere.commons.constants.SessionConstants.ATTR_USER;
public class SessionUtils {
public static String getUserId() {
return Objects.requireNonNull(getUser()).getId();
}
public static SessionUser getUser() {
try {
Subject subject = SecurityUtils.getSubject();
......
......@@ -14,4 +14,5 @@ public class ReportRequest {
private String workspaceId;
private List<OrderRequest> orders;
private Map<String, List<String>> filters;
private Map<String, Object> combine;
}
......@@ -13,4 +13,5 @@ public class QueryTestPlanRequest extends TestPlanRequest {
private String workspaceId;
private List<OrderRequest> orders;
private Map<String, List<String>> filters;
private Map<String, Object> combine;
}
......@@ -4,7 +4,7 @@
<el-card class="table-card" v-loading="result.loading">
<template v-slot:header>
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="search"
:title="$t('api_report.title')" :advanced="advanced"
:title="$t('api_report.title')"
:show-create="false"/>
</template>
<el-table :data="tableData" class="table-content" @sort-change="sort"
......@@ -57,7 +57,7 @@
import {_filter, _sort} from "../../../../common/js/utils";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import ReportTriggerModeItem from "../../common/tableItem/ReportTriggerModeItem";
import {REPORT_CONFIGS} from "../../common/components/search/search-components";
import {getReportConfigs} from "../../common/components/search/search-components";
export default {
components: {
......@@ -68,9 +68,8 @@
data() {
return {
result: {},
condition: {},
advanced: {
components: REPORT_CONFIGS
condition: {
components: getReportConfigs()
},
tableData: [],
multipleSelection: [],
......@@ -99,14 +98,15 @@
},
methods: {
search(advanced) {
console.log(advanced)
search(combine) {
// 只有在点击高级搜索的查询按钮时combine才有值
let condition = combine ? {combine: combine} : this.condition;
if (this.testId !== 'all') {
this.condition.testId = this.testId;
condition.testId = this.testId;
}
let url = "/api/report/list/" + this.currentPage + "/" + this.pageSize;
this.result = this.$post(url, this.condition, response => {
this.result = this.$post(url, condition, response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;
......
......@@ -4,7 +4,7 @@
<el-card class="table-card" v-loading="result.loading">
<template v-slot:header>
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="search"
:title="$t('commons.test')" :advanced="advanced"
:title="$t('commons.test')"
@create="create" :createTip="$t('load_test.create')"/>
</template>
<el-table :data="tableData" class="table-content" @sort-change="sort" @row-click="handleView"
......@@ -54,7 +54,7 @@
import MsApiTestStatus from "./ApiTestStatus";
import MsTableOperators from "../../common/components/MsTableOperators";
import {_filter, _sort} from "../../../../common/js/utils";
import {TEST_CONFIGS} from "../../common/components/search/search-components";
import {getTestConfigs} from "../../common/components/search/search-components";
export default {
components: {
......@@ -64,9 +64,8 @@
data() {
return {
result: {},
condition: {},
advanced: {
components: TEST_CONFIGS
condition: {
components: getTestConfigs()
},
projectId: null,
tableData: [],
......@@ -106,14 +105,15 @@
create() {
this.$router.push('/api/test/create');
},
search(advanced) {
console.log(advanced)
search(combine) {
// 只有在点击高级搜索的查询按钮时combine才有值
let condition = combine ? {combine: combine} : this.condition;
if (this.projectId !== 'all') {
this.condition.projectId = this.projectId;
condition.projectId = this.projectId;
}
let url = "/api/list/" + this.currentPage + "/" + this.pageSize
this.result = this.$post(url, this.condition, response => {
let url = "/api/list/" + this.currentPage + "/" + this.pageSize;
this.result = this.$post(url, condition, response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;
......
......@@ -14,7 +14,7 @@
</span>
<span>
<ms-table-search-bar :condition.sync="condition" @change="search" class="search-bar"/>
<ms-table-adv-search-bar :condition="advanced" @search="search" v-if="advanced"/>
<ms-table-adv-search-bar :condition="condition" @search="search" v-if="isCombine"/>
</span>
</el-row>
</div>
......@@ -43,7 +43,6 @@
condition: {
type: Object
},
advanced: Object,
createTip: {
type: String,
default() {
......@@ -63,6 +62,11 @@
create() {
this.$emit('create');
}
},
computed: {
isCombine() {
return this.condition.components !== undefined && this.condition.components.length > 0;
}
}
}
</script>
......
......@@ -3,10 +3,11 @@
<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%">
<div>
<div class="search-label">{{$t('commons.adv_search.combine')}}: </div>
<el-select v-model="logic" :placeholder="$t('commons.please_select')" size="small" class="search-combine">
<el-option v-for="o in options" :key="o.value" :label="o.label" :value="o.value"/>
</el-select>
<!-- 如果有需求再加上-->
<!-- <div class="search-label">{{$t('commons.adv_search.combine')}}: </div>-->
<!-- <el-select v-model="logic" :placeholder="$t('commons.please_select')" size="small" class="search-combine">-->
<!-- <el-option v-for="o in options" :key="o.value" :label="o.label" :value="o.value"/>-->
<!-- </el-select>-->
<div class="search-items">
<component class="search-item" v-for="(component, index) in condition.components" :key="index"
:is="component.name" :component="component"/>
......@@ -47,27 +48,30 @@
methods: {
search() {
let condition = {
logic: this.logic
// logic: this.logic // 如果有需求再加上
}
this.condition.components.forEach(component => {
let operator = component.operator.value;
let value = component.value;
if (Array.isArray(component.value)) {
if (component.value.length > 0) {
condition[component.key] = {
operator: component.operator,
value: component.value
operator: operator,
value: value
}
}
} else {
if (component.value !== undefined && component.value !== null) {
if (component.value !== undefined && component.value !== null && component.value !== "") {
condition[component.key] = {
operator: component.operator,
value: component.value
operator: operator,
value: value
}
}
}
});
this.$emit('search', condition);
this.visible = false;
},
open() {
this.visible = true;
......
......@@ -3,7 +3,7 @@
<div class="search-label">{{component.label}}:</div>
<el-select class="search-operator" v-model="operator" :placeholder="$t('commons.please_select')" size="small"
@change="change" @input="input">
@change="change" @input="input" v-bind="component.operator.props">
<el-option v-for="o in operators" :key="o.value" :label="o.label" :value="o.value"/>
</el-select>
......@@ -19,19 +19,22 @@
props: ['component'],
data() {
return {
operators: this.component.operators || [],
operators: this.component.operator.options || [],
operator: (() => {
if (this.component.operator === undefined && this.component.operators.length > 0) {
this.$emit('input', this.component.operators[0].value);
return this.component.operators[0].value;
if (this.component.operator.value === undefined && this.component.operator.options.length > 0) {
this.$emit('input', this.component.operator.options[0].value);
return this.component.operator.options[0].value;
} else {
this.component.operator
return this.component.operator.value
}
})()
}
},
methods: {
change(value) {
if (this.component.operator.change) {
this.component.operator.change(this.component, value)
}
this.$emit('change', value);
},
input(value) {
......@@ -41,8 +44,8 @@
computed: {
showContent() {
return operator => {
if (this.component.showContent) {
return this.component.showContent(operator);
if (this.component.isShow) {
return this.component.isShow(operator);
}
return true;
}
......
<template>
<ms-table-search-component v-model="component.operator" :component="component">
<ms-table-search-component v-model="component.operator.value" :component="component">
<template v-slot="scope">
<el-date-picker
v-model="scope.component.value" v-bind="scope.component.props"
......
<template>
<ms-table-search-component v-model="component.operator" :component="component" @change="change">
<ms-table-search-component v-model="component.operator.value" :component="component" @change="change">
<template v-slot="scope">
<el-date-picker v-model="scope.component.value" v-bind="scope.component.props"
:placeholder="$t('commons.date.select_date_time')" size="small"
......
<template>
<ms-table-search-component v-model="component.operator" :component="component">
<ms-table-search-component v-model="component.operator.value" :component="component">
<template v-slot="scope">
<el-input v-model="scope.component.value" v-bind="props"
:placeholder="$t('commons.input_content')" size="small"/>
......
<template>
<ms-table-search-component v-model="component.operator" :component="component">
<ms-table-search-component v-model="component.operator.value" :component="component">
<template v-slot="scope">
<el-select v-model="scope.component.value" :placeholder="$t('commons.please_select')" size="small" filterable
v-bind="scope.component.props" class="search-select">
<el-select v-model="scope.component.value" :placeholder="$t('commons.please_select')" size="small"
filterable v-bind="scope.component.props" class="search-select">
<el-option v-for="op in options" :key="op.value" :label="label(op)" :value="op.value"></el-option>
</el-select>
</template>
......@@ -26,7 +26,10 @@
this.$get(this.component.options.url, response => {
if (response.data) {
response.data.forEach(item => {
this.options.push({label: item[this.component.options.labelKey], value: item[this.component.options.valueKey]})
this.options.push({
label: item[this.component.options.labelKey],
value: item[this.component.options.valueKey]
})
})
}
})
......
......@@ -3,6 +3,7 @@ import MsTableSearchDateTimePicker from "./MsTableSearchDateTimePicker";
import MsTableSearchDatePicker from "./MsTableSearchDatePicker";
import MsTableSearchSelect from "./MsTableSearchSelect";
import i18n from "../../../../../i18n/i18n";
import _ from "lodash"
export default {
MsTableSearchInput, MsTableSearchDatePicker, MsTableSearchDateTimePicker, MsTableSearchSelect
......@@ -27,23 +28,23 @@ export const OPERATORS = {
},
GT: {
label: i18n.t("commons.adv_search.operators.gt"),
value: ">"
value: "gt"
},
GE: {
label: i18n.t("commons.adv_search.operators.ge"),
value: ">="
value: "ge"
},
LT: {
label: i18n.t("commons.adv_search.operators.lt"),
value: "<"
value: "lt"
},
LE: {
label: i18n.t("commons.adv_search.operators.le"),
value: "<="
value: "le"
},
EQ: {
label: i18n.t("commons.adv_search.operators.equals"),
value: "=="
value: "eq"
},
BETWEEN: {
label: i18n.t("commons.adv_search.operators.between"),
......@@ -56,48 +57,61 @@ export const OPERATORS = {
}
export const NAME = {
key: "name",
name: 'MsTableSearchInput',
label: i18n.t('commons.name'),
operators: [OPERATORS.LIKE, OPERATORS.NOT_LIKE],
key: "name", // 返回结果Map的key
name: 'MsTableSearchInput', // Vue控件名称
label: i18n.t('commons.name'), // 显示名称
operator: { // 运算符设置
value: OPERATORS.LIKE.value, // 如果未设置value初始值,则value初始值为options[0]
options: [OPERATORS.LIKE, OPERATORS.NOT_LIKE] // 运算符候选项
},
}
export const UPDATE_TIME = {
key: "updateTime",
name: 'MsTableSearchDateTimePicker',
label: i18n.t('commons.update_time'),
operators: [OPERATORS.BETWEEN, OPERATORS.GT, OPERATORS.GE, OPERATORS.LT, OPERATORS.LE, OPERATORS.EQ],
operator: {
options: [OPERATORS.BETWEEN, OPERATORS.GT, OPERATORS.GE, OPERATORS.LT, OPERATORS.LE, OPERATORS.EQ]
},
}
export const PROJECT_NAME = {
key: "projectName",
name: 'MsTableSearchInput',
label: i18n.t('commons.adv_search.project'),
operators: [OPERATORS.LIKE, OPERATORS.NOT_LIKE],
operator: {
options: [OPERATORS.LIKE, OPERATORS.NOT_LIKE]
},
}
export const TEST_NAME = {
key: "testName",
name: 'MsTableSearchInput',
label: i18n.t('commons.adv_search.test'),
operators: [OPERATORS.LIKE, OPERATORS.NOT_LIKE],
operator: {
options: [OPERATORS.LIKE, OPERATORS.NOT_LIKE]
},
}
export const CREATE_TIME = {
key: "createTime",
name: 'MsTableSearchDateTimePicker',
label: i18n.t('commons.create_time'),
operators: [OPERATORS.BETWEEN, OPERATORS.GT, OPERATORS.GE, OPERATORS.LT, OPERATORS.LE, OPERATORS.EQ],
operator: {
options: [OPERATORS.BETWEEN, OPERATORS.GT, OPERATORS.GE, OPERATORS.LT, OPERATORS.LE, OPERATORS.EQ]
},
}
export const STATUS = {
key: "status",
name: 'MsTableSearchSelect',
label: i18n.t('commons.status'),
operators: [OPERATORS.IN, OPERATORS.NOT_IN],
operator: {
options: [OPERATORS.IN, OPERATORS.NOT_IN]
},
options: [
{label: "Saved", value: "Saved"}, {label: "Starting", value: "Starting"},
{label: "Running", value: "Running"}, {label: "Reporting", value: "Reporting"},
{label: "Completed", value: "Completed"}, {label: "Error", value: "Error"}
],
props: {
props: { // 尾部控件的props,一般为element ui控件的props
multiple: true
}
}
......@@ -106,8 +120,15 @@ export const CREATOR = {
key: "creator",
name: 'MsTableSearchSelect',
label: i18n.t('api_test.creator'),
operators: [OPERATORS.IN, OPERATORS.NOT_IN, OPERATORS.CURRENT_USER],
options: {
operator: {
options: [OPERATORS.IN, OPERATORS.NOT_IN, OPERATORS.CURRENT_USER],
change: function (component, value) { // 运算符change事件
if (value === OPERATORS.CURRENT_USER.value) {
component.value = value;
}
}
},
options: { // 异步获取候选项
url: "/user/list",
labelKey: "name",
valueKey: "id",
......@@ -118,7 +139,7 @@ export const CREATOR = {
props: {
multiple: true
},
showContent: operator => {
isShow: operator => {
return operator !== OPERATORS.CURRENT_USER.value;
}
}
......@@ -127,7 +148,9 @@ export const TRIGGER_MODE = {
key: "triggerMode",
name: 'MsTableSearchSelect',
label: i18n.t('commons.trigger_mode.name'),
operators: [OPERATORS.IN, OPERATORS.NOT_IN],
operator: {
options: [OPERATORS.IN, OPERATORS.NOT_IN]
},
options: [
{label: i18n.t("commons.trigger_mode.manual"), value: "MANUAL"},
{label: i18n.t("commons.trigger_mode.schedule"), value: "SCHEDULE"},
......@@ -138,6 +161,10 @@ export const TRIGGER_MODE = {
}
}
export const TEST_CONFIGS = [NAME, UPDATE_TIME, PROJECT_NAME, CREATE_TIME, STATUS, CREATOR]
export const getTestConfigs = () => {
return _.cloneDeep([NAME, UPDATE_TIME, PROJECT_NAME, CREATE_TIME, STATUS, CREATOR]);
}
export const REPORT_CONFIGS = [NAME, TEST_NAME, PROJECT_NAME, CREATE_TIME, STATUS, CREATOR, TRIGGER_MODE]
export const getReportConfigs = () => {
return _.cloneDeep([NAME, TEST_NAME, PROJECT_NAME, CREATE_TIME, STATUS, CREATOR, TRIGGER_MODE]);
}
......@@ -3,17 +3,9 @@
<ms-main-container>
<el-card class="table-card" v-loading="result.loading">
<template v-slot:header>
<div>
<el-row type="flex" justify="space-between" align="middle">
<span class="title">{{$t('commons.report')}}</span>
<span class="search">
<el-input type="text" size="small" :placeholder="$t('report.search_by_name')"
prefix-icon="el-icon-search"
maxlength="60"
v-model="condition.name" @change="search" clearable/>
</span>
</el-row>
</div>
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="search"
:title="$t('commons.report')"
:show-create="false"/>
</template>
<el-table :data="tableData" class="test-content"
......@@ -91,10 +83,13 @@
import {_filter, _sort} from "../../../../common/js/utils";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import ReportTriggerModeItem from "../../common/tableItem/ReportTriggerModeItem";
import {getReportConfigs} from "../../common/components/search/search-components";
import MsTableHeader from "../../common/components/MsTableHeader";
export default {
name: "PerformanceTestReport",
components: {
MsTableHeader,
ReportTriggerModeItem,
MsTableOperatorButton, MsPerformanceReportStatus, MsTablePagination, MsContainer, MsMainContainer},
created: function () {
......@@ -105,7 +100,9 @@
result: {},
queryPath: "/performance/report/list/all",
deletePath: "/performance/report/delete/",
condition: {},
condition: {
components: getReportConfigs()
},
projectId: null,
tableData: [],
multipleSelection: [],
......@@ -129,15 +126,19 @@
}
},
methods: {
initTableData() {
this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
initTableData(combine) {
let condition = combine ? {combine: combine} : this.condition;
if (this.testId !== 'all') {
condition.testId = this.testId;
}
this.result = this.$post(this.buildPagePath(this.queryPath), condition, response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;
});
},
search() {
this.initTableData();
search(combine) {
this.initTableData(combine);
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
......
......@@ -82,6 +82,7 @@
import MsTableOperators from "../../common/components/MsTableOperators";
import {_filter, _sort} from "../../../../common/js/utils";
import MsTableHeader from "../../common/components/MsTableHeader";
import {getTestConfigs} from "../../common/components/search/search-components";
export default {
components: {
......@@ -98,7 +99,9 @@
result: {},
queryPath: "/performance/list",
deletePath: "/performance/delete",
condition: {},
condition: {
components: getTestConfigs()
},
projectId: null,
tableData: [],
multipleSelection: [],
......@@ -140,20 +143,20 @@
this.initTableData();
},
methods: {
initTableData() {
initTableData(combine) {
let condition = combine ? {combine: combine} : this.condition;
if (this.projectId !== 'all') {
this.condition.projectId = this.projectId;
condition.projectId = this.projectId;
}
this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
this.result = this.$post(this.buildPagePath(this.queryPath), condition, response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;
});
},
search() {
this.initTableData();
search(combine) {
this.initTableData(combine);
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
......@@ -225,6 +228,6 @@
}
.el-table {
cursor:pointer;
cursor: pointer;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册