1 |
- import{aC as J,a2 as Le,_ as Ce,d as we,v as Fe,w as V,ad as le,z as Ve,W as ae,r as L,al as De,H as te,o as r,G as A,C as v,l as k,c as w,F as M,D as q,u as W,b as g,L as j,M as N,a as z,au as X,Q as Ae,R as Se,y as Ee}from"./index.1d5f2f42.js";import{l as ye}from"./status.3ccd5ebb.js";import{u as Be}from"./useCompany.f3b703c8.js";const{VITE_PROXY_DOMAIN_REAL:al,VITE_PROXY_USER_REAL:Ue}=Le(),G=Ue+"/admin/",Me=p=>J.request("post",`${G}roleadd`,{data:p}),tl=(p={})=>J.request("post",`${G}rolelist`,{data:{...p,level:"3"}}),Oe=p=>J.request("post",`${G}roleinfo`,{data:p}),qe=p=>J.request("post",`${G}rolesave`,{data:p}),il=p=>J.request("post",`${G}rolestatus`,{data:p}),Ne=p=>J.request("post",`${G}menuactionlist`,{data:p});const Re=p=>(Ae("data-v-7a947b1c"),p=p(),Se(),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"},Ge={class:"ftitle"},Pe={class:"fbody"},be={class:"stitle clear"},je={class:"_h2 fl"},Xe={key:0,class:"scheck"},Ye={class:"checkAll"},He={class:"checkItem"},Qe={key:1,class:"sfield"},We={class:"checkAll"},Ke={class:"checkItem"},Ze=we({__name:"addEdit",props:{itemId:{type:String,default:""},showModel:{type:Boolean,default:!1},isDetails:{type:String,default:"add"}},emits:["cancel","refresh"],setup(p,{emit:K}){const Z=p,{logout:Y}=Fe(),ie=V("small"),H=V(),{currentCompany:ne}=Be(),O=V(!1),Q=V(""),m=V("add"),n=V([]),R=V([]),U=V([]),T=V([]),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(S.value==!0)return;S.value=!0;const{level:l,role_name:t,roleid:c}=C;if(R.value=[],U.value=[],T.value=[],n.value.forEach(F=>{F.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){X.error("\u8BF7\u9009\u62E9\u529F\u80FD!"),S.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);S.value=!1,f==0?(X.success($.value+"\u6210\u529F\uFF01"),O.value=!1,K("refresh")):f>100&&f<140?(O.value=!1,Y()):X.error(_)}})},fe=async(a,e)=>{!a||(a.clearValidate(),a.resetFields(),await Ee(async()=>{for(let i in C)i=="role"?C[i]=e.roleid||"":C[i]=e[i]}))},I=()=>{O.value=!1,K("cancel")},S=V(!0),$=V("");async function _e(a){switch(S.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?Y():X.error(l);await fe(H.value,a),m.value!=="add"&&await pe(),S.value=!1}const pe=async()=>{const{code:a,data:e,message:i}=await Oe({roleid:Q.value});if(a==0){const{action:l,action_data:t,private_data:c,role_name:h,level:f}=e!=null?e:{};C.roleid=Q.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(F=>(F.child&&F.child.length>0&&F.child.map(d=>(d.action&&d.action.length>0&&(d.action.map(E=>{const D=R.value.length>0?R.value.findIndex(P=>P==E.id):-1;return D!==-1&&d.checkList.push(R.value[D]),E}),d.action.length==d.checkList.length&&(d.checkAll=!0)),d.action_data&&d.action_data.length>0&&(d.action.map(E=>{const D=U.value.length>0?U.value.findIndex(P=>P==E.id):-1;return D!==-1&&d.fieldList.push(U.value[D]),E}),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)),F)),n.value=_}else a>=100&&a<=104?Y():X.warning(i)};Ve(()=>Z.showModel,()=>{const{showModel:a,itemId:e,isDetails:i}=Z;O.value=a,O.value&&(Q.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"),F=L("el-checkbox"),d=L("el-checkbox-group"),E=L("el-row"),D=L("el-button"),P=L("el-form"),ke=L("el-dialog"),ee=De("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(P,{ref_key:"ruleFormRef",ref:H,model:C,rules:oe,"label-width":"90px",class:"role-addedit",size:ie.value,"status-icon":""},{default:v(()=>[k(E,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),w(M,null,q(W(ye),(u,y)=>(r(),A(c,{key:"type"+u.value+y,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),w(M,null,q(n.value,(u,y)=>(r(),A(E,{key:"menu"+u.id+y},{default:v(()=>[u.child&&u.child.length>0?(r(),A(t,{key:0,class:"ffff",span:24},{default:v(()=>[g("div",Ge,[(r(!0),w(M,null,q(u.menu_name,(o,B)=>(r(),w("div",{key:"title"+B+o},j(o),1))),128))]),g("div",Pe,[(r(!0),w(M,null,q(u.child,(o,B)=>(r(),w("div",{class:"fbody-item",key:"yemian"+o.id+B},[o.action&&o.action.length==0&&o.action_data&&o.action_data.length==0?z("v-if",!0):(r(),w(M,{key:0},[g("div",be,[g("span",je,j(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),w(M,null,q(o.private,(s,b)=>(r(),A(f,{size:"small",key:s.label+b,label:String(s.id)},{default:v(()=>[N(j(s.label),1)]),_:2},1032,["label"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])):z("v-if",!0)]),o.action&&o.action.length>0?(r(),w("div",Xe,[g("div",Ye,[k(F,{modelValue:o.checkAll,"onUpdate:modelValue":s=>o.checkAll=s,disabled:m.value=="view",indeterminate:W(ge)(o),onChange:s=>se(s,y,u,B)},{default:v(()=>[N("\u529F\u80FD\u5168\u9009")]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","indeterminate","onChange"])]),g("div",He,[k(d,{modelValue:o.checkList,"onUpdate:modelValue":s=>o.checkList=s,disabled:m.value=="view",onChange:s=>ce(s,y,u,B)},{default:v(()=>[(r(!0),w(M,null,q(o.action,s=>(r(),A(F,{disabled:m.value=="view",key:"checkItem"+s.id,label:String(s.id),onChange:b=>re(b,String(s.id),y,B,u)},{default:v(()=>[N(j(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(),w("div",Qe,[g("div",We,[k(F,{modelValue:o.fieldAll,"onUpdate:modelValue":s=>o.fieldAll=s,disabled:m.value=="view",indeterminate:W(me)(o),onChange:s=>de(s,y,u,B)},{default:v(()=>[N("\u5B57\u6BB5\u5168\u9009")]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","indeterminate","onChange"])]),g("div",Ke,[k(d,{modelValue:o.fieldList,"onUpdate:modelValue":s=>o.fieldList=s,disabled:m.value=="view",onChange:s=>ue(s,y,u,B)},{default:v(()=>[(r(!0),w(M,null,q(o.action_data,s=>(r(),A(F,{key:"FieldItem"+s.id,label:String(s.id),disabled:m.value=="view",onChange:b=>ve(b,String(s.id),y,B,u)},{default:v(()=>[N(j(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:S.value,style:{margin:"0 0 0 16px"},onClick:e[2]||(e[2]=u=>he(H.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,S.value]])]),_:1},8,["modelValue","title"])),[[ee,S.value]])}}});var xe=Ce(Ze,[["__scopeId","data-v-7a947b1c"],["__file","D:/work/rep-v3/report-v3/src/views/supplierManage/supplierRole/addEdit.vue"]]),nl=Object.freeze(Object.defineProperty({__proto__:null,default:xe},Symbol.toStringTag,{value:"Module"}));export{xe as a,tl as b,nl as c,il as h};
|