diff --git a/frontend/src/api/modules/bug-management/index.ts b/frontend/src/api/modules/bug-management/index.ts index 7334aeb733..5665b151d1 100644 --- a/frontend/src/api/modules/bug-management/index.ts +++ b/frontend/src/api/modules/bug-management/index.ts @@ -97,7 +97,7 @@ export function followBug(id: string, isFollow: boolean) { // 创建评论 export function createOrUpdateComment(data: CommentParams) { - if (data.id || data.event !== 'REPLAY') { + if (data.fetchType === 'UPDATE') { return MSR.post({ url: bugURL.postUpdateCommentUrl, data }); } return MSR.post({ url: bugURL.postCreateCommentUrl, data }); diff --git a/frontend/src/components/business/ms-comment/comment-item.vue b/frontend/src/components/business/ms-comment/comment-item.vue index b61e1eadbd..ab3083a73c 100644 --- a/frontend/src/components/business/ms-comment/comment-item.vue +++ b/frontend/src/components/business/ms-comment/comment-item.vue @@ -3,7 +3,7 @@
{{ props.element.createUser }}
-
+
{{ @@ -19,15 +19,28 @@ {{ !expendComment ? t('ms.comment.expendComment') : t('ms.comment.collapseComment') }} ({{ element.childComments?.length }})
-
+
{{ t('ms.comment.reply') }}
-
+
{{ t('ms.comment.edit') }}
-
+
{{ t('ms.comment.delete') }}
@@ -38,7 +51,7 @@ diff --git a/frontend/src/components/business/ms-comment/comment.tsx b/frontend/src/components/business/ms-comment/comment.tsx index cabc8bf149..d7d5133849 100644 --- a/frontend/src/components/business/ms-comment/comment.tsx +++ b/frontend/src/components/business/ms-comment/comment.tsx @@ -5,7 +5,7 @@ import CommentInput from './input.vue'; import { useI18n } from '@/hooks/useI18n'; -import { CommentItem, CommentParams } from './types'; +import { CommentItem, CommentParams, CommentType } from './types'; import message from '@arco-design/web-vue/es/message'; export default defineComponent({ @@ -27,25 +27,45 @@ export default defineComponent({ }, setup(props, { emit }) { const { commentList, disabled } = toRefs(props); - const currentItem = reactive<{ id: string; parentId: string; status: string }>({ + const currentItem = reactive<{ id: string; commentType: CommentType; commentStatus: string }>({ id: '', - parentId: '', - status: 'add', + commentType: 'ADD', + // 控制回复编辑删除按钮的状态 + commentStatus: 'normal', }); + // 被@的用户id + const noticeUserIds = ref([]); const { t } = useI18n(); const resetCurrentItem = () => { currentItem.id = ''; - currentItem.parentId = ''; + currentItem.commentType = 'ADD'; + currentItem.commentStatus = 'normal'; + noticeUserIds.value = []; }; const handlePublish = (content: string, item: CommentItem) => { + // 这个组件里的都是回复和编辑不涉及新增,所以是 COMMENT 或 REPLAY + let parentId = ''; + if (currentItem.commentType === 'REPLY') { + parentId = item.id; + } else if (currentItem.commentType === 'EDIT') { + parentId = item.parentId || ''; + } const params: CommentParams = { - ...item, + id: currentItem.id, + bugId: item.bugId, content, - event: 'REPLAY', - status: currentItem.status, + event: noticeUserIds.value.length > 0 ? 'REPLAY' : 'COMMENT', + commentType: currentItem.commentType, + fetchType: currentItem.commentType === 'EDIT' ? 'UPDATE' : 'ADD', + notifier: noticeUserIds.value.join(';'), + replyUser: item.createUser, + parentId, }; + if (currentItem.commentType === 'EDIT') { + params.id = item.id; + } emit('updateOrAdd', params, (result: boolean) => { if (result) { message.success(t('common.publishSuccessfully')); @@ -62,32 +82,31 @@ export default defineComponent({ const handleReply = (item: CommentItem) => { if (item.childComments && Array.isArray(item.childComments)) { - // 父级评论 + // 点击的是父级评论的回复 currentItem.id = item.id; - currentItem.parentId = ''; } else { // 子级评论 currentItem.id = item.parentId || ''; - currentItem.parentId = item.id; } - currentItem.status = 'replay'; + currentItem.commentType = 'REPLY'; }; const handelEdit = (item: CommentItem) => { currentItem.id = item.id; - currentItem.parentId = item.parentId || ''; - currentItem.status = 'edit'; + currentItem.commentType = 'EDIT'; }; - const noticeUserIds = ref([]); - const renderInput = (item: CommentItem) => { return ( handlePublish(content, item)} - defaultValue={item.content || ''} + defaultValue={currentItem.commentType === 'EDIT' ? item.content : ''} + noticeUserIds={noticeUserIds.value} + onUpdate:noticeUserIds={(ids: string[]) => { + noticeUserIds.value = ids; + }} onCancel={() => resetCurrentItem()} {...item} /> @@ -102,10 +121,14 @@ export default defineComponent({ return (
handleReply(item)} onEdit={() => handelEdit(item)} onDelete={() => handleDelete(item)} - mode={'child'} + status={item.id === currentItem.id ? currentItem.commentStatus : 'normal'} + onUpdate:status={(v: string) => { + currentItem.commentStatus = v; + }} element={item} /> {item.id === currentItem.id && renderInput(item)} @@ -123,9 +146,15 @@ export default defineComponent({ onReply={() => handleReply(item)} onEdit={() => handelEdit(item)} onDelete={() => handleDelete(item)} + status={item.id === currentItem.id ? currentItem.commentStatus : 'normal'} + onUpdate:status={(v: string) => { + currentItem.commentStatus = v; + }} element={item} > -
+
+ {renderChildrenList(item.childComments)} +
{item.id === currentItem.id && renderInput(item)} diff --git a/frontend/src/components/business/ms-comment/input.vue b/frontend/src/components/business/ms-comment/input.vue index 870f696cb1..21e46b497f 100644 --- a/frontend/src/components/business/ms-comment/input.vue +++ b/frontend/src/components/business/ms-comment/input.vue @@ -8,7 +8,7 @@ >
- +
@@ -21,8 +21,7 @@