NEZ-351 perf: 底部滑框、侧滑框重构、动画优化
This commit is contained in:
@@ -1,130 +1,111 @@
|
||||
<template>
|
||||
<transition name="right-box">
|
||||
<div class="right-box right-box-alert-config" v-if="rightBox.show" v-clickoutside="clickos">
|
||||
<!-- begin--顶部按钮-->
|
||||
<div class="right-box-top-btns">
|
||||
<button type="button" v-if="alertRule.id != '' && rightBox.isEdit" id="alert-box-del" @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light nz-btn-min-width-82">
|
||||
<span class="right-box-top-btn-icon"><i class="el-icon-delete"></i></span>
|
||||
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
||||
</button>
|
||||
<button v-if="!rightBox.isEdit && alertRule.buildIn != 1" type="button" @click="saveOrToEdit" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light nz-btn-min-width-82" id="alert-box-edit">
|
||||
<span class="right-box-top-btn-icon"><i class="nz-icon nz-icon-edit"></i></span>
|
||||
<span class="right-box-top-btn-txt">{{$t('overall.edit')}}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- end--顶部按钮-->
|
||||
|
||||
<!-- begin--标题-->
|
||||
<div class="right-box-title">{{rightBox.title}}</div>
|
||||
<!-- end--标题-->
|
||||
|
||||
<!-- begin--表单-->
|
||||
<el-scrollbar class="right-box-form-box">
|
||||
<el-form class="right-box-form right-box-form-left" :model="alertRule" label-position="right" label-width="120px" :rules="rules" ref="alertRuleForm">
|
||||
<!--alertName-->
|
||||
<el-form-item :label='$t("alert.config.name")' prop="alertName">
|
||||
<el-input v-if="rightBox.isEdit" placeholder="" maxlength="64" show-word-limit v-model="alertRule.alertName" size="small"></el-input>
|
||||
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{alertRule.alertName}}</div>
|
||||
</el-form-item>
|
||||
<!--expr-->
|
||||
<!--<el-form-item :label="$t('alert.config.expr')" prop="expr">
|
||||
<el-input maxlength="512" rows="4" show-word-limit v-if="rightBox.isEdit" type="textarea" placeholder="" v-model="alertRule.expr" size="small"></el-input>
|
||||
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{alertRule.expr}}</div>
|
||||
</el-form-item>-->
|
||||
<promql-input
|
||||
ref="promql"
|
||||
:expression-list.sync="expressions"
|
||||
:index="0"
|
||||
:styleType="2"
|
||||
:plugins="['metric-input']"
|
||||
></promql-input>
|
||||
<!--operator-->
|
||||
<el-form-item :label="$t('alert.config.operator')" prop="operator" style="width: 400px;display: inline-block;">
|
||||
<el-select v-if="rightBox.isEdit" popper-class="config-dropdown" v-model="alertRule.operator" placeholder="" size="small">
|
||||
<el-option :id="'operator-'+item.key" v-for="item in operators" :key="item.value" :label="item.label" :value="item.value"></el-option>
|
||||
</el-select>
|
||||
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{alertRule.operator}}</div>
|
||||
</el-form-item>
|
||||
<!--threshold-->
|
||||
<el-form-item :label="$t('alert.config.threshold')" prop="threshold" style="width: 415px;display: inline-block;">
|
||||
<el-input v-if="rightBox.isEdit" type="text" placeholder="" v-model.number="alertRule.threshold" size="small">
|
||||
</el-input>
|
||||
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{alertRule.operator}}s</div>
|
||||
</el-form-item>
|
||||
<!--unit-->
|
||||
<el-form-item :label="$t('alert.config.unit')" prop="unit">
|
||||
<el-cascader filterable placeholder="" popper-class="no-style-class unit-popper-class" size="small" style="width: 100%"
|
||||
:options="unitOptions"
|
||||
:props="{ expandTrigger: 'click',emitPath:false }"
|
||||
:show-all-levels="false"
|
||||
v-model="alertRule.unit"
|
||||
>
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
<!--last-->
|
||||
<el-form-item :label="$t('alert.config.for')" prop="last">
|
||||
<el-input v-if="rightBox.isEdit" type="text" placeholder="" v-model.number="alertRule.last" size="small">
|
||||
<template slot="append">{{$t('alert.config.second')}}</template>
|
||||
</el-input>
|
||||
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{alertRule.last}}s</div>
|
||||
</el-form-item>
|
||||
<!--severity-->
|
||||
<el-form-item :label="$t('alert.severity')" prop="severity">
|
||||
<el-select v-if="rightBox.isEdit" popper-class="config-dropdown" v-model="alertRule.severity" placeholder="" size="small">
|
||||
<el-option :id="'alert-severity-'+item.key" v-for="item in severityData" :key="item.key" :label="item.value" :value="item.key">
|
||||
<template v-if="!item.isEdit">{{item.value}}</template>
|
||||
<span class="config-dropdown-label-input" v-if="item.isEdit" @click.stop>
|
||||
<el-input type="text" v-model="item.name" size="mini"></el-input>
|
||||
</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{alertRule.severity}}</div>
|
||||
</el-form-item>
|
||||
<!--receiver-->
|
||||
<el-form-item :label="$t('config.account.receiver')" prop="receiver">
|
||||
<el-select
|
||||
v-model.trim="alertRule.receiverShow"
|
||||
placeholder=""
|
||||
multiple
|
||||
filterable
|
||||
size="small"
|
||||
value-key="userId"
|
||||
popper-class="no-style-class"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in userData"
|
||||
:key="item.userId"
|
||||
:label="item.username"
|
||||
:value="item.userId">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!--summary-->
|
||||
<el-form-item :label="$t('alert.summary')" prop="summary">
|
||||
<el-input maxlength="512" rows="3" type="textarea" show-word-limit v-if="rightBox.isEdit" placeholder="" v-model="alertRule.summary" size="small"></el-input>
|
||||
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{alertRule.summary}}</div>
|
||||
</el-form-item>
|
||||
<!--description-->
|
||||
<el-form-item :label="$t('alert.description')" prop="description">
|
||||
<el-input maxlength="512" rows="4" show-word-limit v-if="rightBox.isEdit" type="textarea" placeholder="" v-model="alertRule.description" size="small"></el-input>
|
||||
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{alertRule.description}}</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-scrollbar>
|
||||
<!-- end--表单-->
|
||||
|
||||
<!--底部按钮-->
|
||||
<div class="right-box-bottom-btns">
|
||||
<button @click="esc" id="alert-box-esc" class="nz-btn nz-btn-size-normal nz-btn-style-light nz-btn-min-width-100">
|
||||
<span>{{$t('overall.cancel')}}</span>
|
||||
</button>
|
||||
<button v-if="rightBox.isEdit" @click="saveOrToEdit" id="alert-box-save" class="nz-btn nz-btn-size-normal nz-btn-style-normal nz-btn-min-width-100">
|
||||
<span>{{$t('overall.save')}}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="right-box right-box-alert-config" v-clickoutside="clickOutside">
|
||||
<!-- begin--顶部按钮-->
|
||||
<div class="right-box-top-btns">
|
||||
<button type="button" v-if="alertRule.id" id="alert-box-del" @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light">
|
||||
<span class="right-box-top-btn-icon"><i class="el-icon-delete"></i></span>
|
||||
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
||||
</button>
|
||||
</div>
|
||||
</transition>
|
||||
<!-- end--顶部按钮-->
|
||||
|
||||
<!-- begin--标题-->
|
||||
<div class="right-box-title">{{editAlertRule.id ? $t("alert.config.editAlertConfig") + " ID:" + editAlertRule.id : $t("alert.config.createAlertConfig")}}</div>
|
||||
<!-- end--标题-->
|
||||
|
||||
<!-- begin--表单-->
|
||||
<el-scrollbar class="right-box-form-box">
|
||||
<el-form class="right-box-form right-box-form-left" :model="editAlertRule" label-position="right" label-width="120px" :rules="rules" ref="alertRuleForm">
|
||||
<!--alertName-->
|
||||
<el-form-item :label='$t("alert.config.name")' prop="alertName">
|
||||
<el-input placeholder="" maxlength="64" show-word-limit v-model="editAlertRule.alertName" size="small"></el-input>
|
||||
</el-form-item>
|
||||
<promql-input
|
||||
ref="promql"
|
||||
:expression-list.sync="expressions"
|
||||
:index="0"
|
||||
:styleType="2"
|
||||
:plugins="['metric-input']"
|
||||
></promql-input>
|
||||
<!--operator-->
|
||||
<el-form-item :label="$t('alert.config.operator')" prop="operator" style="width: 400px;display: inline-block;">
|
||||
<el-select popper-class="config-dropdown" v-model="editAlertRule.operator" placeholder="" size="small">
|
||||
<el-option :id="'operator-'+item.key" v-for="item in operators" :key="item.value" :label="item.label" :value="item.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!--threshold-->
|
||||
<el-form-item :label="$t('alert.config.threshold')" prop="threshold" style="width: 415px;display: inline-block;">
|
||||
<el-input type="text" placeholder="" v-model.number="editAlertRule.threshold" size="small">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<!--unit-->
|
||||
<el-form-item :label="$t('alert.config.unit')" prop="unit">
|
||||
<el-cascader filterable placeholder="" popper-class="no-style-class unit-popper-class" size="small" style="width: 100%"
|
||||
:options="unitOptions"
|
||||
:props="{ expandTrigger: 'click',emitPath:false }"
|
||||
:show-all-levels="false"
|
||||
v-model="editAlertRule.unit"
|
||||
>
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
<!--last-->
|
||||
<el-form-item :label="$t('alert.config.for')" prop="last">
|
||||
<el-input type="text" placeholder="" v-model.number="editAlertRule.last" size="small">
|
||||
<template slot="append">{{$t('alert.config.second')}}</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<!--severity-->
|
||||
<el-form-item :label="$t('alert.severity')" prop="severity">
|
||||
<el-select popper-class="config-dropdown" v-model="editAlertRule.severity" placeholder="" size="small">
|
||||
<el-option :id="'alert-severity-'+item.key" v-for="item in severityData" :key="item.key" :label="item.value" :value="item.key">
|
||||
<template v-if="!item.isEdit">{{item.value}}</template>
|
||||
<span class="config-dropdown-label-input" v-if="item.isEdit" @click.stop>
|
||||
<el-input type="text" v-model="item.name" size="mini"></el-input>
|
||||
</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!--receiver-->
|
||||
<el-form-item :label="$t('config.account.receiver')" prop="receiver">
|
||||
<el-select
|
||||
v-model.trim="editAlertRule.receiverShow"
|
||||
placeholder=""
|
||||
multiple
|
||||
filterable
|
||||
size="small"
|
||||
value-key="userId"
|
||||
popper-class="no-style-class"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in userData"
|
||||
:key="item.userId"
|
||||
:label="item.username"
|
||||
:value="item.userId">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!--summary-->
|
||||
<el-form-item :label="$t('alert.summary')" prop="summary">
|
||||
<el-input maxlength="512" rows="3" type="textarea" show-word-limit placeholder="" v-model="editAlertRule.summary" size="small"></el-input>
|
||||
</el-form-item>
|
||||
<!--description-->
|
||||
<el-form-item :label="$t('alert.description')" prop="description">
|
||||
<el-input maxlength="512" rows="4" show-word-limit type="textarea" placeholder="" v-model="editAlertRule.description" size="small"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-scrollbar>
|
||||
<!-- end--表单-->
|
||||
|
||||
<!--底部按钮-->
|
||||
<div class="right-box-bottom-btns">
|
||||
<button @click="esc(false)" id="alert-box-esc" class="nz-btn nz-btn-size-normal nz-btn-style-light nz-btn-min-width-100">
|
||||
<span>{{$t('overall.cancel')}}</span>
|
||||
</button>
|
||||
<button @click="save" id="alert-box-save" class="nz-btn nz-btn-size-normal nz-btn-style-normal nz-btn-min-width-100">
|
||||
<span>{{$t('overall.save')}}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -133,7 +114,7 @@
|
||||
export default {
|
||||
name: "alertConfigBox",
|
||||
props: {
|
||||
parentAlertRule: Object
|
||||
alertRule: Object
|
||||
},
|
||||
components: {
|
||||
'promql-input': promqlInput,
|
||||
@@ -145,8 +126,7 @@
|
||||
expressions: [''],
|
||||
legends: [''],
|
||||
|
||||
alertRule: {id: '', receiverShow: [], receiver: ''},
|
||||
rightBox: {show: false, isEdit: false, title: ''},
|
||||
editAlertRule: {},
|
||||
rules:{
|
||||
alertName:[
|
||||
{required:true,message:this.$t('validate.required'),trigger:'blur'}
|
||||
@@ -174,13 +154,6 @@
|
||||
{required:true,message:this.$t('validate.required'),trigger:'blur'},
|
||||
{type:'number',message:this.$t('validate.number')}
|
||||
],
|
||||
|
||||
// description:[
|
||||
// {required:true,message:this.$t('validate.required'),trigger:'blur'},
|
||||
// ],
|
||||
// receiver:[
|
||||
// {required:true,message:this.$t('validate.required'),trigger:'change'},
|
||||
// ]
|
||||
},
|
||||
severityData: [
|
||||
{
|
||||
@@ -222,7 +195,7 @@
|
||||
value:'<='
|
||||
},
|
||||
],
|
||||
unitOptions:chartDataFormat.unitOptions(),
|
||||
unitOptions: chartDataFormat.unitOptions(),
|
||||
typeData: [
|
||||
{
|
||||
key: 1, //project
|
||||
@@ -238,38 +211,34 @@
|
||||
}
|
||||
],
|
||||
userData: [],
|
||||
linkObjList: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clickos() {
|
||||
this.rightBox.show = false;
|
||||
clickOutside() {
|
||||
this.esc(false);
|
||||
},
|
||||
show(show, isEdit) {
|
||||
this.rightBox.show = show;
|
||||
this.rightBox.isEdit = isEdit;
|
||||
esc(refresh) {
|
||||
this.$emit("close", refresh);
|
||||
},
|
||||
save: function() {
|
||||
this.alertRule.expr = this.expressions[0];
|
||||
save() {
|
||||
this.editAlertRule.expr = this.expressions[0];
|
||||
this.$refs.alertRuleForm.validate((valid) => {
|
||||
if (valid) {
|
||||
this.alertRule.receiver = this.alertRule.receiverShow.join(",");
|
||||
if (this.alertRule.id) {
|
||||
this.$put('alert/rule', this.alertRule).then(response => {
|
||||
this.editAlertRule.receiver = this.editAlertRule.receiverShow.join(",");
|
||||
if (this.editAlertRule.id) {
|
||||
this.$put('alert/rule', this.editAlertRule).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
||||
this.$emit('reload');
|
||||
this.rightBox.show = false;
|
||||
this.esc(true);
|
||||
} else {
|
||||
this.$message.error(response.msg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$post('alert/rule', this.alertRule).then(response => {
|
||||
this.$post('alert/rule', this.editAlertRule).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
||||
this.$emit('reload');
|
||||
this.rightBox.show = false;
|
||||
this.esc(true);
|
||||
} else {
|
||||
this.$message.error(response.msg);
|
||||
}
|
||||
@@ -280,42 +249,22 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
del: function() {
|
||||
del() {
|
||||
this.$confirm(this.$t("tip.confirmDelete"), {
|
||||
confirmButtonText: this.$t("tip.yes"),
|
||||
cancelButtonText: this.$t("tip.no"),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$delete("alert/rule?ids=" + this.alertRule.id).then(response => {
|
||||
this.$delete("alert/rule?ids=" + this.editAlertRule.id).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.$message({type: 'success', message: this.$t("tip.deleteSuccess")});
|
||||
this.$emit('reload');
|
||||
this.rightBox.show = false;
|
||||
this.esc(true);
|
||||
} else {
|
||||
this.$message.error(response.msg);
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
saveOrToEdit: function() {
|
||||
if (!this.rightBox.isEdit) {
|
||||
this.rightBox.isEdit = true;
|
||||
this.rightBox.title = this.$t("alert.config.editAlertConfig") + " ID:" + this.alertRule.id;
|
||||
} else {
|
||||
this.save();
|
||||
}
|
||||
},
|
||||
esc: function() {
|
||||
this.rightBox.show = false;
|
||||
},
|
||||
|
||||
getProjectList() {
|
||||
this.$get('project', {pageNo: 1, pageSize: -1}).then(response => {
|
||||
if (response.code == 200) {
|
||||
this.linkObjList = response.data.list;
|
||||
}
|
||||
})
|
||||
},
|
||||
getUserList() {
|
||||
this.$get('sys/user/list', {pageNo: 1, pageSize: -1}).then(response => {
|
||||
if (response.code == 200) {
|
||||
@@ -323,40 +272,19 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
getModuleList() {
|
||||
this.$get('module', {pageNo: 1, pageSize: -1}).then(response => {
|
||||
if (response.code == 200) {
|
||||
this.linkObjList = response.data.list;
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
getAssetList() {
|
||||
this.$get('asset', {pageNo: 1, pageSize: -1}).then(response => {
|
||||
if (response.code == 200) {
|
||||
this.linkObjList = response.data.list;
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
created() {
|
||||
mounted() {
|
||||
this.getUserList();
|
||||
this.rightBox.title = this.$t("alert.config.createAlertConfig");
|
||||
},
|
||||
watch: {
|
||||
parentAlertRule: {
|
||||
alertRule: {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler(n, o) {
|
||||
this.alertRule = n;
|
||||
if (this.alertRule.id) {
|
||||
if (this.alertRule.type == 1) {
|
||||
this.getProjectList();
|
||||
} else if (this.alertRule.type == 2) {
|
||||
this.getModuleList();
|
||||
} else if (this.alertRule.type == 3) {
|
||||
this.getAssetList();
|
||||
}
|
||||
this.expressions = [this.alertRule.expr];
|
||||
console.info(n)
|
||||
this.editAlertRule = JSON.parse(JSON.stringify(n));
|
||||
if (this.editAlertRule.id) {
|
||||
this.expressions = [this.editAlertRule.expr];
|
||||
this.$nextTick(() => {
|
||||
this.expressions.forEach((ex, index) => {
|
||||
if (ex) {
|
||||
@@ -365,24 +293,11 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
if (this.rightBox.show) {
|
||||
if (this.rightBox.isEdit && this.alertRule.id) {
|
||||
this.rightBox.title = this.$t("alert.config.editAlertConfig") + " ID:" + this.alertRule.id;
|
||||
} else if (this.rightBox.isEdit && !this.alertRule.id) {
|
||||
this.rightBox.title = this.$t("alert.config.createAlertConfig");
|
||||
} else if (!this.rightBox.isEdit && this.alertRule.id) {
|
||||
this.rightBox.title = this.$t("alert.config.alertConfig") + " ID:" + this.alertRule.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<style>
|
||||
.unit-popper-class{
|
||||
z-index: 2052 !important;
|
||||
|
||||
Reference in New Issue
Block a user