"use strict";(self["webpackChunkwaf_dashboard"]=self["webpackChunkwaf_dashboard"]||[]).push([[45],{54045:function(t,e,s){s.r(e),s.d(e,{default:function(){return u}});var a=function(){var t=this,e=t._self._c;return e("div",[e("a-row",{attrs:{gutter:24,type:"flex"}},[e("a-col",{staticClass:"mb-24",attrs:{span:24}},[e("a-card",{staticClass:"header-solid h-full",attrs:{bordered:!1,bodyStyle:{padding:0}},scopedSlots:t._u([{key:"title",fn:function(){return[e("a-row",{attrs:{type:"flex",align:"middle"}},[e("a-col",{attrs:{span:24,md:12}},[e("h6",{staticClass:"font-semibold m-0"},[t._v("规则列表")])]),e("a-col",{staticStyle:{display:"flex","align-items":"center","justify-content":"flex-end"},attrs:{span:24,md:12}},[e("a-button",{staticClass:"custom-button",attrs:{icon:"plus-circle",type:"success",shape:"round",size:"small"},on:{click:function(e){return t.redirect(!1)}}},[t._v("添加规则")])],1)],1)]},proxy:!0}])},[e("a-table",{style:{minHeight:"calc(100vh - 228px)"},attrs:{columns:t.columns,"data-source":t.rules,rowKey:t=>t.id,scroll:{x:"calc(600px + 50%)"}},on:{change:t.onChange},scopedSlots:t._u([{key:"level",fn:function(s){return[e("a-tag",{staticClass:"tag-status",class:t.levelcls(s)},[t._v(" "+t._s(t.levelStr(s))+" ")])]}},{key:"type",fn:function(e){return[t._v(" "+t._s(t.typeStr(e))+" ")]}},{key:"ActBtn",fn:function(s){return[e("a-button",{staticClass:"custom-button",attrs:{icon:"setting",shape:"circle",size:"small"},on:{click:function(e){return t.redirect(s)}}}),e("a-divider",{attrs:{type:"vertical"}}),e("a-button",{attrs:{icon:"delete",type:"danger",shape:"circle",size:"small"},on:{click:function(e){return t.showConfirm(s.id)}}})]}}])})],1)],1)],1)],1)},r=[];const n=[{title:"ID",dataIndex:"id",width:70,fixed:"left",align:"center"},{title:"名称",dataIndex:"name",width:200,fixed:"left",ellipsis:!0},{title:"规则描述",dataIndex:"description",ellipsis:!0},{title:"危险等级",dataIndex:"level",scopedSlots:{customRender:"level"},sorter:(t,e)=>Number(t.level)-Number(e.level),width:150,align:"center"},{title:"过滤阶段",dataIndex:"type",scopedSlots:{customRender:"type"},width:140},{title:"操作",scopedSlots:{customRender:"ActBtn"},width:140,fixed:"right",align:"center"}];function l(t,e,s){}var i={props:{searchStr:{type:String,default:""}},data(){return{oldRules:[],rules:[],columns:n}},methods:{onChange:l,showConfirm(t){this.$createElement;let e=this;this.$confirm({title:"是否删除该规则?",content:t=>t("div",{style:"color:red;"},[" ",t("a-icon",{attrs:{type:"warning"}})," 警告: 删除后该规则将失效! "]),okText:"确定",okType:"danger",cancelText:"取消",onOk(){e.http.delete("/rules/"+t).then((t=>{t.data.err?e.$message.error("错误："+t.data.err):(e.$message.success("删除成功!"),e.http.get("/rules/").then((t=>{e.rules=t.data,e.oldRules=e.rules})).catch((t=>{e.$message.error(t.message)})))})).catch((t=>{e.$message.error(t.message)}))},onCancel(){console.log("Cancel")}})},typeStr(t){return"0"===t?"请求阶段":"1"===t?"返回HTTP头":"2"===t?"返回页面":void 0},levelStr(t){return"0"===t?"低危":"1"===t?"中危":"2"===t?"高危":"3"===t?"严重":void 0},levelcls(t){return"0"===t?"ant-tag-primary":"1"===t?"ant-tag-secondary":"2"===t?"ant-tag-warning":"3"===t?"ant-tag-danger":void 0},redirect(t){this.$router.push({name:"规则配置",params:{ex:t}})}},mounted(){this.http.get("/rules/").then((t=>{t.data.err?this.$message.error("错误："+t.data.err):(this.rules=t.data,this.oldRules=this.rules)})).catch((t=>{const e=t.response.status;if(401===e)return this.$message.info("请重新登录！"),void this.$router.push({name:"用户登录"});console.log(t)}))},watch:{searchStr:function(t){this.rules=t?this.oldRules.filter((function(e){return e.name.match(t)||e.description.match(t)})):this.oldRules}}},o=i,c=s(81656),d=(0,c.A)(o,a,r,!1,null,null,null),u=d.exports}}]);