'newschance'

develoop
fwb 3 months ago
parent 3b536e0cad
commit 12f25f1689
  1. 19
      src/api/user/messag.js
  2. 2
      src/router/routers.ts
  3. 23
      src/views/message/components/messageContent.vue
  4. 14
      src/views/message/components/sendMessage.vue
  5. 37
      src/views/message/index.vue
  6. 192
      src/views/news/index.vue
  7. 4
      src/views/student/index.vue

@ -17,9 +17,22 @@ export const deleteSendMessageApi = (params) => {
params, params,
}) })
} }
//一键已读
function parseParams(params){
let str = '?'
try{
for (const paramsKey in params) {
str+=`${paramsKey}=${params[paramsKey]}&`
}
return str.slice(0,-1)
}catch (e) {
return ''
}
}
export const readMessagesBatch = (params) => {
return request.put(`/user-inbox/readmessagesbatch${parseParams(params)}`)
}
//发送邮件 //发送邮件
export const SendMessageApi = (params) => { export const SendMessageApi = (params) => {
return request.post('/messages/addmessage', { return request.post(`/messages/addmessage${parseParams(params)}`)
params,
})
} }

@ -234,7 +234,7 @@ export const constantRoute: any = [
name:'NewsManagement', name:'NewsManagement',
meta: { meta: {
title: '资讯', title: '资讯',
hidden: false, hidden: true,
icon: 'BellFilled' icon: 'BellFilled'
}, },
children: [ children: [

@ -130,27 +130,28 @@ getStuList()
const back= ()=>{ const back= ()=>{
router.push('/messageManagement/message') router.push('/messageManagement/message')
} }
//
const confirm = ()=>{
addPerson.value = false
}
//
const disappoint = ()=>{
addPerson.value = false
}
// //
const send = async (id: any) => { const send = async () => {
await ElMessageBox.confirm('您确定发送这条信息吗', '温馨提示', { await ElMessageBox.confirm('您确定发送这条信息吗', '温馨提示', {
confirmButtonText: '确认', confirmButtonText: '确认',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',
}) })
await SendMessageApi({ await SendMessageApi({
messageIds:id, receiverId:inputPerson.id,
title:inputText,
content:textarea, content:textarea,
userId:userStore.userInfo.id senderId:userStore.userInfo.id
}) })
} }
//
const confirm = ()=>{
addPerson.value = false
}
//
const disappoint = ()=>{
addPerson.value = false
}
</script> </script>
<style scoped> <style scoped>

@ -31,7 +31,7 @@
<span class="sender">收件人:{{item.receiverName}}</span> <span class="sender">收件人:{{item.receiverName}}</span>
<span class="read-status">阅读人数{{item.readUserNum}}</span> <span class="read-status">阅读人数{{item.readUserNum}}</span>
</div> </div>
<div class="message-time">{{item.sendTime}}</div> <div class="message-time">发送时间{{item.sendTime}}</div>
</div> </div>
<!-- 删除按钮默认不显示hover时显示 --> <!-- 删除按钮默认不显示hover时显示 -->
<!-- <el-button v-if="hoveringOver === item.id" class="delete-btn" @click="deleteSendMessage(item.id)" type="danger" round >删除</el-button>--> <!-- <el-button v-if="hoveringOver === item.id" class="delete-btn" @click="deleteSendMessage(item.id)" type="danger" round >删除</el-button>-->
@ -183,7 +183,6 @@ const handleClick = (item)=> {
// //
router.push({ path: '/sendMessageList', query: item }) router.push({ path: '/sendMessageList', query: item })
} }
</script> </script>
<style scoped> <style scoped>
.container{ .container{
@ -199,13 +198,10 @@ const handleClick = (item)=> {
align-items: center; /* 垂直居中对齐子元素 */ align-items: center; /* 垂直居中对齐子元素 */
gap: 10px; /* 设置子元素之间的间距 */ gap: 10px; /* 设置子元素之间的间距 */
} }
.custom-checkbox { .custom-checkbox {
transform: scale(1.5); /* 将勾选框放大1.5倍 */ transform: scale(1.5); /* 将勾选框放大1.5倍 */
} }
.selected-count { .selected-count {
} }
.message-check{ .message-check{
margin-right: 20px; margin-right: 20px;
@ -218,7 +214,6 @@ const handleClick = (item)=> {
padding: 0 10px; padding: 0 10px;
box-sizing: border-box; box-sizing: border-box;
} }
.message-icon { .message-icon {
margin-right: 30px; /* 图标右侧间距 */ margin-right: 30px; /* 图标右侧间距 */
font-size: 34px; /* 图标大小 */ font-size: 34px; /* 图标大小 */
@ -232,32 +227,27 @@ li{
justify-content: center; /* 标题和详情内容垂直居中 */ justify-content: center; /* 标题和详情内容垂直居中 */
flex: 1; /* 填充剩余空间 */ flex: 1; /* 填充剩余空间 */
} }
.message-title { .message-title {
line-height: 30px; line-height: 30px;
font-size: 20px; font-size: 20px;
} }
.message-details { .message-details {
display: flex; display: flex;
align-items: center; /* 细节内容水平居中 */ align-items: center; /* 细节内容水平居中 */
margin-top: 10px; /* 与标题的间距 */ margin-top: 10px; /* 与标题的间距 */
} }
.sender { .sender {
margin-right: 88px; /* 发件人和已读状态的间距 */ margin-right: 88px; /* 发件人和已读状态的间距 */
} }
.read-status { .read-status {
color: #888; /* 已读状态的颜色 */ color: #888; /* 已读状态的颜色 */
} }
.message-time { .message-time {
margin-left: auto; /* 发送时间靠右显示 */ margin-left: auto; /* 发送时间靠右显示 */
font-size: 15px; /* 发送时间字体大小 */ font-size: 15px; /* 发送时间字体大小 */
color: #666; /* 发送时间颜色 */ color: #666; /* 发送时间颜色 */
position: absolute;
} }
.message-list-item { .message-list-item {
cursor: pointer; /* 鼠标悬停时显示手指形状,表示可点击 */ cursor: pointer; /* 鼠标悬停时显示手指形状,表示可点击 */
} }

@ -24,17 +24,23 @@
<!-- 图标 --> <!-- 图标 -->
<div class="message-icon"> <div class="message-icon">
<el-icon><Comment /></el-icon> <el-icon><Comment /></el-icon>
<!-- 添加红色提示符 -->
<span v-if="!item.isRead" class="message-unread-indicator"></span>
</div> </div>
<div class="message-content" @click="handleClick(item)"> <div class="message-content" @click="handleClick(item)">
<h2 class="message-title">{{item.title}}</h2> <h2 class="message-title">{{item.title}}</h2>
<div class="message-details"> <div class="message-details">
<span class="sender">发件人{{item.sendPerson}}</span> <span class="sender">发件人{{item.senderName}}</span>
<span class="read-status">已读状态{{item.isRead}}</span> <span class="read-status" style="margin-right: 40px">是否已读{{ item.isRead ? '已读' : '未读' }}</span>
<span class="read-status">已读人数{{item.readUserNum}} / {{item.userNum}}</span>
</div> </div>
<div class="message-time">发送时间{{item.sendTime}}</div> <div class="message-time">发送时间{{item.sendTime}}</div>
</div> </div>
<!-- 删除按钮默认不显示hover时显示 --> <!-- 删除按钮默认不显示hover时显示 -->
<el-button v-if="hoveringOver === item.id" class="delete-btn" @click="deleteMessage(item.id)" type="danger" round>删除</el-button> <div v-if="!item.isRead" style="margin-right: 10px">
<el-button v-if="hoveringOver === item.id" @click="readMessage(item.id)" type="warning" round>点击已读</el-button>
</div>
<el-button v-if="hoveringOver === item.id" @click="deleteMessage(item.id)" type="danger" round>删除</el-button>
</div> </div>
<el-divider/> <el-divider/>
</li> </li>
@ -58,7 +64,7 @@
import { ref,computed,onMounted} from 'vue'; import { ref,computed,onMounted} from 'vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import useUserStore from "@/store/modules/user"; import useUserStore from "@/store/modules/user";
import {getMessagesListApi,deleteSendMessageApi} from "@/api/user/messag"; import {getMessagesListApi,deleteSendMessageApi,readMessagesBatch} from "@/api/user/messag";
import { ElMessageBox, ElMessage } from 'element-plus' import { ElMessageBox, ElMessage } from 'element-plus'
const userStore = useUserStore() const userStore = useUserStore()
const params = ref({ const params = ref({
@ -151,6 +157,15 @@ const deleteMessage = async (id: any) => {
await getMessageList() await getMessageList()
} }
//
const readMessage = async (id:any) =>{
console.log(id,userStore.userInfo.id,'dddddd')
await readMessagesBatch({
messageIds:id,
userId:userStore.userInfo.id
})
await getMessageList()
}
// //
const handleSizeChange = (size: any) => { const handleSizeChange = (size: any) => {
// loading.value = true // loading.value = true
@ -223,6 +238,7 @@ const handleClick = (item)=> {
.message-icon { .message-icon {
margin-right: 30px; /* 图标右侧间距 */ margin-right: 30px; /* 图标右侧间距 */
font-size: 34px; /* 图标大小 */ font-size: 34px; /* 图标大小 */
position: relative;
} }
li{ li{
list-style: none; list-style: none;
@ -232,8 +248,19 @@ li{
flex-direction: column; flex-direction: column;
justify-content: center; /* 标题和详情内容垂直居中 */ justify-content: center; /* 标题和详情内容垂直居中 */
flex: 1; /* 填充剩余空间 */ flex: 1; /* 填充剩余空间 */
position: relative;
}
/*未读消息加小红点*/
.message-unread-indicator {
position: absolute;
top: -4px; /* 调整位置 */
right: -4px; /* 调整位置 */
width: 10px;
height: 10px;
border-radius: 50%;
background-color: red;
z-index: 1; /* 确保它在其他元素之上 */
} }
.message-title { .message-title {
line-height: 30px; line-height: 30px;
font-size: 20px; font-size: 20px;

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

@ -11,8 +11,8 @@ import {
} from '@/api/user/stud' } from '@/api/user/stud'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import editStu from './components/editStu.vue' // import editStu from './components/editStu.vue'
import { tryOnMounted } from '@vueuse/core' // import { tryOnMounted } from '@vueuse/core'
const userStore = useUserStore() const userStore = useUserStore()
// console.log(userStore.data.id, 'icon') // // console.log(userStore.data.id, 'icon') //
const formLabelWidth = '60px' const formLabelWidth = '60px'

Loading…
Cancel
Save