This commit is contained in:
q4speed 2020-07-15 11:54:52 +08:00
parent b15d35558f
commit cac4d74f56
9 changed files with 43 additions and 39 deletions

View File

@ -57,7 +57,7 @@
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 {REPORT_CONFIGS} from "../../common/components/search/search-components";
export default {
components: {
@ -69,7 +69,7 @@
return {
result: {},
condition: {
components: getReportConfigs()
components: REPORT_CONFIGS
},
tableData: [],
multipleSelection: [],

View File

@ -54,7 +54,7 @@
import MsApiTestStatus from "./ApiTestStatus";
import MsTableOperators from "../../common/components/MsTableOperators";
import {_filter, _sort} from "../../../../common/js/utils";
import {getTestConfigs} from "../../common/components/search/search-components";
import {TEST_CONFIGS} from "../../common/components/search/search-components";
export default {
components: {
@ -65,7 +65,7 @@
return {
result: {},
condition: {
components: getTestConfigs()
components: TEST_CONFIGS
},
projectId: null,
tableData: [],

View File

@ -1,7 +1,8 @@
<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" custom-class="adv-dialog" :append-to-body="true">
<el-dialog :title="$t('commons.adv_search.combine')" :visible.sync="visible" custom-class="adv-dialog"
:append-to-body="true">
<div>
<!-- 如果有需求再加上-->
<!-- <div class="search-label">{{$t('commons.adv_search.combine')}}: </div>-->
@ -9,13 +10,13 @@
<!-- <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"
<component class="search-item" v-for="(component, index) in config.components" :key="index"
:is="component.name" :component="component"/>
</div>
</div>
<template v-slot:footer>
<div class="dialog-footer">
<el-button @click="visible = false">{{$t('commons.cancel')}}</el-button>
<el-button @click="reset">{{$t('commons.adv_search.reset')}}</el-button>
<el-button type="primary" @click="search">{{$t('commons.adv_search.search')}}</el-button>
</div>
</template>
@ -25,6 +26,7 @@
<script>
import components from "./search-components";
import _ from "lodash";
export default {
components: {...components},
@ -35,6 +37,7 @@
data() {
return {
visible: false,
config: this.init(),
options: [{
label: this.$t("commons.adv_search.and"),
value: "and"
@ -46,11 +49,19 @@
}
},
methods: {
init() { //
let config = _.cloneDeep(this.condition);
config.components.forEach(component => {
let operator = component.operator.value;
component.operator.value = operator === undefined ? component.operator.options[0].value : operator;
})
return config;
},
search() {
let condition = {
// logic: this.logic //
}
this.condition.components.forEach(component => {
this.config.components.forEach(component => {
let operator = component.operator.value;
let value = component.value;
if (Array.isArray(component.value)) {
@ -73,6 +84,14 @@
this.$emit('search', condition);
this.visible = false;
},
reset() {
let source = this.condition.components;
this.config.components.forEach((component, index) => {
let operator = source[index].operator.value;
component.operator.value = operator === undefined ? component.operator.options[0].value : operator;
component.value = source[index].value;
})
},
open() {
this.visible = true;
}

View File

@ -2,12 +2,13 @@
<div>
<div class="search-label">{{$t(component.label)}}</div>
<el-select class="search-operator" v-model="operator" :placeholder="$t('commons.please_select')" size="small"
<el-select class="search-operator" v-model="component.operator.value" :placeholder="$t('commons.please_select')"
size="small"
@change="change" @input="input" v-bind="component.operator.props">
<el-option v-for="o in operators" :key="o.value" :label="$t(o.label)" :value="o.value"/>
</el-select>
<div class="search-content" v-if="showContent(operator)">
<div class="search-content" v-if="showContent">
<slot v-bind:component="component"></slot>
</div>
</div>
@ -20,14 +21,6 @@
data() {
return {
operators: this.component.operator.options || [],
operator: (() => {
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 {
return this.component.operator.value
}
})()
}
},
methods: {
@ -43,12 +36,10 @@
},
computed: {
showContent() {
return operator => {
if (this.component.isShow) {
return this.component.isShow(operator);
}
return true;
if (this.component.isShow) {
return this.component.isShow(this.component.operator.value);
}
return true;
}
}
}

View File

@ -2,7 +2,6 @@ import MsTableSearchInput from "./MsTableSearchInput";
import MsTableSearchDateTimePicker from "./MsTableSearchDateTimePicker";
import MsTableSearchDatePicker from "./MsTableSearchDatePicker";
import MsTableSearchSelect from "./MsTableSearchSelect";
import _ from "lodash"
export default {
MsTableSearchInput, MsTableSearchDatePicker, MsTableSearchDateTimePicker, MsTableSearchSelect
@ -221,14 +220,8 @@ export const MODULE = {
},
}
export const getTestConfigs = () => {
return _.cloneDeep([NAME, UPDATE_TIME, PROJECT_NAME, CREATE_TIME, STATUS, CREATOR]);
}
export const TEST_CONFIGS = [NAME, UPDATE_TIME, PROJECT_NAME, CREATE_TIME, STATUS, CREATOR];
export const getReportConfigs = () => {
return _.cloneDeep([NAME, TEST_NAME, PROJECT_NAME, CREATE_TIME, STATUS, CREATOR, TRIGGER_MODE]);
}
export const REPORT_CONFIGS = [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]);
}
export const TEST_CASE_CONFIGS = [NAME, MODULE, PRIORITY, CREATE_TIME, TYPE, UPDATE_TIME, METHOD, CREATOR];

View File

@ -83,7 +83,7 @@
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 {REPORT_CONFIGS} from "../../common/components/search/search-components";
import MsTableHeader from "../../common/components/MsTableHeader";
export default {
@ -101,7 +101,7 @@
queryPath: "/performance/report/list/all",
deletePath: "/performance/report/delete/",
condition: {
components: getReportConfigs()
components: REPORT_CONFIGS
},
projectId: null,
tableData: [],

View File

@ -82,7 +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";
import {TEST_CONFIGS} from "../../common/components/search/search-components";
export default {
components: {
@ -100,7 +100,7 @@
queryPath: "/performance/list",
deletePath: "/performance/delete",
condition: {
components: getTestConfigs()
components: TEST_CONFIGS
},
projectId: null,
tableData: [],

View File

@ -84,7 +84,7 @@
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";
import {TEST_CASE_CONFIGS} from "../../../../common/components/search/search-components";
export default {
name: "TestCaseRelevance",
@ -108,7 +108,7 @@
selectNodeIds: [],
selectNodeNames: [],
condition: {
components: getTestCaseConfigs()
components: TEST_CASE_CONFIGS
},
priorityFilters: [
{text: 'P0', value: 'P0'},

View File

@ -124,6 +124,7 @@ export default {
test: "所属测试",
project: "所属项目",
search: "查询",
reset: "重置",
and: '所有',
or: '任意一个',
operators: {