isDeleted 수정중

This commit is contained in:
kimdaae328 2025-02-28 14:31:36 +09:00
parent 86a6e5b27b
commit e63f9498bd
3 changed files with 35 additions and 1 deletions

View File

@ -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);

View File

@ -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: ''

View File

@ -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("댓글 삭제에 실패했습니다.");
}