박정하 박정하 2023-07-11
230711 박정하 대상자 관리 수정
@c09cd0d4bb6fa64b6b7c2f13f36d629c694da01b
client/views/pages/senior_management/SeniorEdit.jsx
--- client/views/pages/senior_management/SeniorEdit.jsx
+++ client/views/pages/senior_management/SeniorEdit.jsx
@@ -318,7 +318,7 @@
             <tr>
               <th><span style={{ color: "red" }}>*</span>관리기관</th>
               <td>
-                <select onChange={(e) => { seniorGovernmentIdChange(e.target.value) }}
+                <select disabled 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) => {
@@ -332,7 +332,7 @@
               </td>
               <th><span style={{ color: "red" }}>*</span>시행기관</th>
               <td>
-                <select onChange={(e) => { seniorAgencyIdChange(e.target.value) }}
+                <select disabled 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) => {
client/views/pages/senior_management/SeniorSelectOne.jsx
--- client/views/pages/senior_management/SeniorSelectOne.jsx
+++ client/views/pages/senior_management/SeniorSelectOne.jsx
@@ -135,6 +135,8 @@
     });
   };
 
+  const [isRental, setIsRental] = React.useState("false");
+
   //대상자 장비 목록
   const [equipmentBySenior, setEquipmentBySenior] = React.useState([]);
   //대상자 장비 목록 조회
@@ -148,6 +150,21 @@
     }).then((response) => response.json()).then((data) => {
       console.log('equipmentRentalList response : ', data);
       setEquipmentBySenior(data);
+
+      let count = 0;
+      data.map((item, idx) => {
+        console.log("item: ", item)
+        if (CommonUtil.isEmpty(item['rental_start_date']) == false && CommonUtil.isEmpty(item['rental_end_date'])) {
+          count++;
+        }
+      })
+      console.log("count: ", count)
+      if (count > 0) {
+        setIsRental(true);
+      } else {
+        setIsRental(false);
+      }
+      console.log("isRental", isRental);
     }).catch((error) => {
       console.log('equipmentRentalList error : ', error);
     });
@@ -202,7 +219,6 @@
     }).then((response) => response.json()).then((data) => {
       console.log('deliveryEquipmentSelectList response : ', data);
       setDeliveryEquipment(data);
-      rentalCheck();
     }).catch((error) => {
       console.log('deliveryEquipmentSelectList error : ', error);
     });
@@ -435,25 +451,6 @@
       });
     } else {
       return;
-    }
-  }
-
-  const [isRental, setIsRental] = React.useState("false");
-  const rentalCheck = () => {
-    let count = 0;
-
-    equipmentBySenior.map((item, idx) => {
-      if (CommonUtil.isEmpty(item['rental_start_date']) == false && CommonUtil.isEmpty(item['rental_end_date']) == true) {
-        count++;
-      } else {
-        return
-      }
-    })
-
-    if (count > 0) {
-      setIsRental(true);
-    } else {
-      setIsRental(false);
     }
   }
 
client/views/pages/user_management/AgentSelectOne.jsx
--- client/views/pages/user_management/AgentSelectOne.jsx
+++ client/views/pages/user_management/AgentSelectOne.jsx
@@ -203,58 +203,63 @@
           </div>
         </div>
 
-        <SubTitle explanation={"생활보호사의 보호대상자"} className="margin-bottom display-inline-block" />
-        <button className={"btn-small gray-btn display-inline-block float-right"} onClick={() => modalSeniorInsertOpen()}>보호대상자 추가</button>
-        <div className="margin-bottom5">
-          <table className={"agent-user"}>
-            <thead>
-              <tr>
-                <th>No</th>
-                {/* <th>관리기관명</th>
+        {agent['authority'] == 'ROLE_AGENCYADMIN' ? (
+          <>
+            <SubTitle explanation={"생활보호사의 보호대상자"} className="margin-bottom display-inline-block" />
+            <button className={"btn-small gray-btn display-inline-block float-right"} onClick={() => modalSeniorInsertOpen()}>보호대상자 추가</button>
+            <div className="margin-bottom5">
+              <table className={"agent-user"}>
+                <thead>
+                  <tr>
+                    <th>No</th>
+                    {/* <th>관리기관명</th>
                 <th>소속기관명</th> */}
