action-table.6aeae880.js 3.6 KB

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