import{ck as M,X as he,_ as ve,d as fe,l as pe,m as k,a8 as K,w as _e,Q as W,r as F,ag as me,B as Z,o as v,A as V,x as f,h as D,b as p,c as A,F as x,y as U,G as R,H as $,a as e,u as ge,ce as O,L as ke,M as Fe,p as we}from"./index.56449854.js";import{u as be}from"./useCompany.e9cb4fed.js";const{VITE_PROXY_DOMAIN_REAL:Ge,VITE_PROXY_USER_REAL:Le}=he(),T=Le+"/admin/",Ce=h=>M.request("post",`${T}role/create`,{data:h}),Ie=h=>M.request("post",`${T}role/list`,{data:h}),De=h=>M.request("post",`${T}role/info`,{data:h}),Ae=h=>M.request("post",`${T}role/save`,{data:h}),Pe=h=>M.request("post",`${T}role/status`,{data:h}),Ve=h=>M.request("post",`${T}menu/MenuAction`,{data:h});const ye=h=>(ke("data-v-afaf9330"),h=h(),Fe(),h),Ee={class:"quanxian-main"},Se=ye(()=>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)),Be={class:"rule-view"},Ne={class:"rule-list"},xe={class:"ftitle"},Me={class:"fbody"},Te={class:"stitle clear"},Ue={class:"_h2 fl"},$e={key:0,class:"scheck"},Oe={class:"checkAll"},qe={class:"checkItem"},Re=fe({__name:"addEdit",props:{itemId:{type:String,default:""},showModel:{type:Boolean,default:!1},isDetails:{type:String,default:"add"}},emits:["cancel","refresh"],setup(h,{emit:I}){const P=h,{logout:z}=pe(),ee=k("small"),J=k();be();const y=k(!1),j=k(""),m=k("add"),u=k([]),S=k([]),E=k([]),X=k([]),Y={roleid:"",role_name:"",level:"2",action:"",private_data:""},b=K({...Y}),le=K({role_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"}]}),te=(t,l,s,a)=>{u.value[l].child[a].checkAll=t,u.value[l].child[a].child.forEach(i=>{const d=u.value[l].child[a].checkList.findIndex(n=>n===Number(i.id));t&&d==-1?u.value[l].child[a].checkList.push(Number(i.id)):!t&&d>-1&&u.value[l].child[a].checkList.splice(d,1)})},ae=(t,l,s,a)=>{u.value[l].child[a].checkAll=u.value[l].child[a].child.every(i=>u.value[l].child[a].checkList.findIndex(d=>d==Number(i.id))>-1)},ie=(t,l,s,a,i)=>{if(t)u.value[s].child[a].checkList.indexOf(l)==-1&&u.value[s].child[a].checkList.push(l);else{const d=u.value[s].child[a].checkList.findIndex(n=>n==l);d>-1&&u.value[s].child[a].checkList.splice(d,1),u.value[s].child[a].checkAll=!1}},se=async t=>{!t||await t.validate(async(l,s)=>{if(l){if(L.value==!0)return;L.value=!0;const{level:a,role_name:i,roleid:d}=b;if(S.value=[],E.value=[],X.value=[],u.value.forEach(w=>{w.child.forEach(g=>{S.value.push(...g.fieldList),E.value.push(...g.checkList),g.is_private_change=="1"&&X.value.push(g.id)})}),E.value.length==0){O.error("\u8BF7\u9009\u62E9\u529F\u80FD!"),L.value=!1;return}let n={role_name:i,id:d,action:E.value,status:"1"};m.value=="add"&&delete n.roleid;const{code:o,message:C}=m.value=="add"?await Ce(n):await Ae(n);L.value=!1,o==1?(O.success(B.value+"\u6210\u529F\uFF01"),y.value=!1,I("refresh")):o>100&&o<140?(y.value=!1,z()):O.error(C)}})},ne=async(t,l)=>{!t||(t.clearValidate(),t.resetFields(),await we(async()=>{for(let s in b)s=="role"?b[s]=l.roleid||"":b[s]=l[s]}))},H=()=>{y.value=!1,I("cancel")},L=k(!0),B=k("");async function ce(t){switch(L.value=!0,m.value){case"add":B.value="\u65B0\u5EFA\u89D2\u8272";break;case"edit":B.value="\u7F16\u8F91\u89D2\u8272";break;case"view":B.value="\u89D2\u8272\u8BE6\u60C5";break;default:B.value="\u65B0\u5EFA\u89D2\u8272"}const{code:l,data:s,message:a}=await Ve({});if(l==1){let i=JSON.parse(JSON.stringify(s!=null?s:[]));i=i.filter(d=>d.child&&d.child.length>0),i=i.map(d=>(d.child.map(n=>(n.checkAll=!1,n.checkList=[],n.fieldAll=!1,n.fieldList=[],n.is_private_change="0",n.is_private=="0"?n.private=[]:n.private=[],n)),d)),u.value=i}else l>100&&l<140?z():O.error(a);await ne(J.value,t),m.value!=="add"&&await oe(),L.value=!1}const oe=async()=>{const{code:t,data:l,message:s}=await De({id:j.value});if(t==1){const{role_name:a,action:i}=l!=null?l:{};b.roleid=j.value,b.role_name=a!=null?a:"",S.value=i?i.map(n=>Number(n)):[];const d=JSON.parse(JSON.stringify(u.value));d.map(n=>(n.child&&n.child.length>0&&n.child.map(o=>(o.child&&o.child.length>0&&(o.child.map(C=>{const w=S.value.length>0?S.value.findIndex(g=>g==C.id):-1;return w!==-1&&o.checkList.push(S.value[w]),C}),o.child.length==o.checkList.length&&(o.checkAll=!0)),o.child&&o.child.length>0&&(o.child.map(C=>{const w=E.value.length>0?E.value.findIndex(g=>g==C.id):-1;return w!==-1&&o.fieldList.push(E.value[w]),C}),o.child.length==o.fieldList.length&&(o.fieldAll=!0)),o)),n)),u.value=d}else t>=100&&t<=104?z():O.warning(s)};_e(()=>P.showModel,()=>{const{showModel:t,itemId:l,isDetails:s}=P;y.value=t,y.value&&(j.value=l,m.value=s,ce(Y))});let de=W(()=>t=>{const l=t.child.filter(a=>t.checkList.findIndex(i=>Number(i)==a.id)>-1).length,s=t.child.filter(a=>t.checkList.findIndex(i=>Number(i)==a.id)==-1).length;return l>0&&s>0});return W(()=>t=>{const l=t.child.filter(a=>t.fieldList.findIndex(i=>i==a.id)>-1).length,s=t.child.filter(a=>t.fieldList.findIndex(i=>i==a.id)==-1).length;return l>0&&s>0}),(t,l)=>{const s=F("el-input"),a=F("el-form-item"),i=F("el-col"),d=F("el-radio-button"),n=F("el-radio-group"),o=F("el-checkbox"),C=F("el-checkbox-group"),w=F("el-row"),g=F("el-button"),ue=F("el-form"),re=F("el-dialog"),Q=me("loading");return Z((v(),V(re,{"close-on-click-modal":!1,"close-on-press-escape":!1,modelValue:y.value,"onUpdate:modelValue":l[2]||(l[2]=_=>y.value=_),"append-to-body":"",center:"",top:"5vh",width:"900px",title:B.value,onClose:H},{default:f(()=>[Z((v(),V(ue,{ref_key:"ruleFormRef",ref:J,model:b,rules:le,"label-width":"90px",class:"role-addedit",size:ee.value,"status-icon":""},{default:f(()=>[D(w,null,{default:f(()=>[D(i,{span:24},{default:f(()=>[D(a,{label:"\u89D2\u8272\u540D\u79F0",prop:"role_name"},{default:f(()=>[D(s,{modelValue:b.role_name,"onUpdate:modelValue":l[0]||(l[0]=_=>b.role_name=_),disabled:m.value=="view",placeholder:"\u89D2\u8272\u540D\u79F0"},null,8,["modelValue","disabled"])]),_:1})]),_:1}),D(i,{span:24},{default:f(()=>[p("div",Ee,[Se,p("div",Be,[p("div",Ne,[(v(!0),A(x,null,U(u.value,(_,q)=>(v(),V(w,{key:"menu"+_.id+q},{default:f(()=>[_.child&&_.child.length>0?(v(),V(i,{key:0,class:"ffff",span:24},{default:f(()=>[p("div",xe,[(v(!0),A(x,null,U(_.menu_name,(c,N)=>(v(),A("div",{key:"title"+N+c},R(c),1))),128))]),p("div",Me,[(v(!0),A(x,null,U(_.child,(c,N)=>(v(),A("div",{class:"fbody-item",key:"yemian"+c.id+N},[c.action&&c.action.length==0&&c.child&&c.child.length==0?e("v-if",!0):(v(),A(x,{key:0},[p("div",Te,[p("span",Ue,R(c.menu_name),1),c&&c.private&&c.private.length==2?(v(),V(n,{key:0,style:{margin:"0 0 0 20px"},class:"fl",size:"small",modelValue:c.is_private_change,"onUpdate:modelValue":r=>c.is_private_change=r},{default:f(()=>[(v(!0),A(x,null,U(c.private,(r,G)=>(v(),V(d,{size:"small",key:r.label+G,label:String(r.id)},{default:f(()=>[$(R(r.label),1)]),_:2},1032,["label"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])):e("v-if",!0)]),c.child&&c.child.length>0?(v(),A("div",$e,[p("div",Oe,[D(o,{modelValue:c.checkAll,"onUpdate:modelValue":r=>c.checkAll=r,disabled:m.value=="view",indeterminate:ge(de)(c),onChange:r=>te(r,q,_,N)},{default:f(()=>[$("\u529F\u80FD\u5168\u9009")]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","indeterminate","onChange"])]),p("div",qe,[D(C,{modelValue:c.checkList,"onUpdate:modelValue":r=>c.checkList=r,disabled:m.value=="view",onChange:r=>ae(r,q,_,N)},{default:f(()=>[(v(!0),A(x,null,U(c.child,r=>(v(),V(o,{disabled:m.value=="view",key:"checkItem"+r.id,label:Number(r.id),onChange:G=>ie(G,Number(r.id),q,N,_)},{default:f(()=>[$(R(r.action_name),1)]),_:2},1032,["disabled","label","onChange"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","onChange"])])])):e("v-if",!0),e(" 0"),e(' "'),e(" >"),e('
'),e(" \u5B57\u6BB5\u5168\u9009"),e("
"),e('
'),e(" "),e(" {{ children.field_name }}"),e(" "),e("
"),e(" ")],64))]))),128))])]),_:2},1024)):e("v-if",!0)]),_:2},1024))),128))])])])]),_:1})]),_:1}),D(i,{span:24,class:"clear"},{default:f(()=>[m.value=="add"||m.value=="edit"?(v(),V(g,{key:0,type:"primary",class:"fr",loading:L.value,style:{margin:"0 0 0 16px"},onClick:l[1]||(l[1]=_=>se(J.value))},{default:f(()=>[$("\u4FDD\u5B58")]),_:1},8,["loading"])):e("v-if",!0),D(g,{class:"fr",style:{margin:"0 0 0 16px"},onClick:H},{default:f(()=>[$("\u5173\u95ED")]),_:1})]),_:1})]),_:1},8,["model","rules","size"])),[[Q,L.value]])]),_:1},8,["modelValue","title"])),[[Q,L.value]])}}});var ze=ve(Re,[["__scopeId","data-v-afaf9330"],["__file","C:/Users/89793/Desktop/projects/report-v3/src/views/system/role/addEdit.vue"]]),Xe=Object.freeze(Object.defineProperty({__proto__:null,default:ze},Symbol.toStringTag,{value:"Module"}));export{ze as a,Ie as b,Xe as c,Pe as h};