import{a5 as S,b as B,r as f,w as I,o as P,y as U,q as n,v as i,p as s,n as g,s as C,P as v,x as m,N as j,C as T,ay as K,j as q,l as z,br as O,bv as A,D as G}from"./index.8d733f79.js";import{E as H}from"./el-text.54dc8292.js";import J from"./addFaultType.2270a683.js";import{g as L,n as Q}from"./faultType.8bb3732b.js";const W={class:"faultTree-content"},X={class:"df",style:{"margin-bottom":"16px","justify-content":"space-between"}},Y={class:"custom-tree-node df"},Z=["title"],ee=S({name:"faultType"}),ne=Object.assign(ee,{setup(te,{expose:$}){const{t:x}=B(),{proxy:u}=G(),c=f(!1),p=f(),_=f([]),r=f("");I(r,e=>{p.value.filter(e)});const w={children:"children",label:"label"};function N(){c.value=!0,y()}const V=(e,t,o)=>{if(!e)return!0;const l=[];b(o,l,e);let d=!1;return l.forEach(h=>{d=d||h}),d},b=(e,t,o)=>{const l=e.data&&e.data.label&&e.data.label.toUpperCase().includes(o.toUpperCase());l&&t.push(l),!l&&e.level!==1&&e.parent&&b(e.parent,t,o)},y=()=>{L().then(e=>{_.value=e.data,K(()=>{p.value.filter(r.value),p.value.setCurrentKey(_.value[0].globalId)})})},R=()=>{u.$refs.addFaultTypeRef.showModal("add")},E=(e,t)=>{u.$refs.addFaultTypeRef.showModal("edit",t)},D=(e,t)=>{u.$modal.confirm(x("confirmDelete")).then(()=>{Q({id:t.id}).then(o=>{u.$modal.msgSuccess(o.msg),y()})}).catch(()=>{})};return $({showModal:N}),(e,t)=>{const o=q,l=z,d=H,h=O,M=A;return P(),U(M,{title:e.$t("faultTypeManage"),modelValue:g(c),"onUpdate:modelValue":t[2]||(t[2]=a=>C(c)?c.value=a:null),width:"460px","align-center":!0},{default:n(()=>[i("div",W,[i("div",X,[s(o,{modelValue:g(r),"onUpdate:modelValue":t[0]||(t[0]=a=>C(r)?r.value=a:null),placeholder:e.$t("inputP"),style:{flex:"1"},clearable:"","suffix-icon":"Search"},null,8,["modelValue","placeholder"]),s(l,{type:"primary",onClick:t[1]||(t[1]=a=>R()),style:{"margin-left":"10px"}},{default:n(()=>[v(m(e.$t("add")),1)]),_:1})]),s(h,null,{default:n(()=>[s(d,{style:{width:"100%"},ref_key:"treeRef",ref:p,class:"filter-tree","node-key":"id",data:g(_),props:w,"default-expand-all":"","highlight-current":"","filter-node-method":V,"expand-on-click-node":!1},{default:n(({node:a,data:k})=>[i("div",Y,[i("span",{class:j(["node-text",{"txt-omit":!0}]),title:a.label},m(a.label),9,Z),i("span",null,[s(l,{link:"",type:"primary",onClick:T(F=>E(a,k),["stop"])},{default:n(()=>[v(m(e.$t("edit")),1)]),_:2},1032,["onClick"]),s(l,{link:"",type:"danger",onClick:T(F=>D(a,k),["stop"])},{default:n(()=>[v(m(e.$t("delete")),1)]),_:2},1032,["onClick"])])])]),_:1},8,["data"])]),_:1})]),s(J,{ref:"addFaultTypeRef",onRefresh:y},null,512)]),_:1},8,["title","modelValue"])}}});export{ne as default};
