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> <SaveBtn class="btn btn-primary" @click="submitEdit"></SaveBtn>
</div> </div>
</template> </template>
<template v-else-if="comment.isDeleted">
<p class="m-0 text-muted">댓글이 삭제되었습니다.</p>
</template>
<template v-else> <template v-else>
<p class="m-0">{{ comment.content }}</p> <p class="m-0">{{ comment.content }}</p>
</template> </template>
@ -109,6 +114,10 @@ const props = defineProps({
type: Boolean, type: Boolean,
default: false default: false
}, },
isDeleted: {
type: Boolean,
default: false
},
isCommentPassword: { isCommentPassword: {
type: Boolean, type: Boolean,
default: false, default: false,
@ -154,7 +163,6 @@ const handleUpdateReaction = (reactionData) => {
// //
const logPasswordAndEmit = () => { const logPasswordAndEmit = () => {
console.log('비밀번호 확인',props.password)
emit('submitPassword', props.comment, 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 = () => { const submitEdit = () => {
emit('submitEdit', props.comment, localEditedContent.value); emit('submitEdit', props.comment, localEditedContent.value);

View File

@ -10,6 +10,7 @@
:comment="comment" :comment="comment"
:isCommentAuthor="comment.isCommentAuthor" :isCommentAuthor="comment.isCommentAuthor"
:isEditTextarea="comment.isEditTextarea" :isEditTextarea="comment.isEditTextarea"
:isDeleted="comment.isDeleted"
:isCommentPassword="isCommentPassword" :isCommentPassword="isCommentPassword"
:passwordCommentAlert="passwordCommentAlert || ''" :passwordCommentAlert="passwordCommentAlert || ''"
:currentPasswordCommentId="currentPasswordCommentId" :currentPasswordCommentId="currentPasswordCommentId"
@ -53,6 +54,10 @@ const props = defineProps({
type: Boolean, type: Boolean,
default: false, default: false,
}, },
isDeleted: {
type: Boolean,
default: false,
},
passwordCommentAlert: { passwordCommentAlert: {
type: String, type: String,
default: '' default: ''

View File

@ -102,6 +102,7 @@
:comments="commentsWithAuthStatus" :comments="commentsWithAuthStatus"
:isCommentPassword="isCommentPassword" :isCommentPassword="isCommentPassword"
:isEditTextarea="isEditTextarea" :isEditTextarea="isEditTextarea"
:isDeleted="isDeleted"
:passwordCommentAlert="passwordCommentAlert" :passwordCommentAlert="passwordCommentAlert"
:currentPasswordCommentId="currentPasswordCommentId" :currentPasswordCommentId="currentPasswordCommentId"
:password="password" :password="password"
@ -183,6 +184,7 @@ const currentPasswordCommentId = ref(null);
const lastClickedButton = ref(""); const lastClickedButton = ref("");
const lastCommentClickedButton = ref(""); const lastCommentClickedButton = ref("");
const isEditTextarea = ref(false); const isEditTextarea = ref(false);
const isDeleted = ref(true);
const commentAlert = ref(''); const commentAlert = ref('');
const updatePassword = (newPassword) => { const updatePassword = (newPassword) => {
@ -671,6 +673,10 @@ const deletePost = async () => {
const deleteReplyComment = async (comment) => { const deleteReplyComment = async (comment) => {
if (!confirm("정말 이 댓글을 삭제하시겠습니까?")) return; if (!confirm("정말 이 댓글을 삭제하시겠습니까?")) return;
const targetComment = findCommentById(comment.commentId, comments.value);
console.log('잘되니?',comment)
try { try {
const response = await axios.delete(`board/comment/${comment.commentId}`, { const response = await axios.delete(`board/comment/${comment.commentId}`, {
data: { LOCCMTSEQ: comment.commentId } data: { LOCCMTSEQ: comment.commentId }
@ -678,6 +684,14 @@ const deleteReplyComment = async (comment) => {
if (response.data.code === 200) { if (response.data.code === 200) {
await fetchComments(); await fetchComments();
if (targetComment) {
console.log('타겟',targetComment)
// " ." ,
targetComment.content = "댓글이 삭제되었습니다.";
targetComment.author = "알 수 없음"; //
targetComment.isDeleted = true; //
}
} else { } else {
alert("댓글 삭제에 실패했습니다."); alert("댓글 삭제에 실패했습니다.");
} }