import{r as o,n as Q,_ as U,d as W,A as G,t as q,F as d,j as e,S as J,D as N,b as K,B as w,R as X,x as Z,g as v,a as c,v as ee}from"./index-BtzNP73w.js";import{O as te}from"./index-Bulw9wNg.js";import{u as g,w as ae}from"./xlsx-D1HvzHLO.js";import{d as se}from"./htmlToPdf-DfRLdXs-.js";import{B as ne}from"./index-CJeWDVq8.js";import{L as ie}from"./index-BYyeyiZH.js";import{p as le,f as re}from"./chartsConfig-CLQzSBgN.js";import{R as oe}from"./index-BQMiSoaL.js";import{R as ce}from"./PrinterOutlined-CKytW4eE.js";import"./index-B6m4IotF.js";import"./iconUtil-D_WnT0lW.js";var de={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}},{tag:"path",attrs:{d:"M464 336a48 48 0 1096 0 48 48 0 10-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z"}}]},name:"info-circle",theme:"outlined"},me=function(h,r){return o.createElement(Q,U({},h,{ref:r,icon:de}))},he=o.forwardRef(me);const pe=W.div`
  height: 100%;
  display: flex;
  flex-direction: column;
  .searchTop {
    height: 60px;
    padding-left: 25px;
    margin-bottom: 10px;
    border-radius: 6px;
    background-color: ${s=>s.theme.colorBgContainer};
    .ant-form {
      height: 100%;
      display: flex;
      align-items: center;
      .ant-form-item {
        width: 240px;
        &:nth-last-child(1) {
          flex: 1;
          margin-left: 20px;
        }
        &:nth-last-child(2) {
          width: 180px;
        }
        &:nth-last-child(3) {
          width: 180px;
        }
      }
      .moreSelect {
        .ant-select-selection-overflow {
          flex-wrap: nowrap;
          overflow-x: auto;
          overflow-y: hidden;
        }
      }
    }
  }
  .content {
    flex: 1;
    height: 0;
    display: flex;
    letter-spacing: 2px;
    .leftOrgan {
      width: 200px;
      overflow: hidden;
      margin-right: 10px;
      border-radius: 6px;
      background-color: ${s=>s.theme.colorBgContainer};
    }
    .rightChart {
      flex: 1;
      font-size: 12px;
      overflow: auto;
      position: relative;
      border-radius: 6px;
      background-color: ${s=>s.theme.colorBgContainer};
      .report {
        width: 794px;
        padding: 16px;
        margin: 0 auto;
        overflow: auto;
        .title {
          height: 36px;
          line-height: 36px;
          text-align: center;
          font-size: 18px;
          margin-bottom: 10px;
          .exportExcel {
            cursor: pointer;
          }
        }
        
        .titleInfo {
          margin-bottom: 15px;
          padding-bottom: 15px;
          border-bottom: 1px dotted ${s=>s.theme.colorBorder};
            p {
            line-height: 28px;
            font-size: 14px;
            display: flex;
            > span:nth-child(1){
              width: 150px;
              text-align: right;
              
            }
            span:nth-child(2){
              flex: 1;
              text-align: left;
              padding-left: 10px;
              text-indent: 2em;
            }
          }
        }
        .modal1 {
          padding-bottom: 20px;
          margin-bottom: 20px;
          border-bottom: 1px dotted ${s=>s.theme.colorBorder};
          .title {
            height: 30px;
            line-height: 30px;
            font-size: 16px;
            margin-bottom: 10px;
            
            text-align: left;
          }
          .titleTable {
            margin-bottom: 15px;
            li {
              height: 30px;
              line-height: 30px;
              display: flex;
              span {
                flex: 2;
                font-size: 14px;
                text-align: left;
                &:nth-child(2n + 1) {
                  text-align: right;
                  flex: 1;
                  
                }
                &:nth-child(2n) {
                  text-indent: 2em;
                }
              }
            }
          }
          .barChart {
            height: 220px;
            margin-bottom: 15px;
          }
          .tableData {
            display: flex;
            margin-bottom: 16px;
            border: 1px solid ${s=>s.theme.colorBorder};
            .item {
              flex: 1;
              &:nth-child(1) {
                flex: 1.5;
              }
              &:nth-last-child(1) {
                .itemTitle {
                  span:nth-last-child(1) {
                    border: none;
                  }
                }
                .itemValue {
                  span:nth-last-child(1) {
                    border: none;
                  }
                }
              }
              .itemTitle {
                height: 60px;
                font-size: 12px;
                display: flex;
                text-align: center;
                border-bottom: 1px solid ${s=>s.theme.colorBorder};
                span {
                  height: 60px;
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  border-right: 1px solid ${s=>s.theme.colorBorder};
                }
                span:nth-child(1) {
                  flex: 1.5;
                }
                span:nth-child(2) {
                  flex: 1;
                }
              }
              .itemValue {
                height: 60px;
                font-size: 12px;
                display: flex;
                text-align: center;
                span {
                  height: 60px;
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  border-right: 1px solid ${s=>s.theme.colorBorder};
                }
                span:nth-child(1) {
                  flex: 1.5;
                }
                span:nth-child(2) {
                  flex: 1;
                }
              }
            }
          }
          .desc {
            text-indent: 2em;
            
          }
          .lineChart {
            height: 220px;
            margin-bottom: 15px;
          }
        }
        .special {
          .down {
            cursor: pointer;
            text-decoration: underline;
          }
        }
      }
    }
  }
  
@media print {
  @page {
    size: auto;
    margin: 3mm;
    margin-top: 10mm;
    margin-left: 10mm;
    .print-area {
      page-break-after: always;
    }
  }
  body {
    height: auto; //在实际页面中高度不够部分内容隐藏了
  }
}
`,xe=o.memo(()=>{const{message:s}=G.useApp(),{token:h}=q.useToken(),[r,u]=o.useState(null),[k,j]=o.useState([]),[S,D]=o.useState([]),[b,E]=o.useState([]),[I,Y]=o.useState([]),[A,B]=o.useState([]),[y]=d.useForm(),[P,z]=o.useState(0),[F,C]=o.useState(!1),x=o.useRef(null);o.useEffect(()=>{(async()=>{try{const a=await v("/api/PsyTaskName/All",{pageIndex:1,pageSize:999999});if(a.code===200){E(a.data.items);const l=a.data.items.map(i=>({label:i.ptaskname,value:i.ptaskname}));j(l),D(l)}else s.error(a.msg);const n=await v("/api/PsyInfotablebrief/All",{IsStatisticalAnalysisChart:1,pageIndex:1,pageSize:999999});if(n.code===200){B(n.data.items);const l=n.data.items.map(i=>({label:i.nameChinese,value:i.nameEnglish}));Y(l)}else s.error(n.msg)}catch(a){s.error(a),console.log(a)}})()},[s]);const T=async(t=[],a)=>{try{const{code:n,data:l,msg:i}=await ee("/api/PsyInforeport/GetStatisticalAnalysisChart",t,a);n===200?u(l):(u(null),s.warning(i))}catch(n){s.error(n)}},O=t=>{const a=[];S.forEach(n=>{n.value.includes(t)&&a.push(n)}),j(a)},$=t=>{let a=0;t.PTaskname&&b.forEach(i=>{i.ptaskname===t.PTaskname&&(a=i.ptasknameid)});const n={QorganizeId:P,PTasknameId:a};if(t.StartTime&&(n.StartTime=c(t.StartTime).format("YYYY-MM-DD")),t.EndTime&&(n.EndTime=c(t.EndTime).format("YYYY-MM-DD")),c(t.StartTime).valueOf()>c(t.EndTime).valueOf()){s.warning("开始时间大于结束时间, 请重新选择");return}const l=t.NameChinese;if(l.length===0){s.info("量表名称不能为空",3);return}T(l,n)},M=t=>{R(t),z(t)},R=t=>{const a=y.getFieldValue();let n=0;a.PTaskname&&b.forEach(p=>{p.ptaskname===a.PTaskname&&(n=p.ptasknameid)});const l={QorganizeId:t,PTasknameId:n};if(a.StartTime&&(l.StartTime=c(a.StartTime).format("YYYY-MM-DD")),a.EndTime&&(l.EndTime=c(a.EndTime).format("YYYY-MM-DD")),c(a.StartTime).valueOf()>c(a.EndTime).valueOf()){s.warning("开始时间大于结束时间, 请重新选择");return}const i=a.NameChinese;if(i.length===0){s.info("量表名称不能为空",3);return}T(i,l)},m=t=>A.find(n=>n.nameEnglish===t).nameChinese,_=async()=>{if(!x.current){s.info("暂无报告",5);return}await C(!0),await se(`报告_${c().format("YYYY-MM-DD HH:mm:ss")}`,x.current),await C(!1)},L=()=>{if(r.lsExcleData){const t=["任务名称","组织机构","姓名","账号","量表名称","描述","测试时间"],a=r.lsExcleData.map(H=>Object.values(H)),n=[t,...a],l=g.aoa_to_sheet(n),i=g.book_new();g.book_append_sheet(i,l,"Sheet1");const p=ae(i,{bookType:"xlsx",type:"array"});V(p,"统计分析异常表")}else{s.info("不存在异常",3);return}},V=(t,a)=>{const n=new Blob([t],{type:"application/octet-stream"}),l=URL.createObjectURL(n),i=document.createElement("a");i.href=l,i.setAttribute("download",`${a}_${c().format("YYYY-MM-DD HH:mm:ss")}.xlsx`),document.body.appendChild(i),i.click(),document.body.removeChild(i)},f=t=>r.lsExcleData.reduce((a,n)=>a.find(i=>i[t]===n[t])?a:a.concat([n]),[]);return e.jsxs(pe,{theme:h,children:[e.jsx("div",{className:"searchTop",children:e.jsxs(d,{form:y,layout:"inline",onFinish:$,initialValues:{StartTime:null,EndTime:null,PTaskname:"",NameChinese:[]},children:[e.jsx(d.Item,{label:"任务名称 : ",name:"PTaskname",children:e.jsx(oe,{className:"ysh_antd_auto",options:k,allowClear:!0,onChange:O})}),e.jsx(d.Item,{label:"量表名称 : ",name:"NameChinese",children:e.jsx(J,{className:"moreSelect",mode:"multiple",allowClear:!0,style:{width:"100%"},options:I})}),e.jsx(d.Item,{label:"开始 : ",name:"StartTime",children:e.jsx(N,{})}),e.jsx(d.Item,{label:" 至 : ",name:"EndTime",children:e.jsx(N,{})}),e.jsx(d.Item,{children:e.jsxs(K,{children:[e.jsxs(w,{type:"primary",htmlType:"submit",children:[e.jsx(X,{}),"搜 索"]}),e.jsxs(w,{onClick:_,disabled:F,children:[e.jsx(ce,{}),"导出"]})]})})]})}),e.jsxs("div",{className:"content",children:[e.jsx("div",{className:"leftOrgan",children:e.jsx(te,{onSelectOrg:M})}),e.jsx("div",{className:"rightChart",children:r?e.jsxs("div",{className:"report",ref:x,id:"psyReport",children:[e.jsx("p",{className:"title",children:"量表统计分析"}),e.jsxs("div",{className:"titleInfo",children:[e.jsxs("p",{children:[e.jsx("span",{children:"总测试人次:"}),e.jsx("span",{children:r.lsstatisticalAnalysis[0].totalTestCount})]}),e.jsxs("p",{children:[e.jsx("span",{children:"总完成测试人次:"}),e.jsx("span",{children:r.lsstatisticalAnalysis[0].totalTestFinishCount})]}),e.jsxs("p",{children:[e.jsx("span",{children:"总未完成测试人次:"}),e.jsx("span",{children:r.lsstatisticalAnalysis[0].totalTestNoFinishCount})]}),e.jsxs("p",{children:[e.jsx("span",{children:"量表种类:"}),e.jsxs("span",{children:[r.lsstatisticalAnalysis[0].scaleCount," 个 ( ",r.lsstatisticalAnalysisByTableCodes.map((t,a)=>e.jsx("span",{children:m(t.tableCode)+(r.lsstatisticalAnalysisByTableCodes.length-1===a?"":", ")},t.tableCode)),")，其他量表因参与人数较少，本次不参与统计。"]})]})]}),r.lsstatisticalAnalysisByTableCodes.map(t=>e.jsxs("div",{className:"modal1",children:[e.jsx("p",{className:"title",children:m(t.tableCode)}),e.jsxs("ul",{className:"titleTable",children:[e.jsxs("li",{children:[e.jsx("span",{children:"测试人次: "}),e.jsx("span",{children:t.totalCount}),e.jsx("span",{children:"完成测试人次: "}),e.jsx("span",{children:t.totalFinishCount})]}),e.jsxs("li",{children:[e.jsx("span",{children:"未完成测试人次: "}),e.jsx("span",{children:t.totalCount-t.totalFinishCount}),e.jsx("span",{children:"平均耗时: "}),e.jsx("span",{children:t.avg_ConsumeTime.replace(/\.\d+/,"")})]}),e.jsxs("li",{children:[e.jsx("span",{children:"最大耗时: "}),e.jsx("span",{children:t.max_ConsumeTime.replace(/\.\d+/,"")}),e.jsx("span",{children:"最小耗时: "}),e.jsx("span",{children:t.min_ConsumeTime.replace(/\.\d+/,"")})]})]}),e.jsx(e.Fragment,{children:t.tableData&&e.jsxs("div",{className:"tableData",children:[e.jsxs("div",{className:"item",children:[e.jsxs("div",{className:"itemTitle",children:[e.jsx("span",{children:"量表"}),e.jsx("span",{children:"测试人次"})]}),e.jsxs("div",{className:"itemValue",children:[e.jsx("span",{children:m(t.tableCode)}),e.jsx("span",{children:t.totalFinishCount})]})]}),t.tableData.data.map(a=>e.jsxs("div",{className:"item",children:[e.jsxs("div",{className:"itemTitle",children:[e.jsx("span",{children:a.name}),e.jsx("span",{children:"占比"})]}),e.jsxs("div",{className:"itemValue",children:[e.jsx("span",{children:a.countdata}),e.jsxs("span",{children:[a.percentdata.toFixed(1),"%"]})]})]},a.name))]})}),e.jsx("div",{className:"barChart",children:e.jsx(ne,{option:le(t,m(t.tableCode))})}),e.jsx("p",{className:"desc",children:"从组织机构的维度分析，结果如下："}),e.jsx("div",{className:"lineChart",children:e.jsx(ie,{option:re(t,m(t.tableCode))})})]},t.tableCode)),r.lsExcleData&&e.jsxs("p",{className:"special",children:[e.jsx("span",{className:"text",children:"总结:"}),e.jsx("br",{}),e.jsx("span",{className:"text",children:"       在这次量表统计分析中，参加的组织机构有"}),e.jsx("span",{className:"value",children:f("orgName").length}),e.jsx("span",{className:"text",children:"个，参与的测试量表有（"}),e.jsx("span",{className:"value",children:f("nameChinese").length}),e.jsx("span",{className:"text",children:"）个，测试有异常人数为："}),e.jsx("span",{className:"value",children:f("pNum").length}),e.jsx("span",{className:"text",children:"个, 详情见 "}),e.jsx("span",{className:"down",onClick:L,title:"导出统计分析异常数据",children:"附件"})]})]}):e.jsx(Z,{icon:e.jsx(he,{style:{color:h.colorWarning}}),title:e.jsx(e.Fragment,{children:"选择量表名称后, 点击查询获取"})})})]})]})});xe.displayName="PSYAnalysis";export{xe as default};
