addEdit.d6abaf.js 10 KB

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