import{useColumns as N}from"./columns.2906a8dd.js";import{b as D,p as k,H as P,k as g,o as c,c as V,j as y,A as u,h as m,l as H,f as i,E as d,aO as I}from"./index.4d3e3847.js";import{h as j,a as z,b as K}from"./menuOperator.24540560.js";import{T as M}from"./index.a5d44002.js";import{u as p}from"./hooks.428ba1c3.js";import{a as O}from"./useNav.afbe69e0.js";import{r as F}from"./responseHandle.db1518c7.js";const q={class:"main flex",style:{width:"100%"}},w=D({__name:"action-table",emits:["edit","create","view"],setup(G,{expose:B,emit:E}){const{logout:h}=O(),{columns:T}=N(),_=k([]),l=k([]),C=k(!0),x=k(),$=async o=>{const{id:n,status:t}=o,{code:r,message:b}=await j({id:n,status:t+""=="1"?"0":"1"});F({code:r,message:b,logout:h,handler:()=>f()})},L=async o=>{const{id:n}=o,{code:t,message:r}=await z({id:n});F({code:t,message:r,logout:h,handler:()=>f()})};function S(o){}async function f(){C.value=!0;const{code:o,data:n,message:t}=await K({});F({code:o,message:t,logout:h,handler:()=>{_.value=I(n!=null?n:[])}}),C.value=!1}function v(o,n,t){E(t,o,n,t)}return P(()=>{l.value=["001","002","003","004","005","006","007","008","009","010","011"]}),B({onSearch:f}),(o,n)=>{var R;const t=g("el-button"),r=g("el-popconfirm"),b=g("PureTable");return c(),V("div",q,[y(i(M),{title:"\u83DC\u5355\u5217\u8868",loading:C.value,tableRef:(R=x.value)==null?void 0:R.getTableRef(),dataList:_.value,onRefresh:f},{buttons:u(()=>[l.value.some(s=>s=="002")?(c(),m(t,{key:0,type:"primary",icon:i(p)("add"),onClick:n[0]||(n[0]=s=>v(null,"","create"))},{default:u(()=>[H(" \u65B0\u589E ")]),_:1},8,["icon"])):d("",!0)]),default:u(({size:s,checkList:A})=>[y(b,{ref_key:"tableRef",ref:x,border:"",align:"left","row-key":"id","table-layout":"auto","default-expand-all":"",size:s,data:_.value,columns:i(T),checkList:A,"tree-props":{hasChildren:"hasChildren",children:"child"},"header-cell-style":{background:"#fafafa",color:"#606266"},onSelectionChange:S},{operation:u(({row:a})=>[l.value.some(e=>e=="007")?(c(),m(t,{key:0,class:"reset-margin",link:"",type:"primary",size:s,onClick:e=>v(a,a.id,"view"),icon:i(p)("eye-view")},null,8,["size","onClick","icon"])):d("",!0),l.value.some(e=>e=="005")?(c(),m(t,{key:1,class:"reset-margin",link:"",type:"primary",size:s,onClick:e=>v(a,a.id,"edit"),icon:i(p)("edits")},null,8,["size","onClick","icon"])):d("",!0),l.value.some(e=>e=="004")&&a.status+""=="1"||l.value.some(e=>e=="003")&&a.status+""=="0"?(c(),m(r,{key:2,title:a.status==="1"?"\u6539\u4E3A\u7981\u7528\uFF1F":"\u6539\u4E3A\u542F\u7528\uFF1F",onConfirm:e=>$(a)},{reference:u(()=>[y(t,{class:"reset-margin",link:"",type:"primary",size:s,icon:i(p)(a.status==="1"?"close-circle-line":"checkbox-circle-line")},null,8,["size","icon"])]),_:2},1032,["title","onConfirm"])):d("",!0),l.value.some(e=>e=="006")?(c(),m(r,{key:3,title:"\u662F\u5426\u786E\u8BA4\u5220\u9664?",onConfirm:e=>L(a)},{reference:u(()=>[y(t,{class:"reset-margin",link:"",type:"primary",size:s,icon:i(p)("delete")},null,8,["size","icon"])]),_:2},1032,["onConfirm"])):d("",!0),a.menu_type+""=="1"&&l.value.some(e=>e=="002")?(c(),m(t,{key:4,class:"reset-margin",link:"",type:"primary",size:s,onClick:e=>v(null,a.id,"create"),icon:i(p)("add")},null,8,["size","onClick","icon"])):d("",!0)]),_:2},1032,["size","data","columns","checkList"])]),_:1},8,["loading","tableRef","dataList"])])}}});export{w as _};
