최정우 최정우 2023-04-04
230404 최정우 사용자 관리 커밋5
@b5d959af4339a8252beacf9e5541031444e15610
client/resources/css/common.css
--- client/resources/css/common.css
+++ client/resources/css/common.css
@@ -402,6 +402,29 @@
   margin-left: 1rem;
 }
 
+
+/* display */
+.display-inline-block {
+  display: inline-block;
+}
+.display-inline {
+  display: inline;
+}
+.display-block {
+  display: block;
+}
+.display-none {
+  display: none;
+}
+
+/* float */
+.float-left {
+  float: left;
+}
+.float-right {
+  float: right;
+}
+
 hr {
   border-top: 1px solid #d1e4e3;
   margin-top: 2rem
@@ -410,4 +433,6 @@
 /* 컬러 */
 .yellow{background: #f2db71;}
 .sky{background-color: #d1e4e3;}
+.grey{background-color: #8d8d8d;}
+.green{background-color: #219102;}
 
client/views/component/Modal_Guardian.jsx
--- client/views/component/Modal_Guardian.jsx
+++ client/views/component/Modal_Guardian.jsx
@@ -31,25 +31,25 @@
 
     'senior_id': seniorId,
     'senior_relationship': '자녀',
-    'senior_relationship_etc': '',
   };
 
-  //시니어 정보
+  //보호자 정보
   const [guardian, setGuardian] = React.useState(JSON.parse(JSON.stringify(guardianInit)));
 
   //각 데이터별로 Dom 정보 담을 Ref 생성
   const guardianRefInit = JSON.parse(JSON.stringify(guardian));
   guardianRefInit['user_gender'] = {};
+  guardianRefInit['senior_relationship_etc'] = null;
   const guardianRef = React.useRef(guardianRefInit);
 
-  //등록할 시니어 정보 변경
+  //등록할 보호자 정보 변경
   const guardianValueChange = (targetKey, value) => {
     let newGuardian = JSON.parse(JSON.stringify(guardian));
     newGuardian[targetKey] = value;
     setGuardian(newGuardian);
   }
 
-  //시니어 등록 유효성 검사
+  //보호자 등록 유효성 검사
   const guardianInsertValidation = () => {
     if (CommonUtil.isEmpty(guardian['user_name']) == true) {
       guardianRef.current['user_name'].focus();
@@ -77,14 +77,8 @@
       return false;
     }
     if (CommonUtil.isEmpty(guardian['senior_relationship']) == true) {
-      guardianRef.current['senior_relationship'].focus();
-      alert("대상자와의 관계를 선택해 주세요.");
-      return false;
-    }
-    
-    if (guardian['senior_relationship'] == '기타' && CommonUtil.isEmpty(guardian['senior_relationship_etc']) == true) {
       guardianRef.current['senior_relationship_etc'].focus();
-      alert("대상자와의 관계를 입력해 주세요.");
+      alert("대상자와의 관계를 입력 주세요.");
       return false;
     }
 
@@ -94,10 +88,6 @@
   const guardianInsert = () => {
     if (guardianInsertValidation() == false) {
       return;
-    }
-
-    if (guardian['senior_relationship'] == '기타') {
-      guardian['senior_relationship'] = guardian['senior_relationship_etc'];
     }
 
     fetch("/user/guardianInsert.json", {
@@ -119,7 +109,7 @@
     });
   }
 
-  //시니어 수정
+  //보호자 수정
   const guardianUpdate = () => {
     if (guardianInsertValidation() == false) {
       return;
@@ -183,7 +173,7 @@
       console.log('guardianBySenior : ', guardianBySenior);
       setGuardian(JSON.parse(JSON.stringify(guardianInit)));
     }
-  }, [guardianBySenior]);
+  }, [open]);
 
   return (
     <div class={open ? "openModal modal" : "modal"}>
@@ -265,12 +255,12 @@
                       {relationshipList.map((relationship, idx) => { return (
                         <option key={idx}>{relationship}</option>
                       )})}
-                      <option value="기타" selected={guardian['senior_relationship'] == '기타' || relationshipList.indexOf(guardian['senior_relationship']) == -1}>기타</option>
+                      <option value="" selected={relationshipList.indexOf(guardian['senior_relationship']) == -1}>기타</option>
                     </select>
-                    {guardian['senior_relationship'] == '기타' || relationshipList.indexOf(guardian['senior_relationship']) == -1 ? (
+                    {relationshipList.indexOf(guardian['senior_relationship']) == -1 ? (
                       <input type="text"
-                        value={guardian['senior_relationship_etc']}
-                        onChange={(e) => {guardianValueChange('senior_relationship_etc', e.target.value)}}
+                        value={guardian['senior_relationship']}
+                        onChange={(e) => {guardianValueChange('senior_relationship', e.target.value)}}
                         ref={el => guardianRef.current['senior_relationship_etc'] = el}
                       />
                     ) : null}
client/views/component/Modal_SeniorInsert.jsx
--- client/views/component/Modal_SeniorInsert.jsx
+++ client/views/component/Modal_SeniorInsert.jsx
@@ -140,6 +140,16 @@
 
   //시니어 등록 유효성 검사
   const seniorInsertValidation = () => {
+    if (CommonUtil.isEmpty(senior['government_id']) == true) {
+      seniorRef.current['government_id'].focus();
+      alert("관리기관을 선택해 주세요.");
+      return false;
+    }
+    if (CommonUtil.isEmpty(senior['agency_id']) == true) {
+      seniorRef.current['agency_id'].focus();
+      alert("시행기관을 선택해 주세요.");
+      return false;
+    }
     if (CommonUtil.isEmpty(senior['user_name']) == true) {
       seniorRef.current['user_name'].focus();
       alert("이름을 입력해 주세요.");
@@ -227,9 +237,10 @@
               <SubTitle explanation={"회원 등록 시 ID는 연락처, 패스워드는 생년월일 8자리입니다."} className="margin-bottom" />
               <table className="margin-bottom2 senior-insert">
                 <tr>
-                  <th>관리기관</th>
+                  <th><span style={{color : "red"}}>*</span>관리기관</th>
                   <td>
-                    <select onChange={(e) => {seniorGovernmentIdChange(e.target.value)}}>
+                    <select onChange={(e) => {seniorGovernmentIdChange(e.target.value)}}
+                      ref={el => seniorRef.current['government_id'] = el}>
                       <option value={''} selected={senior['government_id'] == null}>관리기관선택</option>
                       {orgListOfHierarchy.map((item, idx) => { return (
                         <option key={idx} value={item['government_id']} selected={senior['government_id'] == item['government_id']}>
@@ -238,9 +249,10 @@
                       )})}
                     </select>
                   </td>
-                  <th>시행기관</th>
+                  <th><span style={{color : "red"}}>*</span>시행기관</th>
                   <td>
-                    <select onChange={(e) => {seniorAgencyIdChange(e.target.value)}}>
+                    <select onChange={(e) => {seniorAgencyIdChange(e.target.value)}}
+                      ref={el => seniorRef.current['agency_id'] = el}>
                       <option value={''} selected={senior['agency_id'] == null}>시행기관선택</option>
                       {getAgencyList().map((item, idx) => { return (
                         <option key={idx} value={item['agency_id']} selected={senior['agency_id'] == item['agency_id']}>
client/views/pages/senior_management/SeniorSelectOne.jsx
--- client/views/pages/senior_management/SeniorSelectOne.jsx
+++ client/views/pages/senior_management/SeniorSelectOne.jsx
@@ -60,7 +60,7 @@
     'underlie_disease': null,
     'senior_note': null,
 
-    'seniorMedicationList': [],
+    'seniorMedicationList': []
   });
   //시니어 상세 조회
   const seniorSelectOne = () => {
@@ -78,8 +78,11 @@
     });
   };
 
-  //보호자 상세 조회
+  //대상자의 보호자 목록
   const [guardianListBySenior, setGuardianListBySenior] = React.useState([]);
+  //대상자의 선택한 보호자 정보
+  const [guardianBySenior, setGuardianBySenior] = React.useState({});
+  //대상자의 보호자 목록 조회
   const guardianSelectListBySenior = () => {
     fetch("/user/guardianSelectListBySenior.json", {
       method: "POST",
@@ -95,14 +98,31 @@
     });
   };
 
-  //선택한 보호자 정보
-  const [guardianBySenior, setGuardianBySenior] = React.useState({});
-
   //선택한 보호자 정보 관리
   const guardianBySeniorManagement = (item) => {
     setGuardianBySenior(item);
     modalGuardianOpen();
   }
+
+
+  //대상자의 보호사 목록
+  const [agent, setAgent] = React.useState({agentListBySenior: [], agentListCountBySenior: 0});
+  //대상자의 보호사 목록 조회
+  const agentSelectListBySenior = () => {
+    fetch("/user/agentSelectListBySenior.json", {
+      method: "POST",
+      headers: {
+        'Content-Type': 'application/json; charset=UTF-8'
+      },
+      body: JSON.stringify(senior),
+    }).then((response) => response.json()).then((data) => {
+      console.log("agentSelectListBySenior data : ", data);
+      setAgent(data);
+    }).catch((error) => {
+      console.log('agentSelectListBySenior() /user/agentSelectListBySenior.json error : ', error);
+    });
+  }
+
 
 
   //가입승인
@@ -132,6 +152,7 @@
     medicationTimeCodeSelectList();
     seniorSelectOne();
     guardianSelectListBySenior();
+    agentSelectListBySenior();
   }, [])
 
 
@@ -142,56 +163,74 @@
       guardianManagementCallback={() => {guardianSelectListBySenior(); modalGuardianClose(); setGuardianBySenior({})}}/>
     <div className="content-wrap row">
       <SubTitle explanation={"대상자 상세 프로필"} className="margin-bottom" />
-      <div>
+      <div className="margin-bottom5">
         <table className="margin-bottom senior-detail">
           <tbody>
-          <tr>
-              <th>아이디</th>
+            <tr>
+              <th>관리기관</th>
               <td>
-                <span>{senior['user_id']}</span>
+                <span>{senior['government_name']}</span>
               </td>             
             </tr>
+
             <tr>
-              <th>이름</th>
+              <th>시행기관</th>
               <td>
-                <span>{senior['user_name']}</span>
-              </td>
+                <span>{senior['agency_name']}</span>
+              </td>              
+            </tr>
+
+            <tr>
+              <th>이름(아이디)</th>
+              <td>
+                <span>{senior['user_name']}({senior['user_id']})</span>
+              </td>           
+            </tr>
+
+            <tr>
               <th>성별</th>
               <td>
                 <span>{senior['user_gender']}</span>
-              </td>              
+              </td>           
             </tr>
+            
             <tr>
-            <th>생년월일</th>
+              <th>생년월일</th>
               <td>
                 <span>{senior['user_birth']}</span>
               </td>
-              <th>연락처</th>
+            </tr>
+
+            <tr>
+              <th>생년월일</th>
               <td>
-                <span>{senior['user_phonenumber']}</span>
+                <span>{senior['user_birth']}</span>
               </td>
             </tr>
+
             <tr>
               <th>주소</th>
               <td>
                 <span>{senior['user_address']}</span>
-              </td>
-                            
+              </td>         
             </tr>
+            
             <tr>
-            <th>필요복약</th>
+              <th>필요복약</th>
               <td className="flex-start">
               {medicationTimeCodeList.filter(item => senior.seniorMedicationList.indexOf(item['medication_time_code']) > -1).map((item, idx) => { return (
                 <span>{item['medication_time_code_name']}</span>
               )})}
               </td>              
             </tr>
+
             <tr>
               <th>복용중인 약</th>
               <td colSpan={3}>
                 <span className="medicine" cols="30" rows="2">{senior['medication_pill']}</span>
               </td>
             </tr>
+            
             <tr>
               <th>비고</th>
               <td colSpan={3}>
@@ -202,13 +241,14 @@
         </table>
         <div className="btn-wrap flex-center">
           <button className={"btn-large gray-btn"} onClick={() => modalGuardianOpen()}>수정</button>
-          <button className={"btn-large green-btn"} onClick={() => {setGuardianBySenior({}); modalGuardianOpen()}}>보호자 추가</button>
+          
           <button className={"btn-large red-btn"} onClick={() => alert("삭제할 수 없습니다.")}>삭제</button>
         </div>
       </div>
 
-      <SubTitle explanation={"대상자의 보호자"} className="margin-bottom" />
-      <div>
+      <SubTitle explanation={"대상자의 보호자"} className="margin-bottom display-inline-block" />
+      <button className={"btn-small gray-btn display-inline-block float-right"} onClick={() => {setGuardianBySenior({}); modalGuardianOpen()}}>보호자 추가</button>
+      <div className="margin-bottom5">
         <table className={"protector-user"}>
           <thead>
             <tr>
@@ -218,8 +258,8 @@
               <th>연락처</th>
               <th>생년월일</th>
               <th>주소</th>
-              <th>관리</th>
               <th>가입승인</th>
+              <th>관리</th>
             </tr>
           </thead>
           <tbody>
@@ -237,7 +277,7 @@
                   }
                 </td>
                 <td>
-                  <button className={"btn-small lightgray-btn"} onClick={() => guardianBySeniorManagement(item)}>관리</button>
+                  <button className={"btn-small lightgray-btn"} onClick={() => guardianBySeniorManagement(item)}>정보 수정</button>
                 </td>
               </tr>
             )})}
