This commit is contained in:
chenjianxing 2020-09-23 16:03:32 +08:00
commit 2e13831daa
10 changed files with 216 additions and 177 deletions

@ -1 +1 @@
Subproject commit e51e5704f9d7fbfb030a8a7d67d0094a9f36c23d Subproject commit 141ee64787b4a28ef108c5fa4dde90446de01887

View File

@ -6,12 +6,13 @@
<el-input size="small" v-model="controller.variable" :placeholder="$t('api_test.request.condition_variable')"/> <el-input size="small" v-model="controller.variable" :placeholder="$t('api_test.request.condition_variable')"/>
</el-col> </el-col>
<el-col :span="5"> <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-option v-for="o in operators" :key="o.value" :label="$t(o.label)" :value="o.value"/>
</el-select> </el-select>
</el-col> </el-col>
<el-col :span="6"> <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>
<el-col :span="4"> <el-col :span="4">
<el-switch v-model="controller.enable" :inactive-text="$t('api_test.scenario.enable_disable')"/> <el-switch v-model="controller.enable" :inactive-text="$t('api_test.scenario.enable_disable')"/>
@ -58,6 +59,14 @@ export default {
LT: { LT: {
label: "commons.adv_search.operators.lt", label: "commons.adv_search.operators.lt",
value: "<" 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() { remove() {
this.controller = new IfController(); this.controller = new IfController();
this.visible = false; 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;
} }
} }
} }

View File

