修改评论删除权限不出来问题
This commit is contained in:
@@ -227,6 +227,16 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-dialog v-model="dialogVisible" title="提示" width="500">
|
||||
<span>确定删除该讨论吗?</span>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="confirmCommentDelete">确 定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
@@ -240,10 +250,12 @@ onMounted(() => {
|
||||
let permissions = ref([]);
|
||||
|
||||
onMounted(() => {
|
||||
// setTimeout(() => {
|
||||
// permissions.value = window["permissions"] || []
|
||||
// // permissions.value = ["comment.edit", "comment.delete"]
|
||||
// }, 1000)
|
||||
setTimeout(() => {
|
||||
// permissions.value = window["permissions"] || [];
|
||||
// if (process.env.NODE_ENV !== "production") permissions.value = ["comment.edit", "comment.delete"];
|
||||
// else
|
||||
permissions.value = window["permissions"] || [];
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
const emit = defineEmits();
|
||||
@@ -714,25 +726,61 @@ const closeUserInfo = (index, i) => {
|
||||
else if (index != undefined) commentList.value[index]["avatarState"] = false;
|
||||
};
|
||||
|
||||
// 点击删除
|
||||
// const commentDelete = (token, index, i) => {
|
||||
// $ajax("/api/comment/commentDelete", {
|
||||
// token,
|
||||
// }).then((res) => {
|
||||
// if (res.code != 200) {
|
||||
// ElMessage.error(res.message);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (i >= 0) {
|
||||
// commentList.value[index].child.splice(i, 1);
|
||||
// commentList.value[index].childnum -= 1;
|
||||
// } else {
|
||||
// commentTotalCount.value -= commentList.value[index].childnum;
|
||||
// commentList.value.splice(index, 1);
|
||||
// }
|
||||
|
||||
// commentTotalCount.value -= 1;
|
||||
// });
|
||||
// };
|
||||
|
||||
let dialogVisible = ref(false);
|
||||
let commemtDelete = {};
|
||||
// 点击删除
|
||||
const commentDelete = (token, index, i) => {
|
||||
$ajax("/api/comment/commentDelete", {
|
||||
commemtDelete = {
|
||||
token,
|
||||
index,
|
||||
i,
|
||||
};
|
||||
dialogVisible.value = true;
|
||||
};
|
||||
|
||||
const confirmCommentDelete = () => {
|
||||
$ajax("/api/comment/commentDelete", {
|
||||
token: commemtDelete.token,
|
||||
}).then((res) => {
|
||||
if (res.code != 200) {
|
||||
ElMessage.error(res.message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (i >= 0) {
|
||||
commentList.value[index].child.splice(i, 1);
|
||||
commentList.value[index].childnum -= 1;
|
||||
if (commemtDelete.i >= 0) {
|
||||
commentList.value[commemtDelete.index].child.splice(commemtDelete.i, 1);
|
||||
commentList.value[commemtDelete.index].childnum -= 1;
|
||||
} else {
|
||||
commentTotalCount.value -= commentList.value[index].childnum;
|
||||
commentList.value.splice(index, 1);
|
||||
commentTotalCount.value -= commentList.value[commemtDelete.index].childnum;
|
||||
commentList.value.splice(commemtDelete.index, 1);
|
||||
}
|
||||
|
||||
commentTotalCount.value -= 1;
|
||||
dialogVisible.value = false;
|
||||
|
||||
ElMessage.success(res.message || "操作成功");
|
||||
});
|
||||
};
|
||||
|
||||
@@ -830,4 +878,3 @@ const postEditComment = () => {
|
||||
|
||||
const closeEditFileUpload = () => (editPicture.value = {});
|
||||
</script>
|
||||
<style scoped></style>
|
||||
|
||||
Reference in New Issue
Block a user