-                <th>이름</th>
-                <th>연락처</th>
-                <th>생년월일</th>
-                <th>성별</th>
-                <th>상태</th>
-                <th>배정시작일</th>
-                <th>배정종료일</th>
-                <th>상세보기</th>
-              </tr>
-            </thead>
-            <tbody>
-              {seniorByAgent.seniorListByAgent.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_birth']}</td>
-                    <td>{item['user_gender']}</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_state'] ?
-                        <button className={"btn-small red-btn"} onClick={() => { agentSeniorDelete(item) }}>케어종료</button>
-                        : item['agent_match_end_date']
-                      }
-                    </td>
-                    <td>
-                      <button className={"btn-small lightgray-btn"} onClick={() => { navigate("/SeniorSelectOne", { state: { 'senior_id': item['user_id'] } }) }}>상세 페이지 이동</button>
-                    </td>
+                    <th>이름</th>
+                    <th>연락처</th>
+                    <th>생년월일</th>
+                    <th>성별</th>
+                    <th>상태</th>
+                    <th>배정시작일</th>
+                    <th>배정종료일</th>
+                    <th>상세보기</th>
                   </tr>
-                )
-              })}
-              {seniorByAgent.seniorListByAgent == null || seniorByAgent.seniorListByAgent.length == 0 ?
-                <tr>
-                  <td colSpan={9}>조회된 데이터가 없습니다</td>
-                </tr>
-                : null}
-            </tbody>
-          </table>
-        </div>
+                </thead>
+                <tbody>
+                  {seniorByAgent.seniorListByAgent.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_birth']}</td>
+                        <td>{item['user_gender']}</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_state'] ?
+                            <button className={"btn-small red-btn"} onClick={() => { agentSeniorDelete(item) }}>케어종료</button>
+                            : item['agent_match_end_date']
+                          }
+                        </td>
+                        <td>
+                          <button className={"btn-small lightgray-btn"} onClick={() => { navigate("/SeniorSelectOne", { state: { 'senior_id': item['user_id'] } }) }}>상세 페이지 이동</button>
+                        </td>
+                      </tr>
+                    )
+                  })}
+                  {seniorByAgent.seniorListByAgent == null || seniorByAgent.seniorListByAgent.length == 0 ?
+                    <tr>
+                      <td colSpan={9}>조회된 데이터가 없습니다</td>
+                    </tr>
+                    : null}
+                </tbody>
+              </table>
+            </div>
+          </>
+        ) : null
+        }
 
         <div className="btn-wrap flex-center">
           <button className={"btn-large gray-btn"} onClick={() => navigate(-1)}>이전</button>
client/views/pages/user_management/UserEdit.jsx
--- client/views/pages/user_management/UserEdit.jsx
+++ client/views/pages/user_management/UserEdit.jsx
@@ -10,7 +10,7 @@
 
   /**** 기본 조회 데이터 (시작) ****/
   //전역 변수 저장 객체
-  const state = useSelector((state) => {return state});
+  const state = useSelector((state) => { return state });
   const defaultGovernmentId = CommonUtil.isEmpty(state.loginUser) ? null : state.loginUser['government_id'];
 
   //권한 타입 종류
@@ -39,7 +39,7 @@
       headers: {
         'Content-Type': 'application/json; charset=UTF-8'
       },
