"use strict";(self["webpackChunkwaf_dashboard"]=self["webpackChunkwaf_dashboard"]||[]).push([[734],{39734:function(e,t,r){r.r(t),r.d(t,{default:function(){return n}});var a=function(){var e=this,t=e._self._c;return t("div",[t("a-row",{attrs:{gutter:24,type:"flex"}},[t("a-col",{staticClass:"mb-24",attrs:{span:24}},[t("a-card",{staticClass:"header-solid h-full",attrs:{bordered:!1}},[t("a-form-model",{ref:"ruleForm",staticStyle:{"margin-top":"50px"},attrs:{model:e.form,rules:e.rules,"label-col":e.labelCol,"wrapper-col":e.wrapperCol}},[t("a-form-model-item",{ref:"host",attrs:{label:"域名",prop:"host","has-feedback":""}},[t("a-input",{model:{value:e.form.host,callback:function(t){e.$set(e.form,"host",t)},expression:"form.host"}},[t("a-icon",{staticStyle:{color:"#52c41a"},attrs:{slot:"addonBefore",type:"global"},slot:"addonBefore"})],1)],1),t("a-form-model-item",{ref:"uri",attrs:{label:"路径",prop:"uri","has-feedback":""}},[t("a-input",{model:{value:e.form.uri,callback:function(t){e.$set(e.form,"uri",t)},expression:"form.uri"}},[t("a-icon",{staticStyle:{color:"#52c41a"},attrs:{slot:"addonBefore",type:"api"},slot:"addonBefore"})],1)],1),t("a-form-model-item",{attrs:{prop:"enable"}},[t("span",{attrs:{slot:"label"},slot:"label"},[e._v(" 启用 "),t("a-tooltip",{attrs:{title:"注意：为了避免误拦截,请先前往站点管理开启攻击观察模式,一段时间没问题后再开启攻击拦截模式。"}},[t("a-icon",{attrs:{type:"question-circle-o"}})],1)],1),t("a-switch",{attrs:{"checked-children":"开","un-checked-children":"关"},model:{value:e.form.enable,callback:function(t){e.$set(e.form,"enable",t)},expression:"form.enable"}})],1),t("a-form-model-item",{attrs:{label:"规则内容",prop:"schema"}},[t("a-textarea",{attrs:{autoSize:{minRows:6}},model:{value:e.form.schema,callback:function(t){e.$set(e.form,"schema",t)},expression:"form.schema"}})],1),t("a-form-model-item",e._b({},"a-form-model-item",e.formItemLayoutWithOutLabel,!1),[t("a-button",{staticClass:"custom-button",attrs:{size:"small",type:"primary",shape:"round",icon:"check-circle","html-type":"submit"},on:{click:function(t){return e.submitForm("ruleForm")}}},[e._v(" 提交 ")]),t("a-button",{staticStyle:{"margin-left":"20px"},attrs:{size:"small",shape:"round",icon:"close-circle"},on:{click:function(t){return e.resetForm("ruleForm")}}},[e._v(" 重置 ")])],1)],1)],1)],1)],1)],1)},s=[],o={data(){return{labelCol:{span:5},wrapperCol:{span:14},formItemLayoutWithOutLabel:{wrapperCol:{xs:{span:24,offset:0},sm:{span:20,offset:10}}},update:!1,form:{id:0,host:"",uri:"",enable:!1,schema:""},rules:{host:[{required:!0,trigger:"change",message:"内容为空或格式不对",pattern:/^(?:[\da-z\-]+\.)+(?:[\da-z]{1,9})$/,transform(e){return e.trim()}},{min:4,max:63,message:"长度必须大于3且小于64",trigger:"blur"}],uri:[{required:!0,trigger:"change",pattern:/^\/.*$/,message:"内容为空或格式不对",transform(e){return e.trim()}}],schema:[{required:!0,trigger:"change",message:"内容为空或格式不对",transform(e){return e.trim()}}]}}},methods:{submitForm(e){this.$refs[e].validate((e=>{if(e){let e="post";this.update&&(e="put");try{var t=JSON.parse(this.form.schema);if("object"!=typeof t||!t)return void this.$message.error("规则内容格式有误！")}catch(r){return void this.$message.error("规则内容格式有误："+r.message)}this.http({url:"/ml/config",method:e,data:this.form}).then((e=>{e.data.err?this.$message.error("规则内容有误："+e.data.err):(this.$message.success("提交成功!"),this.$router.push({name:"机器学习"}))})).catch((e=>{e.response&&401===e.response.status&&(this.$message.info("请重新登录！"),this.$router.push({name:"用户登录"}))}))}else this.$message.error("请根据红色提示修改后重新提交")}))},resetForm(e){this.$refs[e].resetFields()}},mounted(){let e=this.$route.params.ex;this.update=!!e,this.update&&(this.form.id=e.id,this.form.host=e.host,this.form.uri=e.uri,this.form.enable=e.enable,this.form.schema=e.schema)}},l=o,i=r(81656),m=(0,i.A)(l,a,s,!1,null,null,null),n=m.exports}}]);