@ -873,14 +873,17 @@ export class IfController extends Controller {
} }
isValid() { isValid() {
if (!!this.operator && this.operator.indexOf("null") > 0) {
return !!this.variable && !!this.operator;
}
return !!this.variable && !!this.operator && !!this.value; return !!this.variable && !!this.operator && !!this.value;
} }
label() { label() {
if (this.isValid()) { if (this.isValid()) {
let label = this.variable; let label = this.variable;
label += " " + this.operator; if (this.operator) label += " " + this.operator;
label += " " + this.value; if (this.value) label += " " + this.value;
return label; return label;
} }
return ""; return "";
@ -1234,6 +1237,18 @@ class JMXGenerator {
value = "\".*" + value + ".*\""; 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 condition = "${__jexl3(" + variable + operator + value + ")}";
let controller = new JMXIfController(name, {condition: condition}); let controller = new JMXIfController(name, {condition: condition});
controller.put(sampler); controller.put(sampler);

View File

@ -12,11 +12,11 @@
<el-input :disabled="isReadOnly" v-model="form.cronValue" class="inp" <el-input :disabled="isReadOnly" v-model="form.cronValue" class="inp"
:placeholder="$t('schedule.please_input_cron_expression')"/> :placeholder="$t('schedule.please_input_cron_expression')"/>
<!-- <el-button type="primary" @click="showCronDialog">{{$t('schedule.generate_expression')}}</el-button>--> <!-- <el-button type="primary" @click="showCronDialog">{{$t('schedule.generate_expression')}}</el-button>-->
<el-button :disabled="isReadOnly" type="primary" @click="saveCron">{{$t('commons.save')}}</el-button> <el-button :disabled="isReadOnly" type="primary" @click="saveCron">{{ $t('commons.save') }}</el-button>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-link :disabled="isReadOnly" type="primary" @click="showCronDialog"> <el-link :disabled="isReadOnly" type="primary" @click="showCronDialog">
{{$t('schedule.generate_expression')}} {{ $t('schedule.generate_expression') }}
</el-link> </el-link>
</el-form-item> </el-form-item>
<crontab-result :ex="form.cronValue" ref="crontabResult"/> <crontab-result :ex="form.cronValue" ref="crontabResult"/>
@ -71,7 +71,9 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-button type="primary" @click="saveNotice">{{$t('commons.save')}}</el-button> <div style="padding-top: 20px;">
<el-button type="primary" @click="saveNotice">{{ $t('commons.save') }}</el-button>
</div>
</template> </template>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
@ -82,177 +84,177 @@
<script> <script>
import Crontab from "../cron/Crontab"; import Crontab from "../cron/Crontab";
import CrontabResult from "../cron/CrontabResult"; import CrontabResult from "../cron/CrontabResult";
import {cronValidate} from "@/common/js/cron"; import {cronValidate} from "@/common/js/cron";
import {listenGoBack, removeGoBackListener} from "@/common/js/utils"; import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
function defaultCustomValidate() { function defaultCustomValidate() {
return {pass: true}; return {pass: true};
} }
export default { export default {
name: "MsScheduleEdit", name: "MsScheduleEdit",
components: {CrontabResult, Crontab}, components: {CrontabResult, Crontab},
props: { props: {
testId: String, testId: String,
save: Function, save: Function,
schedule: {}, schedule: {},
customValidate: { customValidate: {
type: Function, type: Function,
default: defaultCustomValidate default: defaultCustomValidate
},
isReadOnly: {
type: Boolean,
default: false
},
}, },
isReadOnly: {
type: Boolean,
default: false
},
},
watch: { watch: {
'schedule.value'() { 'schedule.value'() {
this.form.cronValue = this.schedule.value; this.form.cronValue = this.schedule.value;
}
},
data() {
const validateCron = (rule, cronValue, callback) => {
let customValidate = this.customValidate(this.getIntervalTime());
if (!cronValue) {
callback(new Error(this.$t('commons.input_content')));
} else if (!cronValidate(cronValue)) {
callback(new Error(this.$t('schedule.cron_expression_format_error')));
} }
}, // else if(!this.intervalShortValidate()) {
data() { // callback(new Error(this.$t('schedule.cron_expression_interval_short_error')));
const validateCron = (rule, cronValue, callback) => { // }
let customValidate = this.customValidate(this.getIntervalTime()); else if (!customValidate.pass) {
if (!cronValue) { callback(new Error(customValidate.info));
callback(new Error(this.$t('commons.input_content'))); } else {
} else if (!cronValidate(cronValue)) { callback();
callback(new Error(this.$t('schedule.cron_expression_format_error'))); }
} };
// else if(!this.intervalShortValidate()) { return {
// callback(new Error(this.$t('schedule.cron_expression_interval_short_error'))); operation: true,
// } dialogVisible: false,
else if (!customValidate.pass) { showCron: false,
callback(new Error(customValidate.info)); form: {
} else { cronValue: ""
callback(); },
} tableData: [
}; {
return { event: "执行成功",
operation: true, names: [],
dialogVisible: false, email: "邮箱",
showCron: false, enable: false
form: {
cronValue: ""
}, },
tableData: [ {
{ event: "执行失败",
event: "执行成功", names: [],
names: [], email: "邮箱",
email: "邮箱", enable: false
enable: false
},
{
event: "执行失败",
names: [],
email: "邮箱",
enable: false
}
],
options: [{}],
enable: true,
email: "",
activeName: 'first',
rules: {
cronValue: [{required: true, validator: validateCron, trigger: 'blur'}],
} }
} ],
}, options: [{}],
methods: { enable: true,
userList() { email: "",
this.result = this.$get('user/list', response => { activeName: 'first',
this.options = response.data rules: {
}) cronValue: [{required: true, validator: validateCron, trigger: 'blur'}],
},
handleClick() {
if (this.activeName == "second") {
this.result = this.$get('notice/query/' + this.testId, response => {
if (response.data.length > 0) {
this.tableData = response.data
}
})
}
},
buildParam() {
let param = {};
param.notices = this.tableData
param.testId = this.testId
return param;
},
open() {
this.dialogVisible = true;
this.form.cronValue = this.schedule.value;
listenGoBack(this.close);
this.handleClick()
this.activeName = 'first'
},
crontabFill(value, resultList) {
//
this.form.cronValue = value;
this.$refs.crontabResult.resultList = resultList;
this.$refs['from'].validate();
},
showCronDialog() {
this.showCron = true;
},
saveCron() {
this.$refs['from'].validate((valid) => {
if (valid) {
this.intervalShortValidate();
this.save(this.form.cronValue);
this.dialogVisible = false;
} else {
return false;
}
});
},
saveNotice(){
let param = this.buildParam();
this.result = this.$post("notice/save", param, () => {
this.$success(this.$t('commons.save_success'));
})
},
close() {
this.dialogVisible = false;
this.form.cronValue = '';
this.$refs['from'].resetFields();
if (!this.schedule.value) {
this.$refs.crontabResult.resultList = [];
}
removeGoBackListener(this.close);
},
intervalShortValidate() {
if (this.getIntervalTime() < 3 * 60 * 1000) {
// return false;
this.$info(this.$t('schedule.cron_expression_interval_short_error'));
}
return true;
},
resultListChange() {
this.$refs['from'].validate();
},
getIntervalTime() {
let resultList = this.$refs.crontabResult.resultList;
let time1 = new Date(resultList[0]);
let time2 = new Date(resultList[1]);
return time2 - time1;
} }
} }
},
methods: {
userList() {
this.result = this.$get('user/list', response => {
this.options = response.data
})
},
handleClick() {
if (this.activeName == "second") {
this.result = this.$get('notice/query/' + this.testId, response => {
if (response.data.length > 0) {
this.tableData = response.data
}
})
}
},
buildParam() {
let param = {};
param.notices = this.tableData
param.testId = this.testId
return param;
},
open() {
this.dialogVisible = true;
this.form.cronValue = this.schedule.value;
listenGoBack(this.close);
this.handleClick()
this.activeName = 'first'
},
crontabFill(value, resultList) {
//
this.form.cronValue = value;
this.$refs.crontabResult.resultList = resultList;
this.$refs['from'].validate();
},
showCronDialog() {
this.showCron = true;
},
saveCron() {
this.$refs['from'].validate((valid) => {
if (valid) {
this.intervalShortValidate();
this.save(this.form.cronValue);
this.dialogVisible = false;
} else {
return false;
}
});
},
saveNotice() {
let param = this.buildParam();
this.result = this.$post("notice/save", param, () => {
this.$success(this.$t('commons.save_success'));
})
},
close() {
this.dialogVisible = false;
this.form.cronValue = '';
this.$refs['from'].resetFields();
if (!this.schedule.value) {
this.$refs.crontabResult.resultList = [];
}
removeGoBackListener(this.close);
},
intervalShortValidate() {
if (this.getIntervalTime() < 3 * 60 * 1000) {
// return false;
this.$info(this.$t('schedule.cron_expression_interval_short_error'));
}
return true;
},
resultListChange() {
this.$refs['from'].validate();
},
getIntervalTime() {
let resultList = this.$refs.crontabResult.resultList;
let time1 = new Date(resultList[0]);
let time2 = new Date(resultList[1]);
return time2 - time1;
}
} }
}
</script> </script>
<style scoped> <style scoped>
.inp { .inp {
width: 50%; width: 50%;
margin-right: 20px; margin-right: 20px;
} }
.el-form-item { .el-form-item {
margin-bottom: 10px; margin-bottom: 10px;
} }
</style> </style>

View File

@ -113,6 +113,7 @@
import MsTableButton from '../../../../components/common/components/MsTableButton'; import MsTableButton from '../../../../components/common/components/MsTableButton';
import {listenGoBack, removeGoBackListener} from "../../../../../common/js/utils"; import {listenGoBack, removeGoBackListener} from "../../../../../common/js/utils";
import {TokenKey, WORKSPACE_ID} from '../../../../../common/js/constants'; import {TokenKey, WORKSPACE_ID} from '../../../../../common/js/constants';
import axios from "axios";
export default { export default {
name: "TestCaseImport", name: "TestCaseImport",
@ -188,7 +189,14 @@
this.$fileDownload('/test/case/export/template'); this.$fileDownload('/test/case/export/template');
}, },
downloadXmindTemplate() { downloadXmindTemplate() {
this.$fileDownload('/test/case/export/xmindTemplate'); axios.get('/test/case/export/xmindTemplate', {responseType: 'blob'})
.then(response => {
let fileName = window.decodeURI(response.headers['content-disposition'].split('=')[1]);
let link = document.createElement("a");
link.href = window.URL.createObjectURL(new Blob([response.data]));
link.download = fileName;
link.click();
});
}, },
upload(file) { upload(file) {
this.isLoading = false; this.isLoading = false;

View File

@ -29,17 +29,6 @@
<el-col :span="12" class="head-right"> <el-col :span="12" class="head-right">
<span class="head-right-tip" v-if="index + 1 === testCases.length">
{{ $t('test_track.plan_view.pre_case') }} : {{
testCases[index - 1] ? testCases[index - 1].name : ''
}}
</span>
<span class="head-right-tip" v-if="index + 1 !== testCases.length">
{{ $t('test_track.plan_view.next_case') }} : {{
testCases[index + 1] ? testCases[index + 1].name : ''
}}
</span>
<el-button plain size="mini" icon="el-icon-arrow-up" <el-button plain size="mini" icon="el-icon-arrow-up"
:disabled="index + 1 <= 1" :disabled="index + 1 <= 1"
@click="handlePre()"/> @click="handlePre()"/>

View File

@ -136,7 +136,7 @@ export default {
.then(response => { .then(response => {
let fileName = window.decodeURI(response.headers['content-disposition'].split('=')[1]); let fileName = window.decodeURI(response.headers['content-disposition'].split('=')[1]);
let link = document.createElement("a"); let link = document.createElement("a");
link.href = window.URL.createObjectURL(new Blob([response.data])); link.href = window.URL.createObjectURL(new Blob([response.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"}));
link.download = fileName; link.download = fileName;
link.click(); link.click();
}); });

View File

@ -142,6 +142,8 @@ export default {
and: 'All', and: 'All',
or: 'any one', or: 'any one',
operators: { operators: {
is_null: "Is null",
is_not_null: "Is not null",
like: "Contains", like: "Contains",
not_like: "Not included", not_like: "Not included",
in: "Belong to", in: "Belong to",

View File

@ -142,6 +142,8 @@ export default {
and: '所有', and: '所有',
or: '任意一个', or: '任意一个',
operators: { operators: {
is_null: "空",
is_not_null: "非空",
like: "包含", like: "包含",
not_like: "不包含", not_like: "不包含",
in: "属于", in: "属于",

View File

@ -142,6 +142,8 @@ export default {
and: '所有', and: '所有',
or: '任意壹個', or: '任意壹個',
operators: { operators: {
is_null: "空",
is_not_null: "非空",
like: "包含", like: "包含",
not_like: "不包含", not_like: "不包含",
in: "屬於", in: "屬於",