addEdit.8ef557.js 11 KB

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