feat: 评论组件改动

This commit is contained in:
rubyliu 2024-02-18 23:01:29 +08:00 committed by rubylliu
parent af93df7862
commit 058a5e0136
2 changed files with 10 additions and 4 deletions

View File

@ -27,9 +27,10 @@ export default defineComponent({
},
setup(props, { emit }) {
const { commentList, disabled } = toRefs(props);
const currentItem = reactive<{ id: string; parentId?: string }>({
const currentItem = reactive<{ id: string; parentId: string; status: string }>({
id: '',
parentId: '',
status: 'add',
});
const { t } = useI18n();
@ -43,6 +44,7 @@ export default defineComponent({
...item,
content,
event: 'REPLAY',
status: currentItem.status,
};
emit('updateOrAdd', params, (result: boolean) => {
if (result) {
@ -59,19 +61,22 @@ export default defineComponent({
};
const handleReply = (item: CommentItem) => {
if (item.childComments) {
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';
};
const handelEdit = (item: CommentItem) => {
currentItem.id = item.id;
currentItem.parentId = item.parentId || '';
currentItem.status = 'edit';
};
const noticeUserIds = ref<string[]>([]);

View File

@ -20,12 +20,12 @@ export interface CommentItem {
}
// 仅评论: COMMENT; 评论并@: AT; 回复评论/回复并@: REPLAY;)
export type commentEvent = 'COMMENT' | 'AT' | 'REPLAY';
export type CommentEvent = 'COMMENT' | 'AT' | 'REPLAY';
export interface WriteCommentProps {
id?: string; // 评论id
parentId?: string; // 父级评论id
event: commentEvent; // 评论事件
event: CommentEvent; // 评论事件
bugId?: string; // bug id
caseId?: string; // 用例id
}
@ -34,4 +34,5 @@ export interface CommentParams extends WriteCommentProps {
replyUser?: string; // 回复人
notifiers?: string; // 通知人
notifier?: string; // 通知人
status?: string; // 编辑还是新增
}