isDeleted 수정중
This commit is contained in:
parent
86a6e5b27b
commit
e63f9498bd
@ -37,6 +37,11 @@
|
||||
<SaveBtn class="btn btn-primary" @click="submitEdit"></SaveBtn>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else-if="comment.isDeleted">
|
||||
<p class="m-0 text-muted">댓글이 삭제되었습니다.</p>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<p class="m-0">{{ comment.content }}</p>
|
||||
</template>
|
||||
@ -109,6 +114,10 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isDeleted: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isCommentPassword: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
@ -154,7 +163,6 @@ const handleUpdateReaction = (reactionData) => {
|
||||
|
||||
// 비밀번호 확인
|
||||
const logPasswordAndEmit = () => {
|
||||
console.log('비밀번호 확인',props.password)
|
||||
emit('submitPassword', props.comment, props.password);
|
||||
};
|
||||
|
||||
@ -164,6 +172,13 @@ watch(() => props.comment.isEditTextarea, (newVal) => {
|
||||
}
|
||||
});
|
||||
|
||||
watch(() => props.comment.isDeleted, () => {
|
||||
if (newVal) {
|
||||
localEditedContent.value = "댓글이 삭제되었습니다."; // UI 반영
|
||||
props.comment.isEditTextarea = false;
|
||||
}
|
||||
});
|
||||
|
||||
// 수정버튼
|
||||
const submitEdit = () => {
|
||||
emit('submitEdit', props.comment, localEditedContent.value);
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
:comment="comment"
|
||||
:isCommentAuthor="comment.isCommentAuthor"
|
||||
:isEditTextarea="comment.isEditTextarea"
|
||||
:isDeleted="comment.isDeleted"
|
||||
:isCommentPassword="isCommentPassword"
|
||||
:passwordCommentAlert="passwordCommentAlert || ''"
|
||||
:currentPasswordCommentId="currentPasswordCommentId"
|
||||
@ -53,6 +54,10 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isDeleted: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
passwordCommentAlert: {
|
||||
type: String,
|
||||
default: ''
|
||||
|
||||
@ -102,6 +102,7 @@
|
||||
:comments="commentsWithAuthStatus"
|
||||
:isCommentPassword="isCommentPassword"
|
||||
:isEditTextarea="isEditTextarea"
|
||||
:isDeleted="isDeleted"
|
||||
:passwordCommentAlert="passwordCommentAlert"
|
||||
:currentPasswordCommentId="currentPasswordCommentId"
|
||||
:password="password"
|
||||
@ -183,6 +184,7 @@ const currentPasswordCommentId = ref(null);
|
||||
const lastClickedButton = ref("");
|
||||
const lastCommentClickedButton = ref("");
|
||||
const isEditTextarea = ref(false);
|
||||
const isDeleted = ref(true);
|
||||
const commentAlert = ref('');
|
||||
|
||||
const updatePassword = (newPassword) => {
|
||||
@ -671,6 +673,10 @@ const deletePost = async () => {
|
||||
const deleteReplyComment = async (comment) => {
|
||||
if (!confirm("정말 이 댓글을 삭제하시겠습니까?")) return;
|
||||
|
||||
const targetComment = findCommentById(comment.commentId, comments.value);
|
||||
|
||||
console.log('잘되니?',comment)
|
||||
|
||||
try {
|
||||
const response = await axios.delete(`board/comment/${comment.commentId}`, {
|
||||
data: { LOCCMTSEQ: comment.commentId }
|
||||
@ -678,6 +684,14 @@ const deleteReplyComment = async (comment) => {
|
||||
|
||||
if (response.data.code === 200) {
|
||||
await fetchComments();
|
||||
|
||||
if (targetComment) {
|
||||
console.log('타겟',targetComment)
|
||||
// ✅ 댓글 내용만 "삭제된 댓글입니다."로 변경하고, 구조는 유지
|
||||
targetComment.content = "댓글이 삭제되었습니다.";
|
||||
targetComment.author = "알 수 없음"; // 익명 처리
|
||||
targetComment.isDeleted = true; // ✅ 삭제 상태를 추가
|
||||
}
|
||||
} else {
|
||||
alert("댓글 삭제에 실패했습니다.");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user