import{_ as N}from"./index-DIKmrNCq.js?v=1773287522785";import{_ as $}from"./index.vue_vue_type_script_setup_true_lang-BeO8Hyma.js?v=1773287522785";import{h as D,n as P,m as U}from"./index-BTglIPU2.js?v=1773287522785";import{u as z}from"./useTableColumns-DDeyYvje.js?v=1773287522785";import{u as A}from"./useTableData-BmkIKQ_R.js?v=1773287522785";import{f as T,m as j,h as F,i as L,j as I}from"./setting-DouXuJGW.js?v=1773287522785";import{b as c,a8 as Z,B as q}from"./naive-ui--dJnpVcV.js?v=1773287522785";import{k as G,t as H,R as J,e as K,r as g,a0 as l,F as V,n as M,$ as O,Z as Q,_ as i,S as s,a9 as v,j as X,aa as r,N as Y}from"./vue-core-DJjvd5ZC.js?v=1773287522785";import"./data-BVsViUMm.js?v=1773287522785";import"./prismjs-BZPoR7_J.js?v=1773287522785";import"./index-S15tYq5l.js?v=1773287522785";import"./copy-D-wIKr0q.js?v=1773287522785";import"./index.vue_vue_type_script_setup_true_lang-DeTfbeeM.js?v=1773287522785";import"./index-Cg6fMjw6.js?v=1773287522785";const w={class:"p-20px"},ee={class:"flex mb-12px"},ae={class:"flex-1 mr-12px"},te={class:"w-150px mr-12px"},le={class:"text-error"},ye=G({__name:"index",props:{type:{}},setup(y,{expose:h}){const o=H(y,"type"),{t}=J(),n=K({ruleValue:"",ps:""}),b=async()=>{if(n.ruleValue.trim()===""){U.error(t("Waf.Setting.config_194"));return}await I({...Y(n),ruleName:o.value}),u(),n.ruleValue="",n.ps=""},m=g(null),S=g(null),{table:p,columns:k,setLoading:_}=A([{key:"rule",title:t("Waf.Setting.config_82"),render:e=>l(V,null,[e.isEdit?l(c,{ref:m,value:e.ruleVal,size:"small",type:"textarea",autosize:{minRows:2,maxRows:2},placeholder:"",onUpdateValue:a=>{e.ruleVal=a}},null):e.rule])},{key:"ps",title:t("Waf.Setting.config_190"),width:150,render:e=>l(V,null,[e.isEdit?l(c,{ref:S,value:e.psVal,size:"small",placeholder:"",onUpdateValue:a=>{e.psVal=a}},null):e.ps])},{key:"status",title:t("Waf.Setting.config_82"),width:60,render:(e,a)=>l(Z,{value:e.status,size:"small",checkedValue:1,uncheckedValue:0,onUpdateValue:async d=>{await T({index:a,ruleName:o.value}),e.status=d}},null)},z({width:100,options:(e,a)=>e.isEdit?[{label:t("Public.Btn.Save"),onClick:()=>{R(e,a)}},{label:t("Public.Btn.Cancel"),onClick:()=>{B(e)}}]:[{label:t("Public.Btn.Edit"),onClick:()=>{x(e)}},{label:t("Public.Btn.Del"),show:e.isDel,onClick:()=>{C(e,a)}}]})]),x=e=>{e.isEdit=!0,M(()=>{var a;(a=m.value)==null||a.focus()})},R=async(e,a)=>{e.isEdit=!1,await j({index:a,ruleBody:e.ruleVal,rulePs:e.psVal,ruleName:o.value}),e.rule=e.ruleVal,e.ps=e.psVal},B=e=>{e.isEdit=!1,e.ruleVal=e.rule,e.psVal=e.ps},C=async(e,a)=>{D({title:t("Waf.Setting.config_195",[e.rule]),content:t("Waf.Setting.config_196"),onConfirm:async()=>{await F({index:a,ruleName:o.value}),u()}})},u=async()=>{try{_(!0);const{message:e}=await L({ruleName:o.value});P(e)&&(p.data=e.map(a=>({rule:a[1],ruleVal:a[1],ps:a[2],psVal:a[2],status:a[0],isEdit:!1,isDel:a[3]===1})))}finally{_(!1)}};return u(),h({init:u}),(e,a)=>{const d=q,W=$,E=N;return O(),Q("div",w,[i("div",ee,[i("div",ae,[l(s(c),{value:s(n).ruleValue,"onUpdate:value":a[0]||(a[0]=f=>s(n).ruleValue=f),placeholder:e.$t("Waf.Setting.config_189")},null,8,["value","placeholder"])]),i("div",te,[l(s(c),{value:s(n).ps,"onUpdate:value":a[1]||(a[1]=f=>s(n).ps=f),placeholder:e.$t("Waf.Setting.config_190")},null,8,["value","placeholder"])]),l(d,{type:"primary",onClick:b},{default:v(()=>[X(r(e.$t("Public.Btn.Add")),1)]),_:1})]),l(W,{"max-height":340,loading:s(p).loading,data:s(p).data,columns:s(k)},null,8,["loading","data","columns"]),l(E,{class:"mt-16px"},{default:v(()=>[i("li",le,r(e.$t("Waf.Setting.config_191")),1),i("li",null,r(e.$t("Waf.Setting.config_192")),1),i("li",null,r(e.$t("Waf.Setting.config_193")),1)]),_:1})])}}});export{ye as default};
