提交 fe1a9699 authored 作者: 王鹏飞's avatar 王鹏飞

feat: 回复增加标题

上级 48f7ccfe
...@@ -5,11 +5,19 @@ ...@@ -5,11 +5,19 @@
<div v-html="data.comment"></div> <div v-html="data.comment"></div>
</show-more> </show-more>
</div> </div>
<div class="chapter-work-comment-and-reply" v-for="reply in data.details"> <div class="chapter-work-comment-and-reply-list">
<div
class="chapter-work-comment-and-reply"
:class="{ 'is-mine': studentId === reply.student_id, 'is-other': studentId !== reply.student_id }"
v-for="reply in data.details"
>
<p class="chapter-work-comment-and-reply-title" v-if="studentId === reply.student_id">我的回复:</p>
<p class="chapter-work-comment-and-reply-title" v-else>{{ title }}的回复:</p>
<show-more :key="reply.id"> <show-more :key="reply.id">
<div v-html="reply.comment"></div> <div v-html="reply.comment"></div>
</show-more> </show-more>
</div> </div>
</div>
<div class="chapter-work-comment-and-reply-tools"> <div class="chapter-work-comment-and-reply-tools">
<el-button size="small" @click="showComment = !showComment">评论</el-button> <el-button size="small" @click="showComment = !showComment">评论</el-button>
<template v-if="showComment"> <template v-if="showComment">
...@@ -29,7 +37,11 @@ import * as api from '../../api' ...@@ -29,7 +37,11 @@ import * as api from '../../api'
export default { export default {
name: 'ChapterWorkCommentAndReply', name: 'ChapterWorkCommentAndReply',
props: { data: { type: Object, default: () => ({}) }, showFirst: { type: Boolean, default: true } }, props: {
data: { type: Object, default: () => ({}) },
showFirst: { type: Boolean, default: true },
title: { type: String, default: '' }
},
emits: ['update'], emits: ['update'],
components: { VEditor, showMore }, components: { VEditor, showMore },
data() { data() {
...@@ -38,6 +50,11 @@ export default { ...@@ -38,6 +50,11 @@ export default {
comment: '' comment: ''
} }
}, },
computed: {
studentId() {
return window.G.UserInfo?.student_info?.id
}
},
methods: { methods: {
handleSubmit() { handleSubmit() {
api.addChapterHomeworkCommentReply({ comment_id: this.data.id, comment: this.comment }).then((response) => { api.addChapterHomeworkCommentReply({ comment_id: this.data.id, comment: this.comment }).then((response) => {
...@@ -63,6 +80,11 @@ export default { ...@@ -63,6 +80,11 @@ export default {
max-width: 100%; max-width: 100%;
} }
} }
.chapter-work-comment-and-reply-title {
font-size: 14px;
margin-bottom: 10px;
color: #333;
}
.chapter-work-comment-and-reply-tools { .chapter-work-comment-and-reply-tools {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
......
<template> <template>
<div> <div>
<chapter-work-answer-item :data="data" :key="data.id" v-bind="$attrs"> <chapter-work-answer-item :data="data" :index="index" :key="data.id" v-bind="$attrs">
<h3 class="comment-title">{{ $t('viewerWork.commentMyTitle') }}</h3> <h3 class="comment-title">{{ $t('viewerWork.commentMyTitle') }}</h3>
<v-editor v-model="data.comment" :disabled="disabled"></v-editor> <v-editor v-model="data.comment" :disabled="disabled"></v-editor>
</chapter-work-answer-item> </chapter-work-answer-item>
<chapter-work-comment-and-reply :data="data" v-on="$listeners" :show-first="false" /> <chapter-work-comment-and-reply :data="data" v-on="$listeners" :show-first="false" :title="nickname" />
</div> </div>
</template> </template>
...@@ -15,10 +15,16 @@ import VEditor from '@/components/tinymce' ...@@ -15,10 +15,16 @@ import VEditor from '@/components/tinymce'
import chapterWorkCommentAndReply from './chapterWorkCommentAndReply.vue' import chapterWorkCommentAndReply from './chapterWorkCommentAndReply.vue'
export default { export default {
props: { data: { type: Object, default: () => ({}) }, disabled: { type: Boolean } }, props: { data: { type: Object, default: () => ({}) }, disabled: { type: Boolean }, index: { type: Number } },
components: { ChapterWorkAnswerItem, VEditor, chapterWorkCommentAndReply }, components: { ChapterWorkAnswerItem, VEditor, chapterWorkCommentAndReply },
data() { data() {
return {} return {}
},
computed: {
nickname() {
const name = this.data.personal_name
return name ? name + this.$t('viewerWork.student') : this.$t('viewerWork.student') + (this.index + 1)
}
} }
} }
</script> </script>
......
...@@ -4,7 +4,12 @@ ...@@ -4,7 +4,12 @@
<div class="module-item" :key="index"> <div class="module-item" :key="index">
<div class="module-item-hd">{{ $t('viewerWork.comment') }}{{ index + 1 }}:</div> <div class="module-item-hd">{{ $t('viewerWork.comment') }}{{ index + 1 }}:</div>
<div class="module-item-bd"> <div class="module-item-bd">
<chapter-work-comment-and-reply :data="item" :key="item.id" @update="getList" /> <chapter-work-comment-and-reply
:data="item"
:title="$t('viewerWork.comment') + (index + 1)"
:key="item.id"
@update="getList"
/>
</div> </div>
</div> </div>
</template> </template>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论