1 |
- import{aJ as M,aK as ge,b as ke,p as V,a3 as ee,x as Le,e as le,k,ac as Ce,K as Fe,o as h,h as B,A as r,j as g,c as C,r as q,f as W,b9 as Ve,F as S,a as p,t as K,l as $,E as P,aL as X,$ as we,a0 as De,y as Ae,_ as Ee}from"./index.4d3e3847.js";import{a as Be}from"./useNav.afbe69e0.js";const{VITE_PROXY_DOMAIN_REAL:N}=ge();async function ye(v={}){return M.request("post",`${N}admin/roleadd`,{data:v})}async function xe(v={}){return M.request("post",`${N}admin/rolelist`,{data:v})}async function Se(v={}){return M.request("post",`${N}admin/roleRead`,{data:v})}async function Ue(v={}){return M.request("post",`${N}admin/roleEdit`,{data:v})}async function Ie(v={}){return M.request("post",`${N}admin/rolestatus`,{data:v})}async function el(v={}){return M.request("post",`${N}admin/roleDelete`,{data:v})}async function Oe(v={}){return M.request("post",`${N}admin/menuactionlist`,{data:v})}const qe=v=>(we("data-v-dd037472"),v=v(),De(),v),$e={class:"quanxian-main"},Me=qe(()=>p("div",{class:"quanxian-title"},[p("div",{style:{color:"#ff8888"}},"*"),p("div",null,"\u529F"),p("div",null,"\u80FD"),p("div",null,"\u6743"),p("div",null,"\u9650")],-1)),Ne={class:"rule-view"},Te={class:"rule-list"},Je={class:"ftitle"},Re={class:"fbody"},je={class:"stitle"},Pe={class:"_h2"},be={key:0,class:"scheck"},Ge={class:"checkAll"},Ke={class:"checkItem"},Xe={key:1,class:"sfield"},Ye={class:"checkAll"},He={class:"checkItem"},Qe=ke({__name:"addEdit",props:{itemId:{type:String,default:""},showModel:{type:Boolean,default:!1},isDetails:{type:String,default:"add"}},emits:["cancel","refresh"],setup(v,{emit:Z}){const z=v,{logout:Y}=Be(),ae=V("default"),H=V(),U=V(!1),Q=V(""),m=V("create"),n=V([]),T=V([]),y=V([]),J=V([]),x={roleid:"",name:"",level:"1",action:"",private_data:""},L=ee({...x}),te=ee({name:[{required:!0,message:"\u8BF7\u8F93\u5165\u89D2\u8272\u540D\u79F0",trigger:"blur"},{min:2,max:12,message:"\u957F\u5EA6\u5728 2 \u5230 12 \u4E2A\u5B57\u7B26",trigger:"blur"}],level:[{required:!0,message:"\u8BF7\u9009\u62E9\u89D2\u8272\u7B49\u7EA7",trigger:"change"}]}),ie=(a,e,i,l)=>{n.value[e].child[l].checkAll=a,n.value[e].child[l].action.forEach(t=>{const o=n.value[e].child[l].checkList.findIndex(c=>c===t.id);a&&o==-1?n.value[e].child[l].checkList.push(t.id):!a&&o>-1&&n.value[e].child[l].checkList.splice(o,1)})},ne=(a,e,i,l)=>{n.value[e].child[l].fieldAll=a,n.value[e].child[l].action_data.forEach(t=>{const o=n.value[e].child[l].fieldList.findIndex(c=>c===t.id);a&&o==-1?n.value[e].child[l].fieldList.push(t.id):!a&&o>-1&&n.value[e].child[l].fieldList.splice(o,1)})},oe=(a,e,i,l)=>{n.value[e].child[l].checkAll=n.value[e].child[l].action.every(t=>n.value[e].child[l].checkList.findIndex(o=>o===t.id)>-1)},se=(a,e,i,l)=>{n.value[e].child[l].fieldAll=n.value[e].child[l].action_data.every(t=>n.value[e].child[l].fieldList.findIndex(o=>o===t.id)>-1)},de=(a,e,i,l,t)=>{if(a)n.value[i].child[l].checkList.indexOf(e)==-1&&n.value[i].child[l].checkList.push(e);else{const o=n.value[i].child[l].checkList.findIndex(c=>c==e);o>-1&&n.value[i].child[l].checkList.splice(o,1),n.value[i].child[l].checkAll=!1}},ce=(a,e,i,l,t)=>{if(a)n.value[i].child[l].fieldList.indexOf(e)==-1&&n.value[i].child[l].fieldList.push(e);else{const o=n.value[i].child[l].fieldList.findIndex(c=>c==e);o>-1&&n.value[i].child[l].fieldList.splice(o,1),n.value[i].child[l].fieldAll=!1}},ue=async a=>{!a||await a.validate(async(e,i)=>{if(e){if(O.value===!0)return;O.value=!0;const{level:l,name:t,roleid:o}=L;if(T.value=[],y.value=[],J.value=[],n.value.forEach(F=>{F.child.forEach(u=>{T.value.push(...u.fieldList),y.value.push(...u.checkList),u.is_private_change==="1"&&J.value.push(u.id)})}),y.value.length===0){X.error("\u8BF7\u9009\u62E9\u529F\u80FD!"),O.value=!1;return}let c={level:l,name:t,roleid:o,action_data:y.value,private_data:J.value};m.value==="create"&&delete c.roleid;const{code:_,message:j}=m.value==="create"?await ye(c):await Ue(c);O.value=!1,_===0?(X.success(R.value+"\u6210\u529F\uFF01"),U.value=!1,Z("refresh")):_>100&&_<140?(U.value=!1,Y()):X.error(j)}})},re=async(a,e)=>{!a||(a.clearValidate(),a.resetFields(),await Ae(async()=>{for(let i in L)i==="role"?L[i]=e.roleid||"":L[i]=e[i]}))},I=()=>{U.value=!1,Z("cancel")},O=V(!0),R=V("");async function he(a){switch(O.value=!0,m.value){case"create":R.value="\u65B0\u5EFA\u89D2\u8272";break;case"update":R.value="\u7F16\u8F91\u89D2\u8272";break;case"preview":R.value="\u89D2\u8272\u8BE6\u60C5";break;default:R.value="\u65B0\u5EFA\u89D2\u8272"}const{code:e,data:i,message:l}=await Oe({});if(e===0){let t=JSON.parse(JSON.stringify(i!=null?i:[]));t=t.filter(o=>o.child&&o.child.length>0),t=t.map(o=>(o.child.map(c=>(c.checkAll=!1,c.checkList=[],c.fieldAll=!1,c.fieldList=[],c.is_private_change="0",c.is_private==="0"?c.private=[]:c.private=[{id:"0",label:"\u516C\u6709\u6570\u636E"},{id:"1",label:"\u79C1\u6709\u6570\u636E"}],c.action&&c.action.length>0&&c.action.map(_=>(_.id=String(_.id),_.menuid=String(_.menuid),_.status=String(_.status),_)),c)),o)),n.value=t}else e>100&&e<140?Y():X.error(l);await re(H.value,a),m.value!=="create"&&await fe(),O.value=!1}const fe=async()=>{const{code:a,data:e,message:i}=await Se({id:Q.value});if(a===0){const{action:l,action_data:t,private_data:o,name:c,level:_}=e!=null?e:{};L.roleid=Q.value,L.name=c!=null?c:"",L.level=_!=null?_:"1",T.value=l!=null?l:[],y.value=t!=null?t:[],J.value=o!=null?o:[];const j=JSON.parse(JSON.stringify(n.value));j.map(F=>(F.child&&F.child.length>0&&F.child.map(u=>(u.action&&u.action.length>0&&(u.action.map(D=>{const w=T.value.length>0?T.value.findIndex(b=>b===D.id):-1;return w!==-1&&u.checkList.push(T.value[w]),D}),u.action.length===u.checkList.length&&(u.checkAll=!0)),u.action_data&&u.action_data.length>0&&(u.action.map(D=>{const w=y.value.length>0?y.value.findIndex(b=>b===D.id):-1;return w!==-1&&u.fieldList.push(y.value[w]),D}),u.action_data.length===u.fieldList.length&&(u.fieldAll=!0)),u.private&&u.private.length===2&&(J.value.length>0?J.value.findIndex(w=>w===u.id):-1)!==-1?u.is_private_change="1":u.is_private_change="0",u)),F)),n.value=j}else a>=100&&a<=104?Y():X.warning(i)};Le(()=>z.showModel,()=>{const{showModel:a,itemId:e,isDetails:i}=z;U.value=a,U.value&&(Q.value=e,m.value=i,he(x))});let ve=le(()=>a=>{const e=a.action.filter(l=>a.checkList.findIndex(t=>t===l.id)>-1).length,i=a.action.filter(l=>a.checkList.findIndex(t=>t===l.id)==-1).length;return e>0&&i>0}),_e=le(()=>a=>{const e=a.action_data.filter(l=>a.fieldList.findIndex(t=>t===l.id)>-1).length,i=a.action_data.filter(l=>a.fieldList.findIndex(t=>t===l.id)==-1).length;return e>0&&i>0});return(a,e)=>{const i=k("el-input"),l=k("el-form-item"),t=k("el-col"),o=k("el-option"),c=k("el-select"),_=k("el-radio-button"),j=k("el-radio-group"),F=k("el-checkbox"),u=k("el-checkbox-group"),D=k("el-row"),w=k("el-button"),b=k("el-form"),pe=k("el-dialog"),me=Ce("loading");return Fe((h(),B(pe,{"close-on-press-escape":!1,modelValue:U.value,"onUpdate:modelValue":e[3]||(e[3]=f=>U.value=f),"append-to-body":"",center:"",top:"5vh",width:"900px",title:R.value,onClose:I},{default:r(()=>[g(b,{ref_key:"ruleFormRef",ref:H,model:L,rules:te,"label-width":"90px",class:"role-addedit",size:ae.value,"status-icon":""},{default:r(()=>[g(D,null,{default:r(()=>[g(t,{span:12},{default:r(()=>[g(l,{label:"\u89D2\u8272\u540D\u79F0",prop:"name"},{default:r(()=>[g(i,{modelValue:L.name,"onUpdate:modelValue":e[0]||(e[0]=f=>L.name=f),disabled:m.value==="view",placeholder:"\u89D2\u8272\u540D\u79F0"},null,8,["modelValue","disabled"])]),_:1})]),_:1}),g(t,{span:12},{default:r(()=>[g(l,{label:"\u89D2\u8272\u7B49\u7EA7",prop:"level"},{default:r(()=>[g(c,{modelValue:L.level,"onUpdate:modelValue":e[1]||(e[1]=f=>L.level=f),style:{width:"100%"},disabled:m.value==="view",placeholder:"\u83DC\u5355\u7C7B\u578B"},{default:r(()=>[(h(!0),C(S,null,q(W(Ve),(f,A)=>(h(),B(o,{key:"type"+f.value+A,label:f.label,value:f.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"])]),_:1})]),_:1}),g(t,{span:24},{default:r(()=>[p("div",$e,[Me,p("div",Ne,[p("div",Te,[(h(!0),C(S,null,q(n.value,(f,A)=>(h(),B(D,{key:"menu"+f.id+A},{default:r(()=>[f.child&&f.child.length>0?(h(),B(t,{key:0,class:"ffff",span:24},{default:r(()=>[p("div",Je,[(h(!0),C(S,null,q(f.menu_name,(s,E)=>(h(),C("div",{key:"title"+E+s},K(s),1))),128))]),p("div",Re,[(h(!0),C(S,null,q(f.child,(s,E)=>(h(),C("div",{class:"fbody-item",key:"yemian"+s.id+E},[s.action&&s.action.length===0&&s.action_data&&s.action_data.length===0?P("",!0):(h(),C(S,{key:0},[p("div",je,[p("span",Pe,K(s.menu_name),1),s&&s.private&&s.private.length===2?(h(),B(j,{key:0,style:{margin:"0 0 0 20px"},size:"mini",modelValue:s.is_private_change,"onUpdate:modelValue":d=>s.is_private_change=d},{default:r(()=>[(h(!0),C(S,null,q(s.private,(d,G)=>(h(),B(_,{key:d.label+G,label:d.id},{default:r(()=>[$(K(d.label),1)]),_:2},1032,["label"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])):P("",!0)]),s.action&&s.action.length>0?(h(),C("div",be,[p("div",Ge,[g(F,{modelValue:s.checkAll,"onUpdate:modelValue":d=>s.checkAll=d,disabled:m.value==="view",indeterminate:W(ve)(s),onChange:d=>ie(d,A,f,E)},{default:r(()=>[$("\u529F\u80FD\u5168\u9009")]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","indeterminate","onChange"])]),p("div",Ke,[g(u,{modelValue:s.checkList,"onUpdate:modelValue":d=>s.checkList=d,disabled:m.value==="view",onChange:d=>oe(d,A,f,E)},{default:r(()=>[(h(!0),C(S,null,q(s.action,d=>(h(),B(F,{disabled:m.value==="view",key:"checkItem"+d.id,label:d.id,onChange:G=>de(G,d.id,A,E)},{default:r(()=>[$(K(d.action_name),1)]),_:2},1032,["disabled","label","onChange"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","onChange"])])])):P("",!0),s.action_data&&s.action_data.length>0?(h(),C("div",Xe,[p("div",Ye,[g(F,{modelValue:s.fieldAll,"onUpdate:modelValue":d=>s.fieldAll=d,disabled:m.value==="view",indeterminate:W(_e)(s),onChange:d=>ne(d,A,f,E)},{default:r(()=>[$("\u5B57\u6BB5\u5168\u9009")]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","indeterminate","onChange"])]),p("div",He,[g(u,{modelValue:s.fieldList,"onUpdate:modelValue":d=>s.fieldList=d,disabled:m.value==="view",onChange:d=>se(d,A,f,E)},{default:r(()=>[(h(!0),C(S,null,q(s.action_data,d=>(h(),B(F,{key:"FieldItem"+d.id,label:d.id,disabled:m.value==="view",onChange:G=>ce(G,d.id,A,E)},{default:r(()=>[$(K(d.field_name),1)]),_:2},1032,["label","disabled","onChange"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","onChange"])])])):P("",!0)],64))]))),128))])]),_:2},1024)):P("",!0)]),_:2},1024))),128))])])])]),_:1})]),_:1}),g(t,{span:24,class:"clear"},{default:r(()=>[m.value==="create"||m.value==="edit"?(h(),B(w,{key:0,type:"primary",class:"fr",style:{margin:"0 0 0 16px"},onClick:e[2]||(e[2]=f=>ue(H.value))},{default:r(()=>[$("\u4FDD\u5B58")]),_:1})):P("",!0),g(w,{class:"fr",style:{margin:"0 0 0 16px"},onClick:I},{default:r(()=>[$("\u5173\u95ED")]),_:1})]),_:1})]),_:1},8,["model","rules","size"])]),_:1},8,["modelValue","title"])),[[me,O.value]])}}});const We=Ee(Qe,[["__scopeId","data-v-dd037472"]]),ll=Object.freeze(Object.defineProperty({__proto__:null,default:We},Symbol.toStringTag,{value:"Module"}));export{xe as a,Ue as b,Ie as c,el as d,We as e,ll as f,ye as h};
|