mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-10 03:16:42 +08:00
留言调
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
<p>{{item.content}}</p>
|
||||
</div>
|
||||
<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">
|
||||
<interactBar :type="7" :data="item" :comments="false" :shares="false" :views="false" :favorites="false"></interactBar>
|
||||
</div>
|
||||
@@ -29,10 +29,10 @@
|
||||
<!-- 回复框 -->
|
||||
<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-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 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="li-img"><author-img :avatar="rep.authorInfo.avatar" :aid="rep.authorInfo.aid" :sex="rep.authorInfo.sex"></author-img></div>
|
||||
<div class="li-text">
|
||||
@@ -111,23 +111,14 @@
|
||||
},
|
||||
delReplySon(item,index) { //子级的删除手动删掉,调用保存接口
|
||||
//修改后,替换为下面的情况
|
||||
// apiGuestbook.del(item.id).then(res=>{
|
||||
// if(res.status==200){
|
||||
// item.replysList.splice(index,1);
|
||||
// }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('删除留言成功');
|
||||
apiGuestbook.del(item.id).then(res=>{
|
||||
if(res.status==200){
|
||||
item.replyList.splice(index,1);
|
||||
this.$message.success('删除成功');
|
||||
}else{
|
||||
this.$message.error('删除失败'+res.message);
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
delReply(item) {
|
||||
this.$confirm('此操作将永久删除该留言, 是否继续?', '提示', {
|
||||
@@ -145,28 +136,36 @@
|
||||
this.$message({type: 'info', message: '已取消删除'});
|
||||
});
|
||||
},
|
||||
isReplys(item,idx) {
|
||||
showReplyInput(item,idx) {
|
||||
item.isReplys = true;
|
||||
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) {
|
||||
return this.$message.warning('请填写内容!');
|
||||
}
|
||||
this.replysData.reply.push({
|
||||
content: this.replysContent,
|
||||
authorInfo:this.userInfo,
|
||||
praises:0,
|
||||
})
|
||||
this.replysData.reply = JSON.stringify(this.replysData.reply);
|
||||
apiGuestbook.answer(this.replysData).then(res=>{
|
||||
let postData={
|
||||
content:this.replysContent,
|
||||
topId:top.id,
|
||||
parentId:p.id,
|
||||
level:2,
|
||||
replys:0
|
||||
}
|
||||
let $this=this;
|
||||
apiGuestbook.answer(postData).then(res=>{
|
||||
this.replysContent = '';
|
||||
if(res.status == 200) {
|
||||
this.$message.success('留言发布成功');
|
||||
this.leavingList.forEach(item=>{
|
||||
item.isReplys = false;
|
||||
})
|
||||
this.$message.success('回复留言成功');
|
||||
p.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=>{
|
||||
if(res.status == 200) {
|
||||
this.count = res.result.count;
|
||||
let ids=[];
|
||||
res.result.list.forEach(item=>{
|
||||
if(!item.replysList){
|
||||
item.replysList = [];
|
||||
if(!item.replyList){
|
||||
item.replyList = [];
|
||||
}
|
||||
ids.push(item.sysCreateAid);
|
||||
item.isReplys = false;
|
||||
item.authorInfo = { aid: "",name: "",orgInfo: "",avatar: "",sex: null,sign:'' }
|
||||
if(item.replys != '' && item.replys.length>10) {
|
||||
item.replysList = JSON.parse(item.replys);
|
||||
}
|
||||
//if()
|
||||
item.replyList.forEach(child=>{
|
||||
child.isReplys=false;
|
||||
child.authorInfo= { aid: "",name: "",orgInfo: "",avatar: "",sex: null,sign:'' }
|
||||
ids.push(child.sysCreateAid);
|
||||
})
|
||||
})
|
||||
this.leavingList = res.result.list;
|
||||
this.getUserData(res.result.list);
|
||||
this.getUserData(ids,this.leavingList);
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -210,46 +212,37 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
getUserData(list) {
|
||||
if(this.pageId == this.userInfo.aid) {
|
||||
let ids = list.map(item=> item.aid);
|
||||
const noReapetIds = [...new Set(ids)];
|
||||
apiUser.getByIds(noReapetIds).then(res => {
|
||||
if (res.status == 200) {
|
||||
list.forEach((item, index) => {
|
||||
res.result.some(author => {
|
||||
if (author.aid == item.aid) {
|
||||
item.authorInfo = author;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.$message.error(res.message);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
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) => {
|
||||
res.result.some(author => {
|
||||
if (author.aid == item.sysCreateAid) {
|
||||
item.authorInfo = author;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.$message.error(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
getUserData(ids,list) {
|
||||
|
||||
const noReapetIds = [...new Set(ids)];
|
||||
apiUser.getByIds(noReapetIds).then(res => {
|
||||
if (res.status == 200) {
|
||||
list.forEach((item, index) => {
|
||||
res.result.some(author => {
|
||||
if (author.aid == item.sysCreateAid) {
|
||||
item.authorInfo = author;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
item.replyList.forEach(child=>{
|
||||
res.result.some(author => {
|
||||
if (author.aid == child.sysCreateAid) {
|
||||
child.authorInfo = author;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
} else {
|
||||
this.$message.error(res.message);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.page.pageSize = val;
|
||||
|
||||
Reference in New Issue
Block a user