import{p as re,r,A as ye,t as ke,f as Se,j as e,C as d,z as I,E as _,ac as ie,I as u,d as H,h as Te,ad as ne,g as f,aa as Be,v as K}from"./index-CKIL6d0V.js";import{S as b}from"./index-2o7ngel8.js";import{R as Re}from"./PlusCircleOutlined-C3dgw0Zs.js";import{F as Ie}from"./Table-BaVi_066.js";import{R as Ee}from"./FileAddOutlined-DZJhsTo4.js";import{R as Ve}from"./WarningOutlined-DXw3DJIi.js";import"./iconUtil-Co5gbObL.js";import"./index-C-LPyJas.js";const Ae=re.div`
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  .topCommonInfor {
    height: 95px;
    padding-bottom: 15px;
    margin-bottom: 15px;
    display: flex;
    border-bottom: 1px dashed ${l=>l.theme.colorBorder};
    .leftInput {
      flex: 1;
      display: flex;
      flex-wrap: wrap;
      .item {
        width: 33%;
        height: 40px;
        line-height: 40px;
        display: flex;
        .label {
          width: 80px;
          opacity: 0.5;
          text-align: right;
        }
        .value {
          flex: 1;
          padding-left: 10px;
        }
      }
    }
    .rightBtn {
      width: 80px;
      .btn {
        height: 100%;
        line-height: 80px;
        border-radius: 10px;
        font-size: 32px;
        text-align: center;
        cursor: pointer;
        color: ${l=>l.theme.colorBorder};
        border: 1px dashed ${l=>l.theme.colorBorder};

        transition: all 0.2s;
        &:hover {
          border-width: 2px;
          font-size: 36px;
        }
      }
    }
  }

  .Profilelist {
    flex: 1;
    display: flex;
    overflow: hidden;
    .profileTable {
      width: 50%;
      height: 100%;
      overflow: auto;
    }
    .profileDetail {
      width: 50%;
      padding-left: 15px;
      overflow: auto;
      .items {
        line-height: 36px;
        margin-bottom: 15px;
        display: flex;
        .profileLabel {
          width: 100px;
          padding-right: 15px;
          text-align: right;
          opacity: 0.6;
        }
        .profileValue {
          flex: 1;
          width: 0;
          padding-left: 15px;
          border-radius: 5px;
          overflow: auto;
          span {
            padding: 0 10px;
            i {
              display: inline-block;
              vertical-align: middle;
              width: 6px;
              height: 6px;
              border-radius: 50%;
              margin-right: 6px;
              background-color: ${l=>l.theme.colorTextTertiary};
            }
          }
          .remark {
            color: ${l=>l.theme.colorTextTertiary};
          }
        }
      }
    }
  }
  .reportinfo {
    flex: 1;
    height: 0;
  }

  /* 选中表格行样式 */
  .ant-table .ant-table-container tr.table-tr-row-id {
    background-color: ${l=>l.theme.blue1};
  }
`,De=re.div`
  height: 100%;
  height: 700px;
  overflow: auto;
  .abnormal {
    height: 250px;
    display: flex;
    .leftTitle {
      width: 100px;
      padding-top: 10px;
      text-align: center;
    }
    .rightTabs {
      flex: 1;
      height: 100%;
      .tabsStyle {
        height: 250px;
        .ant-tabs-content-holder {
          overflow: auto;
        }
        .specialTitle {
          height: 30px;
          padding-left: 10px;
        }

        .specialCol {
          display: flex;
          min-height: 40px;
          margin-bottom: 10px;
          .leftCheckBox {
            width: 240px;
            display: flex;
            flex-direction: column;
          }
          .right {
            width: 100px;
            margin-left: 20px;
          }
          .centerArea {
            width: 300px;
          }
        }
      }
    }
  }
  .abnormalSelect {
    min-height: 60px;
    padding-left: 100px;

    .tag {
      height: 40px;
      border-radius: 8px;
      display: inline-block;
      line-height: 40px;
      padding: 0 16px;
      margin-right: 10px;
      margin-bottom: 10px;
      
      color: ${l=>l.theme.green};
      background-color: ${l=>l.theme.green1};
      .icon {
        margin-left: 10px;
        cursor: pointer;
        &:hover {
          color: ${l=>l.theme.red5};
        }
      }
    }
  }

  .abnormalRemark {
    height: 60px;
    display: flex;
    .leftTitle {
      width: 100px;
      text-align: center;
    }
    .rightTabs {
      flex: 1;
    }
  }
`,{TextArea:m}=u,Fe=r.memo(l=>{const{message:k}=ye.useApp(),{info:o}=l,{token:S}=ke.useToken(),[le,ce]=r.useState(""),[h,j]=r.useState(null),[U,q]=r.useState(null),{organ:oe,genderList:de,userInfo:T}=Se(a=>a),[he,E]=r.useState(!1),[ve,J]=r.useState([]),[v,w]=r.useState({id:0,behavior_tag1_name:"",behavior_tag1_desc:"",behavior_tag1_iswaring:0,behavior_tag2_name:"",behavior_tag2_desc:"",behavior_tag2_iswaring:0,behavior_tag3_name:"",behavior_tag3_desc:"",behavior_tag3_iswaring:0}),[Q,W]=r.useState(""),[X,Z]=r.useState(""),[g,N]=r.useState({id:0,event_tag1_name:"",event_tag1_desc:"",event_tag1_iswaring:0,event_tag2_name:"",event_tag2_desc:"",event_tag2_iswaring:0,event_tag3_name:"",event_tag3_desc:"",event_tag3_iswaring:0}),[B,V]=r.useState([]),[x,ge]=r.useState([]),[p,_e]=r.useState([]),[me,ee]=r.useState([]),[R,A]=r.useState([]),[xe,ae]=r.useState(!1),se=r.useCallback(({target:a},s)=>{const i=[...B];if(a.checked)i.push({id:s.id,name:s.sub_behavior_event}),V(i);else{const t=i.filter(n=>n.id!==s.id);V(t)}},[B]),D=r.useCallback((a=[])=>{if(a)return e.jsx(d.Group,{children:e.jsx(I,{children:a.map((s,i)=>e.jsxs(_,{span:6,children:[e.jsx(d,{onChange:t=>se(t,s),value:s.id,children:s.sub_behavior_event}),e.jsx(ie,{placement:"top",title:s.behavior_event_desc,children:e.jsx("span",{style:{color:S.blue4,cursor:"pointer"},children:"详情"})})]},i))})})},[S,se]),te=r.useCallback(({target:a},s)=>{const i=[...R];if(a.checked)i.push({id:s.id,name:s.sub_behavior_event}),A(i);else{const t=i.filter(n=>n.id!==s.id);A(t)}},[R]),F=r.useCallback((a=[])=>{if(a)return e.jsx(d.Group,{children:e.jsx(I,{children:a.map((s,i)=>e.jsx(_,{span:6,children:e.jsx(d,{onChange:t=>te(t,s),value:s.id,children:s.sub_behavior_event})},i))})})},[te]),$=({target:a},s)=>{w(i=>{const t={...i};return s===1?t.behavior_tag1_name=a.value:s===2?t.behavior_tag2_name=a.value:s===3&&(t.behavior_tag3_name=a.value),t})},Y=({target:a},s)=>{w(i=>{const t={...i};return s===1?t.behavior_tag1_desc=a.value:s===2?t.behavior_tag2_desc=a.value:s===3&&(t.behavior_tag3_desc=a.value),t})},z=(a,s)=>{w(i=>{const t={...i};return s===1?t.behavior_tag1_iswaring=a?1:0:s===2?t.behavior_tag2_iswaring=a?1:0:s===3&&(t.behavior_tag3_iswaring=a?1:0),t})},P=({target:a},s)=>{N(i=>{const t={...i};return s===1?t.event_tag1_name=a.value:s===2?t.event_tag2_name=a.value:s===3&&(t.event_tag3_name=a.value),t})},L=({target:a},s)=>{N(i=>{const t={...i};return s===1?t.event_tag1_desc=a.value:s===2?t.event_tag2_desc=a.value:s===3&&(t.event_tag3_desc=a.value),t})},M=(a,s)=>{N(i=>{const t={...i};return s===1?t.event_tag1_iswaring=a?1:0:s===2?t.event_tag2_iswaring=a?1:0:s===3&&(t.event_tag3_iswaring=a?1:0),t})},G=r.useCallback((a={behavior_tag1_name:"",behavior_tag1_desc:"",behavior_tag1_iswaring:0,behavior_tag2_name:"",behavior_tag2_desc:"",behavior_tag2_iswaring:0,behavior_tag3_name:"",behavior_tag3_desc:"",behavior_tag3_iswaring:0})=>e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"specialTitle",children:"没有合适的标签, 试试自己创建吧"}),e.jsx(d.Group,{onChange:s=>ge(s),children:e.jsxs(I,{children:[e.jsxs(_,{className:"specialCol",span:24,children:[e.jsx("div",{className:"leftCheckBox",children:e.jsx(d,{value:1,children:e.jsx(u,{defaultValue:a.behavior_tag1_name,onChange:s=>$(s,1)})})}),e.jsx("div",{className:"centerArea",children:e.jsx(m,{className:"textarea",defaultValue:a.behavior_tag1_desc,autoSize:{minRows:1},onChange:s=>Y(s,1)})}),e.jsx("div",{className:"right",children:e.jsx(b,{checkedChildren:"已预警",unCheckedChildren:"不预警",defaultValue:!!a.behavior_tag1_iswaring,onChange:s=>z(s,1)})})]}),e.jsxs(_,{className:"specialCol",span:24,children:[e.jsx("div",{className:"leftCheckBox",children:e.jsx(d,{value:2,children:e.jsx(u,{defaultValue:a.behavior_tag2_name,onChange:s=>$(s,2)})})}),e.jsx("div",{className:"centerArea",children:e.jsx(m,{className:"textarea",defaultValue:a.behavior_tag2_desc,autoSize:{minRows:1},onChange:s=>Y(s,2)})}),e.jsx("div",{className:"right",children:e.jsx(b,{checkedChildren:"已预警",unCheckedChildren:"不预警",defaultValue:!!a.behavior_tag2_iswaring,onChange:s=>z(s,2)})})]}),e.jsxs(_,{className:"specialCol",span:24,children:[e.jsx("div",{className:"leftCheckBox",children:e.jsx(d,{value:3,children:e.jsx(u,{defaultValue:a.behavior_tag3_name,onChange:s=>$(s,3)})})}),e.jsx("div",{className:"centerArea",children:e.jsx(m,{className:"textarea",defaultValue:a.behavior_tag3_desc,autoSize:{minRows:1},onChange:s=>Y(s,3)})}),e.jsx("div",{className:"right",children:e.jsx(b,{checkedChildren:"已预警",unCheckedChildren:"不预警",defaultValue:!!a.behavior_tag3_iswaring,onChange:s=>z(s,3)})})]})]})})]}),[]),O=r.useCallback((a={event_tag1_name:"",event_tag1_desc:"",event_tag1_iswaring:0,event_tag2_name:"",event_tag2_desc:"",event_tag2_iswaring:0,event_tag3_name:"",event_tag3_desc:"",event_tag3_iswaring:0})=>e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"specialTitle",children:"没有合适的标签, 试试自己创建吧"}),e.jsx(d.Group,{onChange:s=>_e(s),children:e.jsxs(I,{children:[e.jsxs(_,{className:"specialCol",span:24,children:[e.jsx("div",{className:"leftCheckBox",children:e.jsx(d,{value:1,children:e.jsx(u,{onChange:s=>P(s,1),defaultValue:a.event_tag1_name})})}),e.jsx("div",{className:"centerArea",children:e.jsx(m,{className:"textarea",defaultValue:a.event_tag1_desc,autoSize:{minRows:1},onChange:s=>L(s,1)})}),e.jsx("div",{className:"right",children:e.jsx(b,{checkedChildren:"已预警",unCheckedChildren:"不预警",defaultValue:!!a.event_tag1_iswaring,onChange:s=>M(s,1)})})]}),e.jsxs(_,{className:"specialCol",span:24,children:[e.jsx("div",{className:"leftCheckBox",children:e.jsx(d,{value:2,children:e.jsx(u,{onChange:s=>P(s,2),defaultValue:a.event_tag2_name})})}),e.jsx("div",{className:"centerArea",children:e.jsx(m,{className:"textarea",defaultValue:a.event_tag2_desc,autoSize:{minRows:1},onChange:s=>L(s,2)})}),e.jsx("div",{className:"right",children:e.jsx(b,{checkedChildren:"已预警",unCheckedChildren:"不预警",defaultValue:!!a.event_tag2_iswaring,onChange:s=>M(s,2)})})]}),e.jsxs(_,{className:"specialCol",span:24,children:[e.jsx("div",{className:"leftCheckBox",children:e.jsx(d,{value:3,children:e.jsx(u,{onChange:s=>P(s,3),defaultValue:a.event_tag3_name})})}),e.jsx("div",{className:"centerArea",children:e.jsx(m,{className:"textarea",defaultValue:a.event_tag3_desc,autoSize:{minRows:1},onChange:s=>L(s,3)})}),e.jsx("div",{className:"right",children:e.jsx(b,{checkedChildren:"已预警",unCheckedChildren:"不预警",defaultValue:!!a.event_tag3_iswaring,onChange:s=>M(s,3)})})]})]})})]}),[]);r.useEffect(()=>{(async()=>{try{const s=await f("/api/Dict/GetDict_behavior_event",{type:"behavior",person_id:o.person_id}),i=await f("/api/Dict/GetDict_behavior_event",{type:"event",person_id:o.person_id});if(s.code===200){const n=[],c=[];s.data.lsrdict_behavior_event.map((C,y)=>{n.push({key:String(y),label:C.major_behavior_event,children:D(C.lssub_behavior_event_tag,y)}),c.push([])}),n.push({key:String(n.length),label:"我的标签",children:G(s.data.lspsy_behavior_tag[0])}),J(n),s.data.lspsy_behavior_tag[0]&&w(s.data.lspsy_behavior_tag[0])}if(i.code===200){const n=[],c=[];i.data.lsrdict_behavior_event.map((C,y)=>{n.push({key:String(y),label:C.major_behavior_event,children:F(C.lssub_behavior_event_tag,y)}),c.push([])}),n.push({key:String(n.length),label:"我的标签",children:O(i.data.lspsy_event_tag[0])}),ee(n),i.data.lspsy_event_tag[0]&&N(i.data.lspsy_event_tag[0])}const t=await f("/api/PsyBehaviorEvent/All",{person_id:o.person_id});t.code===200&&(q(t.data.items),t.data.items.length>0?j(t.data.items[0]):j(null))}catch(s){console.log(s)}})()},[o,D,F,G,O]);const pe=[{title:"序 号",dataIndex:"index",width:60,align:"center",render:(a,s,i)=>e.jsx(e.Fragment,{children:i+1})},{title:"预警",dataIndex:"behavior_iswaring",align:"center",width:60,key:"id",render:(a,s)=>e.jsx("span",{children:s.event_iswaring||s.behavior_iswaring?e.jsx(Ve,{style:{color:"red"}}):e.jsx(Be,{style:{color:"green"}})})},{title:"日期",dataIndex:"record_time",width:150,align:"center",render:a=>e.jsx("span",{children:H(a).format("YYYY-MM-DD HH:mm:ss")})},{title:"表现数",dataIndex:"behavior_name",align:"center",render:a=>e.jsx("span",{children:a===""?0:a.split(",").length})},{title:"事件数",dataIndex:"event_name",align:"center",render:a=>e.jsx("span",{children:a===""?0:a.split(",").length})},{title:"咨询师",dataIndex:"counsellor",align:"center"}],ue=a=>({onClick:()=>{console.log(a),ce(a.id)}}),fe=a=>a.id===le?(j(a),"table-tr-row-id"):"",be=()=>{E(!0)},je=async()=>{let a=0,s=0;x.includes(1)&&v.behavior_tag1_iswaring||x.includes(2)&&v.behavior_tag2_iswaring||x.includes(3)&&v.behavior_tag3_iswaring?a=1:a=0,g.event_tag1_iswaring&&p.includes(1)||g.event_tag2_iswaring&&p.includes(2)||g.event_tag3_iswaring&&p.includes(3)?s=1:s=0;let i="";B.forEach(c=>{i?i=i+","+c.name:i=c.name}),x.includes(1)&&(i?i=i+","+v.behavior_tag1_name:i=v.behavior_tag1_name),x.includes(2)&&(i?i=i+","+v.behavior_tag2_name:i=v.behavior_tag2_name),x.includes(3)&&(i?i=i+","+v.behavior_tag3_name:i=v.behavior_tag3_name);let t="";R.forEach(c=>{t?t=t+","+c.name:t=c.name}),p.includes(1)&&(t?t=t+","+g.event_tag1_name:t=g.event_tag1_name),p.includes(2)&&(t?t=t+","+g.event_tag2_name:t=g.event_tag2_name),p.includes(3)&&(t?t=t+","+g.event_tag3_name:t=g.event_tag3_name);const n={person_id:o.person_id,behavior_name:i,behavior_iswaring:a,event_name:t,behavior_remark:Q,event_iswaring:s,event_remark:X,archives_id:o.archives_id,counsellor_id:T.id,record_time:H().format("YYYY-MM-DD HH:mm:ss")};if(console.log(n,"selectEventTag",p,"selectBehaviorTag",x),!n.behavior_name&&!n.event_name){k.warning("异常表现或者生活事件最少选择一个选项");return}ae(!0);try{const c=await K("/api/PsyBehaviorEvent/addPsyBehaviorEvent",n);c.code===200?k.success(c.msg):k.error(c.msg),await K("/api/PsyBehaviorEvent/AddOrUpdatePsyBehaviorTag",{counsellor_id:T.id,person_id:o.person_id,...v}),await K("/api/PsyBehaviorEvent/AddOrUpdatePsyEventTag",{counsellor_id:T.id,person_id:o.person_id,...g}),we()}catch(c){k.error(c)}finally{ae(!1),E(!1)}},we=async()=>{try{const a=await f("/api/Dict/GetDict_behavior_event",{type:"behavior",person_id:o.person_id}),s=await f("/api/Dict/GetDict_behavior_event",{type:"event",person_id:o.person_id});if(a.code===200){const t=[];a.data.lsrdict_behavior_event.map((n,c)=>{t.push({key:String(c),label:n.major_behavior_event,children:D(n.lssub_behavior_event_tag)})}),t.push({key:String(t.length),label:"我的标签",children:G(a.data.lspsy_behavior_tag[0])}),J(t),w(a.data.lspsy_behavior_tag[0])}if(s.code===200){const t=[];s.data.lsrdict_behavior_event.map((n,c)=>{t.push({key:String(c),label:n.major_behavior_event,children:F(n.lssub_behavior_event_tag)})}),t.push({key:String(t.length),label:"我的标签",children:O(s.data.lspsy_event_tag[0])}),ee(t),N(s.data.lspsy_event_tag[0])}const i=await f("/api/PsyBehaviorEvent/All",{person_id:o.person_id});i.code===200&&(q(i.data.items),i.data.items.length>0?j(i.data.items[0]):j(null))}catch(a){console.log(a)}},Ne=a=>{let s="";return oe.forEach(i=>{i.Id===a&&(s=i.Name)}),s},Ce=()=>{V([]),W(""),A([]),Z(""),E(!1)};return e.jsxs(Ae,{theme:S,children:[e.jsxs("div",{className:"topCommonInfor",children:[e.jsxs("div",{className:"leftInput",children:[e.jsxs("div",{className:"item",children:[e.jsx("span",{className:"label",children:"个案编号: "}),e.jsx("span",{className:"value",children:o.archives_id})]}),e.jsxs("div",{className:"item",children:[e.jsx("span",{className:"label",children:"账号: "}),e.jsx("span",{className:"value",children:o.pNum})]}),e.jsxs("div",{className:"item",children:[e.jsx("span",{className:"label",children:"姓名: "}),e.jsx("span",{className:"value",children:o.pname})]}),e.jsxs("div",{className:"item",children:[e.jsx("span",{className:"label",children:"性别: "}),e.jsx("span",{className:"value",children:de[o.pSex]})]}),e.jsxs("div",{className:"item",children:[e.jsx("span",{className:"label",children:"所属机构: "}),e.jsx("span",{className:"value",children:Ne(o.orgid)})]}),e.jsxs("div",{className:"item",children:[e.jsx("span",{className:"label",children:"建档日期: "}),e.jsx("span",{className:"value",children:H(o.updatetime).format("YYYY-MM-DD")})]})]}),T.isAdmin===2&&e.jsx("div",{className:"rightBtn",children:e.jsx("div",{className:"btn",onClick:be,children:e.jsx(ie,{placement:"bottom",title:"添加咨询",children:e.jsx(Re,{})})})})]}),e.jsxs("div",{className:"Profilelist",children:[e.jsx("div",{className:"profileTable",children:U&&e.jsx(Ie,{columns:pe,rowKey:a=>a.id,dataSource:U,size:"small",sticky:!0,onRow:a=>ue(a),rowClassName:a=>fe(a),pagination:{total:0,showTotal:a=>`共 ${a} 条`}})}),e.jsx("div",{className:"profileDetail",children:e.jsxs(e.Fragment,{children:[h&&h.behavior_name?e.jsxs("div",{className:"items",children:[e.jsx("div",{className:"profileLabel",children:"异常表现:"}),e.jsxs("div",{className:"profileValue",children:[h.behavior_name&&h.behavior_name.split(",").map((a,s)=>{if(a)return e.jsxs("span",{children:[e.jsx("i",{}),a]},s)}),e.jsx("p",{className:"remark",children:h.behavior_remark})]})]}):null,h&&h.event_name?e.jsxs("div",{className:"items",children:[e.jsx("div",{className:"profileLabel",children:"生活事件:"}),e.jsxs("div",{className:"profileValue",children:[h.event_name&&h.event_name.split(",").map((a,s)=>{if(a)return e.jsxs("span",{children:[e.jsx("i",{}),a]},s)}),e.jsx("p",{className:"remark",children:h.event_remark})]})]}):null]})})]}),e.jsx(Te,{width:1e3,text:e.jsxs(e.Fragment,{children:[e.jsx(Ee,{})," 添加行为记录"]}),open:he,confirmLoading:xe,maskClosable:!1,destroyOnClose:!0,onOk:()=>je(),onCancel:()=>Ce(),children:e.jsxs(De,{theme:S,children:[e.jsxs("div",{className:"abnormal",children:[e.jsx("div",{className:"leftTitle",children:"异常表现"}),e.jsx("div",{className:"rightTabs",children:e.jsx(ne,{className:"tabsStyle",defaultActiveKey:"0",items:ve})})]}),e.jsx("div",{className:"abnormalSelect",children:B.map(a=>e.jsx("div",{className:"tag",children:a.name},a.id))}),e.jsxs("div",{className:"abnormalRemark",children:[e.jsx("div",{className:"leftTitle",children:"备注"}),e.jsx("div",{className:"rightTabs",children:e.jsx(m,{value:Q,onChange:({target:a})=>W(a.value)})})]}),e.jsxs("div",{className:"abnormal",children:[e.jsx("div",{className:"leftTitle",children:"生活事件"}),e.jsx("div",{className:"rightTabs",children:e.jsx(ne,{className:"tabsStyle",defaultActiveKey:"0",items:me})})]}),e.jsx("div",{className:"abnormalSelect",children:R.map(a=>e.jsx("div",{className:"tag",children:a.name},a.id))}),e.jsxs("div",{className:"abnormalRemark",children:[e.jsx("div",{className:"leftTitle",children:"备注"}),e.jsx("div",{className:"rightTabs",children:e.jsx(m,{value:X,onChange:({target:a})=>Z(a.value)})})]})]})})]})});Fe.displayName="BehavioralRecords";export{Fe as default};
