addEdit.9fc04eae.js 11 KB

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