edit-dialog.0ea8797a.js 11 KB

1
  1. import{ak as N,al as pe,a as me,r as V,W as ge,I as K,b as g,a7 as ke,Z as Le,c as v,j as B,h as c,f as m,e as k,i as q,u as W,F as O,m as p,p as G,x as y,l as T,an as x,Q as Ve,R as Ce,_ as Fe}from"./index.4d061c66.js";import{r as X}from"./responseHandle.fe68d5aa.js";import{u as we}from"./useNav.5e73c372.js";import{L as De}from"./status.2b37e8be.js";const{VITE_PROXY_DOMAIN_REAL:$}=pe();async function Ee(f={}){return N.request("post",`${$}admin/roleadd`,{data:f})}async function Ke(f={}){return N.request("post",`${$}admin/rolelist`,{data:f})}async function Ae(f={}){return N.request("post",`${$}admin/roleRead`,{data:f})}async function Be(f={}){return N.request("post",`${$}admin/roleEdit`,{data:f})}async function xe(f={}){return N.request("post",`${$}admin/rolestatus`,{data:f})}async function Ie(f={}){return N.request("post",`${$}admin/roleDelete`,{data:f})}async function Se(f={}){return N.request("post",`${$}admin/menuactionlist`,{data:f})}const Ue=f=>(Ve("data-v-e68f799c"),f=f(),Ce(),f),Oe={class:"quanxian-main"},qe=Ue(()=>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)),ye={class:"rule-view"},Ne={class:"rule-list"},$e={class:"ftitle"},be={class:"fbody"},Me={class:"stitle"},Re={class:"_h2"},Te={key:0,class:"scheck"},je={class:"checkAll"},Je={class:"checkItem"},Pe={key:1,class:"sfield"},ze={class:"checkAll"},Ge={class:"checkItem"},Ye=me({__name:"edit-dialog",emits:["reload"],setup(f,{expose:I,emit:ee}){const{logout:Y}=we(),Z=V(),j=V(!1),S=V(!1),b=V(""),H=V(""),_=V("create"),n=V([]),M=V([]),U=V([]),R=V([]),Q={roleid:"",name:"",level:"1",action:"",private_data:""},L=V({...Q}),le=ge({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"}]}),ae=(i,l,s,e)=>{n.value[l].child[e].checkAll=i,n.value[l].child[e].action.forEach(a=>{const t=n.value[l].child[e].checkList.findIndex(r=>r===a.id);i&&t==-1?n.value[l].child[e].checkList.push(a.id):!i&&t>-1&&n.value[l].child[e].checkList.splice(t,1)})},te=(i,l,s,e)=>{n.value[l].child[e].fieldAll=i,n.value[l].child[e].action_data.forEach(a=>{const t=n.value[l].child[e].fieldList.findIndex(r=>r===a.id);i&&t==-1?n.value[l].child[e].fieldList.push(a.id):!i&&t>-1&&n.value[l].child[e].fieldList.splice(t,1)})},ie=(i,l,s,e)=>{n.value[l].child[e].checkAll=n.value[l].child[e].action.every(a=>n.value[l].child[e].checkList.findIndex(t=>t===a.id)>-1)},ne=(i,l,s,e)=>{n.value[l].child[e].fieldAll=n.value[l].child[e].action_data.every(a=>n.value[l].child[e].fieldList.findIndex(t=>t===a.id)>-1)},oe=(i,l,s,e,a)=>{if(i)n.value[s].child[e].checkList.indexOf(l)==-1&&n.value[s].child[e].checkList.push(l);else{const t=n.value[s].child[e].checkList.findIndex(r=>r==l);t>-1&&n.value[s].child[e].checkList.splice(t,1),n.value[s].child[e].checkAll=!1}},ue=(i,l,s,e,a)=>{if(i)n.value[s].child[e].fieldList.indexOf(l)==-1&&n.value[s].child[e].fieldList.push(l);else{const t=n.value[s].child[e].fieldList.findIndex(r=>r==l);t>-1&&n.value[s].child[e].fieldList.splice(t,1),n.value[s].child[e].fieldAll=!1}};function se(){Z.value.validate(async i=>{if(i){if(S.value)return;S.value=!0;const{level:l,name:s,roleid:e}=L.value;if(M.value=[],U.value=[],R.value=[],n.value.forEach(J=>{J.child.forEach(F=>{M.value.push(...F.fieldList),U.value.push(...F.checkList),F.is_private_change==="1"&&R.value.push(F.id)})}),U.value.length===0){x.error("\u8BF7\u9009\u62E9\u529F\u80FD!"),S.value=!1;return}let a={level:l,name:s,id:e,action_data:U.value,private_data:R.value};_.value==="create"&&delete a.roleid;const{code:t,message:r}=_.value==="create"?await Ee(a):await Be(a);S.value=!1,X({code:t,message:r,logout:Y,handler:()=>{x.success(b.value+"\u6210\u529F\uFF01"),j.value=!1,ee("reload")}})}})}const de=async()=>{const{code:i,data:l,message:s}=await Ae({id:H.value});X({code:i,message:s,logout:Y,handler:()=>{const{action:e,action_data:a,private_data:t,name:r,level:J}=l!=null?l:{};L.value.roleid=H.value,L.value.name=r+""||"",L.value.level=J+""||"1",M.value=e!=null?e:[],U.value=a!=null?a:[],R.value=t!=null?t:[];const F=JSON.parse(JSON.stringify(n.value));F.map(w=>(w.child&&w.child.length>0&&w.child.map(d=>(d.action&&d.action.length>0&&(d.action.map(D=>{const C=M.value.length>0?M.value.findIndex(P=>P===D.id):-1;return C!==-1&&d.checkList.push(M.value[C]),D}),d.action.length===d.checkList.length&&(d.checkAll=!0)),d.action_data&&d.action_data.length>0&&(d.action.map(D=>{const C=U.value.length>0?U.value.findIndex(P=>P===D.id):-1;return C!==-1&&d.fieldList.push(U.value[C]),D}),d.action_data.length===d.fieldList.length&&(d.fieldAll=!0)),d.private&&d.private.length===2&&(R.value.length>0?R.value.findIndex(C=>C===d.id):-1)!==-1?d.is_private_change="1":d.is_private_change="0",d)),w)),n.value=F}})};async function ce(i,l,s){switch(S.value=!0,H.value=l,Object.keys(L.value).forEach(e=>{L.value[e]=s==="create"?Q[e]?Q[e]+"":"":i[e]?i[e]+"":""}),_.value=s,_.value){case"create":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"}await re(),_.value!=="create"&&await de(),j.value=!0,S.value=!1}async function re(){const{code:i,data:l,message:s}=await Se({});X({code:i,message:s,logout:Y,handler:()=>{let e=JSON.parse(JSON.stringify(l!=null?l:[]));e=e.filter(a=>a.child&&a.child.length>0),e=e.map(a=>(a.child.map(t=>(t.checkAll=!1,t.checkList=[],t.fieldAll=!1,t.fieldList=[],t.is_private_change="0",t.is_private==="0"?t.private=[]:t.private=[{id:"0",label:"\u516C\u6709\u6570\u636E"},{id:"1",label:"\u79C1\u6709\u6570\u636E"}],t.action&&t.action.length>0&&t.action.map(r=>(r.id=String(r.id),r.menuid=String(r.menuid),r.status=String(r.status),r)),t)),a)),n.value=e}})}let ve=K(()=>i=>{const l=i.action.filter(e=>i.checkList.findIndex(a=>a===e.id)>-1).length,s=i.action.filter(e=>i.checkList.findIndex(a=>a===e.id)==-1).length;return l>0&&s>0}),he=K(()=>i=>{const l=i.action_data.filter(e=>i.fieldList.findIndex(a=>a===e.id)>-1).length,s=i.action_data.filter(e=>i.fieldList.findIndex(a=>a===e.id)==-1).length;return l>0&&s>0});return I({show:ce}),(i,l)=>{const s=g("el-input"),e=g("el-form-item"),a=g("el-col"),t=g("el-option"),r=g("el-select"),J=g("el-radio-button"),F=g("el-radio-group"),w=g("el-checkbox"),d=g("el-checkbox-group"),D=g("el-row"),C=g("el-button"),P=g("el-form"),fe=g("el-dialog"),_e=ke("loading");return Le((v(),B(fe,{"close-on-press-escape":!1,modelValue:j.value,"onUpdate:modelValue":l[3]||(l[3]=h=>j.value=h),"append-to-body":"",center:"",top:"5vh",width:"900px",title:b.value},{default:c(()=>[m(P,{ref_key:"formRef",ref:Z,model:L.value,rules:le,"label-width":"90px",class:"role-addedit",size:"small","status-icon":""},{default:c(()=>[m(D,null,{default:c(()=>[m(a,{span:12},{default:c(()=>[m(e,{label:"\u89D2\u8272\u540D\u79F0",prop:"name"},{default:c(()=>[m(s,{modelValue:L.value.name,"onUpdate:modelValue":l[0]||(l[0]=h=>L.value.name=h),disabled:_.value==="view",placeholder:"\u89D2\u8272\u540D\u79F0"},null,8,["modelValue","disabled"])]),_:1})]),_:1}),m(a,{span:12},{default:c(()=>[m(e,{label:"\u89D2\u8272\u7B49\u7EA7",prop:"level"},{default:c(()=>[m(r,{modelValue:L.value.level,"onUpdate:modelValue":l[1]||(l[1]=h=>L.value.level=h),style:{width:"100%"},disabled:_.value==="view",placeholder:"\u83DC\u5355\u7C7B\u578B"},{default:c(()=>[(v(!0),k(O,null,q(W(De),(h,E)=>(v(),B(t,{key:"type"+h.value+E,label:h.label,value:h.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"])]),_:1})]),_:1}),m(a,{span:24},{default:c(()=>[p("div",Oe,[qe,p("div",ye,[p("div",Ne,[(v(!0),k(O,null,q(n.value,(h,E)=>(v(),B(D,{key:"menu"+h.id+E},{default:c(()=>[h.child&&h.child.length>0?(v(),B(a,{key:0,class:"ffff",span:24},{default:c(()=>[p("div",$e,[(v(!0),k(O,null,q(h.menu_name,(o,A)=>(v(),k("div",{key:"title"+A+o},G(o),1))),128))]),p("div",be,[(v(!0),k(O,null,q(h.child,(o,A)=>(v(),k("div",{class:"fbody-item",key:"yemian"+o.id+A},[o.action&&o.action.length===0&&o.action_data&&o.action_data.length===0?T("",!0):(v(),k(O,{key:0},[p("div",Me,[p("span",Re,G(o.menu_name),1),o&&o.private&&o.private.length===2?(v(),B(F,{key:0,style:{margin:"0 0 0 20px"},size:"small",disabled:_.value==="view",modelValue:o.is_private_change,"onUpdate:modelValue":u=>o.is_private_change=u},{default:c(()=>[(v(!0),k(O,null,q(o.private,(u,z)=>(v(),B(J,{key:u.label+z,label:u.id,disabled:_.value==="view",size:"small"},{default:c(()=>[y(G(u.label),1)]),_:2},1032,["label","disabled"]))),128))]),_:2},1032,["disabled","modelValue","onUpdate:modelValue"])):T("",!0)]),o.action&&o.action.length>0?(v(),k("div",Te,[p("div",je,[m(w,{modelValue:o.checkAll,"onUpdate:modelValue":u=>o.checkAll=u,disabled:_.value==="view",size:"small",indeterminate:W(ve)(o),onChange:u=>ae(u,E,h,A)},{default:c(()=>[y("\u529F\u80FD\u5168\u9009")]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","indeterminate","onChange"])]),p("div",Je,[m(d,{modelValue:o.checkList,"onUpdate:modelValue":u=>o.checkList=u,size:"small",disabled:_.value==="view",onChange:u=>ie(u,E,h,A)},{default:c(()=>[(v(!0),k(O,null,q(o.action,u=>(v(),B(w,{disabled:_.value==="view",size:"small",key:"checkItem"+u.id,label:u.id,onChange:z=>oe(z,u.id,E,A)},{default:c(()=>[y(G(u.action_name),1)]),_:2},1032,["disabled","label","onChange"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","onChange"])])])):T("",!0),o.action_data&&o.action_data.length>0?(v(),k("div",Pe,[p("div",ze,[m(w,{modelValue:o.fieldAll,"onUpdate:modelValue":u=>o.fieldAll=u,disabled:_.value==="view",size:"small",indeterminate:W(he)(o),onChange:u=>te(u,E,h,A)},{default:c(()=>[y("\u5B57\u6BB5\u5168\u9009")]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","indeterminate","onChange"])]),p("div",Ge,[m(d,{modelValue:o.fieldList,"onUpdate:modelValue":u=>o.fieldList=u,size:"small",disabled:_.value==="view",onChange:u=>ne(u,E,h,A)},{default:c(()=>[(v(!0),k(O,null,q(o.action_data,u=>(v(),B(w,{key:"FieldItem"+u.id,label:u.id,size:"small",disabled:_.value==="view",onChange:z=>ue(z,u.id,E,A)},{default:c(()=>[y(G(u.field_name),1)]),_:2},1032,["label","disabled","onChange"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","onChange"])])])):T("",!0)],64))]))),128))])]),_:2},1024)):T("",!0)]),_:2},1024))),128))])])])]),_:1})]),_:1}),m(a,{span:24,class:"clear"},{default:c(()=>[m(C,{class:"fr",style:{margin:"10px 0 0 16px"},onClick:l[2]||(l[2]=h=>j.value=!1)},{default:c(()=>[y("\u5173\u95ED")]),_:1}),_.value==="create"||_.value==="edit"?(v(),B(C,{key:0,type:"primary",class:"fr",disabled:S.value,style:{margin:"10px 0 0 16px"},onClick:se},{default:c(()=>[y("\u4FDD\u5B58")]),_:1},8,["disabled"])):T("",!0)]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])),[[_e,S.value]])}}});const He=Fe(Ye,[["__scopeId","data-v-e68f799c"]]),el=Object.freeze(Object.defineProperty({__proto__:null,default:He},Symbol.toStringTag,{value:"Module"}));export{He as E,xe as a,Ie as b,el as e,Ke as h};