@@ -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;