1 |
- import{ak as J,al as he,a as K,r as w,W as re,I as Q,o as _e,b as V,c as u,e as r,f as y,h as p,m as _,l as E,F as S,i as B,n as fe,x as R,p as M,j as N,u as H,Y as ve,an as X,Q as pe,R as ge,_ as me}from"./index.4d061c66.js";import{u as ke}from"./hooks.9f8f44e2.js";import{u as Le}from"./useNav.5e73c372.js";import{r as z}from"./responseHandle.fe68d5aa.js";import{u as Ce}from"./usePermission.8064505c.js";import"./btnList.6c44b4ef.js";const{VITE_PROXY_DOMAIN_REAL:T}=he();async function we(v={}){return J.request("post",`${T}admin/roleRead`,{data:v})}async function Ae(v={}){return J.request("post",`${T}admin/roleEdit`,{data:v})}async function Ve(v={}){return J.request("post",`${T}admin/menuactionlist`,{data:v})}async function Ee(v={}){return J.request("post",`${T}admin/roleall`,{data:v})}const Se=v=>(pe("data-v-f29f86c9"),v=v(),ge(),v),Fe={class:"action"},Ue={class:"action_show"},Be={class:"action_show_box"},Re={class:"role-list"},Ne=Se(()=>_("p",{class:"role-list__title"},"\u89D2\u8272\u5217\u8868",-1)),De={key:0,style:{"line-height":"60px","text-align":"center",color:"#858599"}},Oe=["onClick"],ye={class:"rule-view"},Me={class:"rule-list",style:{padding:"0 0 100px 0"}},Pe={class:"ftitle"},$e={class:"fbody"},qe={class:"stitle"},ze={class:"_h2"},Je={key:0,class:"scheck"},Te={class:"checkAll"},Ge={class:"checkItem"},He={key:1,class:"sfield"},We={class:"checkAll"},Ye={class:"checkItem"},je={key:0,class:"rule-bottom"},Qe=K({name:"action"}),Xe=K({...Qe,setup(v){const W="setBtn",{hasPermissionWithCode:Ke,permissions:Z}=Ce(W),{logout:q}=Le(),F=w([]),g=w(!0),G=w([]),Y=w([]),s=w([]),D=w("add"),U=w([]),P=w([]),O=w([]),m=re({id:"",name:"",level:"1",action:[],private_data:[]});G.value=Z.value;const 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 ve(async()=>{await j(l)})},ie=async()=>{if(g.value)return;if(U.value=[],P.value=[],O.value=[],s.value.forEach(e=>{e.child.forEach(i=>{P.value.push(...i.fieldList),U.value.push(...i.checkList),i.is_private_change==="1"&&O.value.push(i.id)})}),U.value.length===0){X.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 Ae(t);z({code:l,message:n,logout:q,handler:()=>{X.success(n)}}),g.value=!1},ne=async()=>{const{code:t,data:l,message:n}=await Ve({});z({code:t,message:n,logout:q,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)),Y.value=e}})},ce=async()=>{const{code:t,data:l,message:n}=await Ee({});z({code:t,message:n,logout:q,handler:()=>{F.value=l!=null?l:[]}})},j=async t=>{g.value=!0;const{code:l,data:n,message:e}=await we({id:t});z({code:l,message:e,logout:q,handler:async()=>{const{action:i,action_data:a,private_data:d,id:A,name:f,level:k}=n!=null?n:{};m.id=A,m.name=f!=null?f:"",m.level=k!=null?k:"1",U.value=i!=null?i:[],P.value=a!=null?a:[],O.value=d!=null?d:[],await oe()}}),g.value=!1},oe=async()=>{s.value=JSON.parse(JSON.stringify(Y.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 f=U.value.findIndex(k=>k===A.id);f!==-1&&e.checkList.push(U.value[f]),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 f=P.value.findIndex(k=>k===A.id);f!==-1&&e.fieldList.push(P.value[f])}),e.action_data.length===e.fieldList.length&&(e.fieldAll=!0)),e.private&&e.private.length===2&&(O.value.length>0?O.value.findIndex(f=>f===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 j(F.value[0].id),g.value=!1}let de=Q(()=>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=Q(()=>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(()=>{G.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"),f=V("el-row"),k=V("PageAuth");return u(),r("div",Fe,[y(k,{pageName:W},{default:p(()=>[_("div",Ue,[_("div",Be,[_("ul",Re,[Ne,F.value.length==0?(u(),r("p",De," \u6682\u65E0\u6570\u636E ")):E("",!0),(u(!0),r(S,null,B(F.value,(h,L)=>(u(),r("li",{key:"role"+L,class:fe(["role-list__item",{active:h.id==m.id}]),onClick:c=>!g.value&&te(h)},[R(M(h.name)+" ",1),g.value&&h.id==m.id?(u(),N(n,{key:0,class:"fr",link:"",size:"small",icon:H(ke)("Loading")},null,8,["icon"])):E("",!0)],10,Oe))),128))]),_("div",ye,[_("div",Me,[(u(!0),r(S,null,B(s.value,(h,L)=>(u(),N(f,{key:"menu"+h.id+L},{default:p(()=>[h.child&&h.child.length>0?(u(),N(A,{key:0,class:"ffff",span:24},{default:p(()=>[_("div",Pe,[(u(!0),r(S,null,B(h.menu_name,(c,C)=>(u(),r("div",{key:"title"+C+c},M(c),1))),128))]),_("div",$e,[(u(!0),r(S,null,B(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",qe,[_("span",ze,M(c.menu_name),1),c&&c.private&&c.private.length===2?(u(),N(i,{key:0,style:{margin:"0 0 0 20px"},size:"small",modelValue:c.is_private_change,"onUpdate:modelValue":o=>c.is_private_change=o},{default:p(()=>[(u(!0),r(S,null,B(c.private,(o,$)=>(u(),N(e,{key:o.label+$,label:o.id},{default:p(()=>[R(M(o.label),1)]),_:2},1032,["label"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])):E("",!0)]),c.action&&c.action.length>0?(u(),r("div",Je,[_("div",Te,[y(a,{modelValue:c.checkAll,"onUpdate:modelValue":o=>c.checkAll=o,disabled:D.value==="view",size:"small",indeterminate:H(de)(c),onChange:o=>b(o,L,h,C)},{default:p(()=>[R("\u529F\u80FD\u5168\u9009")]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","indeterminate","onChange"])]),_("div",Ge,[y(d,{modelValue:c.checkList,"onUpdate:modelValue":o=>c.checkList=o,size:"small",disabled:D.value==="view",onChange:o=>I(o,L,h,C)},{default:p(()=>[(u(!0),r(S,null,B(c.action,o=>(u(),N(a,{disabled:D.value==="view",size:"small",key:"checkItem"+o.id,label:o.id,onChange:$=>le($,o.id,L,C)},{default:p(()=>[R(M(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",He,[_("div",We,[y(a,{modelValue:c.fieldAll,"onUpdate:modelValue":o=>c.fieldAll=o,size:"small",disabled:D.value==="view",indeterminate:H(ue)(c),onChange:o=>x(o,L,h,C)},{default:p(()=>[R("\u5B57\u6BB5\u5168\u9009")]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","indeterminate","onChange"])]),_("div",Ye,[y(d,{size:"small",modelValue:c.fieldList,"onUpdate:modelValue":o=>c.fieldList=o,disabled:D.value==="view",onChange:o=>ee(o,L,h,C)},{default:p(()=>[(u(!0),r(S,null,B(c.action_data,o=>(u(),N(a,{key:"FieldItem"+o.id,label:o.id,size:"small",disabled:D.value==="view",onChange:$=>ae($,o.id,L,C)},{default:p(()=>[R(M(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))])])]),G.value.some(h=>h=="001")?(u(),r("div",je,[y(n,{size:"small",type:"primary",onClick:ie},{default:p(()=>[R("\u63D0 \u4EA4")]),_:1})])):E("",!0)])]),_:1})])}}});const al=me(Xe,[["__scopeId","data-v-f29f86c9"]]);export{al as default};
|