@@ -250,6 +290,54 @@
         </table>
       </div>
 
+
+      <SubTitle explanation={"대상자의 보호사"} className="margin-bottom" />
+      <div className="margin-bottom5">
+        <table className={"senior-user"}>
+          <thead>
+            <tr>
+              <th>No</th>
+              <th>관리기관명</th>
+              <th>소속기관명</th>
+              <th>이름</th>
+              <th>연락처</th>
+              <th>이메일</th>
+              <th>상태</th>
+              <th>배정시작일</th>
+              <th>배정종료일</th>
+              <th>상세보기</th>
+            </tr>
+          </thead>
+          <tbody>
+            {agent.agentListBySenior.map((item, idx) => { return (
+              <tr key={idx}>
+                <td>{idx + 1}</td>
+                <td>{item['government_name']}</td>
+                <td>{item['agency_name']}</td>
+                <td>{item['user_name']}</td>
+                <td>{item['user_phonenumber']}</td>
+                <td>{item['user_email']}</td>
+                <td>{item['agent_match_state'] ? <span className="green">현재 보호사</span> : <span className="grey">이전 보호사</span>}</td>
+                <td>{item['agent_match_start_date']}</td>
+                <td>{item['agent_match_end_date']}</td>
+                <td>
+                  <button className={"btn-small lightgray-btn"} onClick={() => {}}>상세 페이지 이동</button>
+                </td>
+              </tr>
+            )})}
+            {agent.agentListBySenior == null || agent.agentListBySenior.length == 0 ?
+              <tr>
+                <td colSpan={10}>조회된 데이터가 없습니다</td>
+              </tr>
+            : null}
+          </tbody>
+        </table>
+      </div>
+
+      <div className="btn-wrap flex-center">
+        <button className={"btn-large gray-btn"} onClick={() => navigate(-1)}>이전</button>
+      </div>
+
     </div>
 
   </main>
