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