index.60a0d789.js 9.8 KB

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