Files
laws_weilai/jero-web/src/views/projectManagement/components/commentList.vue
T
2022-05-05 16:16:21 +08:00

369 lines
9.5 KiB
Java

<template>
<div>
<a-drawer
:title="$t('comment')"
:maskClosable="false"
:width="482"
placement="right"
:closable="true"
@close="handleCancel"
:visible="visible">
<div class="button-box">
<j-input class="box-input" :placeholder="$t('PleaseEnter')+$t('comment')"
v-model="commentContent"></j-input>
<a-button @click="submitQuery" style="margin-right: 8px;" type="primary">{{$t('query')}}</a-button>
<a-button @click="handleSubmit" type="primary">{{$t('publishComment')}}</a-button>
</div>
<div class="comment-box" v-if="dataList && dataList.length > 0">
<div class="comment-box-top-box" v-for="(item,index) in dataList" :key="index">
<div class="title-text">{{$t('record')+(index + 1)}}</div>
<div class="box-content">
<div class="img-box">
<img src="../../../assets/daiban.png" class="img" alt="">
</div>
<div class="box-text">
<span class="box-text-name">{{item.name}}</span>
<span calss="box-text-time">{{item.createTime}}</span>
</div>
<div class="box-text-text">
{{item.content}}
</div>
<div class="box-icon" @click="messageClick(item)">
<a-icon type="message"/>
</div>
</div>
<div class="inside-box" v-if="item.projectCommentVOList && item.projectCommentVOList.length > 0">
<div class="box-content-inside" v-for="(val,indexOne) in item.projectCommentVOList" :key="indexOne">
<div class="img-box">
<img src="../../../assets/daiban.png" class="img" alt="">
</div>
<div class="box-text">
<span class="box-text-name">{{val.name}}</span>
<span calss="box-text-time">{{val.createTime}}</span>
</div>
<div class="box-text-text">
{{val.content}}
</div>
<div class="box-icon" @click="messageClick(item)">
<a-icon type="message"/>
</div>
</div>
</div>
</div>
</div>
<div class="comment-box-text" v-else>{{$t('noComment')}}</div>
<JLoading :loading="loading">{{$t('dataLoading')}}</JLoading>
</a-drawer>
<a-modal
:title="title"
:width="500"
:visible="visibleComment"
:confirm-loading="confirmLoading"
:maskClosable="false"
@ok="handleOkComment"
@cancel="handleCancelComment"
>
<a-form-model :model="formInline" class="formAdd" :rules="rules" ref="ruleForm">
<a-row :gutter="24">
<a-col :span="24">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span class="title-text-text" :title="title">{{title}}</span>
</div>
<a-form-model-item v-if="title == $t('replyToComments')" class="itemModel" :prop="'replyContent'">
<a-textarea
:placeholder="$t('PleaseEnter')+title"
:disabled="false"
v-model="formInline.replyContent" :rows="4"/>
</a-form-model-item>
<a-form-model-item v-else-if="title == $t('publishComment')" class="itemModel" :prop="'commentContent'">
<a-textarea
:placeholder="$t('PleaseEnter')+title"
:disabled="false"
v-model="formInline.commentContent" :rows="4"/>
</a-form-model-item>
</div>
</a-col>
</a-row>
</a-form-model>
</a-modal>
</div>
</template>
<script>
import { getAction, postAction } from '@/api/manage'
export default {
name: 'commentList',
data() {
return {
visible: false,
dataList: [],
formInline: {},
commentContent:'',
loading: false,
title: this.$t('comment'),
confirmLoading: false,
visibleComment: false,
url: {
list: '/project/projectCommentEO/list',
add: '/project/projectCommentEO/add',
edit: '/project/projectReplyEO/add'
},
rules: {
commentContent: [
{
required: true,
message: this.$t('publishComment') + this.$t('cannotEmpty'),
trigger: 'blur'
}
],
replyContent: [
{
required: true,
message: this.$t('replyToComments') + this.$t('cannotEmpty'),
trigger: 'blur'
}
]
}
}
},
mounted() {
},
methods: {
handleCancel() {
this.visible = false
},
getData() {
this.visible = true
this.getList()
},
handleSubmit() {
this.title = this.$t('publishComment')
this.formInline = {}
this.visibleComment = true
this.$nextTick(() => {
this.$refs.ruleForm.clearValidate()
})
},
submitQuery(){
},
getList() {
this.loading = true
getAction(this.url.list, { projectLibraryId: this.$route.query.id,commentContent:this.commentContent }).then((res) => {
if (res.success) {
this.loading = false
this.dataList = res.result || []
} else {
this.loading = false
this.dataList = []
}
})
},
handleOkComment() {
this.$refs.ruleForm.validate(valid => {
if (valid) {
let url = ''
let query = {}
if (this.title == this.$t('publishComment')) {
url = this.url.add
query = {
commentContent: this.formInline.commentContent,
projectLibraryId: this.$route.query.id
}
} else if (this.title == this.$t('replyToComments')) {
url = this.url.edit
query = {
replyContent: this.formInline.replyContent,
projectCommentId: this.formInline.projectCommentId
}
}
this.confirmLoading = true
postAction(url, query).then((res) => {
if (res.success) {
this.$message.success(this.$t('OperationSuccessful'))
this.visibleComment = false
this.confirmLoading = false
this.getList()
} else {
this.confirmLoading = false
this.$message.success(this.$t('operationFailed'))
}
})
}
})
},
handleCancelComment() {
this.visibleComment = false
},
messageClick(row) {
this.formInline = {}
this.formInline.projectCommentId = row.id
this.title = this.$t('replyToComments')
this.visibleComment = true
this.$nextTick(() => {
this.$refs.ruleForm.clearValidate()
})
}
}
}
</script>
<style scoped lang="less">
.comment-box {
position: absolute;
left: 0;
height: calc(100% - 140px);
width: 100%;
overflow: auto;
padding: 0 24px 24px 24px;
box-sizing: border-box;
}
.comment-box-top-box {
padding: 30px 24px 24px 24px;
box-sizing: border-box;
border: 1px solid #F1F2F4;
border-radius: 4px;
margin-bottom: 24px;
}
.img-box {
width: 32px;
height: 32px;
border-radius: 50%;
display: inline-block;
margin-right: 8px;
position: absolute;
.img {
width: 100%;
height: 100%;
}
}
.box-text {
display: inline-block;
position: absolute;
margin-left: 40px;
.box-text-name {
font-size: 14px;
font-weight: bold;
color: #040B29;
margin-right: 8px;
}
.box-text-time {
font-size: 14px;
font-weight: 400;
color: #6F7385;
}
}
.box-text-text {
font-size: 14px;
font-weight: 400;
color: #040B29;
display: inline-block;
margin-top: 22px;
margin-left: 40px;
}
.title-text {
font-size: 16px;
font-weight: 400;
color: #040B29;
margin-bottom: 18px;
}
.box-content {
position: relative;
}
.box-content-inside {
position: relative;
margin-bottom: 15px;
}
.box-icon {
position: absolute;
right: 0;
top: 0;
cursor: pointer;
}
.inside-box {
background: #F6F7FA;
border-radius: 4px;
margin-left: 40px;
width: calc(100% - 40px);
padding: 18px;
box-sizing: border-box;
margin-top: 15px;
}
.button-box {
text-align: right;
margin-bottom: 24px;
}
.drawer-bootom-button {
position: absolute;
bottom: 0;
width: 100%;
border-top: 1px solid #e8e8e8;
padding: 10px 16px;
text-align: right;
left: 0;
background: #fff;
border-radius: 0 0 2px 2px;
}
.box-title-text {
line-height: 1.4;
display: flex;
/*align-items: center;*/
}
.title-text {
width: 74px;
text-align: right;
display: inline-block;
font-weight: 500;
font-size: 14px;
margin-right: 16px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
height: 42px;
line-height: 48px;
}
.itemModel {
width: calc(100% - 64px);
display: inline-block;
margin-top: 2px;
}
.Required {
color: red;
margin-right: 4px;
}
.title-text-text {
margin-top: 9px;
}
.comment-box-text {
text-align: center;
margin-top: 40px;
}
.box-input{
width: calc(100% - 168px);
margin-right: 8px;
}
</style>