diff --git a/apps/web-antd/src/api/license/comment/index.ts b/apps/web-antd/src/api/license/comment/index.ts index f2d2334..f4fb2b1 100644 --- a/apps/web-antd/src/api/license/comment/index.ts +++ b/apps/web-antd/src/api/license/comment/index.ts @@ -45,7 +45,7 @@ export function createComment(data: CommentApi.Comment) { /** 修改评论 */ export function updateComment(data: CommentApi.Comment) { - return requestClient.post('/license/comment/update', data); + return requestClient.put('/license/comment/update', data); } /** 删除客户 */ diff --git a/apps/web-antd/src/locales/langs/en-US/comment.json b/apps/web-antd/src/locales/langs/en-US/comment.json index 8093a07..f260980 100644 --- a/apps/web-antd/src/locales/langs/en-US/comment.json +++ b/apps/web-antd/src/locales/langs/en-US/comment.json @@ -7,5 +7,8 @@ "delete": "Delete", "comment": "Comment", "deleteCommentTitle": "Are you sure you want to delete this comment?", - "sortByTime": "Sort by Time" + "sortByTime": "Sort by Time", + "edit": "Edit", + "editComment": "Edit Comment", + "cancelEdit": "Cancel Edit" } diff --git a/apps/web-antd/src/locales/langs/zh-CN/comment.json b/apps/web-antd/src/locales/langs/zh-CN/comment.json index 7954b76..20e7632 100644 --- a/apps/web-antd/src/locales/langs/zh-CN/comment.json +++ b/apps/web-antd/src/locales/langs/zh-CN/comment.json @@ -7,5 +7,8 @@ "delete": "删除", "comment": "评论", "deleteCommentTitle": "确定删除该条评论吗?", - "sortByTime": "按时间排序" + "sortByTime": "按时间排序", + "edit": "修改", + "editComment": "修改评论", + "cancelEdit": "取消修改" } diff --git a/apps/web-antd/src/views/license/project/comment/child-comment.vue b/apps/web-antd/src/views/license/project/comment/child-comment.vue index a682168..b4391e8 100644 --- a/apps/web-antd/src/views/license/project/comment/child-comment.vue +++ b/apps/web-antd/src/views/license/project/comment/child-comment.vue @@ -39,16 +39,30 @@ const emit = defineEmits(['getCommentByProjectId']); const userStore = useUserStore(); const isShowReply = ref(); +const isShowEdit = ref(); const parentId = ref(); +const commentType = ref(); const reply = (id: number) => { isShowReply.value = !isShowReply.value; parentId.value = id; + isShowEdit.value = false; +}; + +const edit = (id: number) => { + isShowEdit.value = !isShowEdit.value; + parentId.value = id; + commentType.value = 1; + isShowReply.value = false; }; const showReply = (flag: boolean) => { isShowReply.value = flag; }; +const showEdit = (flag: boolean) => { + isShowEdit.value = flag; +}; + const onDelete = async (id: number) => { try { await deleteComment(id); @@ -112,6 +126,27 @@ const formatContent = computed(() => { + + + + {
+
+ +
+ diff --git a/apps/web-antd/src/views/license/project/comment/create-comment.vue b/apps/web-antd/src/views/license/project/comment/create-comment.vue index f7e06e8..7729586 100644 --- a/apps/web-antd/src/views/license/project/comment/create-comment.vue +++ b/apps/web-antd/src/views/license/project/comment/create-comment.vue @@ -5,20 +5,21 @@ import { ref } from 'vue'; import { message } from 'ant-design-vue'; -import { createComment } from '#/api/license/comment'; +import { createComment, updateComment } from '#/api/license/comment'; import { Tinymce as RichTextarea } from '#/components/tinymce'; import { $t } from '#/locales'; const props = defineProps<{ - comments?: CommentApi.Comment[]; + commentContent?: string; + commentType?: number; parentId?: number; projectId?: number; }>(); -const emit = defineEmits(['getCommentByProjectId', 'showReply']); +const emit = defineEmits(['getCommentByProjectId', 'showReply', 'showEdit']); const submitting = ref(false); -const value = ref(''); +const value = ref(props.commentContent || ''); const handleSubmit = async () => { if (!value.value) { @@ -27,15 +28,17 @@ const handleSubmit = async () => { // 提交表单 const data = { - parentId: props.parentId, + id: props.commentType === 1 ? props.parentId : undefined, + parentId: props.commentType === 1 ? undefined : props.parentId, projectId: props.projectId, content: value.value, } as CommentApi.Comment; try { submitting.value = true; - await createComment(data); + await (props.commentType === 1 ? updateComment(data) : createComment(data)); submitting.value = false; emit('showReply', false); + emit('showEdit', false); message.success($t('ui.actionMessage.operationSuccess')); emit('getCommentByProjectId', props.projectId); } finally { @@ -57,7 +60,9 @@ const handleSubmit = async () => { {{ (props.parentId ?? 0) === 0 ? $t('comment.postComment') - : $t('comment.replyComment') + : props.commentType === 1 + ? $t('comment.editComment') + : $t('comment.replyComment') }} diff --git a/apps/web-antd/src/views/license/project/comment/index.vue b/apps/web-antd/src/views/license/project/comment/index.vue index 691f420..e40f9a1 100644 --- a/apps/web-antd/src/views/license/project/comment/index.vue +++ b/apps/web-antd/src/views/license/project/comment/index.vue @@ -92,6 +92,7 @@ function getCommentCount(comments?: CommentApi.Comment[]) { :comments="comments" @get-comment-by-project-id="emit('getCommentByProjectId', projectId)" /> +