client/views/pages/user_management/UserAuthoriySelect.jsx
--- client/views/pages/user_management/UserAuthoriySelect.jsx
+++ client/views/pages/user_management/UserAuthoriySelect.jsx
@@ -385,7 +385,7 @@
                 {/* 탭 제목 */}
                 <ul className="tab-menu flex-end" >
                   <li onClick={() => setTabActiveByRoleType('ROLE_SENIOR')} className={tabActiveByRoleType == 'ROLE_SENIOR' ? "active" : null}>대상자(어르신) ({senior.userListCount})</li>
-                  <li onClick={() => setTabActiveByRoleType('ROLE_AGENCY')} className={tabActiveByRoleType == 'ROLE_AGENCY' ? "active" : null}>담당자 ({agent.userListCount})</li>
+                  <li onClick={() => setTabActiveByRoleType('ROLE_AGENCY')} className={tabActiveByRoleType == 'ROLE_AGENCY' ? "active" : null}>보호사 ({agent.userListCount})</li>
                   <li onClick={() => setTabActiveByRoleType('ROLE_GOVERNMENT')} className={tabActiveByRoleType == 'ROLE_GOVERNMENT' ? "active" : null}>기관 관리자 ({government.userListCount})</li>
                   <li onClick={() => setTabActiveByRoleType('ROLE_ADMIN')} className={tabActiveByRoleType == 'ROLE_ADMIN' ? "active" : null}>시스템 관리자 ({admin.userListCount})</li>
                 </ul>
Add a comment
List