feat: 添加子文章crud
This commit is contained in:
@@ -15,7 +15,6 @@ import { ref,watch } from 'vue';
|
||||
const outputHtml=ref("")
|
||||
const props = defineProps(['code'])
|
||||
watch(props,(n,o)=>{
|
||||
|
||||
marked.setOptions({
|
||||
renderer: new marked.Renderer(),
|
||||
highlight: function(code) {
|
||||
|
||||
@@ -38,7 +38,6 @@ onMounted(() => {
|
||||
//使用传入值
|
||||
if(props.userInfo!= undefined)
|
||||
{
|
||||
console.log(props.userInfo,"props.userInfo333");
|
||||
userInfo.icon=props.userInfo.icon;
|
||||
userInfo.name=props.userInfo.name;
|
||||
userInfo.role=props.userInfo.role;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<el-tree
|
||||
:data="props.data"
|
||||
:props="defaultProps"
|
||||
:data="data"
|
||||
:props="props.defaultProps"
|
||||
@node-click="handleNodeClick"
|
||||
:expand-on-click-node="false"
|
||||
node-key="id"
|
||||
@@ -9,8 +9,15 @@
|
||||
|
||||
<template #default="{ node, data }">
|
||||
<span class="custom-tree-node">
|
||||
<span>{{ node.label }}</span>
|
||||
<span>{{data.name}}</span>
|
||||
<span>
|
||||
|
||||
<a style="color: #409EFF; margin-left: 8px" @click="$emit('create',node, data)"
|
||||
|
||||
> + </a>
|
||||
<a style="color: #409EFF; margin-left: 8px" @click="$emit('update',node, data)"
|
||||
|
||||
> 编辑 </a>
|
||||
<a style="color: #f56c6c; margin-left: 8px" @click="$emit('remove',node, data)"
|
||||
|
||||
> 删除 </a>
|
||||
@@ -22,6 +29,7 @@
|
||||
<script setup>
|
||||
|
||||
const props = defineProps(['data'])
|
||||
const emits= defineEmits(["handleNodeClick"])
|
||||
//数据定义
|
||||
//子文章数据
|
||||
// const articleData =ref([]);
|
||||
@@ -37,6 +45,6 @@ const defaultProps = {
|
||||
// }
|
||||
//点击事件
|
||||
const handleNodeClick = (data) => {
|
||||
console.log(data);
|
||||
emits('handleNodeClick',data)
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Binary file not shown.
@@ -14,5 +14,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||
public string Name { get; set; }
|
||||
public long DiscussId { get; set; }
|
||||
public long ParentId { get; set; }
|
||||
|
||||
public List<ArticleAllOutputDto> Children { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||
{
|
||||
public class ArticleUpdateInputVo
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Content { get; set; }
|
||||
public string Name { get; set; }
|
||||
public long DiscussId { get; set; }
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace Yi.BBS.Application.Forum
|
||||
}
|
||||
|
||||
var entities = await _articleRepository.GetTreeAsync(x => x.DiscussId == discussId);
|
||||
var result = entities.Tile();
|
||||
var items = _mapper.Map<List<ArticleAllOutputDto>>(result);
|
||||
//var result = entities.Tile();
|
||||
var items = _mapper.Map<List<ArticleAllOutputDto>>(entities);
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user