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