feat(接口测试): 条件控制器增加空和非空操作符
This commit is contained in:
parent
a31cd2e8bc
commit
b8b9e9ac64
|
@ -6,12 +6,13 @@
|
|||
<el-input size="small" v-model="controller.variable" :placeholder="$t('api_test.request.condition_variable')"/>
|
||||
</el-col>
|
||||
<el-col :span="5">
|
||||
<el-select v-model="controller.operator" :placeholder="$t('commons.please_select')" size="small">
|
||||
<el-select v-model="controller.operator" :placeholder="$t('commons.please_select')" size="small"
|
||||
@change="change">
|
||||
<el-option v-for="o in operators" :key="o.value" :label="$t(o.label)" :value="o.value"/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-input size="small" v-model="controller.value" :placeholder="$t('api_test.value')"/>
|
||||
<el-input size="small" v-model="controller.value" :placeholder="$t('api_test.value')" v-if="!hasNullOperator"/>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<el-switch v-model="controller.enable" :inactive-text="$t('api_test.scenario.enable_disable')"/>
|
||||
|
@ -58,6 +59,14 @@ export default {
|
|||
LT: {
|
||||
label: "commons.adv_search.operators.lt",
|
||||
value: "<"
|
||||
},
|
||||
IS_NULL: {
|
||||
label: "commons.adv_search.operators.is_null",
|
||||
value: "is null"
|
||||
},
|
||||
IS_NOT_NULL: {
|
||||
label: "commons.adv_search.operators.is_not_null",
|
||||
value: "is not null"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +87,16 @@ export default {
|
|||
remove() {
|
||||
this.controller = new IfController();
|
||||
this.visible = false;
|
||||
},
|
||||
change(value) {
|
||||
if (value.indexOf("null") > 0) {
|
||||
this.controller.value = "";
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
hasNullOperator() {
|
||||
return !!this.controller.operator && this.controller.operator.indexOf("null") > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -873,14 +873,17 @@ export class IfController extends Controller {
|
|||
}
|
||||
|
||||
isValid() {
|
||||
if (!!this.operator && this.operator.indexOf("null") > 0) {
|
||||
return !!this.variable && !!this.operator;
|
||||
}
|
||||
return !!this.variable && !!this.operator && !!this.value;
|
||||
}
|
||||
|
||||
label() {
|
||||
if (this.isValid()) {
|
||||
let label = this.variable;
|
||||
label += " " + this.operator;
|
||||
label += " " + this.value;
|
||||
if (this.operator) label += " " + this.operator;
|
||||
if (this.value) label += " " + this.value;
|
||||
return label;
|
||||
}
|
||||
return "";
|
||||
|
@ -1234,6 +1237,18 @@ class JMXGenerator {
|
|||
value = "\".*" + value + ".*\"";
|
||||
}
|
||||
|
||||
if (operator === "is null") {
|
||||
variable = "empty(\"" + variable + "\")";
|
||||
operator = "";
|
||||
value = "";
|
||||
}
|
||||
|
||||
if (operator === "is not null") {
|
||||
variable = "!empty(\"" + variable + "\")";
|
||||
operator = "";
|
||||
value = "";
|
||||
}
|
||||
|
||||
let condition = "${__jexl3(" + variable + operator + value + ")}";
|
||||
let controller = new JMXIfController(name, {condition: condition});
|
||||
controller.put(sampler);
|
||||
|
|
|
@ -142,6 +142,8 @@ export default {
|
|||
and: 'All',
|
||||
or: 'any one',
|
||||
operators: {
|
||||
is_null: "Is null",
|
||||
is_not_null: "Is not null",
|
||||
like: "Contains",
|
||||
not_like: "Not included",
|
||||
in: "Belong to",
|
||||
|
|
|
@ -142,6 +142,8 @@ export default {
|
|||
and: '所有',
|
||||
or: '任意一个',
|
||||
operators: {
|
||||
is_null: "空",
|
||||
is_not_null: "非空",
|
||||
like: "包含",
|
||||
not_like: "不包含",
|
||||
in: "属于",
|
||||
|
|
|
@ -142,6 +142,8 @@ export default {
|
|||
and: '所有',
|
||||
or: '任意壹個',
|
||||
operators: {
|
||||
is_null: "空",
|
||||
is_not_null: "非空",
|
||||
like: "包含",
|
||||
not_like: "不包含",
|
||||
in: "屬於",
|
||||
|
|
Loading…
Reference in New Issue