style: 前端缩进2个空格

This commit is contained in:
Captain.B 2020-09-27 18:54:23 +08:00
parent 95293a7377
commit 64039e93f8
1 changed files with 264 additions and 263 deletions

View File

@ -1,283 +1,284 @@
<template> <template>
<el-dialog :close-on-click-modal="false" width="60%" class="schedule-edit" :visible.sync="dialogVisible" <el-dialog :close-on-click-modal="false" width="60%" class="schedule-edit" :visible.sync="dialogVisible"
@close="close"> @close="close">
<template> <template>
<div> <div>
<el-tabs v-model="activeName" @tab-click="handleClick"> <el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane :label="$t('schedule.edit_timer_task')" name="first"> <el-tab-pane :label="$t('schedule.edit_timer_task')" name="first">
<el-form :model="form" :rules="rules" ref="from"> <el-form :model="form" :rules="rules" ref="from">
<el-form-item <el-form-item
prop="cronValue"> prop="cronValue">
<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 :disabled="isReadOnly" type="primary" @click="saveCron">{{
}} $t('commons.save')
</el-button> }}
</el-form-item> </el-button>
<el-form-item> </el-form-item>
<el-link :disabled="isReadOnly" type="primary" @click="showCronDialog"> <el-form-item>
{{ $t('schedule.generate_expression') }} <el-link :disabled="isReadOnly" type="primary" @click="showCronDialog">
</el-link> {{ $t('schedule.generate_expression') }}
</el-form-item> </el-link>
<crontab-result :ex="form.cronValue" ref="crontabResult"/> </el-form-item>
</el-form> <crontab-result :ex="form.cronValue" ref="crontabResult"/>
<el-dialog width="60%" :title="$t('schedule.generate_expression')" :visible.sync="showCron" </el-form>
:modal="false"> <el-dialog width="60%" :title="$t('schedule.generate_expression')" :visible.sync="showCron"
<crontab @hide="showCron=false" @fill="crontabFill" :expression="schedule.value" :modal="false">
ref="crontab"/> <crontab @hide="showCron=false" @fill="crontabFill" :expression="schedule.value"
</el-dialog> ref="crontab"/>
</el-tab-pane> </el-dialog>
<el-tab-pane :label="$t('schedule.task_notification')" name="second"> </el-tab-pane>
<template> <el-tab-pane :label="$t('schedule.task_notification')" name="second">
<el-table <template>
:data="tableData" <el-table
style="width: 100%"> :data="tableData"
<el-table-column style="width: 100%">
prop="event" <el-table-column
:label="$t('schedule.event')"> prop="event"
<template v-slot:default="{row}"> :label="$t('schedule.event')">
<span v-if="row.event === 'EXECUTE_SUCCESSFUL'"> {{ $t('schedule.event_success') }}</span> <template v-slot:default="{row}">
<span v-else-if="row.event === 'EXECUTE_FAILED'"> {{ $t('schedule.event_failed') }}</span> <span v-if="row.event === 'EXECUTE_SUCCESSFUL'"> {{ $t('schedule.event_success') }}</span>
<span v-else>{{ row.event }}</span> <span v-else-if="row.event === 'EXECUTE_FAILED'"> {{ $t('schedule.event_failed') }}</span>
</template> <span v-else>{{ row.event }}</span>
</el-table-column> </template>
<el-table-column </el-table-column>
prop="name" <el-table-column
:label="$t('schedule.receiver')" prop="name"
width="240" :label="$t('schedule.receiver')"
> width="240"
<template v-slot:default="{row}"> >
<el-select v-model="row.names" filterable multiple <template v-slot:default="{row}">
:placeholder="$t('commons.please_select')" <el-select v-model="row.names" filterable multiple
@click.native="userList()" style="width: 100%;"> :placeholder="$t('commons.please_select')"
<el-option @click.native="userList()" style="width: 100%;">
v-for="item in options" <el-option
:key="item.id" v-for="item in options"
:label="item.name" :key="item.id"
:value="item.name"> :label="item.name"
</el-option> :value="item.name">
</el-select> </el-option>
</template> </el-select>
</el-table-column> </template>
<el-table-column </el-table-column>
prop="type" <el-table-column
:label="$t('schedule.receiving_mode')" prop="type"
> :label="$t('schedule.receiving_mode')"
</el-table-column> >
<el-table-column </el-table-column>
:label="$t('test_resource_pool.enable_disable')" <el-table-column
prop="enable" :label="$t('test_resource_pool.enable_disable')"
> prop="enable"
<template v-slot:default="{row}"> >
<el-switch <template v-slot:default="{row}">
v-model="row.enable" <el-switch
active-value="true" v-model="row.enable"
inactive-value="false" active-value="true"
inactive-color="#DCDFE6" inactive-value="false"
/> inactive-color="#DCDFE6"
</template> />
</el-table-column> </template>
</el-table> </el-table-column>
<div style="padding-top: 20px;"> </el-table>
<el-button type="primary" @click="saveNotice">{{ $t('commons.save') }}</el-button> <div style="padding-top: 20px;">
</div> <el-button type="primary" @click="saveNotice">{{ $t('commons.save') }}</el-button>
</template> </div>
</el-tab-pane> </template>
</el-tabs> </el-tab-pane>
</div> </el-tabs>
</template> </div>
</el-dialog> </template>
</el-dialog>
</template> </template>
<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 {
name: "MsScheduleEdit",
components: {CrontabResult, Crontab},
props: {
testId: String,
save: Function,
schedule: {},
customValidate: {
type: Function,
default: defaultCustomValidate
},
isReadOnly: {
type: Boolean,
default: false
},
},
watch: {
'schedule.value'() {
this.form.cronValue = this.schedule.value;
} }
},
export default { data() {
name: "MsScheduleEdit", const validateCron = (rule, cronValue, callback) => {
components: {CrontabResult, Crontab}, let customValidate = this.customValidate(this.getIntervalTime());
props: { if (!cronValue) {
testId: String, callback(new Error(this.$t('commons.input_content')));
save: Function, } else if (!cronValidate(cronValue)) {
schedule: {}, callback(new Error(this.$t('schedule.cron_expression_format_error')));
customValidate: { }
type: Function, // else if(!this.intervalShortValidate()) {
default: defaultCustomValidate // callback(new Error(this.$t('schedule.cron_expression_interval_short_error')));
}, // }
isReadOnly: { else if (!customValidate.pass) {
type: Boolean, callback(new Error(customValidate.info));
default: false } else {
}, callback();
}
};
return {
operation: true,
dialogVisible: false,
showCron: false,
form: {
cronValue: ""
},
tableData: [
{
event: "EXECUTE_SUCCESSFUL",
type: "EMAIL",
names: [],
enable: false
}, },
{
event: "EXECUTE_FAILED",
watch: { type: "EMAIL",
'schedule.value'() { names: [],
this.form.cronValue = this.schedule.value; enable: false
}
},
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()) {
// callback(new Error(this.$t('schedule.cron_expression_interval_short_error')));
// }
else if (!customValidate.pass) {
callback(new Error(customValidate.info));
} else {
callback();
}
};
return {
operation: true,
dialogVisible: false,
showCron: false,
form: {
cronValue: ""
},
tableData: [
{
event: "EXECUTE_SUCCESSFUL",
type: "EMAIL",
names: [],
enable: false
},
{
event: "EXECUTE_FAILED",
type: "EMAIL",
names: [],
enable: false
}
],
options: [{}],
enable: true,
type: "",
activeName: 'first',
rules: {
cronValue: [{required: true, validator: validateCron, trigger: 'blur'}],
}
}
},
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
this.tableData[0].event = "EXECUTE_SUCCESSFUL"
this.tableData[0].type = "EMAIL"
this.tableData[1].event = "EXECUTE_FAILED"
this.tableData[1].type = "EMAIL"
} else {
this.tableData[0].names = []
this.tableData[1].names = []
}
})
}
},
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;
}
} }
],
options: [{}],
enable: true,
type: "",
activeName: 'first',
rules: {
cronValue: [{required: true, validator: validateCron, trigger: 'blur'}],
}
} }
},
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
this.tableData[0].event = "EXECUTE_SUCCESSFUL"
this.tableData[0].type = "EMAIL"
this.tableData[1].event = "EXECUTE_FAILED"
this.tableData[1].type = "EMAIL"
} else {
this.tableData[0].names = []
this.tableData[1].names = []
}
})
}
},
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;
} }
/deep/ .el-select__tags { /deep/ .el-select__tags {
flex-wrap: unset; flex-wrap: unset;
overflow: auto; overflow: auto;
} }
</style> </style>