index.807b62.js 9.8 KB

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