1、新增评论、回复功能

2、工具发布权限完善一部分
This commit is contained in:
pan
2024-08-30 19:48:44 +08:00
parent 15a59707c6
commit 4920b41620
6 changed files with 476 additions and 86 deletions

View File

@@ -1,7 +1,7 @@
<template>
<div class="app-container">
<el-card>
<el-form label-width="80px" ref="queryForm">
<el-form :model="queryParams" label-width="80px" ref="queryForm">
<div class="grab" id="add">
<div class="search">
<div class="sl">
@@ -50,7 +50,7 @@
</div>
<div class="sr">
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh-left" @click="reset">重置</el-button>
<el-button icon="el-icon-refresh-left" @click="resetQuery">重置</el-button>
</div>
</div><!--search 默认查询-->
</div><!--grab-->
@@ -58,7 +58,7 @@
</el-card><!--el-card-->
<el-card class="lrtt">
<div class="lt">
<div class="lt" v-hasPermi="['tool:org:tree']">
<el-input
v-model="deptName"
placeholder="请输入部门名称"
@@ -87,10 +87,9 @@
plain
icon="el-icon-plus"
@click="handleAdd"
v-hasPermi="['system:user:add']"
>工具发布</el-button>
<el-button icon="el-icon-delete" @click="handleDelete(selection)">批量删除</el-button>
<el-button icon="el-icon-download" @click="handleOpenExport()">导出</el-button>
<el-button icon="el-icon-delete" @click="handleDelete(selection)" v-hasPermi="['tool:batch:remove']">批量删除</el-button>
<el-button icon="el-icon-download" @click="handleOpenExport()" v-hasPermi="['tool:export']">导出</el-button>
</div><!--operate 操作按钮-->
<el-table v-loading="loading" :data="toolList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" :selectable="selectable"/>
@@ -120,7 +119,7 @@
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button type="text" icon="el-icon-info" v-if="scope.row.recordStatus==='done'" @click="applyUse(scope.row)">申请使用</el-button>
<el-button type="text" icon="el-icon-info" v-if="scope.row.recordStatus=='done'" @click="applyUse(scope.row)">申请使用</el-button>
<el-button type="text" icon="el-icon-info" @click="handleDetail(scope.row)">详情</el-button>
<el-button type="text" icon="el-icon-download" v-if="scope.row.downloadStatus">下载</el-button>
<el-dropdown size="mini" v-if="selectable(scope.row)" @command="(command) => handleCommand(command, scope.row)">
@@ -192,11 +191,13 @@
</el-drawer>
<!-- 工具详情对话框 -->
<el-drawer :visible.sync="detailDrawerOpen" :modal-append-to-body="false" size="85%" class="no-padding">
<el-drawer :visible.sync="detailDrawerOpen" :modal-append-to-body="false" size="85%" class="no-padding" @close="handleCloseDetail()">
<template #title>
<span>工具名称</span>
</template>
<tool-detail ref="toolDetailRef" :toolDetail="toolDetail"/>
<template v-if="detailOpen">
<tool-detail ref="toolDetailRef" :toolDetail="toolDetail"/>
</template>
</el-drawer><!--el-drawer 详情-抽屉-->
</div><!--app-container-->
@@ -251,6 +252,7 @@ export default {
addDrawerOpen: false,
exoportDrawerOpen: false,
detailDrawerOpen: false,
detailOpen: false,
detailActiveName: 'first',
// 部门名称
deptName: undefined,
@@ -436,6 +438,7 @@ export default {
},
handleDetail(row){
this.detailDrawerOpen = true
this.detailOpen = true
this.toolDetail = row
},
// 更多操作触发
@@ -482,9 +485,6 @@ export default {
downloadCheck:false,
excludeFields:excludeFields,
}, `工具信息数据_${new Date().getTime()}.xlsx`)
},
handleUseApply(){
},
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
@@ -537,6 +537,16 @@ export default {
},
selectable(row,index){
return row.recordStatus==='draft'&&row.createBy==this.userInfo.userId
},
/** 关闭详情 **/
handleCloseDetail(){
console.info("1111111111")
this.detailDrawerOpen = false;
this.detailOpen = false;
this.$refs.toolDetailRef.$destroy(); // 销毁组件
this.$nextTick(() => {
this.$refs.toolDetailRef = null; // 清空引用
});
}
}
};

