feat: 添加子文章crud
This commit is contained in:
@@ -8,17 +8,19 @@
|
||||
<InfoCard header="主题信息" text="展开" hideDivider="true">
|
||||
<template #content>
|
||||
<el-button style="width: 100%; margin-bottom: 0.8rem"
|
||||
@click="loadDiscuss"
|
||||
>首页</el-button
|
||||
>
|
||||
<el-button
|
||||
v-hasPer="['bbs:acticle:add']"
|
||||
v-hasPer="['bbs:article:add']"
|
||||
@click="addArticle(0)"
|
||||
type="primary"
|
||||
style="width: 100%; margin-bottom: 0.8rem; margin-left: 0"
|
||||
>添加子文章</el-button
|
||||
>
|
||||
<!--目录在这里 -->
|
||||
<TreeArticleInfo :data="articleData" @remove="delArticle" />
|
||||
<TreeArticleInfo :data="articleData" @remove="delArticle" @update="updateArticle"
|
||||
@create="addNextArticle" @handleNodeClick="handleNodeClick" />
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
@@ -78,6 +80,7 @@
|
||||
<template #content>
|
||||
<div>
|
||||
<ul class="art-info-ul">
|
||||
|
||||
<li>
|
||||
<el-button
|
||||
type="primary"
|
||||
@@ -227,6 +230,48 @@ const updateHander = (discussId) => {
|
||||
router.push(routerPer);
|
||||
};
|
||||
|
||||
//跳转添加子菜单
|
||||
const addNextArticle=(node,data)=>{
|
||||
//跳转路由
|
||||
var routerPer = {
|
||||
path: "/editArt",
|
||||
query: {
|
||||
operType: "create",
|
||||
artType: "article",
|
||||
discussId: data.discussId,
|
||||
parentArticleId: data.id,
|
||||
},
|
||||
};
|
||||
router.push(routerPer);
|
||||
}
|
||||
|
||||
//跳转更新子菜单
|
||||
const updateArticle=(node,data)=>{
|
||||
//跳转路由
|
||||
var routerPer = {
|
||||
path: "/editArt",
|
||||
query: {
|
||||
operType: "update",
|
||||
artType: "article",
|
||||
discussId: data.discussId,
|
||||
parentArticleId: data.parentId,
|
||||
articleId:data.id
|
||||
},
|
||||
};
|
||||
router.push(routerPer);
|
||||
}
|
||||
//单机节点
|
||||
const handleNodeClick=(data)=>{
|
||||
//加载目录
|
||||
var reg = /(#{1,6})\s(.*)/g;
|
||||
discuss.value.content=data.content;
|
||||
var myArray = discuss.value.content.match(reg);
|
||||
if (myArray != null) {
|
||||
catalogueData.value = myArray.map((x) => {
|
||||
return x.replace(/#/g, "").replace(/\s/g, "");
|
||||
});
|
||||
}
|
||||
}
|
||||
//删除子文章
|
||||
const delArticle=( node,data)=>{
|
||||
ElMessageBox.confirm(`确定是否删除编号[${data.id}]的子文章吗?`, "警告", {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
>
|
||||
<el-input placeholder="请输入" v-model="editForm.name" />
|
||||
</el-form-item>
|
||||
<el-form-item label="标题:" prop="title">
|
||||
<el-form-item v-else label="标题:" prop="title">
|
||||
<el-input placeholder="请输入" v-model="editForm.title" />
|
||||
</el-form-item>
|
||||
<el-form-item label="描述:" prop="introduction">
|
||||
@@ -67,9 +67,9 @@ import {
|
||||
} from "@/apis/discussApi.js";
|
||||
|
||||
import {
|
||||
add as acticleAdd,
|
||||
update as acticleUpdate,
|
||||
get as acticleGet,
|
||||
add as articleAdd,
|
||||
update as articleUpdate,
|
||||
get as articleGet,
|
||||
} from "@/apis/articleApi.js";
|
||||
|
||||
//数据定义
|
||||
@@ -136,20 +136,19 @@ const submit = async (formEl) => {
|
||||
//artcle文章处理
|
||||
else if (route.query.artType == "article") {
|
||||
//组装文章内容:需要添加的文章信息
|
||||
|
||||
article. content= editForm.content;
|
||||
article.content= editForm.content;
|
||||
article.name= editForm.name;
|
||||
article.discussId=route.query.discussId;
|
||||
article.parentId=route.query.parentArticleId
|
||||
//文章创建
|
||||
if (route.query.operType == "create") {
|
||||
await acticleAdd(article);
|
||||
await articleAdd(article);
|
||||
}
|
||||
//文章更新
|
||||
else if (route.query.operType == "update") {
|
||||
await articleUpdate(route.query.articleId, article);
|
||||
}
|
||||
}
|
||||
|
||||
//添加成功后跳转到该页面
|
||||
var routerPer = { path: `/discuss/${discuss.plateId}` };
|
||||
router.push(routerPer);
|
||||
@@ -168,8 +167,8 @@ onMounted(async () => {
|
||||
await loadDiscuss();
|
||||
|
||||
//更新文章
|
||||
} else if (route.query.artType == "acticle") {
|
||||
await loadActicle();
|
||||
} else if (route.query.artType == "article") {
|
||||
await loadArticle();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -183,11 +182,11 @@ const loadDiscuss = async () => {
|
||||
discuss.plateId=response.plateId;
|
||||
};
|
||||
//加载文章
|
||||
const loadActicle = async () => {
|
||||
const response = await acticleGet(route.query.acticleId);
|
||||
const loadArticle = async () => {
|
||||
const response = await articleGet(route.query.articleId);
|
||||
editForm.content = response.content;
|
||||
editForm.name = response.name;
|
||||
// editForm.discussId = response.discussId;
|
||||
editForm.discussId = response.discussId;
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user