-      body: JSON.stringify({'government_id': defaultGovernmentId}),
+      body: JSON.stringify({ 'government_id': defaultGovernmentId }),
     }).then((response) => response.json()).then((data) => {
       console.log("기관(관리, 시행) 계층 구조 목록 조회 : ", data);
       setOrgListOfHierarchy(data);
@@ -131,7 +131,7 @@
       alert("아이디를 입력해 주세요.");
       return;
     }
-    
+
     fetch("/user/userSelectOne.json", {
       method: "POST",
       headers: {
@@ -155,10 +155,10 @@
   }
 
 
-   //사용자 등록 유효성 검사
-   const userUpdateValidation = () => {
+  //사용자 등록 유효성 검사
+  const userUpdateValidation = () => {
     if ((user['authority'] == 'ROLE_GOVERNMENT' || user['authority'] == 'ROLE_AGENCY')
-        && CommonUtil.isEmpty(user['government_id']) == true) {
+      && CommonUtil.isEmpty(user['government_id']) == true) {
       userRef.current['government_id'].focus();
       alert("관리기관을 선택해 주세요.");
       return false;
@@ -185,7 +185,7 @@
       return false;
     }
     if (CommonUtil.isEmpty(user['user_password']) == false
-        && user['user_password'] != user['user_password_check']) {
+      && user['user_password'] != user['user_password_check']) {
       userRef.current['user_password_check'].focus();
       alert("비밀번호가 일치하지 않습니다.");
       return false;
@@ -229,135 +229,139 @@
       console.log('userUpdate() /user/userUpdate.json error : ', error);
     });
   }
-  
+
   //Mounted
   React.useEffect(() => {
     authoritiesSelect();
     orgSelectListOfHierarchy();
     userSelectOne();
   }, []);
-  
+
 
   return (
-      <div className="container row flex-center join-login">
-        <div className="join-group">
-          <h3>계정수정</h3>
-          <div className="join-inner">
+    <div className="container row flex-center join-login">
+      <div className="join-group">
+        <h3>계정수정</h3>
+        <div className="join-inner">
+          <div>
+            <div className="flex-start margin-bottom2">
+              <label className="flex25"><span style={{ color: "red" }}>*</span>사용자구분</label>
+              {authorities[user['authority']]}
+            </div>
+          </div>
+
+          {user['authority'] == 'ROLE_GOVERNMENT' || user['authority'] == 'ROLE_AGENCY' ?
             <div>
               <div className="flex-start margin-bottom2">
-                <label className="flex25"><span style={{color : "red"}}>*</span>사용자구분</label>
-                {authorities[user['authority']]}
-              </div>
-            </div>
-
-            {user['authority'] == 'ROLE_GOVERNMENT' || user['authority'] == 'ROLE_AGENCY' ?
-              <div>
-                <div className="flex-start margin-bottom2">
-                  <label className="flex25" htmlFor="name"><span style={{color : "red"}}>*</span>관리기관</label>
-                  <select onChange={(e) => {userGovernmentIdChange(e.target.value)}} ref={el => userRef.current['government_id'] = el}>
-                    <option value={''} selected={user['government_id'] == null}>관리기관선택</option>
-                    {orgListOfHierarchy.map((item, idx) => { return (
+                <label className="flex25" htmlFor="name"><span style={{ color: "red" }}>*</span>관리기관</label>
+                <select disabled onChange={(e) => { userGovernmentIdChange(e.target.value) }} ref={el => userRef.current['government_id'] = el}>
+                  <option value={''} selected={user['government_id'] == null}>관리기관선택</option>
+                  {orgListOfHierarchy.map((item, idx) => {
+                    return (
                       <option key={idx} value={item['government_id']} selected={user['government_id'] == item['government_id']}>
                         {item['government_name']}
                       </option>
-                    )})}
-                  </select>
-                </div>
+                    )
+                  })}
+                </select>
               </div>
+            </div>
             : null}
 
-            {user['authority'] == 'ROLE_AGENCY' ?
-              <div>
-                <div className="flex-start margin-bottom2">
-                  <label className="flex25" htmlFor="name"><span style={{color : "red"}}>*</span>시행기관</label>
-                  <select onChange={(e) => {userAgencyIdChange(e.target.value)}} ref={el => userRef.current['agency_id'] = el}>
-                    <option value={''} selected={user['agency_id'] == null}>시행기관선택</option>
-                    {getAgencyList().map((item, idx) => { return (
+          {user['authority'] == 'ROLE_AGENCY' ?
+            <div>
+              <div className="flex-start margin-bottom2">
+                <label className="flex25" htmlFor="name"><span style={{ color: "red" }}>*</span>시행기관</label>
+                <select disabled onChange={(e) => { userAgencyIdChange(e.target.value) }} ref={el => userRef.current['agency_id'] = el}>
+                  <option value={''} selected={user['agency_id'] == null}>시행기관선택</option>
+                  {getAgencyList().map((item, idx) => {
+                    return (
                       <option key={idx} value={item['agency_id']} selected={user['agency_id'] == item['agency_id']}>
                         {item['agency_name']}
                       </option>
-                    )})}
-                  </select>
-                </div>
+                    )
+                  })}
+                </select>
               </div>
+            </div>
             : null}
 
-            <div>
-              <div className="flex-start margin-bottom2">
-                <label className="flex25" htmlFor="name"><span style={{color : "red"}}>*</span>이름</label>
-                <input type="text"
-                  value={user['user_name']}
-                  onChange={(e) => {userValueChange('user_name', e.target.value)}}
-                  ref={el => userRef.current['user_name'] = el}
-                />
-              </div>
+          <div>
+            <div className="flex-start margin-bottom2">
+              <label className="flex25" htmlFor="name"><span style={{ color: "red" }}>*</span>이름</label>
+              <input type="text"
+                value={user['user_name']}
+                onChange={(e) => { userValueChange('user_name', e.target.value) }}
+                ref={el => userRef.current['user_name'] = el}
+              />
             </div>
-
-            <div className="id">
-              <div className="flex-start margin-bottom2">
-                <label className="flex25" htmlFor="id"><span style={{color : "red"}}>*</span>아이디</label>
-                <input type="text"
-                  value={user['user_id']}
-                  onChange={(e) => {userValueChange('user_id', e.target.value); setIsIdCheck(false)}}
-                  ref={el => userRef.current['user_id'] = el}
-                />
-                <button className={"red-btn btn-large"} onClick={userIdCheck}
-                  ref={el => userRef.current['user_id_check_button'] = el}>
-                  중복확인
-                </button>
-              </div>
-            </div>
-
-            <div>
-              <div className="flex-start margin-bottom2">
-                <label className="flex25" htmlFor="password"><span style={{color : "red"}}>*</span>비밀번호</label>
-                <input type="password"
-                  value={user['user_password']}
-                  onChange={(e) => {userValueChange('user_password', e.target.value)}}
-                  ref={el => userRef.current['user_password'] = el}
-                />
-              </div>
-            </div>
-            <div>
-              <div className="flex-start margin-bottom2">
-                <label className="flex25" htmlFor="password_check"><span style={{color : "red"}}>*</span>비밀번호 확인</label>
-                <input type="password"
-                  value={user['user_password_check']}
-                  onChange={(e) => {userValueChange('user_password_check', e.target.value)}}
-                  ref={el => userRef.current['user_password_check'] = el}
-                />
-              </div>
-            </div>
-
-            <div>
-              <div className="flex margin-bottom2">
-                <label className="flex25" htmlFor="phone_number"><span style={{color : "red"}}>*</span>전화번호</label>
-                <input type="number" maxLength="11"
-                  value={user['user_phonenumber']}
-                  onChange={(e) => {userValueChange('user_phonenumber', e.target.value)}}
-                  ref={el => userRef.current['user_phonenumber'] = el}
-                />
-              </div>
-            </div>
-
-            <div>
-              <div className="flex-start margin-bottom2">
-                <label className="flex25" htmlFor="password_check">이메일</label>
-                <input type="text"
-                  value={user['user_email']}
-                  onChange={(e) => {userValueChange('user_email', e.target.value)}}
-                  ref={el => userRef.current['user_email'] = el}
-                />
-              </div>
-            </div>
-
-            <div className="btn-wrap">
-              <button className={"gray-btn btn-large"} onClick={() => {navigate(-1)}}>취소</button>
-              <button className={"red-btn btn-large"} onClick={userUpdate}>수정</button>
-            </div>
-
           </div>
+
+          <div className="id">
+            <div className="flex-start margin-bottom2">
+              <label className="flex25" htmlFor="id"><span style={{ color: "red" }}>*</span>아이디</label>
+              <input type="text"
+                value={user['user_id']}
+                onChange={(e) => { userValueChange('user_id', e.target.value); setIsIdCheck(false) }}
+                ref={el => userRef.current['user_id'] = el}
+              />
+              <button className={"red-btn btn-large"} onClick={userIdCheck}
+                ref={el => userRef.current['user_id_check_button'] = el}>
+                중복확인
+              </button>
+            </div>
+          </div>
+
+          <div>
+            <div className="flex-start margin-bottom2">
+              <label className="flex25" htmlFor="password"><span style={{ color: "red" }}>*</span>비밀번호</label>
+              <input type="password"
+                value={user['user_password']}
+                onChange={(e) => { userValueChange('user_password', e.target.value) }}
+                ref={el => userRef.current['user_password'] = el}
+              />
+            </div>
+          </div>
+          <div>
+            <div className="flex-start margin-bottom2">
+              <label className="flex25" htmlFor="password_check"><span style={{ color: "red" }}>*</span>비밀번호 확인</label>
+              <input type="password"
+                value={user['user_password_check']}
+                onChange={(e) => { userValueChange('user_password_check', e.target.value) }}
+                ref={el => userRef.current['user_password_check'] = el}
+              />
+            </div>
+          </div>
+
+          <div>
+            <div className="flex margin-bottom2">
+              <label className="flex25" htmlFor="phone_number"><span style={{ color: "red" }}>*</span>전화번호</label>
+              <input type="number" maxLength="11"
+                value={user['user_phonenumber']}
+                onChange={(e) => { userValueChange('user_phonenumber', e.target.value) }}
+                ref={el => userRef.current['user_phonenumber'] = el}
+              />
+            </div>
+          </div>
+
+          <div>
+            <div className="flex-start margin-bottom2">
+              <label className="flex25" htmlFor="password_check">이메일</label>
+              <input type="text"
+                value={user['user_email']}
+                onChange={(e) => { userValueChange('user_email', e.target.value) }}
+                ref={el => userRef.current['user_email'] = el}
+              />
+            </div>
+          </div>
+
+          <div className="btn-wrap">
+            <button className={"gray-btn btn-large"} onClick={() => { navigate(-1) }}>취소</button>
+            <button className={"red-btn btn-large"} onClick={userUpdate}>수정</button>
+          </div>
+
         </div>
       </div>
+    </div>
   );
 }
Add a comment
List