Authored by 王涛

#510 1、指标过滤

对当前的订阅选择过滤指标
     2、对资源过滤、资源指标过滤( 选在对指定指定资源(当前订阅的资源)进行过滤)
          1.能过滤资源
          2.能过滤指定资源下的指标
@@ -313,6 +313,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function @@ -313,6 +313,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function
313 '<button data-id="{{d.subId}}" lay-tips="指标订阅" type="button" class="layui-btn layui-btn-xs layui-btn-normal alarmsubscribe-kpi-btn"><i class="iconfont">&#XE520;</i></button>' + 313 '<button data-id="{{d.subId}}" lay-tips="指标订阅" type="button" class="layui-btn layui-btn-xs layui-btn-normal alarmsubscribe-kpi-btn"><i class="iconfont">&#XE520;</i></button>' +
314 '<button data-id="{{d.subId}}" lay-tips="资源类型订阅" type="button" class="layui-btn layui-btn-xs layui-btn-normal alarmsubscribe-resType-btn"><i class="iconfont">&#XE521;</i></button>' + 314 '<button data-id="{{d.subId}}" lay-tips="资源类型订阅" type="button" class="layui-btn layui-btn-xs layui-btn-normal alarmsubscribe-resType-btn"><i class="iconfont">&#XE521;</i></button>' +
315 '<button data-id="{{d.subId}}" lay-tips="业务类型订阅" type="button" class="layui-btn layui-btn-xs layui-btn-normal alarmsubscribe-busId-btn"><i class="iconfont">&#XE522;</i></button>' + 315 '<button data-id="{{d.subId}}" lay-tips="业务类型订阅" type="button" class="layui-btn layui-btn-xs layui-btn-normal alarmsubscribe-busId-btn"><i class="iconfont">&#XE522;</i></button>' +
  316 + '<button data-id="{{d.subId}}" lay-tips="订阅指标、资源排除配置" type="button" class="layui-btn layui-btn-xs layui-btn-normal alarmsubscribe-exclude-kpi"><i class="layui-icon layui-icon-templeate-1"></i>' +
316 '</div>' 317 '</div>'
317 } 318 }
318 ]], 319 ]],
@@ -772,6 +773,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function @@ -772,6 +773,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function
772 } 773 }
773 }); 774 });
774 }); 775 });
  776 +
775 //查看资源类型订阅列表 777 //查看资源类型订阅列表
776 $(".view-alarmsubscribe-resType").on("click", function () { 778 $(".view-alarmsubscribe-resType").on("click", function () {
777 var subId = $(this).data("id"); 779 var subId = $(this).data("id");
@@ -783,6 +785,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function @@ -783,6 +785,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function
783 return true; 785 return true;
784 }); 786 });
785 }); 787 });
  788 +
786 //查看业务类型订阅列表 789 //查看业务类型订阅列表
787 $(".view-alarmsubscribe-busId").on("click", function () { 790 $(".view-alarmsubscribe-busId").on("click", function () {
788 var subId = $(this).data("id"); 791 var subId = $(this).data("id");
@@ -794,6 +797,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function @@ -794,6 +797,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function
794 return true; 797 return true;
795 }); 798 });
796 }); 799 });
  800 +
797 //资源订阅 801 //资源订阅
798 $(".alarmsubscribe-resource-btn").on("click", function () { 802 $(".alarmsubscribe-resource-btn").on("click", function () {
799 if ($.inArray('back:alarmsubscribe:resource', checkList) == -1) { 803 if ($.inArray('back:alarmsubscribe:resource', checkList) == -1) {
@@ -914,6 +918,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function @@ -914,6 +918,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function
914 return true; 918 return true;
915 }); 919 });
916 }); 920 });
  921 +
917 //资源类型订阅 922 //资源类型订阅
918 $(".alarmsubscribe-resType-btn").on("click", function () { 923 $(".alarmsubscribe-resType-btn").on("click", function () {
919 var subId = $(this).data("id"); 924 var subId = $(this).data("id");
@@ -929,6 +934,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function @@ -929,6 +934,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function
929 insertResTypeOrBusId(data, 0, subId); 934 insertResTypeOrBusId(data, 0, subId);
930 }); 935 });
931 }); 936 });
  937 +
