import{_ as P,d as z,w as k,v as I,x as V,X as H,r as g,o as u,c as O,l as f,C as d,G as v,u as c,J as m,M as q,a as p,b5 as G,b2 as L}from"./index.1d5f2f42.js";import{h as J,a as U,b as X}from"./index.cb757309.js";import{useColumns as j}from"./columns.9c7139e2.js";const K={class:"main flex",style:{width:"100%"}},Q=z({__name:"action-table",emits:["edit","create","view"],setup(W,{expose:M,emit:N}){const{columns:$}=j(),h=k(!0),C=k([]),r=k([]),{logout:x}=I(),F=k(),S=new Map,w=async t=>{const{id:n,status:e}=t,{code:s,message:i}=await J({id:n,status:e+""=="1"?"0":"1"});L({code:s,message:i,logout:x,handler:()=>b(t.pid)})},A=async t=>{const{id:n}=t,{code:e,message:s}=await U({id:n});L({code:e,message:s,logout:x,handler:()=>Number(t.pid)===0?y():b(t.pid)})};function E(t){}async function R(t){return h.value=!0,new Promise(n=>{X(t).then(e=>{h.value=!1;const{code:s,data:i}=e;s===1&&i.list.length!==0?n(i.list):n([])}).catch(()=>{h.value=!1,n([])})})}async function y(){const t=await R({});C.value=t.map(n=>({...n,hasChildren:!0}))}function b(t){const n=t?parseInt(t):0,{row:e,treeNode:s,resolve:i}=S.get(n)||{};e?T(e,s,i):y()}async function T(t,n,e){const{id:s}=t;S.set(s,{row:t,treeNode:n,resolve:e});const i=await R({pid:s});e(i)}function _(t,n,e){N(e,t,n,e)}return V(()=>{r.value=H().getMenuActions("menuOperator")}),M({onSearch:y,reloadTree:b}),(t,n)=>{var B;const e=g("el-button"),s=g("el-popconfirm"),i=g("PureTable");return u(),O("div",K,[f(c(G),{title:"\u83DC\u5355\u5217\u8868",loading:h.value,tableRef:(B=F.value)==null?void 0:B.getTableRef(),dataList:C.value,onRefresh:y},{buttons:d(()=>[r.value.some(l=>l=="2")?(u(),v(e,{key:0,type:"primary",size:"small",icon:c(m)("add"),onClick:n[0]||(n[0]=l=>_(null,"","create"))},{default:d(()=>[q(" \u65B0\u589E ")]),_:1},8,["icon"])):p("v-if",!0)]),default:d(({size:l,checkList:D})=>[f(i,{ref_key:"tableRef",ref:F,border:"",align:"left","row-key":"id","table-layout":"auto",size:l,lazy:!0,data:C.value,columns:c($),checkList:D,"tree-props":{hasChildren:"hasChildren",children:"child"},"header-cell-style":{background:"#fafafa",color:"#606266"},onSelectionChange:E,load:T},{operation:d(({row:o})=>[r.value.some(a=>a=="5")?(u(),v(e,{key:0,class:"reset-margin",link:"",type:"primary",size:l,onClick:a=>_(o,o.id,"view"),icon:c(m)("eye-view")},null,8,["size","onClick","icon"])):p("v-if",!0),r.value.some(a=>a=="4")?(u(),v(e,{key:1,class:"reset-margin",link:"",type:"primary",size:l,onClick:a=>_(o,o.id,"edit"),icon:c(m)("edits")},null,8,["size","onClick","icon"])):p("v-if",!0),r.value.some(a=>a=="7")&&o.status+""=="1"||r.value.some(a=>a=="6")&&o.status+""=="0"?(u(),v(s,{key:2,title:String(o.status)==="1"?"\u6539\u4E3A\u7981\u7528\uFF1F":"\u6539\u4E3A\u542F\u7528\uFF1F",onConfirm:a=>w(o)},{reference:d(()=>[f(e,{class:"reset-margin",link:"",type:"primary",size:l,icon:c(m)(String(o.status)==="1"?"close-circle-line":"checkbox-circle-line")},null,8,["size","icon"])]),_:2},1032,["title","onConfirm"])):p("v-if",!0),r.value.some(a=>a=="8")?(u(),v(s,{key:3,title:"\u662F\u5426\u786E\u8BA4\u5220\u9664?",onConfirm:a=>A(o)},{reference:d(()=>[f(e,{class:"reset-margin",link:"",type:"primary",size:l,icon:c(m)("delete")},null,8,["size","icon"])]),_:2},1032,["onConfirm"])):p("v-if",!0),p(`            v-if="row.menu_type + '' === '1' && powers.some(i => i == '002')"`),f(e,{class:"reset-margin",link:"",type:"primary",size:l,onClick:a=>_(null,o.id,"create"),icon:c(m)("add")},null,8,["size","onClick","icon"])]),_:2},1032,["size","data","columns","checkList"])]),_:1},8,["loading","tableRef","dataList"])])}}});var te=P(Q,[["__file","D:/work/rep-v3/report-v3/src/views/system/menuOperator/components/action-table.vue"]]);export{te as default};
