Commit d565627b authored by 赵伟庚's avatar 赵伟庚

[feat](预警规则设置): 静态列表页及交互弹窗完成

parent 552e1f78
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
@keydown.enter="search" @keydown.enter="search"
@clear="search" @clear="search"
clearable clearable
:style="{ width: inputWidth }"
v-model.trim="modelValue"> v-model.trim="modelValue">
<template #append> <template #append>
<div class="append-btn" @click="search"> <div class="append-btn" @click="search">
...@@ -59,6 +60,10 @@ const props = defineProps({ ...@@ -59,6 +60,10 @@ const props = defineProps({
type: Boolean, type: Boolean,
default: true, default: true,
}, },
inputWidth: {
type: String,
default: "280px",
},
}); });
watch(props, (n, o) => { watch(props, (n, o) => {
......
...@@ -1999,7 +1999,7 @@ a { ...@@ -1999,7 +1999,7 @@ a {
flex: 1; flex: 1;
} }
.right-filter { .right-filter {
width: 398px; min-width: 398px;
justify-content: end; justify-content: end;
display: flex; display: flex;
.el-input { .el-input {
......
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
</bg-pagination> </bg-pagination>
</div> </div>
</div> </div>
<!-- todo: 推送提醒 --> <!-- 推送提醒 -->
<el-dialog title="推送提醒" v-model="pushDialog" width="780px" :before-close="cancelPushDialog"> <el-dialog title="推送提醒" v-model="pushDialog" width="780px" :before-close="cancelPushDialog">
<div class="warning_info"> <div class="warning_info">
<bg-icon <bg-icon
...@@ -537,8 +537,8 @@ const pushConfirm = () => { ...@@ -537,8 +537,8 @@ const pushConfirm = () => {
if (state.pushType == 1) { if (state.pushType == 1) {
ids.push(state.actionRow.id); ids.push(state.actionRow.id);
} else { } else {
state.selected.forEach((e) => { ids = state.selected.map((e) => {
ids.push(e.id); return e.id;
}); });
} }
let params = { let params = {
...@@ -573,8 +573,8 @@ const confirmClose = () => { ...@@ -573,8 +573,8 @@ const confirmClose = () => {
if (state.closeType == 1) { if (state.closeType == 1) {
ids.push(state.actionRow.id); ids.push(state.actionRow.id);
} else { } else {
state.selected.forEach((e) => { ids = state.selected.map((e) => {
ids.push(e.id); return e.id;
}); });
} }
let params = { let params = {
......
<template>
<div>规则详情</div>
</template>
<script setup></script>
<style lang="scss" scoped></style>
...@@ -2,14 +2,18 @@ ...@@ -2,14 +2,18 @@
<div class="detail_container"> <div class="detail_container">
<bg-breadcrumb></bg-breadcrumb> <bg-breadcrumb></bg-breadcrumb>
<div class="main_container"> <div class="main_container">
<bg-filter-group @search="changeSearch" v-model="filter.search" placeholder="请输入预警点/分类/指标"> <bg-filter-group
@search="changeSearch"
v-model="filter.search"
inputWidth="380px"
placeholder="请输入预警规则名称/预警对象/预警分类/预警指标">
<template v-slot:left_action> <template v-slot:left_action>
<div class="apaas_button"> <div class="apaas_button">
<el-button type="primary" @click="batchPush"> <el-button type="primary" @click="addRule">
<bg-icon style="font-size: 12px; color: #fff; margin-right: 8px" icon="#bg-ic-edit"></bg-icon> <bg-icon style="font-size: 12px; color: #fff; margin-right: 8px" icon="#bg-ic-add"></bg-icon>
新增 新增
</el-button> </el-button>
<el-button type="default" @click="batchDelete"> 批量删除 </el-button> <el-button type="default" @click="batchDelete">批量删除</el-button>
<span class="header_info" <span class="header_info"
>已选择 <span style="color: #202531; font-weight: bold"> {{ state.selected.length }} </span> >已选择 <span style="color: #202531; font-weight: bold"> {{ state.selected.length }} </span>
</span> </span>
...@@ -18,41 +22,19 @@ ...@@ -18,41 +22,19 @@
</template> </template>
<template v-slot:filter_group> <template v-slot:filter_group>
<div class="left-filter filter_list"> <div class="left-filter filter_list">
<!-- <div class="filter_item">
<span class="filter_title">预警分类</span>
<el-select v-model="filter.warning_type" placeholder="请选择" style="width: 300px">
<el-option
v-for="(item, index) in warningTypes"
:key="'warningType' + index"
:label="item.name"
:value="item.value">
</el-option>
</el-select>
</div>
<div class="filter_item">
<span class="filter_title">预警指标</span>
<el-select v-model="filter.warning_target" placeholder="请选择" style="width: 300px">
<el-option
v-for="(item, index) in warningTargets"
:key="'warningTargets' + index"
:label="item.name"
:value="item.value">
</el-option>
</el-select>
</div> -->
<div class="filter_item"> <div class="filter_item">
<span class="filter_title">风险等级</span> <span class="filter_title">通知方式</span>
<el-select v-model="filter.risk_level" placeholder="请选择" style="width: 300px"> <el-select v-model="filter.notice_method" placeholder="请选择" style="width: 300px">
<el-option <el-option
v-for="(item, index) in riskLevels" v-for="(item, index) in noticeTypes"
:key="'riskLevels' + index" :key="'noticeTypes' + index"
:label="item.name" :label="item.name"
:value="item.value"> :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
</div> </div>
<div class="filter_item"> <div class="filter_item">
<span class="filter_title">状态</span> <span class="filter_title">启用状态</span>
<el-select v-model="filter.state" placeholder="请选择" style="width: 300px"> <el-select v-model="filter.state" placeholder="请选择" style="width: 300px">
<el-option <el-option
v-for="(item, index) in stateOptions" v-for="(item, index) in stateOptions"
...@@ -63,7 +45,7 @@ ...@@ -63,7 +45,7 @@
</el-select> </el-select>
</div> </div>
<div class="filter_item"> <div class="filter_item">
<span class="filter_title">预警时间</span> <span class="filter_title">时段</span>
<el-date-picker <el-date-picker
style="width: 300px" style="width: 300px"
v-model="filter.time" v-model="filter.time"
...@@ -90,25 +72,28 @@ ...@@ -90,25 +72,28 @@
:isIndex="true" :isIndex="true"
:select="true" :select="true"
:stripe="true"> :stripe="true">
<template v-slot:warning_point="{ row }"> <template v-slot:rule_name="{ row }">
<span class="can_click_text" @click="goDetail(row)"> <span class="can_click_text" @click="goDetail(row)">
{{ row.warning_point }} {{ row.rule_name }}
</span> </span>
</template> </template>
<template v-slot:warning_time="{ row }"> <template v-slot:notice_method="{ row }">
{{ row.warning_time ? row.warning_time.split("+")[0].replace("T", " ").replace("Z", " ") : "-" }} {{ ["", "钉钉", "短信"][row.notice_method] }}
</template>
<template v-slot:last_push_time="{ row }">
{{ row.last_push_time ? row.last_push_time.split("+")[0].replace("T", " ").replace("Z", " ") : "-" }}
</template> </template>
<template #state="{ row }"> <template #state="{ row }">
<span :class="`circle bgc_${row.state}`"></span> <bg-switch
{{ ["未恢复", "已恢复", "已关闭"][row.state] }} @click="stateChange(row)"
:labels="['否', '是']"
:values="[0, 1]"
v-model="row.state"></bg-switch>
</template>
<template v-slot:created_time="{ row }">
{{ row.created_time ? row.created_time.split("+")[0].replace("T", " ").replace("Z", " ") : "-" }}
</template> </template>
<template v-slot:action="{ row }"> <template v-slot:action="{ row }">
<bg-table-btns2 :limit="3" :tableData="tableRows"> <bg-table-btns2 :limit="3" :tableData="tableRows">
<bg-table-btn :disabled="row.state != 0" @click="pushWarning(row)">编辑</bg-table-btn> <bg-table-btn :disabled="row.state != 0" @click="editRow(row)">编辑</bg-table-btn>
<bg-table-btn :disabled="row.state != 0" @click="closeWarning(row)">删除</bg-table-btn> <bg-table-btn :disabled="row.state != 0" @click="deleteRow(row)">删除</bg-table-btn>
</bg-table-btns2> </bg-table-btns2>
</template> </template>
</bg-table> </bg-table>
...@@ -122,26 +107,13 @@ ...@@ -122,26 +107,13 @@
</bg-pagination> </bg-pagination>
</div> </div>
</div> </div>
<!-- todo: 推送提醒 --> <!-- 删除 -->
<el-dialog title="推送提醒" v-model="pushDialog" width="780px" :before-close="cancelPushDialog"> <el-dialog class="dialog_box" title="删除" v-model="delDialog" width="420px">
<div class="warning_info"> <div>确定要删除吗?</div>
<bg-icon
style="font-size: 12px; color: #a9b1c7; margin-right: 8px; vertical-align: middle"
icon="#bg-ic-s-circle-tips"></bg-icon
>该推送为临时推送,可调整推送人员,仅本次有效!如固定通知人员,则前往【预警规则设置】调整预警内容
</div>
<el-form ref="pushForm" :model="pushFormData" :rules="pushRules" label-width="120px" class="bg_form">
<el-form-item label="预警工单推送" prop="method" style="margin-bottom: 24px">
<el-checkbox-group v-model="pushFormData.method">
<el-checkbox :label="1">钉钉</el-checkbox>
<el-checkbox :label="2">短信</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
<template v-slot:footer> <template v-slot:footer>
<div class="apaas_button"> <div class="apaas_button">
<el-button type="default" @click="cancelPushDialog">取消</el-button> <el-button type="default" @click="delDialog = false">取消</el-button>
<el-button type="primary" @click="pushConfirm">确定</el-button> <el-button type="primary" @click="delConfirm">确定</el-button>
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
...@@ -158,52 +130,20 @@ import { useRouter } from "vue-router"; ...@@ -158,52 +130,20 @@ import { useRouter } from "vue-router";
const router = useRouter(); const router = useRouter();
const bgForm = ref(null);
const dataTable = ref(null); const dataTable = ref(null);
const closeForm = ref(null);
const userTable = ref(null);
const pushForm = ref(null);
const state = reactive({ const state = reactive({
warningTypes: [ noticeTypes: [
{
name: "全部",
value: "",
},
{
name: "分类1",
value: 1,
},
{
name: "分类2",
value: 2,
},
], // 预警分类数据
warningTargets: [
{
name: "全部",
value: "",
},
{
name: "指标1",
value: 1,
},
{
name: "指标2",
value: 2,
},
], // 预警指标数据
riskLevels: [
{ {
name: "全部", name: "全部",
value: "", value: "",
}, },
{ {
name: "等级1", name: "钉钉",
value: 1, value: 1,
}, },
{ {
name: "等级2", name: "短信",
value: 2, value: 2,
}, },
], // 风险等级 ], // 风险等级
...@@ -213,28 +153,23 @@ const state = reactive({ ...@@ -213,28 +153,23 @@ const state = reactive({
value: "", value: "",
}, },
{ {
name: "已恢复", name: "启用",
value: "1", value: 1,
},
{
name: "未恢复",
value: "0",
}, },
{ {
name: "已关闭", name: "停用",
value: "2", value: 2,
}, },
], // 状态 ], // 状态
headers: [ headers: [
{ {
label: "预警", label: "预警规则名称",
prop: "warning_point", prop: "rule_name",
width: 180, width: 200,
}, },
{ {
label: "预警时间", label: "预警对象",
prop: "warning_time", prop: "warning_object",
width: 160,
}, },
{ {
label: "预警分类", label: "预警分类",
...@@ -245,41 +180,30 @@ const state = reactive({ ...@@ -245,41 +180,30 @@ const state = reactive({
prop: "warning_target_name", prop: "warning_target_name",
}, },
{ {
label: "风险等级", label: "通知方式",
prop: "risk_level_name", prop: "notice_method",
},
{
label: "当前报警值",
prop: "now_warn_data",
},
{
label: "预警阈值",
prop: "warn_threshold",
}, },
{ {
label: "通知人数", label: "通知人数",
prop: "notice_people_num", prop: "notice_people_num",
width: 80,
}, },
{ {
label: "推送次数", label: "是否启用",
prop: "push_times", prop: "state",
width: 80,
}, },
{ {
label: "最后推送时间", label: "创建人",
prop: "last_push_time", prop: "created_user",
width: 160,
}, },
{ {
label: "状态", label: "创建时间",
prop: "state", prop: "created_time",
width: 90, width: 160,
}, },
{ {
label: "操作", label: "操作",
prop: "action", prop: "action",
width: 180, width: 136,
fixed: "right", fixed: "right",
}, },
], ],
...@@ -287,9 +211,7 @@ const state = reactive({ ...@@ -287,9 +211,7 @@ const state = reactive({
selected: [], //选择数据 selected: [], //选择数据
tableTotal: 0, // 表格数据条数 tableTotal: 0, // 表格数据条数
filter: { filter: {
warning_type: "", // 预警类型 notice_method: "", // 通知方式
warning_target: "", // 预警指标
risk_level: "", // 风险等级
state: "", // 状态 state: "", // 状态
time: [], time: [],
search: "", search: "",
...@@ -297,26 +219,8 @@ const state = reactive({ ...@@ -297,26 +219,8 @@ const state = reactive({
limit: 10, limit: 10,
}, // 表格筛选项 }, // 表格筛选项
actionRow: null, // 当前操作的数据 actionRow: null, // 当前操作的数据
closeWarningDialog: false, // 删除弹窗 delDialog: false, // 删除弹窗
closeFormData: { delType: 0, // 1-单条删除 2-批量删除
close_notes: "",
close_remind: false,
},
closeRules: {
close_notes: [{ required: true, message: "请输入关闭备注", trigger: "blur" }],
},
pushDialog: false,
userData: [],
pushFormData: {
method: [],
},
pushRules: {
method: [{ type: "array", required: true, message: "请最少选择一种推送方式", trigger: "change" }],
},
});
const userTableFlag = computed(() => {
return !!state.pushDialog;
}); });
const selectRows = (data) => { const selectRows = (data) => {
...@@ -329,11 +233,17 @@ const clearSelected = () => { ...@@ -329,11 +233,17 @@ const clearSelected = () => {
const batchDelete = () => { const batchDelete = () => {
console.log("批量删除"); console.log("批量删除");
if (!state.selected || state.selected.length == 0) {
ElMessage.error("请先勾选要删除的数据");
return;
}
state.delType = 2;
state.delDialog = true;
}; // 批量删除 }; // 批量删除
const goDetail = (row) => { const goDetail = (row) => {
console.log("去详情"); console.log("去详情");
router.push(`/forewarning/list/detail?id=${row.id}`); router.push(`/forewarning/rule-set/detail?id=${row.id}`);
}; // 查看详情 }; // 查看详情
const changeSearch = (val) => { const changeSearch = (val) => {
...@@ -347,9 +257,7 @@ const filterAction = () => { ...@@ -347,9 +257,7 @@ const filterAction = () => {
const filterClear = () => { const filterClear = () => {
state.filter = { state.filter = {
warning_type: "", // 预警类型 notice_method: "", // 通知方式
warning_target: "", // 预警指标
risk_level: "", // 风险等级
state: "", // 状态 state: "", // 状态
time: "", time: "",
search: "", search: "",
...@@ -377,45 +285,39 @@ const getTableRows = () => { ...@@ -377,45 +285,39 @@ const getTableRows = () => {
state.tableRows = [ state.tableRows = [
{ {
id: 1, id: 1,
warning_point: "容器云/tyyh", rule_name: "容器云/tyyh",
warning_time: "2020-01-01 00:00:00", warning_object: "容器云",
warning_type_name: "容器组", warning_type_name: "容器组",
warning_target_name: "服务中断", warning_target_name: "服务中断",
risk_level_name: "重大风险", notice_people_num: 1,
now_warn_data: "", created_user: "王五",
warn_threshold: "", created_time: "2020-01-01 00:00:00",
notice_people_num: 2, state: 1,
push_times: 2, notice_method: 1,
last_push_time: "2020-01-01 00:00:00",
state: 0,
}, },
{ {
id: 2, id: 2,
warning_point: "容器云/kube-apiserver", rule_name: "容器云/kube-apiserver",
warning_time: "2020-01-01 00:00:00", warning_object: "容器云",
warning_type_name: "容器集群", warning_type_name: "容器集群",
warning_target_name: "内存使用率", warning_target_name: "内存使用率",
risk_level_name: "较大风险", notice_people_num: 23,
now_warn_data: "66%", created_user: "李四",
warn_threshold: "60%-70%", created_time: "2020-01-01 00:00:00",
notice_people_num: 3,
push_times: 1,
last_push_time: "2020-01-01 00:00:00",
state: 0, state: 0,
notice_method: 2,
}, },
{ {
id: 3, id: 3,
warning_point: "容器云/kube-apiserver", rule_name: "容器云/kube-apiserver",
warning_time: "2020-01-01 00:00:00", warning_object: "容器云",
warning_type_name: "容器集群", warning_type_name: "容器集群",
warning_target_name: "内存使用率", warning_target_name: "内存使用率",
risk_level_name: "较大风险", notice_people_num: 456,
now_warn_data: "66%", created_user: "张三",
warn_threshold: "60%-70%", created_time: "2020-01-01 00:00:00",
notice_people_num: 3, state: 0,
push_times: 1, notice_method: 1,
last_push_time: "2020-01-01 00:00:00",
state: 2,
}, },
]; ];
}; // 获取表格数据 }; // 获取表格数据
...@@ -430,94 +332,60 @@ const changeSize = (size) => { ...@@ -430,94 +332,60 @@ const changeSize = (size) => {
changePage(1); changePage(1);
}; // 改变每页条数 }; // 改变每页条数
const batchPush = () => { const stateChange = (row) => {
console.log("批量推送"); console.log("更改状态");
}; // 批量推送 // axios
// .put(`/xxx/xxx?id=${row.id}&state=${row.state}`)
const pushWarning = (row) => { // .then((res) => {
state.actionRow = row; // if (res.data.code == 200) {
console.log("推送提醒"); // ElMessage.success(res.data.msg);
state.userData = [ // changePage(1);
{ // } else {
account: 1, // ElMessage.error(res.data.data);
name: "张一", // row.state = row.state == 0 ? 1 : 0;
mobile: "13111111111", // }
}, // });
{
account: 2,
name: "张二二",
mobile: "13222222222",
},
{
account: 4,
name: "张四三",
mobile: "13443434344",
},
];
state.pushDialog = true;
}; // 推送提醒
const changeData = (data) => {
state.userData = data.data;
}; };
const cancelPushDialog = () => { const addRule = () => {
pushForm.value.resetFields(); console.log("新增");
state.pushDialog = false; // router.push(`/xxx/xxx`);
}; // 预警推送弹窗取消按钮:重置表单 }; // 新增规则
const pushConfirm = () => { const editRow = (row) => {
pushForm.value.validate((valid) => { console.log("编辑");
if (valid) { // router.push(`/xxx/xxx?id=${row.id}`);
console.log(state.actionRow.id, state.userData); }; // 编辑
console.log(state.pushFormData);
cancelPushDialog();
}
});
};
const closeWarning = (row) => { const deleteRow = (row) => {
state.actionRow = row; state.actionRow = row;
state.closeWarningDialog = true; state.delType = 1;
console.log("关闭预警"); state.delDialog = true;
}; // 关闭预警 console.log("删除");
}; // 删除
const cancelCloseWarningDialog = () => { const delConfirm = () => {
closeForm.value.resetFields(); let ids = [];
state.closeWarningDialog = false; if (state.delType == 1) {
}; // 关闭预警弹窗取消按钮:重置表单 ids.push(state.actionRow.id);
} else {
const confirmClose = () => { ids = state.selected.map((e) => {
closeForm.value.validate((valid) => { return e.id;
if (valid) { });
console.log(state.actionRow.id); }
console.log(state.closeFormData); console.log(ids);
cancelCloseWarningDialog(); state.delDialog = false;
} setTimeout(() => {
}); clearSelected();
}; // 关闭预警弹窗确定按钮:提交表单 changePage(1);
}, 200);
}; // 确定删除
onBeforeMount(() => { onBeforeMount(() => {
getTableRows(); getTableRows();
}); });
const { const { headers, tableRows, tableTotal, filter, noticeTypes, stateOptions, delDialog } = toRefs(state);
headers,
tableRows,
tableTotal,
filter,
warningTypes,
warningTargets,
riskLevels,
stateOptions,
closeWarningDialog,
closeFormData,
closeRules,
pushDialog,
userData,
pushFormData,
pushRules,
} = toRefs(state);
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
...@@ -554,53 +422,8 @@ const { ...@@ -554,53 +422,8 @@ const {
padding: 0 16px; padding: 0 16px;
.table { .table {
max-height: calc(100% - 64px); max-height: calc(100% - 64px);
.circle {
display: inline-block;
width: 6px;
height: 6px;
border-radius: 3px;
margin-right: 8px;
transform: translateY(-2px);
}
.bgc_0 {
background-color: #d75138;
}
.bgc_1 {
background-color: #48ad97;
}
.bgc_2 {
background-color: #9e9e9e;
}
}
}
}
.bg_form {
width: 100%;
box-sizing: border-box;
.el-form-item {
margin-bottom: 16px;
:deep().el-form-item__label {
line-height: 36px;
height: 36px;
}
.el-form-item__content {
width: 100%;
.el-textarea {
:deep().el-input__count {
bottom: 6px;
right: 4px;
font-family: Roboto-Regular;
color: #a9b1c7;
}
}
} }
} }
} }
:deep().dialog_box {
.el-dialog__body {
padding-bottom: 0;
}
}
} }
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment