留言调

This commit is contained in:
daihh
2022-11-08 14:48:23 +08:00
parent bf7e0de08b
commit 08efabdd21

View File

@@ -19,7 +19,7 @@
<p>{{item.content}}</p> <p>{{item.content}}</p>
</div> </div>
<div class="li-right"> <div class="li-right">
<div class="replys-icon" v-if="userInfo.aid == pageId" @click="isReplys(item, idx)"><svg-icon style="margin-right: 4px;font-size: 14px;" icon-class="comment"></svg-icon>回复</div> <div class="replys-icon" v-if="userInfo.aid == pageId" @click="showReplyInput(item, idx)"><svg-icon style="margin-right: 4px;font-size: 14px;" icon-class="comment"></svg-icon>回复</div>
<div style="margin-top:4px"> <div style="margin-top:4px">
<interactBar :type="7" :data="item" :comments="false" :shares="false" :views="false" :favorites="false"></interactBar> <interactBar :type="7" :data="item" :comments="false" :shares="false" :views="false" :favorites="false"></interactBar>
</div> </div>
@@ -29,10 +29,10 @@
<!-- 回复框 --> <!-- 回复框 -->
<div class="replys-input" style="padding-left: 60px;margin:10px 0" v-if="item.isReplys"> <div class="replys-input" style="padding-left: 60px;margin:10px 0" v-if="item.isReplys">
<el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="replysContent" maxlength="200" show-word-limit></el-input> <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="replysContent" maxlength="200" show-word-limit></el-input>
<el-button class="lea-btn" type="primary" @click="addReplys()">回复</el-button> <el-button class="lea-btn" type="primary" @click="addReplys(item,item)">回复</el-button>
</div> </div>
<!-- 回复框 --> <!-- 回复框 -->
<div class="lev-li-tow" v-for="(rep,index) in item.replysList" :key="index"> <div class="lev-li-tow" v-for="(rep,index) in item.replyList" :key="index">
<div class="lev-li"> <div class="lev-li">
<div class="li-img"><author-img :avatar="rep.authorInfo.avatar" :aid="rep.authorInfo.aid" :sex="rep.authorInfo.sex"></author-img></div> <div class="li-img"><author-img :avatar="rep.authorInfo.avatar" :aid="rep.authorInfo.aid" :sex="rep.authorInfo.sex"></author-img></div>
<div class="li-text"> <div class="li-text">
@@ -111,23 +111,14 @@
}, },
delReplySon(item,index) { //子级的删除手动删掉,调用保存接口 delReplySon(item,index) { //子级的删除手动删掉,调用保存接口
//修改后,替换为下面的情况 //修改后,替换为下面的情况
// apiGuestbook.del(item.id).then(res=>{ apiGuestbook.del(item.id).then(res=>{
// if(res.status==200){ if(res.status==200){
// item.replysList.splice(index,1); item.replyList.splice(index,1);
// }else{ this.$message.success('删除成功');
// this.$message.error('删除失败'+res.message); }else{
// } this.$message.error('删除失败'+res.message);
// });
item.replysList.splice(index,1);
let replysData = {
id:item.id,
reply:JSON.stringify(item.replysList)
}
apiGuestbook.answer(replysData).then(res=>{
if(res.status == 200) {
this.$message.success('删除留言成功');
} }
}) });
}, },
delReply(item) { delReply(item) {
this.$confirm('此操作将永久删除该留言, 是否继续?', '提示', { this.$confirm('此操作将永久删除该留言, 是否继续?', '提示', {
@@ -145,28 +136,36 @@
this.$message({type: 'info', message: '已取消删除'}); this.$message({type: 'info', message: '已取消删除'});
}); });
}, },
isReplys(item,idx) { showReplyInput(item,idx) {
item.isReplys = true; item.isReplys = true;
this.replysData.id = item.id; this.replysData.id = item.id;
this.replysData.reply = item.replysList; //this.replysData.reply = item.replyList;
}, },
addReplys() { addReplys(top,p) {
if(this.replysContent.trim().length == 0) { if(this.replysContent.trim().length == 0) {
return this.$message.warning('请填写内容!'); return this.$message.warning('请填写内容!');
} }
this.replysData.reply.push({ let postData={
content: this.replysContent, content:this.replysContent,
authorInfo:this.userInfo, topId:top.id,
praises:0, parentId:p.id,
}) level:2,
this.replysData.reply = JSON.stringify(this.replysData.reply); replys:0
apiGuestbook.answer(this.replysData).then(res=>{ }
let $this=this;
apiGuestbook.answer(postData).then(res=>{
this.replysContent = ''; this.replysContent = '';
if(res.status == 200) { if(res.status == 200) {
this.$message.success('留言发布成功'); this.$message.success('回复留言成功');
this.leavingList.forEach(item=>{ p.isReplys = false;
item.isReplys = false; res.result.authorInfo=$this.userInfo;
}) p.replyList.push(res.result);
//直接追加到列表后面
// this.leavingList.forEach(item=>{
// item.isReplys = false;
// })
}else{
this.$message.error('回复留言失败');
} }
}) })
}, },
@@ -175,19 +174,22 @@
apiGuestbook.givelist(this.page).then(res=>{ apiGuestbook.givelist(this.page).then(res=>{
if(res.status == 200) { if(res.status == 200) {
this.count = res.result.count; this.count = res.result.count;
let ids=[];
res.result.list.forEach(item=>{ res.result.list.forEach(item=>{
if(!item.replysList){ if(!item.replyList){
item.replysList = []; item.replyList = [];
} }
ids.push(item.sysCreateAid);
item.isReplys = false; item.isReplys = false;
item.authorInfo = { aid: "",name: "",orgInfo: "",avatar: "",sex: null,sign:'' } item.authorInfo = { aid: "",name: "",orgInfo: "",avatar: "",sex: null,sign:'' }
if(item.replys != '' && item.replys.length>10) { item.replyList.forEach(child=>{
item.replysList = JSON.parse(item.replys); child.isReplys=false;
} child.authorInfo= { aid: "",name: "",orgInfo: "",avatar: "",sex: null,sign:'' }
//if() ids.push(child.sysCreateAid);
})
}) })
this.leavingList = res.result.list; this.leavingList = res.result.list;
this.getUserData(res.result.list); this.getUserData(ids,this.leavingList);
} }
}) })
}, },
@@ -210,46 +212,37 @@
} }
}) })
}, },
getUserData(list) { getUserData(ids,list) {
if(this.pageId == this.userInfo.aid) {
let ids = list.map(item=> item.aid); const noReapetIds = [...new Set(ids)];
const noReapetIds = [...new Set(ids)]; apiUser.getByIds(noReapetIds).then(res => {
apiUser.getByIds(noReapetIds).then(res => { if (res.status == 200) {
if (res.status == 200) { list.forEach((item, index) => {
list.forEach((item, index) => { res.result.some(author => {
res.result.some(author => { if (author.aid == item.sysCreateAid) {
if (author.aid == item.aid) { item.authorInfo = author;
item.authorInfo = author; return true;
return true; } else {
} else { return false;
return false; }
} });
}); item.replyList.forEach(child=>{
}); res.result.some(author => {
} else { if (author.aid == child.sysCreateAid) {
this.$message.error(res.message); child.authorInfo = author;
} return true;
}); } else {
} else { return false;
let ids = list.map(item=> item.sysCreateAid); }
const noReapetIds = [...new Set(ids)]; });
apiUser.getByIds(noReapetIds).then(res => { })
if (res.status == 200) { });
list.forEach((item, index) => { } else {
res.result.some(author => { this.$message.error(res.message);
if (author.aid == item.sysCreateAid) { }
item.authorInfo = author; });
return true;
} else {
return false;
}
});
});
} else {
this.$message.error(res.message);
}
});
}
}, },
handleSizeChange(val) { handleSizeChange(val) {
this.page.pageSize = val; this.page.pageSize = val;