index.1bf4fa35.js 8.8 KB

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