932 //业务类型订阅 938 //业务类型订阅
933 $(".alarmsubscribe-busId-btn").on("click", function () { 939 $(".alarmsubscribe-busId-btn").on("click", function () {
934 var subId = $(this).data("id"); 940 var subId = $(this).data("id");
@@ -944,6 +950,20 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function @@ -944,6 +950,20 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function
944 insertResTypeOrBusId(data, 1, subId); 950 insertResTypeOrBusId(data, 1, subId);
945 }); 951 });
946 }); 952 });
  953 +
  954 + // 排除订阅指标
  955 + $(".alarmsubscribe-exclude-kpi").on("click",function () {
  956 + var subId = $(this).data("id");
  957 + var title = `<a class="layui-icon layui-icon-templeate-1"></a>告警订阅排除订阅指标`;
  958 + layer.open({
  959 + type: 2
  960 + , title: title
  961 + , shade: 0.8
  962 + , area: ['80%', '90%']
  963 + , id: 'alarmsubscribe-exclude-kpi' //设定一个id,防止重复弹出
  964 + , content: `/vue3/index.html#/alarmsubscribe/excludeKpi?subId=${subId}`
  965 + })
  966 + });
947 } 967 }
948 }); 968 });
949 969
@@ -36,6 +36,10 @@ @@ -36,6 +36,10 @@
36 display: flex; 36 display: flex;
37 } 37 }
38 38
  39 +.container .cm-card .search>button {
  40 + margin-left: 10px;
  41 +}
  42 +