View File

@@ -67,65 +67,53 @@
<div class="tit">评论</div>
</div><!--tboper 标题与操作按钮-->
<div class="pltextarea">
<el-input type="textarea" placeholder="请输入您的意见" :rows="4" maxlength="1000" show-word-limit></el-input>
<div class="plbtn"><el-button>发布</el-button></div>
<el-input v-model="discussionContent" type="textarea" placeholder="请输入您的意见" :rows="4" maxlength="1000" show-word-limit></el-input>
<div class="plbtn"><el-button @click="handleDiscussions">发布</el-button></div>
</div><!--pltextarea-->
<div class="pllist">
<div class="list">
<div class="luser"><span class="xuser"></span></div>
<div class="ltext">
<div class="nt"><span class="name">张鑫辉</span><span class="time">05/01 12:00</span></div>
<div class="te">这个工具可以</div>
<div class="hb"><a class="btn"><i class="el-icon-chat-line-round"></i>回复</a></div>
<div class="pltextarea">
<el-input type="textarea" placeholder="请输入您的意见" :rows="2" maxlength="1000" show-word-limit></el-input>
<div class="plbtn"><el-button>取消</el-button><el-divider direction="vertical"></el-divider><el-button>发布</el-button></div>
</div><!--pltextarea-->
</div>
</div><!--list-->
<div class="list">
<div class="luser"><span class="xuser"></span></div>
<div class="ltext">
<div class="nt"><span class="name">钱多多</span><span class="time">05/01 12:00</span></div>
<div class="te">好用</div>
<div class="hb"><a class="btn"><i class="el-icon-chat-line-round"></i>回复</a></div>
<div class="list">
<div class="luser"><span class="xuser"></span></div>
<div class="ltext">
<div class="nt"><span class="name">赵宇</span><span class="time">05/01 12:00</span></div>
<div class="te">希望再选代一下还有待完善的地方</div>
<div class="hb"><a class="btn"><i class="el-icon-chat-line-round"></i>回复</a></div>
<template v-if="discussionsList && discussionsList.length > 0">
<div class="list" v-for="(item,index) in discussionsList" :key="item.id">
<div class="luser"><span class="xuser">{{getFirstChar(item.nickName)}}</span></div>
<div class="ltext">
<div class="nt"><span class="name">{{item.nickName}}</span><span class="time">{{ parseTime(item.createTime, '{y}-{m}-{d} {h}:{i}') }}</span></div>
<div class="te">{{item.content}}</div>
<div class="hb">
<a class="btn" @click="toggleReplyForm(index)">
<i class="el-icon-chat-line-round"></i>回复
</a>
</div>
</div><!--list-->
<div class="list">
<div class="luser"><span class="xuser"></span></div>
<div class="ltext">
<div class="nt"><span class="name">李志</span><span class="time">05/01 12:00</span></div>
<div class="te">很好的解决了我的问题感谢</div>
<div class="hb"><a class="btn"><i class="el-icon-chat-line-round"></i>回复</a></div>
<div class="pltextarea" v-if="showReplyForm[index]">
<el-input type="textarea" v-model="replyContent[index]" placeholder="请输入您的意见" :rows="2" maxlength="1000" show-word-limit></el-input>
<div class="plbtn">
<el-button @click="cancelReply(index)">取消</el-button>
<el-divider direction="vertical"></el-divider>
<el-button @click="submitReply(index, item)">发布</el-button>
</div>
</div>
</div><!--list-->
<!--第二层级-->
<template v-if="item.repliesList && item.repliesList.length > 0">
<div class="list" v-for="(repItem,repIdex) in item.repliesList" :key="repItem.id">
<div class="luser"><span class="xuser">{{getFirstChar(repItem.nickName)}}</span></div>
<div class="ltext">
<div class="nt"><span class="name">{{repItem.nickName}}</span><span class="time">{{ parseTime(repItem.createTime, '{y}-{m}-{d} {h}:{i}') }}</span></div>
<div class="te">{{repItem.content}}</div>
<!-- <div class="hb"><a class="btn" @click="toggleReplyFormSon(index,repIdex)"><i class="el-icon-chat-line-round"></i>回复</a></div>
<div class="pltextarea" v-if="item.showReplyFormSon[repIdex]">
<el-input type="textarea" v-model="item.replyContentSon[repIdex]" placeholder="请输入您的意见" :rows="2" maxlength="1000" show-word-limit></el-input>
<div class="plbtn">
<el-button @click="cancelReplySon(index,repIdex)">取消</el-button>
<el-divider direction="vertical"></el-divider>
<el-button @click="submitReplySon(index,repIdex, item)">发布</el-button>
</div>
</div>-->
</div>
</div>
</template>
</div>
</div>
</div><!--list-->
<div class="list">
<div class="luser"><span class="xuser"></span></div>
<div class="ltext">
<div class="nt"><span class="name">赵宇</span><span class="time">05/01 12:00</span></div>
<div class="te">希望再选代一下还有待完善的地方</div>
<div class="hb"><a class="btn"><i class="el-icon-chat-line-round"></i>回复</a></div>
</div>
</div><!--list-->
<div class="list">
<div class="luser"><span class="xuser"></span></div>
<div class="ltext">
<div class="nt"><span class="name">李志</span><span class="time">05/01 12:00</span></div>
<div class="te">很好的解决了我的问题感谢</div>
<div class="hb"><a class="btn"><i class="el-icon-chat-line-round"></i>回复</a></div>
</div>
</div><!--list-->
</div><!--pllist-->
</div><!--fl 右侧评论-->
</template>
</div>
</div>
<el-dialog :title="viewDialogTitle" :visible.sync="viewDialogOpen" fullscreen width="500px" append-to-body>
<i-frame :src="previewUrl" />
</el-dialog>
@@ -137,6 +125,9 @@
<script>
import { listDocument, getDocument, delDocument, addDocument, updateDocument } from "@/api/document/document";
import { listDiscussions, addDiscussions } from "@/api/tool/discussions.js";
import { listReplies, addReplies} from "@/api/tool/replies.js";
import AddDoc from './AddDoc'
import editDocument from "../document/editDocument";
import { Base64 } from 'js-base64';
@@ -167,10 +158,25 @@
title: '新增文档',
open: false,
loadingDownload: false,
discussionContent: null, // 评论内容
repliesContent: null, // 回复内容
// 评论列表
discussionsList: [],
// 回复列表
repliesList: [],
showReplyForm: [],
replyContent: [],
}
},
created(){
this.getDocList()
this.getDiscussionsList()
},
watch: {
discussionsList(newList) {
this.showReplyForm = new Array(newList.length).fill(false);
this.replyContent = new Array(newList.length).fill('');
}
},
methods:{
getDocList() {
@@ -216,6 +222,152 @@
self.loadingDownload = false
},1000)
},
getDiscussionsList() {
let self = this
listDiscussions({businessId:this.toolDetail.toolId}).then(res => {
self.discussionsList = res.rows
self.discussionsList.forEach(item => {
if(item.repliesList && item.repliesList.length > 0){
self.$set(item, 'showReplyFormSon', new Array(item.repliesList.length).fill(false))
self.$set(item, 'replyContentSon', new Array(item.repliesList.length).fill(''))
}else{
self.$set(item, 'showReplyFormSon', false)
self.$set(item, 'replyContentSon', '')
}
});
});
},
/** 评论 **/
handleDiscussions(){
let self = this
if (this.discussionContent == '' || this.discussionContent == null || this.discussionContent == undefined) {
self.$message({
message: '内容不能为空',//提示的信息
type:'warning',  //类型是成功
duration:1200,  //显示时间, 毫秒。设为 0 则不会自动关闭建议1200
});
return;
}
let data = {
businessId: this.toolDetail.toolId,
content: this.discussionContent,
type: "tool",
}
self.$modal.confirm('是否确认发布?').then(()=> {
addDiscussions(data).then(res => {
this.discussionContent = null
self.$message({
message: '发布成功',//提示的信息
type:'success',  //类型是成功
duration:1200,  //显示时间, 毫秒。设为 0 则不会自动关闭建议1200
});
self.getDiscussionsList()
}).catch(err =>{
this.discussionContent = null
console.error("handleDiscussions==err==", err)
self.$modal.msgError("发布失败");
});
})
},
getFirstChar(value) {
if(!value){return ''}
return value.charAt(0);
},
toggleReplyForm(index) {
this.$set(this.showReplyForm, index, !this.showReplyForm[index]);
},
cancelReply(index) {
this.$set(this.showReplyForm, index, false);
this.$set(this.replyContent, index, '');
},
/** 回复 **/
submitReply(index, item) {
let self = this
const content = this.replyContent[index];
if (content == '' || content == null || content == undefined) {
self.$message({
message: '回复内容不能为空',//提示的信息
type:'warning',  //类型是成功
duration:1200,  //显示时间, 毫秒。设为 0 则不会自动关闭建议1200
});
return;
}
let data = {
"discussionId": item.id,
"content": content,
}
self.$modal.confirm('是否确认发布?').then(()=> {
addReplies(data).then(res => {
self.$message({
message: '发布成功',//提示的信息
type:'success',  //类型是成功
duration:1200,  //显示时间, 毫秒。设为 0 则不会自动关闭建议1200
});
self.cancelReply(index)
self.getDiscussionsList()
}).catch(err =>{
console.error("handleDiscussions==err==", err)
self.$modal.msgError("发布失败");
});
})
// 清空回复内容并隐藏表单
this.replyContent[index] = '';
this.showReplyForm[index] = false;
},
/** 第二级 **/
toggleReplyFormSon(parentIndex, repIndex) {
const parentItem = this.discussionsList[parentIndex];
this.$set(parentItem.showReplyFormSon, repIndex, !parentItem.showReplyFormSon[repIndex]);
// this.$set(this.showReplyFormSon, index, !this.showReplyFormSon[index]);
},
/** 第二级,取消回复 **/
cancelReplySon(parentIndex, repIndex) {
const parentItem = this.discussionsList[parentIndex];
this.$set(parentItem.showReplyFormSon, repIndex, false);
this.$set(parentItem.replyContentSon, repIndex, '');
},
/** 第二级回复 **/
submitReplySon(parentIndex, repIndex, repItem) {
let self = this
const parentItem = this.discussionsList[parentIndex];
const content = parentItem.replyContentSon[repIndex];
if (content.trim() == '' || content == null || content == undefined) {
self.$message({
message: '回复内容不能为空',//提示的信息
type:'warning',  //类型是成功
duration:1200,  //显示时间, 毫秒。设为 0 则不会自动关闭建议1200
});
return;
}
let data = {
"discussionId": repItem.id,
"content": content,
}
self.$modal.confirm('是否确认发布?').then(()=> {
addReplies(data).then(res => {
self.$message({
message: '发布成功',//提示的信息
type:'success',  //类型是成功
duration:1200,  //显示时间, 毫秒。设为 0 则不会自动关闭建议1200
});
self.cancelReplySon(parentIndex, repIndex)
self.getDiscussionsList()
}).catch(err =>{
console.error("submitReplySon==err==", err)
self.$modal.msgError("发布失败");
});
})
// 清空回复内容并隐藏表单
this.$set(parentItem.replyContentSon, repIndex, '');
this.$set(parentItem.showReplyFormSon, repIndex, false);
},
}
}
</script>