하관우 하관우 04-04
2025-04-04 하관우 회원 및 카테고리 수정정
@b4f252b677e0704ce224e2c5aa8f990b06006666
client/views/pages/ctgry/CategoryManagement.vue
--- client/views/pages/ctgry/CategoryManagement.vue
+++ client/views/pages/ctgry/CategoryManagement.vue
@@ -233,7 +233,7 @@
                         try {
                             const response = await saveCategory(this.selectedCategory);
                             if (response.status === 200) {
-                                alert("등록되었습니다..");
+                                alert("등록되었습니다.");
                                 this.searchCategories();
                             }
                         } catch (error) {
@@ -249,7 +249,7 @@
                             try {
                                 const response = await updateCategory(this.ctgryId, this.copySelectedCategory);
                                 if (response.status === 200) {
-                                    alert("수정되었습니다..");
+                                    alert("수정되었습니다.");
                                     this.searchCategories();
                                 }
                             } catch (error) {
@@ -262,7 +262,7 @@
                             try {
                                 const response = await updateCategory(this.ctgryId, this.copySelectedCategory);
                                 if (response.status === 200) {
-                                    alert("수정되었습니다..");
+                                    alert("수정되었습니다.");
                                     this.searchCategories();
                                 }
                             } catch (error) {
@@ -280,7 +280,7 @@
         toggleUseAt() {
             this.selectedCategory.useAt = this.selectedCategory.useAt === 'Y' ? 'N' : 'Y';
         },
-        //취소소
+        //취소
         cancelCategory() {
             if (confirm("초기값으로 변경하시겠습니까?")) {
                 if (this.ctgryId === null || this.ctgryId === "") {
client/views/pages/member/MemberManagement.vue
--- client/views/pages/member/MemberManagement.vue
+++ client/views/pages/member/MemberManagement.vue
@@ -61,13 +61,14 @@
                         class="button green-line" @click="updateByUseAtUser">복구</div>
                     <div v-if="copySelectedUser.useAt === 'Y' && isNewInsert && userId != null" class="button red-line"
                         @click="updateByUseAtUser">회원탈퇴</div>
-                    <div class="button gray-line" @click="restPassword">비밀번호 초기화</div>
-                    <div class="button pink-line-bg flex align-center" @click="resetUser"><img :src="check_pink" alt="">
+                    <div v-if="newInsertCheck" class="button gray-line" @click="restPassword">비밀번호 초기화</div>
+                    <div v-if="newInsertCheck" class="button pink-line-bg flex align-center" @click="resetUser"><img
+                            :src="check_pink" alt="">
                         <p>신규등록</p>
                     </div>
                     <div class="button blue-line-bg flex align-center" @click="insertByUpdateUser"><img
                             :src="check_blue" alt="">
-                        <p>등록</p>
+                        {{ newInsertCheck ? "수정" : "등록" }}
                     </div>
                     <div class="button gray-bg" @click="cancelUser">취소</div>
                 </div>
@@ -117,7 +118,8 @@
                             <label for="use" class="require">사용여부</label>
                             <div class="switch">
                                 <input type="checkbox" id="switch" :checked="selectedUser.useAt === 'Y'"
-                                    @change="toggleUseAt" :disabled="!isNewInsert || (this.userId !== null || this.userId !== '')" />
+                                    @change="toggleUseAt"
+                                    :disabled="!isNewInsert || (this.userId !== null || this.userId !== '')" />
                                 <label for="switch">Toggle</label>
                             </div>
                         </dd>
@@ -149,6 +151,7 @@
             check_blue: 'client/resources/images/checkbox_blue.png',
             searchicon: 'client/resources/images/icon/search.png',
             selectedUsers: [],
+            newInsertCheck: false,
             //사용자 로그인 아이다
             loginId: null,
             //사용자 아이디
@@ -202,23 +205,25 @@
     },
     methods: {
         cancelUser() {
-            if (this.userId === null || this.userId === "") {
-                this.loginId = null;
-                this.password = null;
-                this.passwordCheck = null;
-                this.selectedUser = {
-                    userNm: null,
-                    useAt: "Y",
-                    authorUpdateCheck: false,
-                    authorList: [{ authorCode: "ROLE_ADMIN" }]
-                };
-            } else {
-                this.selectedUser = {
-                    userNm: this.copySelectedUser.userNm,
-                    useAt: this.copySelectedUser.useAt,
-                    authorUpdateCheck: false,
-                    authorList: [{ authorCode: this.copySelectedUser.authorList[0].authorCode }] // 배열 형태로 설정
-                };
+            if (confirm("초기값으로 변경하시겠습니까?")) {
+                if (this.userId === null || this.userId === "") {
+                    this.loginId = null;
+                    this.password = null;
+                    this.passwordCheck = null;
+                    this.selectedUser = {
+                        userNm: null,
+                        useAt: "Y",
+                        authorUpdateCheck: false,
+                        authorList: [{ authorCode: "ROLE_ADMIN" }]
+                    };
+                } else {
+                    this.selectedUser = {
+                        userNm: this.copySelectedUser.userNm,
+                        useAt: this.copySelectedUser.useAt,
+                        authorUpdateCheck: false,
+                        authorList: [{ authorCode: this.copySelectedUser.authorList[0].authorCode }] // 배열 형태로 설정
+                    };
+                }
             }
         },
         //등록 함수
@@ -237,7 +242,7 @@
                         try {
                             const response = await join(this.joinDTO);
                             if (response.status === 200) {
-                                alert("회원가입되었습니다..");
+                                alert("회원가입되었습니다.");
                                 this.searchUsers();
 
                             }
@@ -246,47 +251,50 @@
                             this.searchUsers();
                         }
                     }
+                } else {
+                    // 권한이 변경되었는지 확인
+                    const isAuthorChanged = this.copySelectedUser.authorList[0].authorCode !== this.selectedUser.authorList[0].authorCode;
+                    if (isAuthorChanged) {
+                        this.selectedUser.authorUpdateCheck = true; // 권한 변경 체크
+                        if (confirm("회원 수정을 하시겠습니까?")) {
+                            try {
+                                const response = await updateUsers(this.userId, this.selectedUser);
+                                if (response.status === 200) {
+                                    alert("수정되었습니다.");
+                                    this.searchUsers();
+                                }
+                            } catch (error) {
+                                alert("수정이 실패하였습니다.");
+                                this.searchUsers();
+                            }
+                        }
+                    } else {
+                        // 권한이 변경되지 않았다면 기존 수정 로직 실행
+                        if (confirm("회원 수정을 하시겠습니까?")) {
+                            try {
+                                const response = await updateUsers(this.userId, this.selectedUser);
+                                if (response.status === 200) {
+                                    alert("수정되었습니다.");
+                                    this.searchUsers();
+                                }
+                            } catch (error) {
+                                alert("수정이 실패하였습니다.");
+                                this.searchUsers();
+                            }
+                        }
+                    }
                 }
             } else {
-                // 권한이 변경되었는지 확인
-                console.log("복사", this.copySelectedUser.authorList[0].authorCode);
-                console.log("본체", this.selectedUser.authorList[0].authorCode);
-                const isAuthorChanged = this.copySelectedUser.authorList[0].authorCode !== this.selectedUser.authorList[0].authorCode;
-                console.log("권한이 같은지 다른지 ", isAuthorChanged);
-                if (isAuthorChanged) {
-                    this.selectedUser.authorUpdateCheck = true; // 권한 변경 체크
-                    if (confirm("회원 수정을 하시겠습니까?")) {
-                        try {
-                            const response = await updateUsers(this.userId, this.selectedUser);
-                            if (response.status === 200) {
-                                alert("수정되었습니다..");
-                                this.searchUsers();
-                            }
-                        } catch (error) {
-                            alert("수정이 실패하였습니다.");
-                            this.searchUsers();
-                        }
-                    }
-                } else {
-                    // 권한이 변경되지 않았다면 기존 수정 로직 실행
-                    if (confirm("회원 수정을 하시겠습니까?")) {
-                        try {
-                            const response = await updateUsers(this.userId, this.selectedUser);
-                            if (response.status === 200) {
-                                alert("수정되었습니다..");
-                                this.searchUsers();
-                            }
-                        } catch (error) {
-                            alert("수정이 실패하였습니다.");
-                            this.searchUsers();
-                        }
-                    }
-                }
+                alert("필수 항목 값을 입력해주세요");
             }
         },
         //사용자 벨류데이션 체크
         isValidationUser() {
-            return this.selectedUser.userNm == null || this.selectedUser.userNm == '' || this.loginId == null || this.loginId == '' || this.password == null || this.password == '';
+            if(this.newInsertCheck){
+                return this.selectedUser.userNm == null || this.selectedUser.userNm == '' || this.loginId == null || this.loginId == '';   
+            }else{
+                return this.selectedUser.userNm == null || this.selectedUser.userNm == '' || this.loginId == null || this.loginId == '' || this.password == null || this.password == '';   
+            }
         },
         validatePassword() {
             // 빈 문자열이나 null 체크
@@ -313,7 +321,8 @@
         },
         // 선택한 사용자
         selectUser(item) {
-            this.isNewInsert = true;
+            this.newInsertCheck = true,
+                this.isNewInsert = true;
 
             this.loginId = item.loginId;
             this.userId = item.userId;
@@ -338,9 +347,10 @@
         // 삭제 또는 복구 로직
         async updateByUseAtUser() {
             if (this.selectedUser.useAt === 'Y') {
-                this.selectedUser.useAt = 'N'
                 if (confirm("선택한 사용자를 탈퇴 하시겠습니까?")) {
                     try {
+                        this.selectedUser.useAt = 'N'
+                        this.copySelectedCategory = 'N'
                         const response = await updateUsers(this.userId, this.selectedUser);
                         if (response.status === 200) {
                             alert("탈퇴되었습니다..");
@@ -354,9 +364,10 @@
                     }
                 }
             } else {
-                this.selectedUser.useAt = 'Y'
                 if (confirm("선택한 사용자를 복구 하시겠습니까?")) {
                     try {
+                        this.selectedUser.useAt = 'Y'
+                        this.copySelectedCategory = 'Y'
                         const response = await updateUsers(this.userId, this.selectedUser);
                         if (response.status === 200) {
                             alert("복구되었습니다..");
@@ -393,6 +404,7 @@
         },
         // 사용자 초기화
         resetUser() {
+            this.newInsertCheck = false;
             this.isNewInsert = false;
 
             this.loginId = null;
@@ -422,6 +434,7 @@
     },
     mounted() {
         this.searchUsers(); // 컴포넌트가 마운트될 때 사용자 목록을 조회
+        this.resetUser();
     }
 };
 </script>
Add a comment
List