39 .container .cm-card .search .condition { 43 .container .cm-card .search .condition {
40 width: calc(100% - 200px); 44 width: calc(100% - 200px);
41 display: flex; 45 display: flex;
@@ -42,6 +42,11 @@ const routes = [{ @@ -42,6 +42,11 @@ const routes = [{
42 path: '/vue3/portSenseSelect', 42 path: '/vue3/portSenseSelect',
43 name: 'portSenseSelect', 43 name: 'portSenseSelect',
44 component: () => myImport('views/portSenseSelect/index') 44 component: () => myImport('views/portSenseSelect/index')
  45 + },
  46 + {
  47 + path: '/alarmsubscribe/excludeKpi',
  48 + name: 'alarmSubscribeExcludeKpi',
  49 + component: () => myImport('views/alarmsubscribe/index')
45 } 50 }
46 ]; 51 ];
47 52
  1 +<div class="container" :style="{'height':height+'px','max-height':height+'px','padding':'0px'}">
  2 + <div class="cm-card" :style="{'min-height':height+'px','max-height':height+'px','height':'100%'}">
  3 + <div class="search">
  4 + <el-form-item>
  5 + <el-input v-model="searchForm.keyword" placeholder="输入关键字"
  6 + @keydown.enter.native="getPage"></el-input>
  7 + </el-form-item>
  8 + <el-form-item style="margin-left: 10px">
  9 + <el-button type="primary" @click="getPage"><i class="iconfont icon-sousuo"></i>搜索</el-button>
  10 + <el-button @click="showExcludeKpi(true)">指标过滤</el-button>
  11 + <el-button @click="showResDialog(true)">资源过滤</el-button>
  12 + </el-form-item>
  13 + </div>
  14 +
  15 + <div class="search-table">
  16 + <cm-table-page :columns="list.columns"
  17 + :dataList="list.dataList"
  18 + :total="list.total"
  19 + :showIndex="true"
  20 + :showBorder="true"
  21 + :showPage="false"
  22 + :showTools="true"
  23 + :height="(height - 105)">
  24 + <template #default="{row,prop,column}">
  25 + <div v-if="prop == 'enable'">
  26 + <el-switch
  27 + @change="setEnable(row)"
  28 + inline-prompt
  29 + :active-value="1"
  30 + :inactive-value="0"
  31 + active-text="启用"
  32 + inactive-text="禁用"
  33 + v-model="row.enable"
  34 + active-color="#13ce66"
  35 + inactive-color="#ff4949"
  36 + />
  37 + </div>
  38 + </template>
  39 + <template #tools="{scope}">
  40 + <el-button type="text" size="small" @click.prevent="deleteItem(scope.row,scope.$index)">
  41 + <i class="el-icon-delete"/>
  42 + </el-button>
  43 + </template>
  44 + </cm-table-page>
  45 + </div>
  46 + </div>
  47 +
  48 + <!-- 弹框区域 -->
  49 + <cm-dialog title="指标过滤配置" width="300px" :showDialogVisible="excludeKpiFlag"
  50 + @hidedialog="showExcludeKpi" :showFooter="true" @okfunc="saveKpiInfo">
  51 + <template v-slot>
  52 + <el-select clearable multiple v-model="kpiDetail.dataList" placeholder="请选择指标">
  53 + <el-option
  54 + v-for="item in kpiDetail.options"
  55 + :key="item.kpiId"
  56 + :label="item.kpiName"
  57 + :value="item.kpiId">
  58 + <span style="float: left">{{ item.kpiId }}</span>
  59 + <span style="float: right;color: var(--el-text-color-secondary);font-size: 13px;">{{ item.kpiName }}</span>
  60 + </el-option>
  61 + </el-select>
  62 + </template>
  63 + </cm-dialog>
  64 +
  65 + <cm-dialog title="资源指标过滤配置" width="80%" :showDialogVisible="resFlag"
  66 + @hidedialog="showResDialog" :showFooter="true" @okfunc="saveResInfo">
  67 + <template v-slot >
  68 + <div style="height: 300px">
  69 + <cm-table-page :columns="reslist.columns"
  70 + :dataList="reslist.dataList"
  71 + :showIndex="true"
  72 + :showBorder="true"
  73 + :showPage="false"
  74 + :showTools="false"
  75 + :height="300">
  76 + <template #default="{row,prop,column}">
  77 + <div v-if="prop == 'excludeKpi'">
  78 + <el-select clearable multiple collapse-tags v-model="row.excludeKpi" placeholder="请选择指标">
  79 + <el-option
  80 + v-for="item in resKpiList"
  81 + :key="item.kpiId"
  82 + :label="item.kpiName"
  83 + :value="item.kpiId">
  84 + <span style="float: left">{{ item.kpiId }}</span>
  85 + <span style="float: right;color: var(--el-text-color-secondary);font-size: 13px;">{{ item.kpiName }}</span>
  86 + </el-option>
  87 + </el-select>
  88 + </div>
  89 + </template>
  90 + </cm-table-page>
  91 + </div>
  92 + </cm-dialog>
  93 +</div>
  1 +const excludeResInfo = (proxy,subId,callback) =>{
  2 + let resFlag = Vue.ref(false);
  3 + // 列表展示结果
  4 + let reslist = Vue.ref({
  5 + columns: [{
  6 + prop: 'resName',
  7 + label: '资源名称'
  8 + }, {
  9 + prop: 'ip',
  10 + label: 'IP地址'
  11 + }, {
  12 + prop: 'adminName',
  13 + label: '负责人'
  14 + }, {
  15 + prop: 'resTypeName',
  16 + label: '资源类型'
  17 + }, {
  18 + prop: 'healthDesc',
  19 + label: '资源状态'
  20 + }, {
  21 + prop: 'excludeKpi',
  22 + label: '过滤指标'
  23 + }],
  24 + dataList: [],
  25 + total: 0
  26 + });
  27 + let resKpiList = Vue.ref([]);
  28 +
  29 + let showResDialog = (flg) =>{
  30 +
  31 + if(flg && flg == true){
  32 + getResList();
  33 + // 获取指标列表
  34 + proxy.$http.get(`/api-web/alarmsubscribe/exclude/getAlarmPolicyKpiList/res`, {subId:subId}, function (res) {
  35 + if (res && res.data) {
  36 + resKpiList.value = res.data;
  37 + }
  38 + });
  39 + } else {
  40 + resFlag.value = flg;
  41 + }
  42 + }
  43 +
  44 + /**
  45 + * 获取资源列表
  46 + * <p>
  47 + * 作者: Wang
  48 + * 时间:2022/2/15 15:27
  49 + */
  50 + let getResList = () => {
  51 + proxy.$http.get(`/api-web/alarmsubscribe/exclude/getSubResListBySubId/${subId}`, {subId:subId}, function (res) {
  52 + if (res && res.data) {
  53 + reslist.value.dataList = res.data;
  54 + resFlag.value = true;
  55 + }
  56 + });
  57 + }
  58 +
  59 + let saveResInfo = () => {
  60 + let params = [];
  61 +
  62 + reslist.value.dataList.forEach(function (v){
  63 + v.excludeKpi.forEach(function (kpi){
  64 + params.push({
  65 + resId:v.resId,
  66 + subId:subId,
  67 + kpiId:kpi
  68 + })
  69 + })
  70 +
  71 + })
  72 +
  73 + // 保存策略过滤配置
  74 + proxy.$http.post(`/api-web/alarmsubscribe/exclude/saveResConfig`, params, function (res) {
  75 + if (res && res.success) {
  76 + proxy.$global.showMsg("保存成功", "success");
  77 + if(callback){
  78 + callback();
  79 + }
  80 + showResDialog(false);
  81 + }
  82 + });
  83 +
  84 + }
  85 +
  86 + return {
  87 + resFlag,
  88 + reslist,
  89 + showResDialog,
  90 + getResList,
  91 + resKpiList,
  92 + saveResInfo
  93 + }
  94 +
  95 +}
  96 +
  97 +const excludeKpi = (proxy,subId,callback) => {
  98 + let excludeKpiFlag = Vue.ref(false);
  99 + let kpiDetail = Vue.ref({
  100 + options:[],
  101 + dataList:[]
  102 + });
  103 +
  104 + let showExcludeKpi = function (flag) {
  105 + excludeKpiFlag.value = flag;
  106 + if(flag && flag == true && kpiDetail.value.options.length == 0){
  107 + getAlarmPolicyKpiList();
  108 + }
  109 + }
  110 +
  111 + let getAlarmPolicyKpiList = function (){
  112 + proxy.$http.get(`/api-web/alarmsubscribe/exclude/getAlarmPolicyKpiList/kpi`, {subId:subId}, function (res) {
  113 + if (res && res.data) {
  114 + kpiDetail.value.options = res.data;
  115 + }
  116 + });
  117 + }
  118 +
  119 + let saveKpiInfo = function () {
  120 + let params = [];
  121 + kpiDetail.value.dataList.forEach(function (v){
  122 + params.push({
  123 + subId:subId,
  124 + kpiId:v
  125 + })
  126 + })
  127 + if(params.length > 0){
  128 + // 保存策略过滤配置
  129 + proxy.$http.post(`/api-web/alarmsubscribe/exclude/saveConfig`, params, function (res) {
  130 + if (res && res.success) {
  131 + proxy.$global.showMsg("保存成功", "success");
  132 + if(callback){
  133 + callback();
  134 + }
  135 + showExcludeKpi(false);
  136 + }
  137 + });
  138 + }
  139 + }
  140 +
  141 + return {
  142 + excludeKpiFlag,
  143 + showExcludeKpi,
  144 + kpiDetail,
  145 + saveKpiInfo
  146 + }
  147 +}
  148 +
  149 +export default {
  150 + name: 'resIndex',
  151 + template: '',
  152 + components: {},
  153 + data() {
  154 + return {
  155 + props: {
  156 + label: 'label',
  157 + children: 'children'
  158 + }
  159 + }
  160 + },
  161 + setup() {
  162 + const {proxy} = Vue.getCurrentInstance();
  163 + let height = Vue.ref(window.innerHeight - 20);
  164 +
  165 + let sunId = proxy.$global.getQueryVariable('subId');
  166 +
  167 + // 搜索表单内容
  168 + let searchForm = Vue.ref({
  169 + keyword: '',
  170 + page: 1,
  171 + pageSize: 10
  172 + });
  173 +
  174 + // 列表展示结果
  175 + let list = Vue.ref({
  176 + columns: [{
  177 + prop: 'subName',
  178 + label: '订阅名称'
  179 + }, {
  180 + prop: 'resName',
  181 + label: '资源名称'
  182 + }, {
  183 + prop: 'kpiId',
  184 + label: '指标ID'
  185 + }, {
  186 + prop: 'kpiName',
  187 + label: '指标名称'
  188 + }, {
  189 + prop: 'enable',
  190 + label: '状态'
  191 + }],
  192 + dataList: [],
  193 + total: 0
  194 + });
  195 +
  196 + /**
  197 + * 分页查询
  198 + * <p>
  199 + * 作者: Wang
  200 + * 时间:2021/12/13 16:51
  201 + */
  202 + let getPage = () => {
  203 + proxy.$http.get(`/api-web/alarmsubscribe/exclude/list`, {
  204 + keyword: searchForm.value.keyword,
  205 + subId: sunId
  206 + }, function (res) {
  207 + if (res && res.data) {
  208 + list.value.dataList = res.data;
  209 + }
  210 + });
  211 + }
  212 +
  213 + /**
  214 + * 修改状态
  215 + * <p>
  216 + * 作者: Wang
  217 + * 时间:2022/2/11 16:30
  218 + */
  219 + let setEnable = (row) => {
  220 + if (!row.id) {
  221 + return;
  222 + }
  223 + proxy.$http.get(`/api-web/alarmsubscribe/exclude/setEnable`, {
  224 + id: row.id,
  225 + enable: row.enable
  226 + }, function (res) {
  227 + if (res && res.success) {
  228 + proxy.$global.showMsg("更新成功", "success")
  229 + }
  230 + });
  231 + }
  232 +
  233 + /**
  234 + * 删除
  235 + * @param row
  236 + * @param index
  237 + */
  238 + let deleteItem = (row,index) =>{
  239 + proxy.$global.confirm("将永久删除该配置选项,请确认!", function () {
  240 + debugger
  241 + proxy.$http.get(`/api-web/alarmsubscribe/exclude/delete/${row.id}`, {}, function (res) {
  242 + if (res && res.success) {
  243 + proxy.$global.showMsg('保存成功!');
  244 + getPage()
  245 + }
  246 + })
  247 +
  248 + });
  249 + }
  250 +
  251 +
  252 + const {
  253 + excludeKpiFlag,
  254 + showExcludeKpi,
  255 + kpiDetail,
  256 + saveKpiInfo
  257 + } = excludeKpi(proxy,sunId,getPage)
  258 +
  259 +
  260 + const {
  261 + resFlag,
  262 + reslist,
  263 + showResDialog,
  264 + getResList,
  265 + resKpiList,
  266 + saveResInfo
  267 + } = excludeResInfo(proxy,sunId,getPage);
  268 +
  269 +
  270 + // 挂载完
  271 + Vue.onMounted(() => {
  272 + // 初始化加载页面
  273 + getPage();
  274 + })
  275 +
  276 + return {
  277 + height,
  278 + searchForm,
  279 + list,
  280 + getPage,
  281 + setEnable,
  282 + deleteItem,
  283 +
  284 + // 配置指标
  285 + excludeKpiFlag,
  286 + showExcludeKpi,
  287 + kpiDetail,
  288 + saveKpiInfo,
  289 +
  290 + // 配置资源
  291 + resFlag,
  292 + reslist,
  293 + showResDialog,
  294 + getResList,
  295 + resKpiList,
  296 + saveResInfo
  297 +
  298 + }
  299 + }
  300 +}
@@ -164,6 +164,11 @@ const routes = [{ @@ -164,6 +164,11 @@ const routes = [{
164 path: '/vue3/portSenseSelect', 164 path: '/vue3/portSenseSelect',
165 name: 'portSenseSelect', 165 name: 'portSenseSelect',
166 component: () => myImport('views/portSenseSelect/index') 166 component: () => myImport('views/portSenseSelect/index')
  167 + },
  168 + {
  169 + path: '/alarmsubscribe/excludeKpi',
  170 + name: 'alarmSubscribeExcludeKpi',
  171 + component: () => myImport('views/alarmsubscribe/index')
167 } 172 }
168 ]; 173 ];
169 174