import{P as a,$ as e}from"./utils-lib.js?v=1761009159";import{c as t,o as s,r as o,g as l,q as i,v as r,x as p,e as d,B as n,y as c,F as m,b0 as u,ab as f,ae as h,a9 as b,z as _,A as g,U as D}from"./base-lib.js?v=1761009159";import{_ as j}from"./index103.js?v=1761009159";import{bJ as y}from"./firewall.js?v=1761009159";import{f as w}from"./validator.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index106.js?v=1761009159";import"./column.js?v=1761009159";const x={class:"p-20px"},v=t({__name:"add-file-monitor",props:{compData:{default:()=>{}}},setup(t,{expose:v}){const V=t,q=s({path:"",type:"dir",domain:V.compData.name,actions:[]}),k=o(),C=l(()=>"dir"===q.type),U=[{name:"read",title:"读取"},{name:"del",title:"删除"},{name:"reit",title:"修改/增加"}],F={path:[{required:!0,message:"请选择监测路径",trigger:"blur"}],actions:[{required:!0,message:"请选择告警操作",trigger:"change"}]},P=()=>{V.compData.row||w({type:"all",path:q.path,change:(a,e)=>{q.path=a,q.type=e,q.actions="dir"===e?["read"]:["read","del","reit"]}})};return i(()=>(()=>{if(V.compData.path&&(q.path=V.compData.path.replace("//","/")),V.compData.row){const a=["del","read","reit"],e=[];Object.entries(V.compData.row).forEach(([t,s])=>{a.includes(t)&&Number(s)&&e.push(t)}),q.type=V.compData.row.type,q.actions=e}})()),v({onConfirm:async e=>{await k.value.validate();let t={...q},s=[0,0,0,0];q.actions.includes("read")&&(s[0]=1),q.actions.includes("del")&&(s[1]=1),q.actions.includes("reit")&&(s[2]=1,s[3]=1),t.actions=s.join(","),await a({loading:"正在添加文件监视器，请稍后...",request:y(!!V.compData.row,{...t}),message:!0,success:a=>{a.status&&(V.compData.refresh&&V.compData.refresh(),e())}})}}),(a,t)=>{const s=j,o=f,l=D,i=h,y=b,w=e;return r(),p("div",x,[d(y,{model:c(q),ref_key:"addFileMonitorRef",ref:k,rules:F},{default:n(()=>[d(o,{prop:"path",label:"监测路径"},{default:n(()=>[d(s,{modelValue:c(q).path,"onUpdate:modelValue":t[0]||(t[0]=a=>c(q).path=a),class:"!w-[28rem]",icon:"icon-file_mode",onIconClick:P,disabled:!!V.compData.row,onChangePassive:t[1]||(t[1]=a=>{q.path=q.path.replace(/\s+/g,"")}),placeholder:"请选择文件目录"},null,8,["modelValue","disabled"])]),_:1}),d(o,{label:"告警操作",prop:"actions"},{default:n(()=>[d(i,{modelValue:c(q).actions,"onUpdate:modelValue":t[2]||(t[2]=a=>c(q).actions=a)},{default:n(()=>[(r(),p(m,null,u(U,(a,e)=>d(l,{key:e,label:a.name,disabled:c(C)&&e>0},{default:n(()=>[_("div",null,[_("span",null,g(a.title),1)])]),_:2},1032,["label","disabled"])),64))]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model"]),d(w,{options:[{content:"目录暂时只支持读取告警操作"}],class:"ml-20px mt-20px","list-style":"disc"})])}}});export{v as default};
