import{p as se,r as d,A as ne,t as re,F as h,j as t,I as A,D as P,a as oe,B as D,g as T,d as m}from"./index-CKIL6d0V.js";import{u as l,w as M}from"./xlsx-DPk0xC4-.js";import{O as ie}from"./index-DS0KBckH.js";import{R as O}from"./index-CQHEr9cF.js";import{F as le}from"./Table-BaVi_066.js";import"./index-C-LPyJas.js";import"./iconUtil-Co5gbObL.js";const ce=se.div`
  height: 100%;
  display: flex;
  flex-direction: column;
  .searchTop {
    height: 60px;
    padding-left: 15px;
    padding-right: 45px;
    border-radius: 6px;
    margin-bottom: 10px;
    background-color: ${i=>i.theme.colorBgContainer};
    .ant-form {
      height: 100%;
      display: flex;
      align-items: center;
      .ant-form-item {
        flex: 1;
        margin-right: 20px;
      }
      .ant-form-item:nth-child(3) {
        flex: none;
        width: 180px;
      }
      .ant-form-item:nth-child(4) {
        flex: none;
        width: 180px;
      }
      .ant-form-item:nth-last-child(2) {
        flex: none;
        width: 180px;
      }
      .ant-form-item:nth-last-child(3) {
        flex: none;
        width: 180px;
        margin-right: 5px;
      }
      .ant-form-item:nth-last-child(1) {
        text-align: right;
      }
    }
  }
  .content {
    flex: 1;
    height: 0;
    display: flex;
    letter-spacing: 2px;
    .leftOrgan {
      width: 200px;
      margin-right: 10px;
      overflow: auto;
      border-radius: 6px;
      background-color: ${i=>i.theme.colorBgContainer};
    }
    .rightTable {
      flex: 1;
      height: 100%;
      font-size: 12px;
      padding: 16px;
      border-radius: 15px;
      overflow: hidden;
      border-radius: 6px;
      background-color: ${i=>i.theme.colorBgContainer};
      .table {
        border-radius: 15px;
        height: 100%;
        overflow: hidden;
      }
    }
  }
`,de=d.memo(()=>{const{message:i}=ne.useApp(),{token:v}=re.useToken(),[L,j]=d.useState([]),[B,F]=d.useState([]),[z,R]=d.useState([]),[V,C]=d.useState([]),[g,$]=d.useState([]),[H,Q]=d.useState([]),[b]=h.useForm(),[U,N]=d.useState(0),[f,_]=d.useState([]),[W,I]=d.useState([]),[k,S]=d.useState(!1);d.useEffect(()=>{(async()=>{try{const e=await T("/api/PsyTaskName/All",{pageIndex:1,pageSize:999999});if(e.code===200){R(e.data.items);const r=e.data.items.map(n=>({label:n.ptaskname,value:n.ptaskname}));j(r),F(r)}else i.warning(e.msg);const a=await T("/api/PsyInfotablebrief/All",{pageIndex:1,pageSize:999999});if(a.code===200){$(a.data.items);const n=a.data.items.sort((c,p)=>c.sortCode-p.sortCode).map(c=>({label:c.nameChinese,value:c.nameChinese}));C(n),Q(n)}else i.warning(a.msg)}catch(e){i.error(e),console.log(e)}})()},[i]);const G=[{title:t.jsx("span",{children:"序号"}),width:50,align:"center",key:"key",render:(s,e,a)=>a+1},{title:t.jsx("span",{children:"组织名称"}),dataIndex:"组织名称",ellipsis:!0,align:"center",key:"组织名称"},{title:t.jsx("span",{children:"任务名称"}),dataIndex:"任务名称",align:"center",ellipsis:!0,key:"任务名称"},{title:t.jsx("span",{children:"用户编号"}),dataIndex:"用户编号",align:"center",key:"用户编号"},{title:t.jsx("span",{children:"姓名"}),dataIndex:"姓名",align:"center",key:"姓名"},{title:t.jsx("span",{children:"性别"}),width:80,dataIndex:"性别",align:"center",key:"性别"},{title:t.jsx("span",{children:"量表编号"}),dataIndex:"量表编号",align:"center",key:"量表编号"},{title:t.jsx("span",{children:"量表名称"}),dataIndex:"量表名称",align:"center",ellipsis:!0,key:"量表名称"},{title:t.jsx("span",{children:"年龄"}),dataIndex:"年龄",width:80,align:"center",key:"年龄"},{title:t.jsx("span",{children:"创建时间"}),dataIndex:"创建时间",align:"center",key:"创建时间",render:s=>m(s).format("YYYY-MM-DD")},{title:t.jsx("span",{children:"完成时间"}),dataIndex:"完成时间",align:"center",key:"完成时间",render:s=>m(s).format("YYYY-MM-DD")},{title:t.jsx("span",{children:"评价等级"}),dataIndex:"评价等级",align:"center",key:"评价等级"},{title:t.jsx("span",{children:"评价"}),dataIndex:"评价",align:"center",ellipsis:!0,key:"评价"}],J=s=>{const e=[];B.forEach(a=>{a.value.includes(s)&&e.push(a)}),j(e)},K=s=>{const e=[];H.forEach(a=>{a.value.includes(s)&&e.push(a)}),C(e)},q=async s=>{if(k)return;let e=0;z.forEach(n=>{s.PTaskname===n.ptaskname&&(e=n.ptasknameid)});let a="";if(s.tableCode)g.forEach(n=>{s.tableCode===n.nameChinese&&(a=n.nameEnglish)});else{i.warning("请选择量表名称",3);return}const r={QorganizeId:U,PTasknameId:e||0,PNum:s.PNum,PName:s.PName,TableCode:a};if(s.StartTime&&(r.StartTime=m(s.StartTime).format("YYYY-MM-DD")),s.EndTime&&(r.EndTime=m(s.EndTime).format("YYYY-MM-DD")),m(s.StartTime).valueOf()>m(s.EndTime).valueOf()){i.warning("开始时间大于结束时间, 请重新选择");return}Y(r)},Y=async s=>{await S(!0);const e=await T("/api/PsyInforeport/GetScaleDataAnalysisExport",s);if(e.code===200){const a=[],r=[];for(const c in e.data[0])a.push(c);e.data.forEach(c=>{const p=Object.values(c);r.push(p)});const n=[a,...r];_(n),I(e.data),i.success(e.msg,4)}else i.warning(e.msg,4),_([]),I([]);await S(!1)},X=async(s=0)=>{const e=b.getFieldValue();s||N(0);let a="";if(e.tableCode)g.forEach(n=>{e.tableCode===n.nameChinese&&(a=n.nameEnglish)});else{i.warning("请选择量表名称",3);return}const r={QorganizeId:s,PTasknameId:e.PTaskname?e.PTaskname:0,PNum:e.PNum,PName:e.PName,TableCode:a};if(e.StartTime&&(r.StartTime=m(e.StartTime).format("YYYY-MM-DD")),e.EndTime&&(r.EndTime=m(e.EndTime).format("YYYY-MM-DD")),m(e.StartTime).valueOf()>m(e.EndTime).valueOf()){i.warning("开始时间大于结束时间, 请重新选择");return}Y(r)},Z=s=>{k||(X(s),N(s))},ee=()=>{const s=b.getFieldValue();let e="";if(g.forEach(a=>{s.tableCode===a.nameChinese&&(e=a.nameEnglish)}),e==="Cbcl"){const a=f[0];a.pop();const r=[a],n=[a],c=[a],p=[a],y=[a],w=[a];for(let o=1;o<f.length;o++){const ae=f[o][f[o].length-1],u=f[o];switch(u.pop(),ae){case 1:r.push(u);break;case 2:n.push(u);break;case 3:c.push(u);break;case 4:p.push(u);break;case 5:y.push(u);break;case 6:w.push(u);break}}const x=l.book_new();if(r.length>1){const o=l.aoa_to_sheet(r);l.book_append_sheet(x,o,"儿童行为量表(男4-5岁)")}if(n.length>1){const o=l.aoa_to_sheet(n);l.book_append_sheet(x,o,"儿童行为量表(男6-11岁)")}if(c.length>1){const o=l.aoa_to_sheet(c);l.book_append_sheet(x,o,"儿童行为量表(男12-16岁)")}if(p.length>1){const o=l.aoa_to_sheet(p);l.book_append_sheet(x,o,"儿童行为量表(女4-5岁)")}if(y.length>1){const o=l.aoa_to_sheet(y);l.book_append_sheet(x,o,"儿童行为量表(女6-11岁)")}if(w.length>1){const o=l.aoa_to_sheet(w);l.book_append_sheet(x,o,"儿童行为量表(女12-16岁)")}const te=M(x,{bookType:"xlsx",type:"array"});E(te,"量表分析")}else{const a=l.aoa_to_sheet(f),r=l.book_new();l.book_append_sheet(r,a,"Sheet1");const n=M(r,{bookType:"xlsx",type:"array"});E(n,"量表分析")}},E=(s,e)=>{const a=new Blob([s],{type:"application/octet-stream"}),r=URL.createObjectURL(a),n=document.createElement("a");n.href=r,n.setAttribute("download",`${e}_${m().format("YYYY-MM-DD HH:mm:ss")}.xlsx`),document.body.appendChild(n),n.click(),document.body.removeChild(n)};return t.jsxs(ce,{theme:v,children:[t.jsx("div",{className:"searchTop",children:t.jsxs(h,{form:b,layout:"inline",onFinish:q,initialValues:{StartTime:"",EndTime:"",PNum:"",PName:"",PTaskname:"",tableCode:""},children:[t.jsx(h.Item,{label:"量表名称: ",name:"tableCode",children:t.jsx(O,{className:"ysh_antd_auto",options:V,allowClear:!0,placeholder:"量表名称",onChange:K})}),t.jsx(h.Item,{label:"任务名称 : ",name:"PTaskname",children:t.jsx(O,{className:"ysh_antd_auto",options:L,allowClear:!0,placeholder:"任务名称",onChange:J})}),t.jsx(h.Item,{label:"账号 : ",name:"PNum",children:t.jsx(A,{allowClear:!0,placeholder:"账号"})}),t.jsx(h.Item,{label:"姓名 : ",name:"PName",children:t.jsx(A,{allowClear:!0,placeholder:"姓名"})}),t.jsx(h.Item,{label:"开始 : ",name:"StartTime",children:t.jsx(P,{})}),t.jsx(h.Item,{label:" 至 : ",name:"EndTime",children:t.jsx(P,{})}),t.jsx(h.Item,{children:t.jsxs(oe,{children:[t.jsx(D,{type:"primary",htmlType:"submit",children:"搜 索"}),t.jsx(D,{onClick:ee,children:"导出"})]})})]})}),t.jsxs("div",{className:"content",children:[t.jsx("div",{className:"leftOrgan",children:t.jsx(ie,{onSelectOrg:Z})}),t.jsx("div",{className:"rightTable",children:t.jsx(le,{className:"table",size:"small",sticky:!0,loading:k,rowKey:s=>JSON.stringify(s),dataSource:W,columns:G,pagination:!1})})]})]})});de.displayName="PSYExport";export{de as default};
