import{d as I,r as l,u as Q,A as V,f as W,t as q,j as a,I as y,b as j,B as w,R as G,g as d,a as H,c as U,ck as X,v as Z,N as _}from"./index-BtzNP73w.js";import{O as ee}from"./index-Bulw9wNg.js";import{R as ae}from"./PlusCircleOutlined-Dx3NdtuO.js";import{F as te}from"./Table-BCm752cP.js";import{R as se}from"./DeleteOutlined-ClifBhia.js";import"./index-B6m4IotF.js";import"./iconUtil-D_WnT0lW.js";const re=I.div`
  height: 100%;
  display: flex;
  flex-direction: column;
  .search {
    height: 60px;
    padding: 0 25px;
    margin-bottom: 16px;
    border-radius: 6px;
    background-color: ${i=>i.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: ${i=>i.theme.colorBgContainer};
    }
    .tableBox {
      flex: 1;
      height: 100%;
      padding: 16px;
      box-sizing: border-box;
      overflow: hidden;
      border-radius: 6px;
      background-color: ${i=>i.theme.colorBgContainer};
    }
  }
`;I.div`
 height: 100%;
 padding: 16px;
 .adminEdit {
  .ant-form-item {
    width: 45%;
    margin-bottom: 16px;
  }
  .organ {
    width: 93%;
  }
  .birthday {
    .ant-picker {
      width: 100%;
    }
  }
 }
`;const ne=l.memo(()=>{const i=Q(),{message:n,modal:p}=V.useApp(),{organ:b,genderList:C,userInfo:c}=W(e=>e),{token:u}=q.useToken(),[k,g]=l.useState([]),[v,h]=l.useState(0),[N,S]=l.useState([]),[R,o]=l.useState(!1),[x,A]=l.useState(null),[m,z]=l.useState(null),[B,F]=l.useState("");l.useEffect(()=>{const e={pageIndex:1,pageSize:50};c.isAdmin===2&&(e.code=c.userID),(async()=>{o(!0);try{const t=await d("/api/Counsellor/All",e);await g(t.data.items),await h(t.data.totalRecords);const{data:r}=await d("/api/Role/All",{pageSize:9999,pageIndex:1});await S(r)}catch(t){n.error(t),console.log(t)}finally{o(!1)}})()},[n,c]);const E=e=>{A(e.target.value)},$=e=>{z(e.target.value)},D=async()=>{o(!0);const e={code:x,name:m,pageIndex:1,pageSize:50};try{const s=await d("/api/Counsellor/All",e);await g(s.data.items),await h(s.data.totalRecords)}catch(s){n.error(s),console.log(s)}finally{o(!1)}},O=[{title:"序 号",dataIndex:"index",align:"center",key:"index",render:(e,s,t)=>a.jsx(a.Fragment,{children:t+1})},{title:"账 号",dataIndex:"code",align:"center",key:"id",render:e=>a.jsx(a.Fragment,{children:e})},{title:"姓 名",dataIndex:"name",align:"center",key:"name",render:e=>a.jsx(a.Fragment,{children:e})},{title:"性 别",dataIndex:"sex",align:"center",key:"sex",render:e=>a.jsx(a.Fragment,{children:C[e]})},{title:"出生日期",dataIndex:"birthday",align:"center",key:"birthday",render:e=>a.jsx(a.Fragment,{children:H(e).format("YYYY-MM-DD")})},{title:"联系方式",dataIndex:"mobile",align:"center",key:"mobile",render:e=>a.jsx(a.Fragment,{children:e})},{title:"组织机构",dataIndex:"orgid",align:"center",key:"orgid",render:e=>a.jsx(a.Fragment,{children:L(e)})},{title:"角色类型",dataIndex:"roleid",align:"center",key:"roleid",render:e=>a.jsx(a.Fragment,{children:T(e)})},{title:"操 作",dataIndex:"handle",width:240,align:"center",key:"handle",render:(e,s)=>a.jsx(a.Fragment,{children:a.jsxs(j,{size:"middle",style:{color:u.colorPrimaryText},children:[a.jsxs("span",{style:{cursor:"pointer"},onClick:()=>f(s),children:[a.jsx(U,{}),"  编 辑"]}),a.jsxs("span",{style:{cursor:"pointer"},onClick:()=>{p.confirm({title:"温馨提示",content:"确定重置密码吗?",onOk(){Y(s.id)}})},children:[a.jsx(X,{}),"  重置密码"]}),c.isAdmin!==2&&a.jsxs("span",{style:{cursor:"pointer"},onClick:()=>{p.confirm({title:"温馨提示",content:"确定删除吗?",onOk(){J(s.id)}})},children:[a.jsx(se,{}),"  删 除"]})]})})}],L=e=>{let s="";return b.forEach(t=>{t.Id===e&&(s=t.Name)}),s},T=e=>{let s="";return N.forEach(t=>{t.id===e&&(s=t.name)}),s},f=e=>{i("/layout/CounselorEdit",{state:e})},M=e=>{P(e)},P=async e=>{F(e);const s={code:x,name:m,orgid:e,pageIndex:1,pageSize:50};o(!0);try{const t=await d("/api/Counsellor/All",s);await g(t.data.items),await h(t.data.totalRecords)}catch(t){n.error(t),console.log(t)}finally{o(!1)}},Y=async e=>{const s=btoa(123456);try{const{code:t,msg:r}=await Z("/api/Counsellor/ResetPWd",{},{id:e,pwd:s});t===200?n.success(r):n.warning(r)}catch(t){n.error(t)}},J=async e=>{try{const{code:s,msg:t}=await _(`/api/Counsellor/Del/${e}`);if(o(!0),s===200){n.success(t);const{data:r}=await d("/api/Counsellor/All",{pageIndex:1,pageSize:50});g(r.items),h(r.totalRecords)}else n.error(t)}catch(s){n.error(s)}finally{o(!1)}},K=async(e,s)=>{const t={code:x,name:m,orgid:B,pageIndex:e,pageSize:s};o(!0);try{const r=await d("/api/Counsellor/All",t);await g(r.data.items),await h(r.data.totalRecords)}catch(r){n.error(r),console.log(r)}finally{o(!1)}};return a.jsxs(re,{theme:u,children:[c.isAdmin!==2&&a.jsxs("div",{className:"search",children:[a.jsxs("div",{className:"searchflex",children:[a.jsx("span",{className:"label",children:"账 号: "}),a.jsx(y,{className:"value",allowClear:!0,value:x,onChange:E,placeholder:"请输入账号"})]}),a.jsxs("div",{className:"searchflex",children:[a.jsx("span",{className:"label",children:"姓 名: "}),a.jsx(y,{className:"value",allowClear:!0,value:m,onChange:$,placeholder:"请输入姓名"})]}),a.jsx("div",{className:"searchflex",children:a.jsxs(j,{size:"large",children:[a.jsxs(w,{type:"primary",onClick:D,children:[a.jsx(G,{})," 搜 索"]}),a.jsxs(w,{onClick:()=>f(null),children:[a.jsx(ae,{})," 添 加"]})]})})]}),a.jsxs("div",{className:"content",children:[c.isAdmin!==2&&a.jsx("div",{className:"organ",children:a.jsx(ee,{onSelectOrg:M})}),a.jsx("div",{className:"tableBox",children:a.jsx(te,{size:"small",showExpandColumn:!1,rowKey:e=>e.id,columns:O,loading:R,dataSource:k,sticky:!0,pagination:{total:v,showSizeChanger:!0,showQuickJumper:!0,defaultPageSize:50,onChange:K,showTotal:e=>`共 ${e} 条`}})})]})]})});ne.displayName="CounselorManage";export{ne as default};
