import{p as O,r as n,A as ie,t as de,f as ce,F as i,j as e,I as p,S as f,a as F,B as R,R as he,h as me,b as A,D as ge,ae as pe,g as d,ch as xe,d as ue,v as D,M as fe}from"./index-CKIL6d0V.js";import{O as je}from"./index-DS0KBckH.js";import{R as ye}from"./PlusCircleOutlined-C3dgw0Zs.js";import{F as Ie}from"./Table-BaVi_066.js";import{R as we}from"./UserAddOutlined-DO_35nHW.js";import{T as be}from"./index-DhKd6wcu.js";import{R as Ne}from"./DeleteOutlined-BHDTCKcb.js";import"./index-C-LPyJas.js";import"./iconUtil-Co5gbObL.js";const Se=O.div`
  height: 100%;
  display: flex;
  flex-direction: column;
  .search {
    height: 60px;
    padding: 0 25px;
    margin-bottom: 16px;
    border-radius: 6px;
    background-color: ${t=>t.theme.colorBgContainer};
    display: flex;
    justify-content: space-between;
    align-items: center;
    .searchflex {
      width: 300px;

      display: flex;
      .label {
        width: 50px;
        line-height: 30px;
      }
      .value {
        flex: 1;
        height: 30px;
      }
    }
  }
  .content {
    flex: 1;
    height: 100%;
    display: flex;
    overflow: hidden;
    .organ {
      width: 220px;
      height: 100%;
      margin-right: 16px;
      border-radius: 6px;
      background-color: ${t=>t.theme.colorBgContainer};
    }
    .tableBox {
      flex: 1;
      height: 100%;
      padding: 16px;
      box-sizing: border-box;
      overflow: hidden;
      border-radius: 6px;
      background-color: ${t=>t.theme.colorBgContainer};
    }
  }
`,ke=O.div`
 height: 100%;
 padding: 16px;
 .adminEdit {
  .ant-form-item {
    width: 45%;
    margin-bottom: 16px;
  }
  .organ {
    width: 93%;
  }
  .birthday {
    .ant-picker {
      width: 100%;
    }
  }
 }
`,{Option:N}=f,ve=n.memo(()=>{const{message:t,modal:S}=ie.useApp(),{token:k}=de.useToken(),{organ:j,genderList:v,userInfo:_}=ce(a=>a),[c]=i.useForm(),[B,h]=n.useState([]),[$,m]=n.useState(0),[y,q]=n.useState([]),[E,o]=n.useState(!1),[x,T]=n.useState(null),[u,Y]=n.useState(null),[I,L]=n.useState(null),[P,V]=n.useState(""),[g,C]=n.useState("添 加"),[H,M]=n.useState(""),[J,w]=n.useState(!1);n.useEffect(()=>{(async()=>{o(!0);try{const s=await d("/api/Manager/All",{pageIndex:1,pageSize:50});await h(s.data),await m(s.total);const{data:r}=await d("/api/Role/All",{pageSize:9999,pageIndex:1});await q(r)}catch(s){t.error(s),console.log(s)}finally{o(!1)}})()},[t]);const K=a=>{T(a.target.value)},Q=a=>{Y(a.target.value)},U=a=>{L(a)},W=async()=>{o(!0);const a={code:x,name:u,roleid:I,pageIndex:1,pageSize:50};try{const s=await d("/api/Manager/All",a);await h(s.data),await m(s.total)}catch(s){t.error(s),console.log(s)}finally{o(!1)}},G=[{title:"编 号",dataIndex:"index",align:"center",key:"index",render:(a,s,r)=>e.jsx(e.Fragment,{children:r+1})},{title:"账 号",dataIndex:"code",align:"center",key:"id",render:a=>e.jsx(e.Fragment,{children:a})},{title:"姓 名",dataIndex:"name",align:"center",key:"name",render:a=>e.jsx(e.Fragment,{children:a})},{title:"组织机构",dataIndex:"organizationName",align:"center",key:"id",render:a=>e.jsx(e.Fragment,{children:a})},{title:"角 色",dataIndex:"roleId",align:"center",key:"id",render:a=>e.jsx(e.Fragment,{children:X(a)})},{title:"操 作",dataIndex:"handle",align:"center",key:"handle",render:(a,s)=>e.jsx(e.Fragment,{children:e.jsxs(F,{size:"middle",style:{color:k.colorPrimaryText},children:[e.jsxs("span",{style:{cursor:"pointer"},onClick:()=>z("编 辑",s),children:[e.jsx(A,{}),"  编 辑"]}),e.jsxs("span",{style:{cursor:"pointer"},onClick:()=>{S.confirm({title:"温馨提示",content:"确定重置密码吗?",onOk(){te(s.id)}})},children:[e.jsx(xe,{}),"  重置密码"]}),_.userID==="administrator"&&e.jsxs("span",{style:{cursor:"pointer"},onClick:()=>{S.confirm({title:"温馨提示",content:"确定删除吗?",onOk(){le(s.id)}})},children:[e.jsx(Ne,{}),"  删 除"]})]})})}],X=a=>{let s="";return y.forEach(r=>{r.id===a&&(s=r.name)}),s},z=(a,s)=>{a==="添 加"?(C("添 加"),c.resetFields()):(C("编 辑"),c.setFieldsValue({code:s.code,name:s.name,pwd:"",genderId:s.genderId,birthday:ue(s.birthday),telephone:s.telephone,roleId:s.roleId,organizeId:s.organizeId}),M(s.id)),w(!0)},Z=()=>{c.submit()},ee=()=>{w(!1),c.resetFields(),M("")},ae=async a=>{a.birthday=a.birthday.format("YYYY-MM-DD"),g==="编 辑"&&(a.id=H);const s={...a};o(!0);try{const{code:r,msg:l}=await D("/api/Manager/AddOrUpdate",s);r===200?t.success(l):t.error(l),w(!1);const{data:b,total:oe}=await d("/api/Manager/All",{pageIndex:1,pageSize:50});h(b),m(oe)}catch(r){t.error(r)}finally{o(!1),c.resetFields()}},se=a=>{re(a)},re=async a=>{V(a);const s={code:x,name:u,roleid:I,organizeId1:a,pageIndex:1,pageSize:50};o(!0);try{const r=await d("/api/Manager/All",s);await h(r.data),await m(r.total)}catch(r){t.error(r),console.log(r)}finally{o(!1)}},te=async a=>{const s=btoa(123456);try{const{code:r,msg:l}=await D("/api/Manager/ResetPWd",{},{id:a,pwd:s});r===200?t.success(l):t.warning(l)}catch(r){t.error(r)}},le=async a=>{try{const{code:s,msg:r}=await fe(`/api/Manager/Del/${a}`);if(o(!0),s===200){t.success(r);const{data:l,total:b}=await d("/api/Manager/All",{pageIndex:1,pageSize:50});h(l),m(b)}else t.error(r)}catch(s){t.error(s)}finally{o(!1)}},ne=async(a,s)=>{const r={code:x,name:u,roleid:I,organizeId1:P,pageIndex:a,pageSize:s};o(!0);try{const l=await d("/api/Manager/All",r);await h(l.data),await m(l.total)}catch(l){t.error(l),console.log(l)}finally{o(!1)}};return e.jsxs(Se,{theme:k,children:[e.jsxs("div",{className:"search",children:[e.jsxs("div",{className:"searchflex",children:[e.jsx("span",{className:"label",children:"账 号: "}),e.jsx(p,{className:"value",allowClear:!0,value:x,onChange:K,placeholder:"请输入账号"})]}),e.jsxs("div",{className:"searchflex",children:[e.jsx("span",{className:"label",children:"姓 名: "}),e.jsx(p,{className:"value",allowClear:!0,value:u,onChange:Q,placeholder:"请输入姓名"})]}),e.jsxs("div",{className:"searchflex",children:[e.jsx("span",{className:"label",children:"角 色: "}),e.jsx(f,{className:"value",placeholder:"请选择角色",onChange:U,allowClear:!0,children:y.map(a=>e.jsx(N,{value:a.id,children:a.name},a.id))})]}),e.jsx("div",{className:"searchflex",children:e.jsxs(F,{size:"large",children:[e.jsxs(R,{type:"primary",onClick:W,children:[e.jsx(he,{})," 搜 索"]}),e.jsxs(R,{onClick:()=>z("添 加"),children:[e.jsx(ye,{})," 添 加"]})]})})]}),e.jsxs("div",{className:"content",children:[e.jsx("div",{className:"organ",children:e.jsx(je,{onSelectOrg:se})}),e.jsx("div",{className:"tableBox",children:e.jsx(Ie,{size:"small",showExpandColumn:!1,rowKey:a=>a.id,columns:G,loading:E,dataSource:B,sticky:!0,pagination:{total:$,showSizeChanger:!0,showQuickJumper:!0,defaultPageSize:50,onChange:ne,showTotal:a=>`共 ${a} 条`}})})]}),e.jsx(me,{className:"ysh_antd_modal",text:e.jsxs("span",{style:{fontSize:"24px"},children:[g==="添 加"?e.jsx(we,{}):e.jsx(A,{}),"   ",g]}),width:618,open:J,onOk:Z,onCancel:ee,children:e.jsx(ke,{children:e.jsxs(i,{className:"adminEdit",form:c,layout:"inline",onFinish:ae,children:[e.jsx(i.Item,{label:"账 号",name:"code",rules:[{required:!0,message:"请输入账号"}],children:e.jsx(p,{className:"ysh_antd_input",placeholder:"请输入账号"})}),g==="添 加"&&e.jsx(i.Item,{style:{display:g!=="添 加"&&"none"},label:"密 码",name:"pwd",rules:[{required:!0,message:"请输入密码"}],children:e.jsx(p,{disabled:g!=="添 加",className:"ysh_antd_input",placeholder:"请输入密码"})}),e.jsx(i.Item,{label:"姓 名",name:"name",rules:[{required:!0,message:"请输入姓名"}],children:e.jsx(p,{className:"ysh_antd_input",placeholder:"请输入姓名"})}),e.jsx(i.Item,{label:"性别",name:"genderId",rules:[{required:!0,message:"请选择性别"}],children:e.jsx(f,{className:"ysh_antd_select ysh_basicinfo_select",placeholder:"请选择性别",allowClear:!0,children:Object.keys(v).map((a,s)=>e.jsx(N,{value:s,children:v[a]},a))})}),e.jsx(i.Item,{className:"birthday",label:"生 日",name:"birthday",rules:[{required:!0,message:"请选择出生日期"}],children:e.jsx(ge,{format:"YYYY-MM-DD"})}),e.jsx(i.Item,{label:"电 话",name:"telephone",rules:[{required:!0,message:"请输入电话"}],children:e.jsx(p,{placeholder:"请输入电话"})}),e.jsx(i.Item,{label:"角 色",name:"roleId",rules:[{required:!0,message:"请输入角色"}],children:e.jsx(f,{placeholder:"请选择角色",allowClear:!0,children:y.map(a=>e.jsx(N,{value:a.id,children:a.name},a.id))})}),e.jsx(i.Item,{className:"organ",label:"机构",name:"organizeId",rules:[{required:!0,message:"请选择组织机构"}],children:j[0]&&e.jsx(be,{dropdownStyle:{maxHeight:400,overflow:"auto"},treeData:pe(j,j[0].PId),placeholder:"请选择组织机构",treeDefaultExpandAll:!0,allowClear:!0,fieldNames:{label:"Name",value:"Id",children:"children"}})})]})})})]})});ve.displayName="AdminManage";export{ve as default};
