No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

2 líneas
7.8KB

  1. import{G,E as k,a as P,r as m,y as me,o as pe,b as u,c as g,L as I,h as a,u as b,f as t,j as F,e as p,d as C,F as O,H as z,i as f,M as A,t as N,k as fe,Z as ce,az as ge,ax as _e,ay as be,aA as ve,aB as ye,s as Re}from"./index-dd5fae99.js";import{E as Ne}from"./index-29b4120c.js";import{h as Le}from"./moment-a9aaa855.js";import{g as S,a as Ee}from"./getIsShowRegionTree-21a24141.js";const Ie=["onClick"],he=["onClick"],we=["onClick"],ke=fe({name:"userManage"}),xe=Object.assign(ke,{setup(Ce){const{proxy:v}=Re(),Y=G(k.userStore).userInfo||{},j=G(k.userStore).roleList||{},s=P({userRoleList:void 0,name:void 0,phoneNo:void 0,orgName:void 0}),y=m(),B=m(0),q=P([{label:"序号",type:"index",width:"80"},{label:"姓名",key:"name",prop:"name"},{label:"手机号码",key:"phoneNo",prop:"phoneNo",width:"150"},{label:"所属单位(主职)",key:"orgName",prop:"orgName",showOverflowTooltip:!0,width:250},{label:"所属区域",key:"regionName",prop:"regionName",width:"150"},{label:"用户角色",key:"userRoleList",prop:"userRoleList",width:200},{label:"状态",slot:"isEnable",width:"100"},{label:"更新时间",key:"updateTime",prop:"updateTime",width:"250"},{label:"操作",slot:"action",width:"200",fixed:"right"}]),V=m([]),c=async(o=y.value.pageParams)=>{const e=await ce({...o,...s,scene:2,userRoleList:[{id:s.userRoleList}]}),n=e.data.records;n.forEach(r=>{const d=[];r.userRoleList.forEach(h=>{d.push(h.name)}),r.userRoleList=d}),V.value=n,B.value=e.data.total},H=()=>{c()},J=()=>{s.userRoleList=void 0,s.name=void 0,s.phoneNo=void 0,s.orgName=void 0,y.value.pageParams.pageNumber=1,y.value.pageParams.pageSize=10,c()},R=m(!1),x=m(),i=m({}),Z=async o=>{oe(),R.value=!0,x.value=o.name;const e=await ge({employeeCode:o.employeeCode,userId:o.userId}),n=[];e.data.userRoleInfoList.forEach(r=>{n.push(r.id)}),i.value={employeeCode:o.employeeCode,userRoleInfoList:n,phoneNo:o.phoneNo,status:o.status!=="DISABLE",userId:o.userId}},K={phoneNo:[{required:!0,pattern:/^1[3456789]\d{9}$/,message:"手机号码格式不正确",trigger:"blur"}],userRoleInfoList:[{required:!0,message:"请选择用户角色",trigger:"change"}],status:[{required:!0,message:"请选择状态",trigger:"change"}]},D=m(),Q=async o=>{o&&await o.validate(async e=>{if(e){const n={...i.value},r=JSON.parse(JSON.stringify(n));r.status?r.status="ENABLE":r.status="DISABLE",r.userRoleInfoList=[],n.userRoleInfoList.forEach(d=>{r.userRoleInfoList.push({id:d})}),await _e(r),v.$message.success("编辑成功!"),R.value=!1,c()}})},W=o=>{const e=o.status==="DISABLE"?"启用":"禁用";v.$messageBox.confirm(`是否${e}该用户?`,"提示!",{type:"warning"}).then(async()=>{await be({employeeCode:o.employeeCode,operation:o.status==="DISABLE"?"ENABLE":"DISABLE",userId:o.userId}),v.$message.success(`${e}成功!`),c()})},X=me(),ee=async o=>{v.$messageBox.confirm(`确定要代登录${o.name}账号?`,"提示!",{type:"warning"}).then(async()=>{const e=new URLSearchParams;e.append("userId",o.userId),await ve(e),v.$message.success("登录成功!"),location.reload(),X.push("/")})},le=o=>{s.regionId=o.regionLevel===3?o.regionCode:void 0,y.value.pageParams.pageNumber=1,c()},ae=m(!1),te=(o,e)=>{e==="单位管理员"&&(ae.value=o)},M=m(),oe=async()=>{const o=await ye();M.value=o.data};return pe(()=>{k.userStore.setRoleStore(),S(["SUPER_ADMIN","REGION_MANAGER"])||c()}),(o,e)=>{const n=u("el-col"),r=u("el-input"),d=u("el-form-item"),h=u("el-option"),se=u("el-select"),w=u("el-row"),L=u("el-button"),$=u("el-form"),U=u("el-card"),ne=u("table-list"),re=u("el-checkbox"),ue=u("el-checkbox-group"),de=u("el-switch"),ie=u("el-dialog");return g(),I(w,null,{default:a(()=>[b(S)(["SUPER_ADMIN","REGION_MANAGER"])?(g(),I(n,{key:0,style:{"padding-right":"16px"},span:4},{default:a(()=>[t(Ne,{params:b(Ee)({SUPER_ADMIN:!1,REGION_MANAGER:!1}),onGetTree:le},null,8,["params"])]),_:1})):F("",!0),t(n,{span:b(S)(["SUPER_ADMIN","REGION_MANAGER"])?20:24},{default:a(()=>[p("div",null,[t(U,{class:"search mb-16"},{default:a(()=>[t($,{"label-suffix":":",model:s,size:"small"},{default:a(()=>[t(w,{gutter:16,class:"mb-16"},{default:a(()=>[t(n,{span:8},{default:a(()=>[t(d,{label:"用户姓名"},{default:a(()=>[t(r,{modelValue:s.name,"onUpdate:modelValue":e[0]||(e[0]=l=>s.name=l),placeholder:"请输入"},null,8,["modelValue"])]),_:1})]),_:1}),t(n,{span:8},{default:a(()=>[t(d,{label:"手机号码"},{default:a(()=>[t(r,{modelValue:s.phoneNo,"onUpdate:modelValue":e[1]||(e[1]=l=>s.phoneNo=l),maxlength:"11",placeholder:"请输入"},null,8,["modelValue"])]),_:1})]),_:1}),t(n,{span:8},{default:a(()=>[t(d,{label:"用户角色"},{default:a(()=>[t(se,{modelValue:s.userRoleList,"onUpdate:modelValue":e[2]||(e[2]=l=>s.userRoleList=l),style:{width:"100%"},clearable:"",placeholder:"请选择"},{default:a(()=>[(g(!0),C(O,null,z(b(j),(l,_)=>(g(),I(h,{key:_,label:l.name,value:l.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1}),t(w,{gutter:16},{default:a(()=>[t(n,{span:8},{default:a(()=>[t(d,{label:"所在单位",maxlength:"50"},{default:a(()=>[t(r,{modelValue:s.orgName,"onUpdate:modelValue":e[3]||(e[3]=l=>s.orgName=l),placeholder:"请输入"},null,8,["modelValue"])]),_:1})]),_:1}),t(n,{span:16},{default:a(()=>[t(d,{class:"btn"},{default:a(()=>[t(L,{type:"primary",onClick:H},{default:a(()=>e[10]||(e[10]=[f("查询")])),_:1}),t(L,{onClick:J},{default:a(()=>e[11]||(e[11]=[f("重置")])),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])]),_:1}),t(U,null,{header:a(()=>e[12]||(e[12]=[p("div",{class:"flex justify-between items-center"},[p("span",null,"用户列表")],-1)])),default:a(()=>[t(ne,{ref_key:"tableListRef",ref:y,column:q,data:V.value,total:B.value,onGetTableData:c},{isEnable:a(({scope:l})=>[p("div",{class:"dot",style:A({background:l.row.status=="DISABLE"?"#FF3B30":"#4ECB74"})},null,4),e[13]||(e[13]=f("  ")),p("span",{style:A({color:l.row.status=="DISABLE"?"#FF3B30":"#4ECB74"})},N(l.row.status=="DISABLE"?"禁用中":"启用中"),5)]),updated:a(({scope:l})=>[f(N(b(Le)(l.row.updated).format("YYYY-MM-DD HH:mm:ss")),1)]),action:a(({scope:l})=>{var _,T;return[p("a",{onClick:E=>Z(l.row)},"编辑",8,Ie),l.row.status==="ENABLE"&&((T=(_=b(Y).userRoleInfoList)==null?void 0:_.filter(E=>E.code==="SUPER_ADMIN"))!=null&&T.length)?(g(),C("a",{key:0,onClick:E=>ee(l.row)},"代登录",8,he)):F("",!0),p("a",{onClick:E=>W(l.row)},N(l.row.status==="DISABLE"?"启用":"禁用"),9,we)]}),_:1},8,["column","data","total"])]),_:1}),t(ie,{"model-value":R.value,title:"编辑 - "+x.value,width:"600px",onClose:e[9]||(e[9]=l=>R.value=!1)},{footer:a(()=>[t(L,{type:"primary",onClick:e[7]||(e[7]=l=>Q(D.value))},{default:a(()=>e[15]||(e[15]=[f(" 提交 ")])),_:1}),t(L,{onClick:e[8]||(e[8]=l=>R.value=!1)},{default:a(()=>e[16]||(e[16]=[f(" 关闭 ")])),_:1})]),default:a(()=>[t($,{ref_key:"formRef",ref:D,model:i.value,rules:K,"label-width":"90px","label-suffix":":"},{default:a(()=>[t(d,{label:"手机号码",prop:"phoneNo"},{default:a(()=>[t(r,{modelValue:i.value.phoneNo,"onUpdate:modelValue":e[4]||(e[4]=l=>i.value.phoneNo=l),placeholder:"请输入",maxlength:"11"},null,8,["modelValue"])]),_:1}),t(d,{label:"用户角色",prop:"userRoleInfoList"},{default:a(()=>[t(ue,{modelValue:i.value.userRoleInfoList,"onUpdate:modelValue":e[5]||(e[5]=l=>i.value.userRoleInfoList=l)},{default:a(()=>[(g(!0),C(O,null,z(M.value,l=>(g(),I(re,{key:l.id,label:l.id,onChange:_=>te(_,l.name)},{default:a(()=>[f(N(l.name),1)]),_:2},1032,["label","onChange"]))),128))]),_:1},8,["modelValue"])]),_:1}),t(d,{label:"状态",prop:"status"},{default:a(()=>[t(de,{modelValue:i.value.status,"onUpdate:modelValue":e[6]||(e[6]=l=>i.value.status=l),style:{"--el-switch-on-color":"#4ecb74","--el-switch-off-color":"#ff3b30"}},null,8,["modelValue"]),e[14]||(e[14]=f("  ")),p("span",{style:A({color:i.value.status?"#4ECB74":"#FF3B30"})},N(i.value.status?"已启用":"已禁用"),5)]),_:1})]),_:1},8,["model"])]),_:1},8,["model-value","title"])])]),_:1},8,["span"])]),_:1})}}});export{xe as default};