index.e162d3f3.js 9.7 KB

1
  1. import{aC as X,a2 as he,_ as _e,d as ve,v as fe,w,ad as pe,W as b,x as ge,X as me,z as ke,r as E,o as d,c as h,H as Y,K,u as O,b as _,a as p,F as V,D as y,l as z,C as g,M as F,J as x,au as Q,b2 as G,B as Se,L as M,G as D,Q as Le,R as Ce,y as we}from"./index.1d5f2f42.js";import{u as Ae}from"./useCompany.f3b703c8.js";const{VITE_PROXY_DOMAIN_REAL:al,VITE_PROXY_USER_REAL:Ee}=he(),P=Ee+"/admin/",Ve=f=>X.request("post",`${P}roleinfo`,{data:f}),Fe=f=>X.request("post",`${P}rolesave`,{data:f}),Be=f=>X.request("post",`${P}menuactionlist`,{data:f}),Ne=f=>X.request("post",`${P}roleall`,{data:f});const ye=f=>(Le("data-v-235465d4"),f=f(),Ce(),f),ze={class:"action"},De={class:"action_show"},Ue={class:"action_show_box"},Re={class:"role-list"},Oe=ye(()=>_("p",{class:"role-list__title"},"\u89D2\u8272\u5217\u8868",-1)),Me={key:0,style:{"line-height":"60px","text-align":"center",color:"#858599"}},Je=["onClick"],Te={class:"rule-view"},$e={class:"rule-list",style:{padding:"0 0 100px 0"}},qe={class:"ftitle"},He={class:"fbody"},Ge={class:"stitle clear"},Xe={class:"_h2 fl"},Pe={key:0,class:"scheck"},Ye={class:"checkAll"},Ke={class:"checkItem"},Qe={key:1,class:"sfield"},We={class:"checkAll"},je={class:"checkItem"},Ze={key:0,class:"rule-bottom"},be={class:"warning-message"},xe={name:"action"},Ie=ve({...xe,setup(f){const{logout:H}=fe(),{currentCompany:J}=Ae(),B=w([]),m=w(!0),T=w([]),W=w([]),s=w([]),U=w("add"),N=w([]),$=w([]),R=w([]),k=pe({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 we(async()=>{await j(l)})},oe=async()=>{if(m.value)return;if(N.value=[],$.value=[],R.value=[],s.value.forEach(e=>{e.child.forEach(n=>{$.value.push(...n.fieldList),N.value.push(...n.checkList),String(n.is_private_change)==="1"&&R.value.push(n.id)})}),N.value.length===0){Q.error("\u8BF7\u9009\u62E9\u529F\u80FD!");return}const a={roleid:k.roleid,role_name:k.role_name,level:k.level,action:N.value,private_data:R.value};m.value=!0;const{code:l,message:i}=await Fe(a);G({code:l,message:i,logout:H,handler:()=>{Q.success(i)}}),m.value=!1},ce=async()=>{const{code:a,data:l,message:i}=await Be({level:"2"});G({code:a,message:i,logout:H,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 Ne({companyNo:J.value.companyNo});G({code:a,message:i,logout:H,handler:()=>{B.value=l!=null?l:[]}})},j=async a=>{m.value=!0;const{code:l,data:i,message:e}=await Ve({roleid:a});G({code:l,message:e,logout:H,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",N.value=n!=null?n:[],$.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=N.value.findIndex(S=>String(S)===String(A.id));v!==-1&&e.checkList.push(N.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=$.value.findIndex(S=>String(S)===String(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&&(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(!J.value.companyNo){Q.warning("\u8BF7\u9009\u62E9\u4E00\u4E2A\u516C\u53F8");return}m.value=!0,await se(),await ce(),(B==null?void 0:B.value.length)>0&&await j(B.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 ge(()=>{T.value=me().getMenuActions("action"),T.value.some(a=>a=="001")&&Z()}),ke(()=>J.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",ze,[Y(_("div",null,[_("div",De,[_("div",Ue,[_("ul",Re,[Oe,p(" "),p(" "),p(' v-if="isBtnDisabled && item.id == roleActive.id" '),B.value.length==0?(d(),h("p",Me," \u6682\u65E0\u6570\u636E ")):p("v-if",!0),(d(!0),h(V,null,y(B.value,(r,L)=>(d(),h("li",{key:"role"+L,class:Se(["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,Je))),128))]),_("div",Te,[_("div",$e,[(d(!0),h(V,null,y(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",qe,[(d(!0),h(V,null,y(r.menu_name,(o,C)=>(d(),h("div",{key:"title"+C+o},M(o),1))),128))]),_("div",He,[(d(!0),h(V,null,y(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",Ge,[_("span",Xe,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,y(o.private,(c,q)=>(d(),D(e,{size:"small",key:c.label+q,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",Pe,[_("div",Ye,[z(t,{modelValue:o.checkAll,"onUpdate:modelValue":c=>o.checkAll=c,size:"small",disabled:U.value==="view",indeterminate:O(re)(o),onChange:c=>I(c,L,r,C)},{default:g(()=>[F("\u529F\u80FD\u5168\u9009")]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","indeterminate","onChange"])]),_("div",Ke,[z(u,{size:"small",modelValue:o.checkList,"onUpdate:modelValue":c=>o.checkList=c,disabled:U.value==="view",onChange:c=>le(c,L,r,C)},{default:g(()=>[(d(!0),h(V,null,y(o.action,c=>(d(),D(t,{size:"small",disabled:U.value==="view",key:"checkItem"+c.id,label:String(c.id),onChange:q=>te(q,String(c.id),L,C,r)},{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",Qe,[_("div",We,[z(t,{size:"small",modelValue:o.fieldAll,"onUpdate:modelValue":c=>o.fieldAll=c,disabled:U.value==="view",indeterminate:O(ue)(o),onChange:c=>ee(c,L,r,C)},{default:g(()=>[F("\u5B57\u6BB5\u5168\u9009")]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","indeterminate","onChange"])]),_("div",je,[z(u,{modelValue:o.fieldList,"onUpdate:modelValue":c=>o.fieldList=c,size:"small",disabled:U.value==="view",onChange:c=>ae(c,L,r,C)},{default:g(()=>[(d(!0),h(V,null,y(o.action_data,c=>(d(),D(t,{key:"FieldItem"+c.id,label:c.id,size:"small",disabled:U.value==="view",onChange:q=>ie(q,c.id,L,C,r)},{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))])])]),T.value.some(r=>r=="008")?(d(),h("div",Ze,[z(i,{size:"small",type:"primary",onClick:oe},{default:g(()=>[F("\u63D0 \u4EA4")]),_:1})])):p("v-if",!0)])],512),[[K,T.value.some(r=>r=="001")&&O(J).companyNo]]),Y(z(S,null,null,512),[[K,!T.value.some(r=>r=="001")]]),Y(_("h1",be,[z(i,{text:"",size:"large",icon:O(x)("warning-filled"),disabled:""},null,8,["icon"]),F(" \u8BF7\u5728\u53F3\u4E0A\u89D2\u9009\u62E9\u4E00\u5BB6\u4E1A\u52A1\u516C\u53F8 ")],512),[[K,!O(J).companyNo]])])}}});var tl=_e(Ie,[["__scopeId","data-v-235465d4"],["__file","D:/work/rep-v3/report-v3/src/views/interest/action/index.vue"]]);export{tl as default};