|
|
|
@ -2,26 +2,34 @@ |
|
|
|
|
<div class="header_title"> |
|
|
|
|
<span>资讯</span> |
|
|
|
|
</div> |
|
|
|
|
<div> |
|
|
|
|
<el-card shadow="always"> |
|
|
|
|
<div class="header-flex-container"> |
|
|
|
|
<div class="common-layout"> |
|
|
|
|
<el-container> |
|
|
|
|
<el-aside> |
|
|
|
|
<div class="header-flex-container"> |
|
|
|
|
<ul class="header-list"> |
|
|
|
|
<li v-for="item in column"> |
|
|
|
|
<el-dropdown placement="bottom"> |
|
|
|
|
<span @mouseenter="EssayList(item.id)">{{ item.categoryName }}</span> <!-- 使用span代替p --> |
|
|
|
|
<el-dropdown placement="right"> |
|
|
|
|
<div class="header-column" type="primary"> |
|
|
|
|
<span @mouseenter="EssayList(item.id)">{{ item.categoryName }}</span> <!-- 使用span代替p --> |
|
|
|
|
</div> |
|
|
|
|
<!-- 当前栏目新闻管理--> |
|
|
|
|
<template #dropdown> |
|
|
|
|
<el-dropdown-menu> |
|
|
|
|
<el-dropdown-item> |
|
|
|
|
<ul> |
|
|
|
|
<li class="flex-container" @click="newViews(listObject)" v-for="listObject in essay" style="margin-bottom: 15px"> |
|
|
|
|
<ul> |
|
|
|
|
<li class="flex-container" @click="newViews(listObject)" v-for="listObject in essay" style="margin-bottom: 15px"> |
|
|
|
|
<el-tag type="info" size="large" style="height: 30px;font-size: 15px"> |
|
|
|
|
<p >{{listObject.title}}</p> |
|
|
|
|
<el-button type="danger" @click.stop="deleteNewsList(listObject.id)" round>删除</el-button> |
|
|
|
|
<el-button type="primary" @click.stop="editNewsDialogFormVisible = true; newViews(listObject)" round>编辑</el-button> |
|
|
|
|
</li> |
|
|
|
|
</ul> |
|
|
|
|
</el-tag> |
|
|
|
|
<div class="button-container"> |
|
|
|
|
<el-button type="danger" @click.stop="deleteNewsList(listObject.id)" round plain>删除</el-button> |
|
|
|
|
<el-button type="primary" @click.stop="editNewsDialogFormVisible = true; newViews(listObject)" round plain>编辑</el-button> |
|
|
|
|
</div> |
|
|
|
|
</li> |
|
|
|
|
</ul> |
|
|
|
|
</el-dropdown-item> |
|
|
|
|
<div class="add-news-button"> |
|
|
|
|
<el-button @click="addNewsDialogFormVisibleButton(item.id)" type="primary" plain round>添加当前栏目新闻</el-button> |
|
|
|
|
<el-button @click="addNewsDialogFormVisibleButton(item.id)" type="success" style="margin-bottom: 10px" plain round>添加当前栏目新闻</el-button> |
|
|
|
|
</div> |
|
|
|
|
</el-dropdown-menu> |
|
|
|
|
</template> |
|
|
|
@ -29,10 +37,43 @@ |
|
|
|
|
</li> |
|
|
|
|
</ul> |
|
|
|
|
<div> |
|
|
|
|
<el-button name="editColumnButton" @click="editHandle" round>栏目管理</el-button> |
|
|
|
|
<el-button class="button-container_column" name="editColumnButton" @click="editHandle" round>栏目管理</el-button> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</el-card> |
|
|
|
|
</el-aside> |
|
|
|
|
<!-- 右侧--> |
|
|
|
|
<el-main> |
|
|
|
|
<div class="mainContainer"> |
|
|
|
|
<div class="card-header"> |
|
|
|
|
<el-card shadow="hover"> |
|
|
|
|
<div style="height:33px"> |
|
|
|
|
<span class="contentTitle">{{nowTimeNewsData.title}}</span> |
|
|
|
|
</div> |
|
|
|
|
</el-card> |
|
|
|
|
<el-card shadow="hover"> |
|
|
|
|
<div class="news-flex-container"> |
|
|
|
|
<p>发布人:{{ nowTimeNewsData.userId }}</p> |
|
|
|
|
<p>阅读数量:{{ nowTimeNewsData.readingNumber }}</p> |
|
|
|
|
<p>发布日期:{{ nowTimeNewsData.publishTime }}</p> |
|
|
|
|
<p>更新时间:{{nowTimeNewsData.updateTime}}</p> |
|
|
|
|
</div> |
|
|
|
|
</el-card> |
|
|
|
|
</div> |
|
|
|
|
<div style="text-align: center"> |
|
|
|
|
<el-input |
|
|
|
|
v-model="nowTimeNewsData.content" |
|
|
|
|
style="font-size: 20px" |
|
|
|
|
:rows="18" |
|
|
|
|
type="textarea" |
|
|
|
|
readonly |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<el-card style="text-align: center"> |
|
|
|
|
<el-link href="https://element-plus.org" target="_blank" style="margin-right: 30px;font-size: 19px">关于我们</el-link> |
|
|
|
|
</el-card> |
|
|
|
|
</div> |
|
|
|
|
</el-main> |
|
|
|
|
</el-container> |
|
|
|
|
</div> |
|
|
|
|
<!-- 栏目编辑弹框--> |
|
|
|
|
<el-drawer v-model="drawer" title="title" :with-header="false"> |
|
|
|
@ -91,72 +132,8 @@ |
|
|
|
|
</template> |
|
|
|
|
</el-dialog> |
|
|
|
|
<!-- 新闻内容--> |
|
|
|
|
<el-card class="container"> |
|
|
|
|
<template #header> |
|
|
|
|
<div class="card-header"> |
|
|
|
|
<span class="contentTitle">{{nowTimeNewsData.title}}</span> |
|
|
|
|
<el-card shadow="hover"> |
|
|
|
|
<div class="news-flex-container"> |
|
|
|
|
<p>发布人:{{ nowTimeNewsData.userId }}</p> |
|
|
|
|
<p>阅读数量:{{ nowTimeNewsData.readingNumber }}</p> |
|
|
|
|
<p>发布日期:{{ nowTimeNewsData.publishTime }}</p> |
|
|
|
|
<p>更新时间:{{nowTimeNewsData.updateTime}}</p> |
|
|
|
|
</div> |
|
|
|
|
</el-card> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
<div style="text-align: center"> |
|
|
|
|
<el-input |
|
|
|
|
v-model="nowTimeNewsData.content" |
|
|
|
|
style="width: 80%;font-size: 20px" |
|
|
|
|
:rows="15" |
|
|
|
|
type="textarea" |
|
|
|
|
placeholder="Please input" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<template #footer> |
|
|
|
|
<div style="text-align: center"> |
|
|
|
|
<el-link href="https://element-plus.org" target="_blank" style="margin-right: 30px;font-size: 19px">关于我们</el-link> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
</el-card> |
|
|
|
|
<!-- 栏目内添加新闻--> |
|
|
|
|
<el-dialog v-model="addNewsDialogFormVisible" title="添加新闻" width="500px"> |
|
|
|
|
<el-form v-model="newsForm"> |
|
|
|
|
<el-form-item label="所属栏目id" label-width="140px"> |
|
|
|
|
<el-input v-model="newsForm.categoryId" autocomplete="off" readonly disabled/> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="文章内容" label-width="140px"> |
|
|
|
|
<el-input v-model="newsForm.content" autocomplete="off" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
<!-- <el-form-item label="文章文件" label-width="140px">--> |
|
|
|
|
<!-- <el-input v-model="newsForm.file" autocomplete="off" />--> |
|
|
|
|
<!-- </el-form-item>--> |
|
|
|
|
<!-- <el-form-item label="文章id" label-width="140px">--> |
|
|
|
|
<!-- <el-input v-model="newsForm.id" autocomplete="off" />--> |
|
|
|
|
<!-- </el-form-item>--> |
|
|
|
|
<!-- <el-form-item label="标题图片" label-width="140px">--> |
|
|
|
|
<!-- <el-input v-model="newsForm.pic" autocomplete="off" />--> |
|
|
|
|
<!-- </el-form-item>--> |
|
|
|
|
<!-- <el-form-item label="发布时间" label-width="140px">--> |
|
|
|
|
<!-- <el-input v-model="newsForm.publishTime" autocomplete="off" type="date"/>--> |
|
|
|
|
<!-- </el-form-item>--> |
|
|
|
|
<el-form-item label="浏览次数" label-width="140px"> |
|
|
|
|
<el-input v-model="newsForm.readingNumber" autocomplete="off" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="发布状态" label-width="140px"> |
|
|
|
|
<el-input v-model="newsForm.status" placeholder="1:已发布 2:未发布" autocomplete="off" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="文章标题" label-width="140px"> |
|
|
|
|
<el-input v-model="newsForm.title" autocomplete="off" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
<!-- <el-form-item label="更新时间" label-width="140px">--> |
|
|
|
|
<!-- <el-input v-model="newsForm.updateTime" autocomplete="off" type="date"/>--> |
|
|
|
|
<!-- </el-form-item>--> |
|
|
|
|
<el-form-item label="发布文章的用户id" label-width="140px"> |
|
|
|
|
<el-input v-model="newsForm.userId" autocomplete="off" readonly disabled/> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form> |
|
|
|
|
<template #footer> |
|
|
|
|
<div class="dialog-footer"> |
|
|
|
|
<el-button @click="addNewsDialogFormVisible = false">取消</el-button> |
|
|
|
@ -205,7 +182,7 @@ |
|
|
|
|
</el-form> |
|
|
|
|
<template #footer> |
|
|
|
|
<div class="dialog-footer"> |
|
|
|
|
<el-button @click="addNewsDialogFormVisible = false">取消</el-button> |
|
|
|
|
<el-button @click="editNewsDialogFormVisible = false">取消</el-button> |
|
|
|
|
<el-button type="primary" @click="editNewsContentConfirm"> |
|
|
|
|
提交 |
|
|
|
|
</el-button> |
|
|
|
@ -224,9 +201,11 @@ import { |
|
|
|
|
deleteEssay, |
|
|
|
|
editEssay |
|
|
|
|
} from "@/api/user/news.js" |
|
|
|
|
import {ref,reactive,onMounted} from 'vue'; |
|
|
|
|
import {ref,reactive,onMounted,mounted} from 'vue'; |
|
|
|
|
import {ElButton,ElDrawer, ElMessageBox, ElMessage} from 'element-plus' |
|
|
|
|
import useUserStore from "@/store/modules/user"; |
|
|
|
|
import {useRouter} from "vue-router"; |
|
|
|
|
const router = useRouter(); |
|
|
|
|
const userStore = useUserStore() |
|
|
|
|
const drawer = ref(false) |
|
|
|
|
const addFormVisible = ref(false) |
|
|
|
@ -240,15 +219,15 @@ const addNewsDialogFormVisible = ref(false) |
|
|
|
|
const editNewsDialogFormVisible = ref(false) |
|
|
|
|
//添加当前新闻栏目按钮 |
|
|
|
|
const addNewsDialogFormVisibleButton = (id)=>{ |
|
|
|
|
addNewsDialogFormVisible.value = true |
|
|
|
|
// addNewsDialogFormVisible.value = true |
|
|
|
|
router.push(`/news/newsContentDetails?id=${id}`) |
|
|
|
|
columnId.value = id |
|
|
|
|
} |
|
|
|
|
const nowTimeNewsData = ref({}) |
|
|
|
|
//新闻详细信息获取 |
|
|
|
|
const newViews = (listObject)=> { |
|
|
|
|
nowTimeNewsData.value = listObject |
|
|
|
|
nowTimeNewsData.value = { ...listObject } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//栏目 |
|
|
|
|
const form = ref({ |
|
|
|
|
categoryName:'', |
|
|
|
@ -260,7 +239,6 @@ const form = ref({ |
|
|
|
|
status:'', |
|
|
|
|
updateTime:'' |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
//新闻 |
|
|
|
|
const newsForm = ref({ |
|
|
|
|
categoryId:columnId, |
|
|
|
@ -326,13 +304,16 @@ const deleteHandle = async (id)=>{ |
|
|
|
|
} |
|
|
|
|
//新闻文章查询 |
|
|
|
|
const EssayList = async (id)=>{ |
|
|
|
|
const ress = await queryEssay(id) |
|
|
|
|
// console.log(ress.data,'ress') |
|
|
|
|
essay.value = ress.data |
|
|
|
|
const response = await queryEssay(id) |
|
|
|
|
// console.log(response.data,'response') |
|
|
|
|
essay.value = response.data |
|
|
|
|
if (essay.value.length > 0) { |
|
|
|
|
newViews(essay.value[0]); // 显示第一条新闻 |
|
|
|
|
} |
|
|
|
|
// console.log(essay.value,'essay') |
|
|
|
|
} |
|
|
|
|
//新闻文章添加 |
|
|
|
|
const addNewsContentConfirm = async ()=>{ |
|
|
|
|
const addNewsContentConfirm = async (id)=>{ |
|
|
|
|
addNewsDialogFormVisible.value = false |
|
|
|
|
await addEssay({ |
|
|
|
|
categoryId:newsForm.value.categoryId, |
|
|
|
@ -346,8 +327,17 @@ const addNewsContentConfirm = async ()=>{ |
|
|
|
|
title:newsForm.value.title, |
|
|
|
|
updateTime:newsForm.value.updateTime, |
|
|
|
|
userId:newsForm.value.userId |
|
|
|
|
}).then(()=>{ |
|
|
|
|
EssayList(id); |
|
|
|
|
ElMessage({ |
|
|
|
|
message:'添加成功', |
|
|
|
|
type:'success' |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
// mounted((id)=>{ |
|
|
|
|
// EssayList(id); |
|
|
|
|
// }) |
|
|
|
|
//新闻删除 |
|
|
|
|
const deleteNewsList = async (id)=>{ |
|
|
|
|
// console.log(id) |
|
|
|
@ -390,17 +380,23 @@ const editNewsContentConfirm = async ()=>{ |
|
|
|
|
margin: auto; |
|
|
|
|
background-image: linear-gradient(60deg,honeydew,powderblue,honeydew); |
|
|
|
|
} |
|
|
|
|
.el-aside { |
|
|
|
|
height: 100vh; /* 设置高度为视窗高度 */ |
|
|
|
|
overflow-y: auto; /* 当内容超出时显示滚动条 */ |
|
|
|
|
} |
|
|
|
|
.header-flex-container { |
|
|
|
|
display: flex; |
|
|
|
|
align-items: center; /* 垂直居中 */ |
|
|
|
|
/*align-items: center; !* 垂直居中 *!*/ |
|
|
|
|
padding: 20px; |
|
|
|
|
background: #4b81d7; |
|
|
|
|
justify-content: space-between; /* 左边对齐和右边对齐 */ |
|
|
|
|
gap: 10px; |
|
|
|
|
background: white; |
|
|
|
|
margin-top: 20px; |
|
|
|
|
height: 81vh; |
|
|
|
|
} |
|
|
|
|
.header-list { |
|
|
|
|
display: flex; /* 使li元素水平排列 */ |
|
|
|
|
/*display: flex; !* 使li元素水平排列 *!*/ |
|
|
|
|
flex-wrap: wrap; /* 如果需要换行 */ |
|
|
|
|
align-items: center; /* 如果需要,也可以使li元素垂直居中 */ |
|
|
|
|
/*align-items: center; !* 如果需要,也可以使li元素垂直居中 *!*/ |
|
|
|
|
margin: 0; /* 移除默认外边距 */ |
|
|
|
|
padding: 0; /* 移除默认内边距 */ |
|
|
|
|
} |
|
|
|
@ -412,8 +408,16 @@ const editNewsContentConfirm = async ()=>{ |
|
|
|
|
list-style: none; |
|
|
|
|
margin-right: 10px; |
|
|
|
|
} |
|
|
|
|
.el-dropdown { |
|
|
|
|
margin-right: 30px; |
|
|
|
|
.header-column{ |
|
|
|
|
height:30px; |
|
|
|
|
margin-top: 20px; |
|
|
|
|
margin-right: 80px; |
|
|
|
|
padding: 5px; |
|
|
|
|
margin-bottom: 20px; |
|
|
|
|
cursor: pointer; /* 鼠标悬停时显示手指形状,表示可点击 */ |
|
|
|
|
} |
|
|
|
|
.header-column span{ |
|
|
|
|
color: #222222; |
|
|
|
|
} |
|
|
|
|
.add-news-button { |
|
|
|
|
margin-top: auto; /* 将按钮推到底部 */ |
|
|
|
@ -426,8 +430,6 @@ const editNewsContentConfirm = async ()=>{ |
|
|
|
|
text-align: center; |
|
|
|
|
display: block; |
|
|
|
|
width: 100%; /* 或者设置一个具体的宽度 */ |
|
|
|
|
line-height: 40px; |
|
|
|
|
margin-bottom: 20px; |
|
|
|
|
} |
|
|
|
|
.flex-container { |
|
|
|
|
display: flex; |
|
|
|
@ -435,7 +437,15 @@ const editNewsContentConfirm = async ()=>{ |
|
|
|
|
align-items: center; |
|
|
|
|
flex-direction: row; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* 添加新的类来控制按钮的位置 */ |
|
|
|
|
.button-container { |
|
|
|
|
display: flex; |
|
|
|
|
justify-content: flex-end; /* 按钮靠右 */ |
|
|
|
|
align-items: center; /* 垂直居中 */ |
|
|
|
|
} |
|
|
|
|
.button-container_column{ |
|
|
|
|
position:absolute; |
|
|
|
|
} |
|
|
|
|
.news-flex-container { |
|
|
|
|
display: flex; /* 使用 Flexbox 布局 */ |
|
|
|
|
justify-content: space-between; /* 平均分配空间 */ |
|
|
|
|