import{d as R,r as n,t as T,f as H,j as e,l as E,B,a as c,A as I,I as L,D as k,g as W,b as M,m as F}from"./index-BtzNP73w.js";import{B as _}from"./index-CJeWDVq8.js";import{R as z}from"./index-BYZ7EzgM.js";import{L as P}from"./index-BYyeyiZH.js";import{a as J,d as O,c as q}from"./chartsConfig-CLQzSBgN.js";import{d as U,h as V}from"./htmlToPdf-DfRLdXs-.js";import{h as G,F as Z}from"./FileSaver.min-QKvCmR1E.js";import{F as K}from"./Table-BCm752cP.js";import"./iconUtil-D_WnT0lW.js";import"./index-B6m4IotF.js";const Q=R.div`
  height: 100%;
  display: flex;
  .leftTable {
    flex: 1;
    display: flex;
    flex-direction: column;
    .topsearch {
      height: 60px;
      display: flex;
      background-color: ${i=>i.theme.colorBgContainer};
      .inp {
        flex: 2;
        display: flex;
        padding: 0 16px;
        align-items: center;
        .label {
          width: 60px;
          line-height: 30px;
        }
        .antd_input {
          height: 30px;
        }
      }
      .date {
        flex: 4;
        display: flex;
        padding: 0 16px;
        .startDate {
          width: 50%;
          display: flex;
          align-items: center;
          margin-right: 16px;
          .label {
            width: 40px;
            line-height: 30px;
          }
          .date {
            height: 30px;
          }
        }
        .endDate {
          width: 50%;
          display: flex;
          align-items: center;
          margin-right: 16px;
          .label {
            width: 40px;
            line-height: 30px;
          }
          .date {
            height: 30px;
          }
        }
      }
      .btn {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
      }
    }
    .bottomtable {
      flex: 1;
      padding: 16px 0;
      box-sizing: border-box;
      overflow: hidden;
      border-radius: 6px;
    }
  }
  .rightReport {
    width: 794px;
    height: 100%;
    overflow: auto;
    position: relative;
  }
`,X=R.div`
  height: 1100px;
  position: relative;
  .dom {
    height: 100%;
    padding: 16px;
    overflow: auto;
    .title {
      font-size: 18px;
      text-align: center;
    }
    
    .chartLine {
      height: 200px;
      padding-top: 20px;
    }
    .charts {
      height: 240px;
      display: flex;
      justify-content: center;
      .radarChart {
        width: 40%;
      }
      .barChart {
        width: 60%;
      }
    }
    .suggestText {
      text-indent: 2em;
      font-size: 14px;
    }
  }
  .isprint.dom {
    color: #000;
    background-color: #fff;
  }

  .dividerLine {
    height: 50px;
    display: flex;
    align-items: center;
    .line {
      flex: 1;
      height: 1px;
      border-top: 1px solid ${i=>i.theme.colorText};
    }
    .world {
      text-align: center;
      padding: 0 20px;
      height: 100%;
      line-height: 50px;
    }
  }
  .printbtn {
    position: absolute;
    top: 16px;
    right: 24px;
  }
`,ee=i=>{switch(i){case 1:return"轻";case 2:return"中";case 3:return"重";default:return""}},Y=i=>{switch(i){case 1:return"低";case 2:return"中";case 3:return"高";default:return""}},te=i=>{switch(i){case 1:return"无";case 2:return"中";case 3:return"高";default:return""}},re=i=>{switch(i){case 1:return"比较稳定";case 2:return"小幅波动";case 3:return"大幅波动";default:return""}},oe=n.memo(i=>{const{token:t}=T.useToken(),u=n.useRef(null),{data:o}=i;let h=null;o&&(h=o.outputTrain_Subject_Infos?JSON.parse(o.outputTrain_Subject_Infos):[]);const[j,b]=n.useState(!1),{genderList:v}=H(l=>l),y=()=>{b(!0),setTimeout(()=>{U("训练报告",u.current),b(!1)},0)},S=(l,x="")=>`
      Content-Type: text/html; charset='utf-8'
      <!DOCTYPE html>
      <html>
      <head>
        <style>${`
      @page { margin: 0; padding: 0; }
      img { 
        max-width: 100% !important; 
        height: auto !important;
        display: block !important;
        margin: 0 auto !important;
      }
    `+x}</style>
      </head>
      <body>${l}</body>
      </html>
    `,C=async l=>(await V(l,{backgroundColor:"#ffffff",scale:.8})).toDataURL("image/png"),f=async({filename:l,selector:x})=>{const p=document.querySelector(x).cloneNode(!0),D=["#linechart","#charts"];for(const s of D){const a=document.querySelector(s);if(a)try{const m=await C(a),g=p.querySelector(s);if(g){const A=document.createElement("img");A.src=m,A.style="max-width: 100%; height: 50px; display: block;",g.replaceWith(A)}}catch(m){console.error(`Error processing ${s}:`,m)}}const $=document.querySelectorAll(".echarts:not(#linechart .echarts):not(#charts .echarts)");for(const s of $)try{const a=await C(s),m=p.querySelector(`#${s.id}`);if(m){const g=document.createElement("img");g.src=a,g.style="max-width: 100%; height: auto; display: block;",m.replaceWith(g)}}catch(a){console.error(`Error processing chart ${s.id}:`,a)}const r=S(p.innerHTML),d=G.asBlob(r);Z.saveAs(d,`${l}.docx`)};let N=[{label:e.jsx("span",{onClick:y,children:"导出为pdf"}),key:"0"},{type:"divider"},{label:e.jsx("span",{onClick:()=>f({filename:`报告_${c().format("YYYY-MM-DD")}`,selector:"#userreport"}),children:"导出为word"}),key:"1"}];return e.jsxs(X,{theme:t,children:[o&&e.jsxs("div",{className:`dom ${j?"isprint":""}`,ref:u,id:"userreport",children:[e.jsx("p",{style:{fontSize:"18px",textAlign:"center"},children:"单人训练报告"}),e.jsxs("div",{className:"dividerLine",children:[e.jsx("div",{className:"line"}),e.jsx("div",{className:"world",children:"基本信息"}),e.jsx("div",{className:"line"})]}),e.jsx("table",{style:{width:"100%",borderSpacing:0,borderCollapse:"collapse"},children:e.jsxs("tbody",{children:[e.jsxs("tr",{style:{height:"36px",display:"flex",justifyContent:"space-around",lineHeight:"36px"},children:[e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:"账 号"}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:o.pNum}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:"姓 名"}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:o.pName})]}),e.jsxs("tr",{style:{height:"36px",display:"flex",justifyContent:"space-around",lineHeight:"36px"},children:[e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:"性 别"}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:v[o.pSex]}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:"年龄"}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:o.pAge})]}),e.jsxs("tr",{style:{height:"36px",display:"flex",justifyContent:"space-around",lineHeight:"36px"},children:[e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:"训练日期"}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`,colspan:"1"},children:o.trainDate.split(" ")[0]}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`,colspan:"1"},children:"训练总分"}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`,colspan:"1"},children:o.totalScore})]}),e.jsxs("tr",{style:{height:"36px",display:"flex",justifyContent:"space-around",lineHeight:"36px"},children:[e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`,colspan:"1"},children:"开始时间"}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`,colspan:"1"},children:o.startTime.split(" ")[1]}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`,colspan:"1"},children:"结束时间"}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`,colspan:"1"},children:o.endTime.split(" ")[1]})]})]})}),e.jsxs("div",{className:"dividerLine",children:[e.jsx("div",{className:"line"}),e.jsx("div",{className:"world",children:"心理应激状态数据"}),e.jsx("div",{className:"line"})]}),e.jsx("table",{style:{width:"100%",borderSpacing:0,borderCollapse:"collapse"},children:e.jsxs("tbody",{children:[e.jsxs("tr",{style:{height:"36px",display:"flex",justifyContent:"space-around",lineHeight:"36px"},children:[e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:"训练区域"}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:"情绪稳定性"}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:"脑力应激"}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:"疲劳度"}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:"兴奋度"}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:"专注度"})]}),h&&h.map((l,x)=>e.jsxs("tr",{style:{height:"36px",display:"flex",justifyContent:"space-around",lineHeight:"36px"},children:[e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:"训练区"}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:re(l.JinZhang)}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:te(l.CognitiveStress)}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:ee(l.Fatigue_State)}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:Y(l.Energy_State)}),e.jsx("td",{style:{flex:1,textAlign:"center",borderWidth:"1px",borderStyle:"solid",borderColor:`${t.colorBorder}`},children:Y(l.Focus_State)})]},x))]})}),e.jsx("div",{className:"chartLine",id:"linechart",children:e.jsx(P,{option:J(JSON.parse(o.meanHr),"心率变化曲线图",JSON.parse(o.meanHrTime))})}),e.jsxs("div",{className:"charts",id:"charts",children:[e.jsx("div",{className:"radarChart",children:e.jsx(z,{option:O(JSON.parse(o.train))})}),e.jsx("div",{className:"barChart",children:e.jsx(_,{option:q(JSON.parse(o.subject),["时空估计","视觉检索","空间知觉","反应速度","注意力分配","手眼脑协调","工作记忆","注意广度"],"训练任务正确率")})})]}),e.jsxs("div",{className:"dividerLine",children:[e.jsx("div",{className:"line"}),e.jsx("div",{className:"world",children:"评价建议"}),e.jsx("div",{className:"line"})]}),e.jsx("div",{className:"suggestText",children:o.rEvaluateDesc})]}),e.jsx(E,{placement:"bottom",arrow:!0,menu:{items:N},trigger:["click"],children:e.jsx("div",{className:"printbtn",children:e.jsx(B,{children:"导 出"})})})]})}),le=n.memo(()=>{const{token:i}=T.useToken(),{message:t}=I.useApp(),{genderList:u}=H(r=>r),[o,h]=n.useState(0),[j,b]=n.useState([]),[v,y]=n.useState(null),[S,C]=n.useState(""),[f,N]=n.useState(c().add(-5,"year")),[l,x]=n.useState(c());n.useEffect(()=>{(async()=>{const{code:d,data:s,msg:a}=await W("/api/DVReport/GetSingleReport",{StartTime:c().add(-5,"year").format("YYYY-MM-DD HH:mm:ss"),EndTime:c().format("YYYY-MM-DD HH:mm:ss"),pageIndex:1,pageSize:9999});d===200?(b(s.items),y(s.items[0]),h(s.totalRecords)):t.error(a)})()},[]);const w=[{title:"账 号",dataIndex:"pNum",align:"center",key:"id",render:r=>e.jsx(e.Fragment,{children:r})},{title:"姓 名",dataIndex:"pName",align:"center",key:"id",render:r=>e.jsx(e.Fragment,{children:r})},{title:"性别",dataIndex:"pSex",align:"center",key:"id",render:r=>e.jsx(e.Fragment,{children:u[r]})},{title:"年龄",dataIndex:"pAge",align:"center",key:"id",render:r=>e.jsx(e.Fragment,{children:r})},{title:"总 分",dataIndex:"totalScore",align:"center",key:"id",render:r=>e.jsx(e.Fragment,{children:r})},{title:"训练时间",dataIndex:"trainDate",align:"center",key:"id",width:180,render:(r,d)=>e.jsx(e.Fragment,{children:r})},{title:"操 作",dataIndex:"id",align:"center",key:"id",fixed:"right",width:180,className:"columnStyle",render:(r,d)=>e.jsx(M,{children:e.jsxs(B,{onClick:s=>y(d),children:["预览",e.jsx(F,{})]})})}],p=(r,d)=>{console.log(r,d),N(r)},D=(r,d)=>{console.log(r,d),x(r)},$=async()=>{const r={StartTime:f?c(f).format("YYYY-MM-DD HH:mm:ss"):c().add(-5,"year").format("YYYY-MM-DD HH:mm:ss"),EndTime:l?c(l).format("YYYY-MM-DD HH:mm:ss"):c().format("YYYY-MM-DD HH:mm:ss"),pageIndex:1,pageSize:9999,pName:S};console.log(r);const{code:d,data:s,msg:a}=await W("/api/DVReport/GetSingleReport",r);d===200?(b(s.items),y(s.items[0]),h(s.totalRecords)):t.error(a)};return e.jsxs(Q,{theme:i,children:[e.jsxs("div",{className:"leftTable",children:[e.jsxs("div",{className:"topsearch",children:[e.jsxs("div",{className:"inp",children:[e.jsx("span",{className:"label",children:"姓 名: "}),e.jsx(L,{className:"antd_input",value:S,allowClear:!0,onChange:r=>C(r.target.value),placeholder:"请输入姓名"})]}),e.jsxs("div",{className:"date",children:[e.jsxs("div",{className:"startDate",children:[e.jsx("span",{className:"label",children:"开 始: "}),e.jsx(k,{className:"date",value:f,onChange:p})]}),e.jsxs("div",{className:"endDate",children:[e.jsx("span",{className:"label",children:"结 束: "}),e.jsx(k,{className:"date",value:l,onChange:D})]})]}),e.jsx("div",{className:"btn",children:e.jsx(B,{onClick:$,children:"搜 索"})})]}),e.jsx("div",{className:"bottomtable",children:j&&e.jsx(K,{rowKey:r=>r.id,size:"small",showExpandColumn:!1,columns:w,dataSource:j,sticky:!0,pagination:{total:o||0,showSizeChanger:!0,showQuickJumper:!0,defaultPageSize:13,showTotal:()=>`共 ${o} 条`}})})]}),e.jsx("div",{className:"rightReport",children:e.jsx(oe,{data:v})})]})});le.displayName="DarkPersonReport";export{le as default};
