addEdit.f6d59f33.js 11 KB

1
  1. import{aC as M,a2 as he,_ as ve,d as fe,v as pe,w as k,ad as W,z as _e,W as K,r as w,al as me,H as Z,o as v,G as y,C as f,l as D,b as p,c as V,F as x,D as $,L as R,M as O,a as e,u as ge,au as U,Q as ke,R as we,y as Fe}from"./index.1d5f2f42.js";import{u as be}from"./useCompany.f3b703c8.js";const{VITE_PROXY_DOMAIN_REAL:Ie,VITE_PROXY_USER_REAL:Le}=he(),T=Le+"/admin/",Ce=h=>M.request("post",`${T}role/create`,{data:h}),Pe=h=>M.request("post",`${T}role/list`,{data:h}),De=h=>M.request("post",`${T}role/info`,{data:h}),Ve=h=>M.request("post",`${T}role/save`,{data:h}),je=h=>M.request("post",`${T}role/status`,{data:h}),ye=h=>M.request("post",`${T}menu/MenuAction`,{data:h});const Ae=h=>(ke("data-v-afaf9330"),h=h(),we(),h),Ee={class:"quanxian-main"},Se=Ae(()=>p("div",{class:"quanxian-title"},[p("div",{style:{color:"#ff8888"}},"*"),p("div",null,"\u529F"),p("div",null,"\u80FD"),p("div",null,"\u6743"),p("div",null,"\u9650")],-1)),Be={class:"rule-view"},Ne={class:"rule-list"},xe={class:"ftitle"},Me={class:"fbody"},Te={class:"stitle clear"},$e={class:"_h2 fl"},Oe={key:0,class:"scheck"},Ue={class:"checkAll"},qe={class:"checkItem"},Re=fe({__name:"addEdit",props:{itemId:{type:String,default:""},showModel:{type:Boolean,default:!1},isDetails:{type:String,default:"add"}},emits:["cancel","refresh"],setup(h,{emit:P}){const j=h,{logout:z}=pe(),ee=k("small"),J=k();be();const A=k(!1),G=k(""),m=k("add"),u=k([]),S=k([]),E=k([]),X=k([]),Y={roleid:"",role_name:"",level:"2",action:"",private_data:""},b=W({...Y}),le=W({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"}]}),te=(t,l,s,a)=>{u.value[l].child[a].checkAll=t,u.value[l].child[a].child.forEach(i=>{const o=u.value[l].child[a].checkList.findIndex(n=>n===Number(i.id));t&&o==-1?u.value[l].child[a].checkList.push(Number(i.id)):!t&&o>-1&&u.value[l].child[a].checkList.splice(o,1)})},ae=(t,l,s,a)=>{u.value[l].child[a].checkAll=u.value[l].child[a].child.every(i=>u.value[l].child[a].checkList.findIndex(o=>o==Number(i.id))>-1)},ie=(t,l,s,a,i)=>{if(t)u.value[s].child[a].checkList.indexOf(l)==-1&&u.value[s].child[a].checkList.push(l);else{const o=u.value[s].child[a].checkList.findIndex(n=>n==l);o>-1&&u.value[s].child[a].checkList.splice(o,1),u.value[s].child[a].checkAll=!1}},se=async t=>{!t||await t.validate(async(l,s)=>{if(l){if(L.value==!0)return;L.value=!0;const{level:a,role_name:i,roleid:o}=b;if(S.value=[],E.value=[],X.value=[],u.value.forEach(F=>{F.child.forEach(g=>{S.value.push(...g.fieldList),E.value.push(...g.checkList),g.is_private_change=="1"&&X.value.push(g.id)})}),E.value.length==0){U.error("\u8BF7\u9009\u62E9\u529F\u80FD!"),L.value=!1;return}let n={role_name:i,id:o,action:E.value,status:"1"};m.value=="add"&&delete n.roleid;const{code:d,message:C}=m.value=="add"?await Ce(n):await Ve(n);L.value=!1,d==1?(U.success(B.value+"\u6210\u529F\uFF01"),A.value=!1,P("refresh")):d>100&&d<140?(A.value=!1,z()):U.error(C)}})},ne=async(t,l)=>{!t||(t.clearValidate(),t.resetFields(),await Fe(async()=>{for(let s in b)s=="role"?b[s]=l.roleid||"":b[s]=l[s]}))},H=()=>{A.value=!1,P("cancel")},L=k(!0),B=k("");async function ce(t){switch(L.value=!0,m.value){case"add":B.value="\u65B0\u5EFA\u89D2\u8272";break;case"edit":B.value="\u7F16\u8F91\u89D2\u8272";break;case"view":B.value="\u89D2\u8272\u8BE6\u60C5";break;default:B.value="\u65B0\u5EFA\u89D2\u8272"}const{code:l,data:s,message:a}=await ye({});if(l==1){let i=JSON.parse(JSON.stringify(s!=null?s:[]));i=i.filter(o=>o.child&&o.child.length>0),i=i.map(o=>(o.child.map(n=>(n.checkAll=!1,n.checkList=[],n.fieldAll=!1,n.fieldList=[],n.is_private_change="0",n.is_private=="0"?n.private=[]:n.private=[],n)),o)),u.value=i}else l>100&&l<140?z():U.error(a);await ne(J.value,t),m.value!=="add"&&await de(),L.value=!1}const de=async()=>{const{code:t,data:l,message:s}=await De({id:G.value});if(t==1){const{role_name:a,action:i}=l!=null?l:{};b.roleid=G.value,b.role_name=a!=null?a:"",S.value=i?i.map(n=>Number(n)):[];const o=JSON.parse(JSON.stringify(u.value));o.map(n=>(n.child&&n.child.length>0&&n.child.map(d=>(d.child&&d.child.length>0&&(d.child.map(C=>{const F=S.value.length>0?S.value.findIndex(g=>g==C.id):-1;return F!==-1&&d.checkList.push(S.value[F]),C}),d.child.length==d.checkList.length&&(d.checkAll=!0)),d.child&&d.child.length>0&&(d.child.map(C=>{const F=E.value.length>0?E.value.findIndex(g=>g==C.id):-1;return F!==-1&&d.fieldList.push(E.value[F]),C}),d.child.length==d.fieldList.length&&(d.fieldAll=!0)),d)),n)),u.value=o}else t>=100&&t<=104?z():U.warning(s)};_e(()=>j.showModel,()=>{const{showModel:t,itemId:l,isDetails:s}=j;A.value=t,A.value&&(G.value=l,m.value=s,ce(Y))});let oe=K(()=>t=>{const l=t.child.filter(a=>t.checkList.findIndex(i=>Number(i)==a.id)>-1).length,s=t.child.filter(a=>t.checkList.findIndex(i=>Number(i)==a.id)==-1).length;return l>0&&s>0});return K(()=>t=>{const l=t.child.filter(a=>t.fieldList.findIndex(i=>i==a.id)>-1).length,s=t.child.filter(a=>t.fieldList.findIndex(i=>i==a.id)==-1).length;return l>0&&s>0}),(t,l)=>{const s=w("el-input"),a=w("el-form-item"),i=w("el-col"),o=w("el-radio-button"),n=w("el-radio-group"),d=w("el-checkbox"),C=w("el-checkbox-group"),F=w("el-row"),g=w("el-button"),ue=w("el-form"),re=w("el-dialog"),Q=me("loading");return Z((v(),y(re,{"close-on-click-modal":!1,"close-on-press-escape":!1,modelValue:A.value,"onUpdate:modelValue":l[2]||(l[2]=_=>A.value=_),"append-to-body":"",center:"",top:"5vh",width:"900px",title:B.value,onClose:H},{default:f(()=>[Z((v(),y(ue,{ref_key:"ruleFormRef",ref:J,model:b,rules:le,"label-width":"90px",class:"role-addedit",size:ee.value,"status-icon":""},{default:f(()=>[D(F,null,{default:f(()=>[D(i,{span:24},{default:f(()=>[D(a,{label:"\u89D2\u8272\u540D\u79F0",prop:"role_name"},{default:f(()=>[D(s,{modelValue:b.role_name,"onUpdate:modelValue":l[0]||(l[0]=_=>b.role_name=_),disabled:m.value=="view",placeholder:"\u89D2\u8272\u540D\u79F0"},null,8,["modelValue","disabled"])]),_:1})]),_:1}),D(i,{span:24},{default:f(()=>[p("div",Ee,[Se,p("div",Be,[p("div",Ne,[(v(!0),V(x,null,$(u.value,(_,q)=>(v(),y(F,{key:"menu"+_.id+q},{default:f(()=>[_.child&&_.child.length>0?(v(),y(i,{key:0,class:"ffff",span:24},{default:f(()=>[p("div",xe,[(v(!0),V(x,null,$(_.menu_name,(c,N)=>(v(),V("div",{key:"title"+N+c},R(c),1))),128))]),p("div",Me,[(v(!0),V(x,null,$(_.child,(c,N)=>(v(),V("div",{class:"fbody-item",key:"yemian"+c.id+N},[c.action&&c.action.length==0&&c.child&&c.child.length==0?e("v-if",!0):(v(),V(x,{key:0},[p("div",Te,[p("span",$e,R(c.menu_name),1),c&&c.private&&c.private.length==2?(v(),y(n,{key:0,style:{margin:"0 0 0 20px"},class:"fl",size:"small",modelValue:c.is_private_change,"onUpdate:modelValue":r=>c.is_private_change=r},{default:f(()=>[(v(!0),V(x,null,$(c.private,(r,I)=>(v(),y(o,{size:"small",key:r.label+I,label:String(r.id)},{default:f(()=>[O(R(r.label),1)]),_:2},1032,["label"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])):e("v-if",!0)]),c.child&&c.child.length>0?(v(),V("div",Oe,[p("div",Ue,[D(d,{modelValue:c.checkAll,"onUpdate:modelValue":r=>c.checkAll=r,disabled:m.value=="view",indeterminate:ge(oe)(c),onChange:r=>te(r,q,_,N)},{default:f(()=>[O("\u529F\u80FD\u5168\u9009")]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","indeterminate","onChange"])]),p("div",qe,[D(C,{modelValue:c.checkList,"onUpdate:modelValue":r=>c.checkList=r,disabled:m.value=="view",onChange:r=>ae(r,q,_,N)},{default:f(()=>[(v(!0),V(x,null,$(c.child,r=>(v(),y(d,{disabled:m.value=="view",key:"checkItem"+r.id,label:Number(r.id),onChange:I=>ie(I,Number(r.id),q,N,_)},{default:f(()=>[O(R(r.action_name),1)]),_:2},1032,["disabled","label","onChange"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","disabled","onChange"])])])):e("v-if",!0),e(" <div"),e(' class="sfield"'),e(' v-if="'),e(" subItem.child &&"),e(" subItem.child.length > 0"),e(' "'),e(" >"),e(' <div class="checkAll">'),e(" <el-checkbox"),e(' v-model="subItem.fieldAll"'),e(` :disabled="editType == 'view'"`),e(' :indeterminate="indeterminateField(subItem)"'),e(' @change="'),e(" handleFieldAllChange("),e(" $event,"),e(" index,"),e(" item,"),e(" subIndex"),e(" )"),e(' "'),e(" >\u5B57\u6BB5\u5168\u9009</el-checkbox"),e(" >"),e(" </div>"),e(' <div class="checkItem">'),e(" <el-checkbox-group"),e(' v-model="subItem.fieldList"'),e(` :disabled="editType == 'view'"`),e(' @change="'),e(" handleFieldGroupChange("),e(" $event,"),e(" index,"),e(" item,"),e(" subIndex"),e(" )"),e(' "'),e(" >"),e(" <el-checkbox"),e(' v-for="children in subItem.child"'),e(` :key="'FieldItem' + children.id"`),e(' :label="String(children.id)"'),e(` :disabled="editType == 'view'"`),e(' @change="'),e(" handleFieldChange("),e(" $event,"),e(" String(children.id),"),e(" index,"),e(" subIndex,"),e(" item"),e(" )"),e(' "'),e(" >{{ children.field_name }}</el-checkbox"),e(" >"),e(" </el-checkbox-group>"),e(" </div>"),e(" </div>")],64))]))),128))])]),_:2},1024)):e("v-if",!0)]),_:2},1024))),128))])])])]),_:1})]),_:1}),D(i,{span:24,class:"clear"},{default:f(()=>[m.value=="add"||m.value=="edit"?(v(),y(g,{key:0,type:"primary",class:"fr",loading:L.value,style:{margin:"0 0 0 16px"},onClick:l[1]||(l[1]=_=>se(J.value))},{default:f(()=>[O("\u4FDD\u5B58")]),_:1},8,["loading"])):e("v-if",!0),D(g,{class:"fr",style:{margin:"0 0 0 16px"},onClick:H},{default:f(()=>[O("\u5173\u95ED")]),_:1})]),_:1})]),_:1},8,["model","rules","size"])),[[Q,L.value]])]),_:1},8,["modelValue","title"])),[[Q,L.value]])}}});var ze=ve(Re,[["__scopeId","data-v-afaf9330"],["__file","D:/work/rep-v3/report-v3/src/views/system/role/addEdit.vue"]]),Xe=Object.freeze(Object.defineProperty({__proto__:null,default:ze},Symbol.toStringTag,{value:"Module"}));export{ze as a,Pe as b,Xe as c,je as h};