feat: 完成子文章的操作
This commit is contained in:
41
Yi.BBS.Vue3/src/apis/articleApi.js
Normal file
41
Yi.BBS.Vue3/src/apis/articleApi.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import myaxios from '@/utils/request'
|
||||
export function getList(data){
|
||||
return myaxios({
|
||||
url: '/article',
|
||||
method: 'get',
|
||||
params:data
|
||||
})
|
||||
};
|
||||
export function get(id){
|
||||
return myaxios({
|
||||
url: `/article/${id}`,
|
||||
method: 'get'
|
||||
})
|
||||
};
|
||||
export function add(data){
|
||||
return myaxios({
|
||||
url: `/article`,
|
||||
method: 'post',
|
||||
data:data
|
||||
})
|
||||
};
|
||||
export function update(id,data){
|
||||
return myaxios({
|
||||
url: `/article/${id}`,
|
||||
method: 'put',
|
||||
data:data
|
||||
})
|
||||
};
|
||||
export function del(ids){
|
||||
return myaxios({
|
||||
url: `/article/${ids}`,
|
||||
method: 'delete'
|
||||
})
|
||||
};
|
||||
export function all(discussId)
|
||||
{
|
||||
return myaxios({
|
||||
url: `/article/all/discuss-id/${discussId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
@@ -26,3 +26,9 @@ export function update(id,data){
|
||||
data:data
|
||||
})
|
||||
};
|
||||
export function del(ids){
|
||||
return myaxios({
|
||||
url: `/discuss/${ids}`,
|
||||
method: 'delete'
|
||||
})
|
||||
};
|
||||
42
Yi.BBS.Vue3/src/components/TreeArticleInfo.vue
Normal file
42
Yi.BBS.Vue3/src/components/TreeArticleInfo.vue
Normal file
@@ -0,0 +1,42 @@
|
||||
<template>
|
||||
<el-tree
|
||||
:data="props.data"
|
||||
:props="defaultProps"
|
||||
@node-click="handleNodeClick"
|
||||
:expand-on-click-node="false"
|
||||
node-key="id"
|
||||
>
|
||||
|
||||
<template #default="{ node, data }">
|
||||
<span class="custom-tree-node">
|
||||
<span>{{ node.label }}</span>
|
||||
<span>
|
||||
<a style="color: #f56c6c; margin-left: 8px" @click="$emit('remove',node, data)"
|
||||
|
||||
> 删除 </a>
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
</template>
|
||||
<script setup>
|
||||
|
||||
const props = defineProps(['data'])
|
||||
//数据定义
|
||||
//子文章数据
|
||||
// const articleData =ref([]);
|
||||
//树形子文章选项
|
||||
const defaultProps = {
|
||||
children: "children",
|
||||
label: "name",
|
||||
};
|
||||
// //子文章初始化
|
||||
// const loadArticleData=async()=>
|
||||
// {
|
||||
// articleData.value= await articleall(route.params.discussId);
|
||||
// }
|
||||
//点击事件
|
||||
const handleNodeClick = (data) => {
|
||||
console.log(data);
|
||||
};
|
||||
</script>
|
||||
@@ -16,9 +16,9 @@ background-color:#F0F2F5;
|
||||
|
||||
}
|
||||
.content-main{
|
||||
/* max-width:1200px; */
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
min-height: 1150px;
|
||||
}
|
||||
</style>
|
||||
@@ -33,7 +33,7 @@ const router = createRouter({
|
||||
//artType:discuss主题、article文章
|
||||
//operType:create创建、update更新
|
||||
name:'editArt',
|
||||
path:'/editArt/:artType/:operType/:id',
|
||||
path:'/editArt',
|
||||
component:()=>import('../views/EditArticle.vue')
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,320 +1,332 @@
|
||||
<template>
|
||||
<div style="width: 90%;min-width: 1200px;">
|
||||
<!-- <div style="width: 1200px;"> -->
|
||||
<el-row :gutter="20" class="top-div">
|
||||
|
||||
<el-col :span="5">
|
||||
<el-row class="art-info-left">
|
||||
|
||||
<el-col :span="24">
|
||||
<InfoCard header="主题信息" text="展开" hideDivider="true">
|
||||
<template #content>
|
||||
<el-button style="width: 100%;margin-bottom: 0.8rem;">首页</el-button>
|
||||
<el-tree :data="data" @node-click="handleNodeClick" />
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<InfoCard :items=items header="推荐好友" text="更多">
|
||||
<template #item="temp">
|
||||
<AvatarInfo />
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<InfoCard :items=items header="推荐好友" text="更多">
|
||||
<template #item="temp">
|
||||
<AvatarInfo />
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
|
||||
|
||||
</el-row>
|
||||
|
||||
</el-col>
|
||||
|
||||
<el-col :span="14">
|
||||
|
||||
<el-row class="left-div">
|
||||
<el-col :span="24">
|
||||
<AvatarInfo :size="50" :showWatching="true" :time="'2023-03-08 21:09:02'"></AvatarInfo>
|
||||
|
||||
<el-divider />
|
||||
<h2>{{discuss.title}}</h2>
|
||||
<ArticleContentInfo :code="discuss.content"></ArticleContentInfo>
|
||||
|
||||
<el-divider class="tab-divider" />
|
||||
|
||||
|
||||
<el-space :size="10" :spacer="spacer">
|
||||
<el-button icon="Pointer" text>
|
||||
4</el-button>
|
||||
<el-button icon="Star" text>
|
||||
0</el-button>
|
||||
<el-button icon="Share" text>
|
||||
分享</el-button>
|
||||
<el-button icon="Operation" text>
|
||||
操作</el-button>
|
||||
</el-space>
|
||||
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="comment">
|
||||
文章评论
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</el-col>
|
||||
|
||||
<el-col :span="5">
|
||||
<el-row class="right-div">
|
||||
<el-col :span="24">
|
||||
<InfoCard class="art-info-right" header="文章信息" text="更多" hideDivider="true">
|
||||
<template #content>
|
||||
<div>
|
||||
|
||||
|
||||
|
||||
<ul class="art-info-ul">
|
||||
<li>
|
||||
|
||||
<RouterLink :to='`/editArt/discuss/update/${route.params.discussId}`'> <el-button type="primary" size="default" >编辑</el-button></RouterLink>
|
||||
</li>
|
||||
<li>
|
||||
分类: <span>文章</span>
|
||||
</li>
|
||||
标签: <el-tag type="success">文章</el-tag>
|
||||
<el-tag type="info">资源</el-tag>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<InfoCard class="art-info-right" header="目录" hideDivider="true">
|
||||
<template #content>
|
||||
<div>
|
||||
<ul class="art-info-ul">
|
||||
<li v-for="(item,i) in catalogueData" :key="i">
|
||||
<el-button style="width: 100%;justify-content: left" type="primary" text>{{ `${i+1} : ${item}` }}</el-button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<InfoCard :items=items header="推荐好友" text="更多">
|
||||
<template #item="temp">
|
||||
<AvatarInfo />
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<InfoCard :items=items header="推荐好友" text="更多">
|
||||
<template #item="temp">
|
||||
<AvatarInfo />
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
<div style="width: 90%; min-width: 1200px">
|
||||
<!-- <div style="width: 1200px;"> -->
|
||||
<el-row :gutter="20" class="top-div">
|
||||
<el-col :span="5">
|
||||
<el-row class="art-info-left">
|
||||
<el-col :span="24">
|
||||
<InfoCard header="主题信息" text="展开" hideDivider="true">
|
||||
<template #content>
|
||||
<el-button style="width: 100%; margin-bottom: 0.8rem"
|
||||
>首页</el-button
|
||||
>
|
||||
<el-button
|
||||
@click="addArticle(0)"
|
||||
type="primary"
|
||||
style="width: 100%; margin-bottom: 0.8rem; margin-left: 0"
|
||||
>添加子文章</el-button
|
||||
>
|
||||
<!--目录在这里 -->
|
||||
<TreeArticleInfo :data="articleData" @remove="delArticle" />
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<InfoCard :items="items" header="推荐好友" text="更多">
|
||||
<template #item="temp">
|
||||
<AvatarInfo />
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<InfoCard :items="items" header="推荐好友" text="更多">
|
||||
<template #item="temp">
|
||||
<AvatarInfo />
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="14">
|
||||
<el-row class="left-div">
|
||||
<el-col :span="24">
|
||||
<AvatarInfo
|
||||
:size="50"
|
||||
:showWatching="true"
|
||||
:time="'2023-03-08 21:09:02'"
|
||||
></AvatarInfo>
|
||||
|
||||
<el-divider />
|
||||
<h2>{{ discuss.title }}</h2>
|
||||
<ArticleContentInfo :code="discuss.content"></ArticleContentInfo>
|
||||
|
||||
<el-divider class="tab-divider" />
|
||||
|
||||
<el-space :size="10" :spacer="spacer">
|
||||
<el-button icon="Pointer" text> 4</el-button>
|
||||
<el-button icon="Star" text> 0</el-button>
|
||||
<el-button icon="Share" text> 分享</el-button>
|
||||
<el-button icon="Operation" text> 操作</el-button>
|
||||
</el-space>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="comment"> 文章评论 </el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="5">
|
||||
<el-row class="right-div">
|
||||
<el-col :span="24">
|
||||
<InfoCard
|
||||
class="art-info-right"
|
||||
header="文章信息"
|
||||
text="更多"
|
||||
hideDivider="true"
|
||||
>
|
||||
<template #content>
|
||||
<div>
|
||||
<ul class="art-info-ul">
|
||||
<li>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="default"
|
||||
@click="updateHander(route.params.discussId)"
|
||||
>编辑</el-button
|
||||
>
|
||||
<el-button
|
||||
style="margin-left: 1rem"
|
||||
type="danger"
|
||||
@click="delHander(route.params.discussId)"
|
||||
>删除</el-button
|
||||
>
|
||||
</li>
|
||||
<li>分类: <span>文章</span></li>
|
||||
标签:
|
||||
<el-tag type="success">文章</el-tag>
|
||||
<el-tag type="info">资源</el-tag>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<InfoCard class="art-info-right" header="目录" hideDivider="true">
|
||||
<template #content>
|
||||
<div>
|
||||
<ul class="art-info-ul">
|
||||
<li v-for="(item, i) in catalogueData" :key="i">
|
||||
<el-button
|
||||
style="width: 100%; justify-content: left"
|
||||
type="primary"
|
||||
text
|
||||
>{{ `${i + 1} : ${item}` }}</el-button
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<InfoCard :items="items" header="推荐好友" text="更多">
|
||||
<template #item="temp">
|
||||
<AvatarInfo />
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<InfoCard :items="items" header="推荐好友" text="更多">
|
||||
<template #item="temp">
|
||||
<AvatarInfo />
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { h, ref ,onMounted } from 'vue'
|
||||
import AvatarInfo from '@/components/AvatarInfo.vue'
|
||||
import InfoCard from '@/components/InfoCard.vue';
|
||||
import ArticleContentInfo from '@/components/ArticleContentInfo.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { h, ref, onMounted } from "vue";
|
||||
import AvatarInfo from "@/components/AvatarInfo.vue";
|
||||
import InfoCard from "@/components/InfoCard.vue";
|
||||
import ArticleContentInfo from "@/components/ArticleContentInfo.vue";
|
||||
|
||||
import {get as discussGet} from '@/apis/discussApi.js';
|
||||
import TreeArticleInfo from "@/components/TreeArticleInfo.vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import { get as discussGet, del as discussDel } from "@/apis/discussApi.js";
|
||||
import {all as articleall,del as articleDel} from "@/apis/articleApi.js";
|
||||
//数据定义
|
||||
const route=useRoute()
|
||||
const spacer = h(ElDivider, { direction: 'vertical' })
|
||||
const items = [{ user: "用户1" }, { user: "用户2" }, { user: "用户3" }]
|
||||
const handleNodeClick = (data) => {
|
||||
console.log(data)
|
||||
}
|
||||
const data = [
|
||||
{
|
||||
label: 'HTML',
|
||||
children: [
|
||||
{
|
||||
label: 'Level two 1-1',
|
||||
children: [
|
||||
{
|
||||
label: 'Level three 1-1-1',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'HTML5',
|
||||
children: [
|
||||
{
|
||||
label: 'Level two 2-1',
|
||||
children: [
|
||||
{
|
||||
label: 'Level three 2-1-1',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Level two 2-2',
|
||||
children: [
|
||||
{
|
||||
label: 'Level three 2-2-1',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'XHTML',
|
||||
children: [
|
||||
{
|
||||
label: 'Level two 3-1',
|
||||
children: [
|
||||
{
|
||||
label: 'Level three 3-1-1',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Level two 3-2',
|
||||
children: [
|
||||
{
|
||||
label: 'Level three 3-2-1',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Xcss',
|
||||
},
|
||||
{
|
||||
label: 'CSS3',
|
||||
},
|
||||
{
|
||||
label: 'Bootstrap 5',
|
||||
},
|
||||
{
|
||||
label: 'Tcp/ip',
|
||||
}
|
||||
]
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const spacer = h(ElDivider, { direction: "vertical" });
|
||||
const items = [{ user: "用户1" }, { user: "用户2" }, { user: "用户3" }];
|
||||
|
||||
|
||||
//子文章数据
|
||||
const articleData =ref([]);
|
||||
//主题内容
|
||||
const discuss=ref({});
|
||||
const discuss = ref({});
|
||||
|
||||
//目录数据
|
||||
const catalogueData=ref([]);
|
||||
const catalogueData = ref([]);
|
||||
|
||||
//子文章初始化
|
||||
const loadArticleData=async()=>
|
||||
{
|
||||
articleData.value= await articleall(route.params.discussId);
|
||||
}
|
||||
|
||||
//主题初始化
|
||||
const loadDiscuss=async()=>{
|
||||
discuss.value= await discussGet(route.params.discussId);
|
||||
//加载目录
|
||||
var reg = /(#{1,6})\s(.*)/g;
|
||||
var myArray =discuss.value.content.match(reg);
|
||||
if(myArray!=null)
|
||||
{
|
||||
catalogueData.value= myArray.map(x=>{ return x.replace(/#/g,"").replace(/\s/g,'')})
|
||||
}
|
||||
|
||||
const loadDiscuss = async () => {
|
||||
discuss.value = await discussGet(route.params.discussId);
|
||||
//加载目录
|
||||
var reg = /(#{1,6})\s(.*)/g;
|
||||
var myArray = discuss.value.content.match(reg);
|
||||
if (myArray != null) {
|
||||
catalogueData.value = myArray.map((x) => {
|
||||
return x.replace(/#/g, "").replace(/\s/g, "");
|
||||
});
|
||||
}
|
||||
};
|
||||
//添加树型子文章
|
||||
const addArticle = (parentArticleId) => {
|
||||
//跳转路由
|
||||
var routerPer = {
|
||||
path: "/editArt",
|
||||
query: {
|
||||
operType: "create",
|
||||
artType: "article",
|
||||
discussId: route.params.discussId,
|
||||
parentArticleId: parentArticleId,
|
||||
},
|
||||
};
|
||||
router.push(routerPer);
|
||||
};
|
||||
|
||||
//删除主题
|
||||
const delHander = async (ids) => {
|
||||
ElMessageBox.confirm(`确定是否删除编号[${ids}]的主题吗?`, "警告", {
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(async () => {
|
||||
const response = await discussDel(ids);
|
||||
//删除成功后,跳转到主页
|
||||
router.push("/index");
|
||||
ElMessage({
|
||||
type: "success",
|
||||
message: "删除成功",
|
||||
});
|
||||
});
|
||||
};
|
||||
//更新操作
|
||||
const updateHander = (discussId) => {
|
||||
//跳转路由
|
||||
var routerPer = {
|
||||
path: "/editArt",
|
||||
query: {
|
||||
operType: "update",
|
||||
artType: "discuss",
|
||||
discussId: discussId,
|
||||
},
|
||||
};
|
||||
router.push(routerPer);
|
||||
};
|
||||
|
||||
//删除子文章
|
||||
const delArticle=( node,data)=>{
|
||||
ElMessageBox.confirm(`确定是否删除编号[${data.id}]的子文章吗?`, "警告", {
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(async () => {
|
||||
|
||||
await articleDel(data.id);
|
||||
await loadArticleData();
|
||||
|
||||
ElMessage({
|
||||
type: "success",
|
||||
message: "删除成功",
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
onMounted(async()=>{
|
||||
await loadDiscuss();
|
||||
|
||||
})
|
||||
onMounted(async () => {
|
||||
await loadDiscuss();
|
||||
await loadArticleData();
|
||||
});
|
||||
</script>
|
||||
<style scoped >
|
||||
.comment
|
||||
{
|
||||
height:40rem;
|
||||
.comment {
|
||||
height: 40rem;
|
||||
}
|
||||
.art-info-left .el-col {
|
||||
margin-bottom: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.art-info-ul span {
|
||||
margin-left: 1rem;
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
.art-info-ul .el-tag {
|
||||
margin-left: 1rem;
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
.art-info-ul {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
li {
|
||||
list-style: none;
|
||||
margin-bottom: 0.5rem;
|
||||
list-style: none;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.art-info-right {
|
||||
height: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.left-div .el-col {
|
||||
background-color: #FFFFFF;
|
||||
min-height: 12rem;
|
||||
margin-bottom: 1rem;
|
||||
background-color: #ffffff;
|
||||
min-height: 12rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.right-div .el-col {
|
||||
background-color: #FFFFFF;
|
||||
min-height: 10rem;
|
||||
margin-bottom: 1rem;
|
||||
background-color: #ffffff;
|
||||
min-height: 10rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
|
||||
.left-top-div .el-col {
|
||||
min-height: 2rem;
|
||||
background-color: #FAFAFA;
|
||||
margin-bottom: 1rem;
|
||||
margin-left: 10px;
|
||||
min-height: 2rem;
|
||||
background-color: #fafafa;
|
||||
margin-bottom: 1rem;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.top-div {
|
||||
padding-top: 1rem;
|
||||
padding-top: 1rem;
|
||||
}
|
||||
|
||||
.left-top-div {
|
||||
font-size: small;
|
||||
text-align: center;
|
||||
line-height: 2rem;
|
||||
font-size: small;
|
||||
text-align: center;
|
||||
line-height: 2rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-bottom: .5em;
|
||||
color: rgba(0, 0, 0, .85);
|
||||
font-weight: 600;
|
||||
font-size: 30px;
|
||||
line-height: 1.35;
|
||||
margin-bottom: 0.5em;
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
font-weight: 600;
|
||||
font-size: 30px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.left-div .el-col {
|
||||
padding: 1.4rem 1.4rem 0.5rem 1.4rem;
|
||||
|
||||
padding: 1.4rem 1.4rem 0.5rem 1.4rem;
|
||||
}
|
||||
|
||||
.el-space {
|
||||
display: flex;
|
||||
vertical-align: top;
|
||||
justify-content: space-evenly;
|
||||
display: flex;
|
||||
vertical-align: top;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
|
||||
.tab-divider {
|
||||
margin-bottom: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -104,7 +104,13 @@ const loadDiscussList=async()=>{
|
||||
|
||||
//进入添加主题页面
|
||||
const enterEditArticle=()=>{
|
||||
router.push(`/editArt/discuss/create/${route.params.plateId}`)
|
||||
//跳转路由
|
||||
var routerPer= { path: '/editArt', query: {
|
||||
operType: 'create',
|
||||
artType:'discuss',
|
||||
plateId:route.params.plateId,
|
||||
}}
|
||||
router.push(routerPer);
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
@@ -1,111 +1,194 @@
|
||||
<template>
|
||||
<div style="width: 100%;">
|
||||
<div style="width: 100%">
|
||||
<div class="body-div">
|
||||
<el-form label-width="120px" :model="discuss" label-position="left" :rules="rules" ref="ruleFormRef">
|
||||
|
||||
<el-form
|
||||
label-width="120px"
|
||||
:model="editForm"
|
||||
label-position="left"
|
||||
:rules="rules"
|
||||
ref="ruleFormRef"
|
||||
>
|
||||
<el-form-item label="分类:">
|
||||
<el-radio-group v-model="radio">
|
||||
<el-radio-button label="1">文章</el-radio-button>
|
||||
<el-radio-button label="2">主题</el-radio-button>
|
||||
<el-radio-button label="3">板块</el-radio-button>
|
||||
<el-radio-button label="4">其他</el-radio-button>
|
||||
<el-radio-button label="discuss">主题</el-radio-button>
|
||||
<el-radio-button label="article">文章</el-radio-button>
|
||||
<el-radio-button label="plate">板块</el-radio-button>
|
||||
<el-radio-button label="orther">其他</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="route.query.artType == 'article'"
|
||||
label="名称:"
|
||||
prop="name"
|
||||
>
|
||||
<el-input placeholder="请输入" v-model="editForm.name" />
|
||||
</el-form-item>
|
||||
<el-form-item label="标题:" prop="title">
|
||||
<el-input placeholder="请输入" v-model="discuss.title" />
|
||||
<el-input placeholder="请输入" v-model="editForm.title" />
|
||||
</el-form-item>
|
||||
<el-form-item label="描述:" prop="introduction">
|
||||
<el-input placeholder="请输入" v-model="discuss.introduction" />
|
||||
<el-input placeholder="请输入" v-model="editForm.introduction" />
|
||||
</el-form-item>
|
||||
<el-form-item label="内容:" prop="content">
|
||||
{{ discuss.content + "[111]" }}
|
||||
<MavonEdit height="30rem" v-model="discuss.content" :codeStyle="codeStyle" />
|
||||
{{ editForm.content + "*" }}
|
||||
<MavonEdit
|
||||
height="30rem"
|
||||
v-model="editForm.content"
|
||||
:codeStyle="codeStyle"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="封面:">
|
||||
<el-input placeholder="请输入" />
|
||||
</el-form-item>
|
||||
<el-form-item label="标签:" prop="types">
|
||||
<el-input placeholder="请输入" v-model="discuss.types" />
|
||||
<el-input placeholder="请输入" v-model="editForm.types" />
|
||||
</el-form-item>
|
||||
<el-form-item> <el-button @click="submit(ruleFormRef)" class="submit-btn"
|
||||
type="primary">提交</el-button></el-form-item>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
@click="submit(ruleFormRef)"
|
||||
class="submit-btn"
|
||||
type="primary"
|
||||
>提交</el-button
|
||||
></el-form-item
|
||||
>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import MavonEdit from '@/components/MavonEdit.vue'
|
||||
import { ref, reactive,onMounted } from 'vue';
|
||||
import { useRoute } from 'vue-router'
|
||||
import MavonEdit from "@/components/MavonEdit.vue";
|
||||
import { ref, reactive, onMounted } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import { add as discussAdd, update as discussUpdate,get as discussGet } from '@/apis/discussApi.js'
|
||||
import {
|
||||
add as discussAdd,
|
||||
update as discussUpdate,
|
||||
get as discussGet,
|
||||
} from "@/apis/discussApi.js";
|
||||
|
||||
import {
|
||||
add as acticleAdd,
|
||||
update as acticleUpdate,
|
||||
get as acticleGet,
|
||||
} from "@/apis/articleApi.js";
|
||||
|
||||
//数据定义
|
||||
const route = useRoute()
|
||||
const radio = ref(1)
|
||||
const codeStyle = "atom-one-dark"
|
||||
//需要添加的主题信息
|
||||
const discuss = reactive({
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const radio = ref(route.query.artType);
|
||||
const codeStyle = "atom-one-dark";
|
||||
|
||||
//整个页面上的表单
|
||||
const editForm = reactive({
|
||||
title: "",
|
||||
types: "",
|
||||
introduction: "",
|
||||
content: "",
|
||||
plateId: route.params.id
|
||||
name: ""
|
||||
});
|
||||
|
||||
//组装主题内容: 需要更新主题信息
|
||||
const discuss = {
|
||||
|
||||
};
|
||||
|
||||
//组装文章内容:需要添加的文章信息
|
||||
const article = {
|
||||
};
|
||||
|
||||
//定义效验规则
|
||||
const ruleFormRef = ref(null)
|
||||
const ruleFormRef = ref(null);
|
||||
const rules = reactive({
|
||||
title: [
|
||||
{ required: true, message: '请输入标题', trigger: 'blur' },
|
||||
{ min: 3, max: 20, message: '长度 3 到 20', trigger: 'blur' },
|
||||
{ required: true, message: "请输入标题", trigger: "blur" },
|
||||
{ min: 3, max: 20, message: "长度 3 到 20", trigger: "blur" },
|
||||
],
|
||||
|
||||
})
|
||||
content: [
|
||||
{ required: true, message: "请输入内容", trigger: "blur" },
|
||||
{ min: 10, max: 4000, message: "长度 10 到4000", trigger: "blur" },
|
||||
],
|
||||
});
|
||||
//提交按钮,需要区分操作类型
|
||||
const submit = async (formEl) => {
|
||||
if (!formEl) return
|
||||
if (!formEl) return;
|
||||
await formEl.validate(async (valid, fields) => {
|
||||
if (valid) {
|
||||
//创建
|
||||
if (route.params.operType == 'create') {
|
||||
await discussAdd(discuss)
|
||||
//dicuss主题处理
|
||||
if (route.query.artType == "discuss") {
|
||||
|
||||
}
|
||||
//更新
|
||||
else if (route.params.operType == 'update') {
|
||||
await discussUpdate(route.params.id, discuss)
|
||||
|
||||
discuss.title=editForm.title;
|
||||
discuss.types= editForm.types;
|
||||
discuss.introduction= editForm.introduction;
|
||||
discuss.content= editForm.content;
|
||||
discuss.plateId= discuss.plateId??route.query.plateId
|
||||
|
||||
//主题创建
|
||||
if (route.query.operType == "create") {
|
||||
await discussAdd(discuss);
|
||||
}
|
||||
//主题更新
|
||||
else if (route.query.operType == "update") {
|
||||
await discussUpdate(route.query.discussId, discuss);
|
||||
}
|
||||
}
|
||||
|
||||
ruleFormRef.value.resetFields();
|
||||
discuss.plateId = route.params.id;
|
||||
//artcle文章处理
|
||||
else if (route.query.artType == "article") {
|
||||
//组装文章内容:需要添加的文章信息
|
||||
|
||||
article. content= editForm.content;
|
||||
article.name= editForm.name;
|
||||
article.discussId=route.query.discussId;
|
||||
//文章创建
|
||||
if (route.query.operType == "create") {
|
||||
await acticleAdd(article);
|
||||
}
|
||||
//文章更新
|
||||
else if (route.query.operType == "update") {
|
||||
await articleUpdate(route.query.articleId, article);
|
||||
}
|
||||
}
|
||||
|
||||
//添加成功后跳转到该页面
|
||||
var routerPer = { path: `/discuss/${discuss.plateId}` };
|
||||
router.push(routerPer);
|
||||
// ruleFormRef.value.resetFields();
|
||||
// discuss.plateId = route.query.plateId;
|
||||
}
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
onMounted(async()=>{
|
||||
onMounted(async () => {
|
||||
//如果是更新操作,需要先查询
|
||||
if (route.params.operType == 'update') {
|
||||
await loadDiscuss();
|
||||
}
|
||||
})
|
||||
//加载主题
|
||||
const loadDiscuss=async()=>{
|
||||
const response= await discussGet(route.params.id);
|
||||
discuss.content= response.content;
|
||||
discuss.title= response.title;
|
||||
discuss.types= response.types;
|
||||
discuss.introduction= response.introduction;
|
||||
}
|
||||
// const clear = (source) => {
|
||||
// const keys = Object.keys(source);
|
||||
// let obj = {};
|
||||
// keys.forEach((item) => {
|
||||
// obj[item] = "";
|
||||
// });
|
||||
// Object.assign(source, obj);
|
||||
// };
|
||||
if (route.query.operType == "update") {
|
||||
|
||||
//更新主题
|
||||
if (route.query.artType == "discuss") {
|
||||
await loadDiscuss();
|
||||
|
||||
//更新文章
|
||||
} else if (route.query.artType == "acticle") {
|
||||
await loadActicle();
|
||||
}
|
||||
}
|
||||
});
|
||||
//加载主题
|
||||
const loadDiscuss = async () => {
|
||||
const response = await discussGet(route.query.discussId);
|
||||
editForm.content = response.content;
|
||||
editForm.title = response.title;
|
||||
editForm.types = response.types;
|
||||
editForm.introduction = response.introduction;
|
||||
discuss.plateId=response.plateId;
|
||||
};
|
||||
//加载文章
|
||||
const loadActicle = async () => {
|
||||
const response = await acticleGet(route.query.acticleId);
|
||||
editForm.content = response.content;
|
||||
editForm.name = response.name;
|
||||
// editForm.discussId = response.discussId;
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
.submit-btn {
|
||||
|
||||
@@ -94,16 +94,20 @@ import BottomInfo from '@/components/BottomInfo.vue'
|
||||
|
||||
import {getList} from '@/apis/plateApi.js'
|
||||
import {getList as discussGetList} from '@/apis/discussApi.js'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { onMounted, ref ,reactive} from 'vue'
|
||||
var plateList=ref([]);
|
||||
var discussList=ref([]);
|
||||
const items=[{user:"用户1"},{user:"用户2"},{user:"用户3"}]
|
||||
|
||||
//主题查询参数
|
||||
const query=reactive({
|
||||
pageNum:1,
|
||||
pageSize:10,
|
||||
});
|
||||
onMounted(async()=>{
|
||||
const response= await getList();
|
||||
plateList.value= response.items;
|
||||
|
||||
const discussReponse=await discussGetList();
|
||||
const discussReponse=await discussGetList(query);
|
||||
discussList.value= discussReponse.items;
|
||||
});
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.FileManager",
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.MultiTenancy", "src\framework\Yi.Framework.MultiTenancy\Yi.Framework.MultiTenancy.csproj", "{590B1EC0-CDA9-4937-BE07-FBB04437D21F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.DictionaryManager", "Yi.Framework.DictionaryManager\Yi.Framework.DictionaryManager.csproj", "{8941B30D-698B-477A-8737-43E7B4A8695A}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.DictionaryManager", "src\module\Yi.Framework.DictionaryManager\Yi.Framework.DictionaryManager.csproj", "{8941B30D-698B-477A-8737-43E7B4A8695A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
||||
@@ -13,6 +13,8 @@ using Yi.Framework.Core.Configuration;
|
||||
using Yi.Framework.Core.Model;
|
||||
using Yi.Framework.Core.Sqlsugar.Const;
|
||||
using Yi.Framework.Core.Sqlsugar.Options;
|
||||
using Yi.Framework.Data.Auditing;
|
||||
using Yi.Framework.Data.Entities;
|
||||
using DbType = SqlSugar.DbType;
|
||||
|
||||
namespace Yi.Framework.Core.Sqlsugar.Extensions
|
||||
@@ -93,15 +95,46 @@ namespace Yi.Framework.Core.Sqlsugar.Extensions
|
||||
}
|
||||
db.Aop.DataExecuting = (oldValue, entityInfo) =>
|
||||
{
|
||||
//这里将进行审计日志
|
||||
|
||||
switch (entityInfo.OperationType)
|
||||
{
|
||||
case DataFilterType.InsertByObject:
|
||||
break;
|
||||
case DataFilterType.UpdateByObject:
|
||||
|
||||
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModificationTime)))
|
||||
{
|
||||
entityInfo.SetValue(DateTime.Now);
|
||||
}
|
||||
//if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModifierId)))
|
||||
//{
|
||||
// if (_currentUser != null)
|
||||
// {
|
||||
// entityInfo.SetValue(_currentUser.Id);
|
||||
// }
|
||||
//}
|
||||
break;
|
||||
case DataFilterType.InsertByObject:
|
||||
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreationTime)))
|
||||
{
|
||||
entityInfo.SetValue(DateTime.Now);
|
||||
}
|
||||
//if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreatorId)))
|
||||
//{
|
||||
// if (_currentUser != null)
|
||||
// {
|
||||
// entityInfo.SetValue(_currentUser.Id);
|
||||
// }
|
||||
//}
|
||||
|
||||
//插入时,需要租户id,先预留
|
||||
if (entityInfo.PropertyName.Equals(nameof(IMultiTenant.TenantId)))
|
||||
{
|
||||
//if (this.CurrentTenant is not null)
|
||||
//{
|
||||
// entityInfo.SetValue(this.CurrentTenant.Id);
|
||||
//}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
};
|
||||
db.Aop.OnLogExecuting = (s, p) =>
|
||||
{
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\src\framework\Yi.Framework.Data\Yi.Framework.Data.csproj" />
|
||||
<ProjectReference Include="..\src\framework\Yi.Framework.Ddd\Yi.Framework.Ddd.csproj" />
|
||||
<ProjectReference Include="..\..\framework\Yi.Framework.Data\Yi.Framework.Data.csproj" />
|
||||
<ProjectReference Include="..\..\framework\Yi.Framework.Ddd\Yi.Framework.Ddd.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Binary file not shown.
@@ -14,7 +14,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
public string Title { get; set; }
|
||||
public string Types { get; set; }
|
||||
public string? Introduction { get; set; }
|
||||
public DateTime? CreateTime { get; set; }
|
||||
public DateTime? CreateTime { get; set; } = DateTime.Now;
|
||||
public string Content { get; set; }
|
||||
public string? Color { get; set; }
|
||||
|
||||
|
||||
@@ -20,5 +20,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
public int SeeNum { get; set; }
|
||||
public string Content { get; set; }
|
||||
public string? Color { get; set; }
|
||||
|
||||
public long PlateId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,5 +20,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||
public int SeeNum { get; set; }
|
||||
public string Content { get; set; }
|
||||
public string? Color { get; set; }
|
||||
|
||||
public long PlateId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
public string Title { get; set; }
|
||||
public string Types { get; set; }
|
||||
public string? Introduction { get; set; }
|
||||
public DateTime? CreateTime { get; set; }
|
||||
public int AgreeNum { get; set; }
|
||||
public int SeeNum { get; set; }
|
||||
public string Content { get; set; }
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace Yi.BBS.Application.Forum
|
||||
var entities = await _DbQueryable
|
||||
.WhereIF(!string.IsNullOrEmpty(input.Title), x => x.Title.Contains(input.Title))
|
||||
.WhereIF(input.PlateId is not null, x => x.PlateId == input.PlateId)
|
||||
.OrderByDescending(x => x.CreateTime)
|
||||
.ToPageListAsync(input.PageNum, input.PageSize, total);
|
||||
var items = await MapToGetListOutputDtosAsync(entities);
|
||||
return new PagedResultDto<DiscussGetListOutputDto>(total, items);
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace Yi.BBS.Domain.Forum.Entities
|
||||
/// <returns></returns>
|
||||
public static List<ArticleEntity> Tile(this List<ArticleEntity> entities)
|
||||
{
|
||||
if(entities is null)return new List<ArticleEntity>();
|
||||
var result = new List<ArticleEntity>();
|
||||
return StartRecursion(entities, result);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -15,8 +15,8 @@
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\Yi.Framework.DictionaryManager\Yi.Framework.DictionaryManager.csproj" />
|
||||
<ProjectReference Include="..\..\..\framework\Yi.Framework.Data\Yi.Framework.Data.csproj" />
|
||||
<ProjectReference Include="..\..\..\module\Yi.Framework.DictionaryManager\Yi.Framework.DictionaryManager.csproj" />
|
||||
<ProjectReference Include="..\..\..\module\Yi.Framework.EventBus\Yi.Framework.EventBus.csproj" />
|
||||
<ProjectReference Include="..\..\..\module\Yi.Framework.FileManager\Yi.Framework.FileManager.csproj" />
|
||||
<ProjectReference Include="..\..\..\module\Yi.Framework.OperLogManager\Yi.Framework.OperLogManager.csproj" />
|
||||
|
||||
Reference in New Issue
Block a user