import{L as k,r as m,w as v,j as e,M as z,z as D,P as x,B as o,D as I,a as w}from"./index-DWaKf7-t.js";import{b,d as A,e as M}from"./index-DpT0T8kB.js";import{F as P}from"./Table-DdQ_sLHU.js";const J=({visible:c,onClose:l,params:d,callback:p})=>{if(!c)return null;const{modal:i,openModal:y,closeModal:u}=k(),{component_id:r,component_type:h,namespace:$,namespace_name:B,name:j,...F}=d,[_,C]=m.useState([]),{messageApi:a}=v(),s=async()=>{const t=await w.get(`/get-depend-component/${r}`);C(t.data)},f=async t=>{try{const n=await A(t);a.success("删除成功!"),s()}catch(n){console.log(n),a.error(`删除失败!${n.response.data.detail}`)}},g=async t=>{try{const n=await M(t);a.success("删除成功!"),l(),p&&p()}catch(n){console.log(n),a.error(`删除失败!${n.response.data.detail}`)}};return m.useEffect(()=>{s()},[r]),e.jsxs("div",{children:[e.jsxs(z,{width:"70%",title:`组件(${h},${j})`,open:c,onCancel:l,footer:(t,{OkBtn:n,CancelBtn:O})=>e.jsxs(e.Fragment,{children:[e.jsx(x,{title:"确定要删除组件吗？",onConfirm:()=>{g(r)},children:e.jsx(o,{size:"small",color:"danger",variant:"solid",children:"删除组件"})}),e.jsx(o,{size:"small",color:"cyan",variant:"solid",onClick:s,children:"刷新"}),e.jsx(o,{size:"small",color:"cyan",variant:"solid",onClick:l,children:"关闭"})]}),children:[e.jsx("div",{children:e.jsx(P,{size:"small",bordered:!0,pagination:!1,columns:[{title:"组件名称",dataIndex:"component_name",key:"component_name"},{title:"组件类型",dataIndex:"component_type",key:"component_type"},{title:"关系类型",dataIndex:"relation_type",key:"relation_type"},{title:"组件ID",dataIndex:"component_id",key:"component_id"},{title:"关系ID",dataIndex:"relation_id",key:"relation_id"},{title:"操作",key:"action",render:(t,n)=>e.jsxs(D,{gap:"small",children:[e.jsx(x,{title:"确定要移除关系吗？",onConfirm:()=>{f(n.relation_id)},children:e.jsx(o,{size:"small",color:"danger",variant:"solid",children:"移除关系"})}),e.jsx(o,{size:"small",color:"cyan",variant:"solid",onClick:()=>{y("modalA",{data:n,structure:{component_type:n.component_type}})},children:"更新组件"})]})}],dataSource:_})}),e.jsx(I,{ghost:!0,items:[{key:"1",label:"更多",children:e.jsx("pre",{children:JSON.stringify(d,null,2)})}]})]}),e.jsx(b,{callback:s,visible:i.key=="modalA"&&i.visible,onClose:u,params:i.params})]})};export{J as D};
