index.dce5a806.js 9.0 KB

1
  1. import{aJ as G,aK as he,b as z,p as w,a3 as re,e as Y,H as _e,k as V,o as u,c as r,K as Q,L as W,a as _,E,F as S,r as N,J as ve,l as B,t as y,h as D,f as j,A as p,j as J,y as fe,aL as Z,$ as pe,a0 as ge,_ as me}from"./index.4d3e3847.js";import{u as ke}from"./hooks.428ba1c3.js";import{a as Le}from"./useNav.afbe69e0.js";import{r as H}from"./responseHandle.db1518c7.js";const{VITE_PROXY_DOMAIN_REAL:K}=he();async function Ce(f={}){return G.request("post",`${K}admin/roleRead`,{data:f})}async function we(f={}){return G.request("post",`${K}admin/roleEdit`,{data:f})}async function Ae(f={}){return G.request("post",`${K}admin/menuactionlist`,{data:f})}async function Ve(f={}){return G.request("post",`${K}admin/roleall`,{data:f})}const Ee=f=>(pe("data-v-3b1d9187"),f=f(),ge(),f),Se={class:"action"},Fe={class:"action_show"},Ue={class:"action_show_box"},Ne={class:"role-list"},Be=Ee(()=>_("p",{class:"role-list__title"},"\u89D2\u8272\u5217\u8868",-1)),De={key:0,style:{"line-height":"60px","text-align":"center",color:"#858599"}},Re=["onClick"],Oe={class:"rule-view"},ye={class:"rule-list",style:{padding:"0 0 100px 0"}},Je={class:"ftitle"},Me={class:"fbody"},$e={class:"stitle"},qe={class:"_h2"},Te={key:0,class:"scheck"},He={class:"checkAll"},Ge={class:"checkItem"},Ke={key:1,class:"sfield"},je={class:"checkAll"},Pe={class:"checkItem"},Xe={key:0,class:"rule-bottom"},Ye=z({name:"action"}),Qe=z({...Ye,setup(f){const{logout:T}=Le(),F=w([]),g=w(!0),M=w([]),P=w([]),s=w([]),R=w("add"),U=w([]),$=w([]),O=w([]),m=re({id:"",name:"",level:"1",action:[],private_data:[]}),b=(t,l,n,e)=>{s.value[l].child[e].checkAll=t,s.value[l].child[e].action.forEach(i=>{const a=s.value[l].child[e].checkList.findIndex(d=>d===i.id);t&&a==-1?s.value[l].child[e].checkList.push(i.id):!t&&a>-1&&s.value[l].child[e].checkList.splice(a,1)})},x=(t,l,n,e)=>{s.value[l].child[e].fieldAll=t,s.value[l].child[e].action_data.forEach(i=>{const a=s.value[l].child[e].fieldList.findIndex(d=>d===i.id);t&&a==-1?s.value[l].child[e].fieldList.push(i.id):!t&&a>-1&&s.value[l].child[e].fieldList.splice(a,1)})},I=(t,l,n,e)=>{s.value[l].child[e].checkAll=s.value[l].child[e].action.every(i=>s.value[l].child[e].checkList.findIndex(a=>a===i.id)>-1)},ee=(t,l,n,e)=>{s.value[l].child[e].fieldAll=s.value[l].child[e].action_data.every(i=>s.value[l].child[e].fieldList.findIndex(a=>a===i.id)>-1)},le=(t,l,n,e,i)=>{if(t)s.value[n].child[e].checkList.indexOf(l)==-1&&s.value[n].child[e].checkList.push(l);else{const a=s.value[n].child[e].checkList.findIndex(d=>d==l);a>-1&&s.value[n].child[e].checkList.splice(a,1),s.value[n].child[e].checkAll=!1}},ae=(t,l,n,e,i)=>{if(t)s.value[n].child[e].fieldList.indexOf(l)==-1&&s.value[n].child[e].fieldList.push(l);else{const a=s.value[n].child[e].fieldList.findIndex(d=>d==l);a>-1&&s.value[n].child[e].fieldList.splice(a,1),s.value[n].child[e].fieldAll=!1}},te=async t=>{const{id:l}=t;m.id=l,await fe(async()=>{await X(l)})},ie=async()=>{if(g.value)return;if(U.value=[],$.value=[],O.value=[],s.value.forEach(e=>{e.child.forEach(i=>{$.value.push(...i.fieldList),U.value.push(...i.checkList),i.is_private_change==="1"&&O.value.push(i.id)})}),U.value.length===0){Z.error("\u8BF7\u9009\u62E9\u529F\u80FD!");return}const t={id:m.id,name:m.name,level:m.level,action_data:U.value,private_data:O.value};g.value=!0;const{code:l,message:n}=await we(t);H({code:l,message:n,logout:T,handler:()=>{Z.success(n)}}),g.value=!1},ne=async()=>{const{code:t,data:l,message:n}=await Ae({});H({code:t,message:n,logout:T,handler:()=>{let e=JSON.parse(JSON.stringify(l!=null?l:[]));e=e.filter(i=>i.child&&i.child.length>0),e=e.map(i=>(i.child.map(a=>(a.checkAll=!1,a.checkList=[],a.fieldAll=!1,a.fieldList=[],a.is_private_change="0",a.is_private==="0"?a.private=[]:a.private=[{id:"0",label:"\u516C\u6709\u6570\u636E"},{id:"1",label:"\u79C1\u6709\u6570\u636E"}],a.action&&a.action.length>0&&a.action.map(d=>(d.id=String(d.id),d.menuid=String(d.menuid),d.status=String(d.status),d)),a)),i)),P.value=e}})},ce=async()=>{const{code:t,data:l,message:n}=await Ve({});H({code:t,message:n,logout:T,handler:()=>{F.value=l!=null?l:[]}})},X=async t=>{g.value=!0;const{code:l,data:n,message:e}=await Ce({id:t});H({code:l,message:e,logout:T,handler:async()=>{const{action:i,action_data:a,private_data:d,id:A,name:v,level:k}=n!=null?n:{};m.id=A,m.name=v!=null?v:"",m.level=k!=null?k:"1",U.value=i!=null?i:[],$.value=a!=null?a:[],O.value=d!=null?d:[],await oe()}}),g.value=!1},oe=async()=>{s.value=JSON.parse(JSON.stringify(P.value)),s.value.forEach((t,l)=>{var n;((n=t==null?void 0:t.child)==null?void 0:n.length)>0&&t.child.forEach((e,i)=>{var a,d;((a=e==null?void 0:e.action)==null?void 0:a.length)>0&&e.action.forEach(A=>{const v=U.value.findIndex(k=>k===A.id);v!==-1&&e.checkList.push(U.value[v]),e.action.length===e.checkList.length&&(e.checkAll=!0)}),((d=e==null?void 0:e.action_data)==null?void 0:d.length)>0&&(e.action_data.map(A=>{const v=$.value.findIndex(k=>k===A.id);v!==-1&&e.fieldList.push($.value[v])}),e.action_data.length===e.fieldList.length&&(e.fieldAll=!0)),e.private&&e.private.length===2&&(O.value.length>0?O.value.findIndex(v=>v===e.id):-1)!==-1?e.is_private_change="1":e.is_private_change="0"})})};async function se(){g.value=!0,await ce(),await ne(),(F==null?void 0:F.value.length)>0&&await X(F.value[0].id),g.value=!1}let de=Y(()=>t=>{const l=t.action.filter(e=>t.checkList.findIndex(i=>i===e.id)>-1).length,n=t.action.filter(e=>t.checkList.findIndex(i=>i===e.id)==-1).length;return l>0&&n>0}),ue=Y(()=>t=>{const l=t.action_data.filter(e=>t.fieldList.findIndex(i=>i===e.id)>-1).length,n=t.action_data.filter(e=>t.fieldList.findIndex(i=>i===e.id)==-1).length;return l>0&&n>0});return _e(()=>{M.value=["001","002","003","004","005","006","007","008","009","010","011"],M.value.some(t=>t=="001")&&se()}),(t,l)=>{const n=V("el-button"),e=V("el-radio-button"),i=V("el-radio-group"),a=V("el-checkbox"),d=V("el-checkbox-group"),A=V("el-col"),v=V("el-row"),k=V("NoAuth");return u(),r("div",Se,[Q(_("div",null,[_("div",Fe,[_("div",Ue,[_("ul",Ne,[Be,F.value.length==0?(u(),r("p",De," \u6682\u65E0\u6570\u636E ")):E("",!0),(u(!0),r(S,null,N(F.value,(h,L)=>(u(),r("li",{key:"role"+L,class:ve(["role-list__item",{active:h.id==m.id}]),onClick:c=>!g.value&&te(h)},[B(y(h.name)+" ",1),g.value&&h.id==m.id?(u(),D(n,{key:0,class:"fr",link:"",size:"mini",icon:j(ke)("Loading")},null,8,["icon"])):E("",!0)],10,Re))),128))]),_("div",Oe,[_("div",ye,[(u(!0),r(S,null,N(s.value,(h,L)=>(u(),D(v,{key:"menu"+h.id+L},{default:p(()=>[h.child&&h.child.length>0?(u(),D(A,{key:0,class:"ffff",span:24},{default:p(()=>[_("div",Je,[(u(!0),r(S,null,N(h.menu_name,(c,C)=>(u(),r("div",{key:"title"+C+c},y(c),1))),128))]),_("div",Me,[(u(!0),r(S,null,N(h.child,(c,C)=>(u(),r("div",{class:"fbody-item",key:"yemian"+c.id+C},[c.action&&c.action.length===0&&c.action_data&&c.action_data.length===0?E("",!0):(u(),r(S,{key:0},[_("div",$e,[_("span",qe,y(c.menu_name),1),c&&c.private&&c.private.length===2?(u(),D(i,{key:0,style:{margin:"0 0 0 20px"},size:"mini",modelValue:c.is_private_change,"onUpdate:modelValue":o=>c.is_private_change=o},{default:p(()=>[(u(!0),r(S,null,N(c.private,(o,q)=>(u(),D(e,{key:o.label+q,label:o.id},{default:p(()=>[B(y(o.label),1)]),_:2},1032,["label"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])):E("",!0)]),c.action&&c.action.length>0?(u(),r("div",Te,[_("div",He,[J(a,{modelValue:c.checkAll,"onUpdate:modelValue":o=>c.checkAll=o,disabled:R.value==="view",indeterminate:j(de)(c),onChange:o=>b(o,L,h,C)},{default:p(()=>[B("\u529F\u80FD\u5168\u9009")]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","indeterminate","onChange"])]),_("div",Ge,[J(d,{modelValue:c.checkList,"onUpdate:modelValue":o=>c.checkList=o,disabled:R.value==="view",onChange:o=>I(o,L,h,C)},{default:p(()=>[(u(!0),r(S,null,N(c.action,o=>(u(),D(a,{disabled:R.value==="view",key:"checkItem"+o.id,label:o.id,onChange:q=>le(q,o.id,L,C)},{default:p(()=>[B(y(o.action_name),1)]),_:2},1032,["disabled","label","onChange"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","onChange"])])])):E("",!0),c.action_data&&c.action_data.length>0?(u(),r("div",Ke,[_("div",je,[J(a,{modelValue:c.fieldAll,"onUpdate:modelValue":o=>c.fieldAll=o,disabled:R.value==="view",indeterminate:j(ue)(c),onChange:o=>x(o,L,h,C)},{default:p(()=>[B("\u5B57\u6BB5\u5168\u9009")]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","indeterminate","onChange"])]),_("div",Pe,[J(d,{modelValue:c.fieldList,"onUpdate:modelValue":o=>c.fieldList=o,disabled:R.value==="view",onChange:o=>ee(o,L,h,C)},{default:p(()=>[(u(!0),r(S,null,N(c.action_data,o=>(u(),D(a,{key:"FieldItem"+o.id,label:o.id,disabled:R.value==="view",onChange:q=>ae(q,o.id,L,C)},{default:p(()=>[B(y(o.field_name),1)]),_:2},1032,["label","disabled","onChange"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","onChange"])])])):E("",!0)],64))]))),128))])]),_:2},1024)):E("",!0)]),_:2},1024))),128))])])]),M.value.some(h=>h=="008")?(u(),r("div",Xe,[J(n,{size:"small",type:"primary",onClick:ie},{default:p(()=>[B("\u63D0 \u4EA4")]),_:1})])):E("",!0)])],512),[[W,M.value.some(h=>h=="001")]]),Q(J(k,null,null,512),[[W,!M.value.some(h=>h=="001")]])])}}});const xe=me(Qe,[["__scopeId","data-v-3b1d9187"]]);export{xe as default};