1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 23:11:24 +08:00

the function of modify top have been completed and modify the manageTable index

This commit is contained in:
cccccyb
2023-05-20 02:32:51 +08:00
parent b1f4ad07a8
commit e122933bb9
10 changed files with 144 additions and 64 deletions

View File

@@ -67,13 +67,12 @@ public class NoticeController {
} }
//修改登录用户所接收公告的阅读状态 //修改登录用户所接收公告的阅读状态
@GetMapping("/modifyNoticeIsRead") @PutMapping("/modifyNoticeIsRead")
public ResponseResult modifyNoticeIsRead(String noticeId,Integer readStatus){ public ResponseResult modifyNoticeIsRead(@RequestBody Notice notice) {
Long nid=null; boolean updateById = false;
if (StringUtils.hasText(noticeId)){ if (null != notice) {
nid = Long.parseLong(noticeId); updateById = noticeReceiveService.modifyNoticeIsRead(notice);
} }
boolean updateById = noticeReceiveService.modifyNoticeIsRead(nid,readStatus);
String msg = updateById ? "" : "服务器出错,请重试!"; String msg = updateById ? "" : "服务器出错,请重试!";
return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateById); return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateById);
@@ -87,6 +86,15 @@ public class NoticeController {
return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateById); return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateById);
} }
//更新公告置顶
@PutMapping("/updateNoticeTop")
public ResponseResult updateNoticeTop(@RequestBody Notice notice) {
String operationMessage = notice.getTop() == 1 ? "取消置顶" : "置顶";
boolean updateResult = noticeService.updateNoticeTop(notice);
String msg = updateResult ? "已成功" + operationMessage : operationMessage + "失败,请重试!";
return ResponseResult.build(updateResult ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateResult);
}
//添加公告 //添加公告
@PostMapping @PostMapping
public ResponseResult addNotice(@RequestBody Notice notice) { public ResponseResult addNotice(@RequestBody Notice notice) {
@@ -105,13 +113,13 @@ public class NoticeController {
//分页查询所有公告或分页模糊查询 //分页查询所有公告或分页模糊查询
@GetMapping("/page") @GetMapping("/page")
public ResponseResult selectPageAllNotice(Integer currentPage,Integer pageSize,String title, String type, String startTime, String endTime) { public ResponseResult selectPageAllNotice(Integer currentPage, Integer pageSize, String title, String type, String startTime, String endTime) {
IPage<Notice> noticePageList; IPage<Notice> noticePageList;
Page<?> page = new Page(); Page<?> page = new Page();
if (null!=currentPage&&null!=pageSize){ if (null != currentPage && null != pageSize) {
page.setCurrent(currentPage.intValue()); page.setCurrent(currentPage.intValue());
page.setSize(pageSize.intValue()); page.setSize(pageSize.intValue());
}else { } else {
// 不进行分页 // 不进行分页
page.setCurrent(1); page.setCurrent(1);
page.setSize(-1); page.setSize(-1);
@@ -119,7 +127,7 @@ public class NoticeController {
if (!StringUtils.hasText(title) && !StringUtils.hasText(type) && !StringUtils.hasText(startTime) && !StringUtils.hasText(endTime)) { if (!StringUtils.hasText(title) && !StringUtils.hasText(type) && !StringUtils.hasText(startTime) && !StringUtils.hasText(endTime)) {
noticePageList = noticeService.selectPageAllNotice(page); noticePageList = noticeService.selectPageAllNotice(page);
} else { } else {
noticePageList = noticeService.selectPageByCond(page,title, type, startTime, endTime); noticePageList = noticeService.selectPageByCond(page, title, type, startTime, endTime);
} }
int code = noticePageList.getRecords() != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR; int code = noticePageList.getRecords() != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = noticePageList.getRecords() != null ? String.valueOf(noticePageList.getTotal()) : "数据查询失败,请重试!"; String msg = noticePageList.getRecords() != null ? String.valueOf(noticePageList.getTotal()) : "数据查询失败,请重试!";

View File

@@ -17,5 +17,5 @@ import java.util.List;
public interface INoticeReceiveService extends IService<NoticeReceive> { public interface INoticeReceiveService extends IService<NoticeReceive> {
List<Notice> selectByUserId(Integer readStatus); List<Notice> selectByUserId(Integer readStatus);
Boolean modifyNoticeIsRead(Long noticeId,Integer readStatus); Boolean modifyNoticeIsRead(Notice notice);
} }

View File

@@ -25,6 +25,8 @@ public interface INoticeService extends IService<Notice> {
Boolean updateNotice(Notice notice); Boolean updateNotice(Notice notice);
Boolean updateNoticeTop(Notice notice);
Boolean addNotice(Notice notice); Boolean addNotice(Notice notice);
IPage<Notice> selectPageAllNotice(IPage<?> page); IPage<Notice> selectPageAllNotice(IPage<?> page);

View File

@@ -31,10 +31,14 @@ public class NoticeReceiveServiceImpl extends ServiceImpl<NoticeReceiveMapper, N
} }
@Override @Override
public Boolean modifyNoticeIsRead(Long noticeId,Integer readStatus) { public Boolean modifyNoticeIsRead(Notice notice) {
Integer readStatus = null;
if (null!=notice.getIsRead()){
readStatus=notice.getIsRead()==0?1:0;
}
LambdaUpdateWrapper<NoticeReceive> luw = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<NoticeReceive> luw = new LambdaUpdateWrapper<>();
Long userId = WebUtil.getLoginUser().getUser().getId(); Long userId = WebUtil.getLoginUser().getUser().getId();
luw.eq(NoticeReceive::getNoticeId, noticeId).eq(NoticeReceive::getUserId, userId).set(null!=readStatus,NoticeReceive::getAlreadyRead, readStatus); luw.eq(NoticeReceive::getNoticeId, notice.getId()).eq(NoticeReceive::getUserId, userId).set(null!=readStatus,NoticeReceive::getAlreadyRead, readStatus);
return noticeReceiveMapper.update(null,luw)>0; return noticeReceiveMapper.update(null,luw)>0;
} }
} }

View File

@@ -5,7 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cfive.pinnacle.entity.Notice; import com.cfive.pinnacle.entity.Notice;
import com.cfive.pinnacle.entity.NoticeReceive; import com.cfive.pinnacle.entity.NoticeReceive;
import com.cfive.pinnacle.entity.NoticeType; import com.cfive.pinnacle.entity.common.ResponseCode;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.mapper.NoticeMapper; import com.cfive.pinnacle.mapper.NoticeMapper;
import com.cfive.pinnacle.mapper.NoticeReceiveMapper; import com.cfive.pinnacle.mapper.NoticeReceiveMapper;
import com.cfive.pinnacle.mapper.NoticeTypeMapper; import com.cfive.pinnacle.mapper.NoticeTypeMapper;
@@ -15,11 +16,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cfive.pinnacle.utils.WebUtil; import com.cfive.pinnacle.utils.WebUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@@ -109,6 +108,12 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
return this.addNotice(notice); return this.addNotice(notice);
} }
@Override
public Boolean updateNoticeTop(Notice notice) {
notice.setTop(notice.getTop() == 1 ? 0 : 1);
return noticeMapper.updateById(notice) > 0;
}
@Override @Override
public Boolean addNotice(Notice notice) { public Boolean addNotice(Notice notice) {
Boolean noticeFlag,noticeRecFlag=false; Boolean noticeFlag,noticeRecFlag=false;

View File

@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1684501083843" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2133" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64"><path d="M189.3 115h653.4c12.1 0 22-9.9 22-22v-6c0-12.1-9.9-22-22-22H189.3c-12.1 0-22 9.9-22 22v6c0 12.1 9.9 22 22 22zM152.2 524.5c-16.1 15.5-16.5 41.4-1 57.5s41.4 16.5 57.5 1l150.5-145-57.4-57.6-149.6 144.1zM474.5 918.4c0 22.4 18.3 40.6 40.6 40.6 22.4 0 40.6-18.3 40.6-40.6V635.3l-81.3-81.6v364.7zM872.3 524.5L547.1 211.3c-7.5-9.5-19-15.6-32-15.6h-0.5c-0.8 0-1.6 0-2.4 0.1-10.9-0.6-22 3.2-30.4 11.3l-98.4 94.7 57.4 57.6 33.6-32.3v66l81.3 81.6V332.5l260.1 250.4c16.1 15.5 41.9 15.1 57.5-1 15.6-16 15.1-41.9-1-57.4zM257.1 207c-6.6-6.7-15.4-10-24.1-10-8.7 0-17.4 3.3-24 9.9-13.3 13.3-13.3 34.8-0.1 48.1l538 540c6.6 6.7 15.4 10 24.1 10 8.7 0 17.4-3.3 24-9.9 13.3-13.3 13.3-34.8 0.1-48.1l-538-540z" p-id="2134"></path></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -1,5 +1,5 @@
<template> <template>
<el-button size="large" @click="clearFilter" type="primary">清除筛选条件 </el-button> <el-button size="large" @click="clearFilter" type="primary">清除筛选条件</el-button>
<el-table <el-table
v-loading="loading" v-loading="loading"
element-loading-text="加载中..." element-loading-text="加载中..."
@@ -15,8 +15,15 @@
color: '#fff', color: '#fff',
'font-size': '20px' 'font-size': '20px'
}" }"
><el-table-column type="selection" width="55" align="center" /> >
<el-table-column type="index" label="序号" width="70" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column
type="index"
label="序号"
width="70"
align="center"
:index="computeIndex"
/>
<el-table-column <el-table-column
prop="title" prop="title"
label="公告标题" label="公告标题"
@@ -139,6 +146,7 @@
import _ from 'lodash' import _ from 'lodash'
import { mapState } from 'pinia' import { mapState } from 'pinia'
import { useNoticeStore } from '@/store/notice' import { useNoticeStore } from '@/store/notice'
const noticeStore = useNoticeStore() const noticeStore = useNoticeStore()
export default { export default {
@@ -153,6 +161,7 @@ export default {
'hackReset' 'hackReset'
]) ])
}, },
emits: ['clearFilter', 'handleDeleteById'],
data() { data() {
return { return {
filterSenderName: [], filterSenderName: [],
@@ -163,6 +172,9 @@ export default {
}, },
props: [], props: [],
methods: { methods: {
computeIndex(index) {
return (this.currentPage - 1) * this.pageSize + index + 1
},
handleSelectionChange(val) { handleSelectionChange(val) {
// val的值为所勾选行的数组对象 // val的值为所勾选行的数组对象
this.multipleSelection = val this.multipleSelection = val
@@ -247,6 +259,7 @@ export default {
.el-table { .el-table {
margin-top: 10px; margin-top: 10px;
} }
.pagination { .pagination {
margin: 30px 400px; margin: 30px 400px;
} }

View File

@@ -105,14 +105,7 @@ export default {
noticeStore.selectNoticeType() noticeStore.selectNoticeType()
}, 800) }, 800)
}, },
handleEdit(index, row) { handleEdit(index, row) {},
noticeStore.$patch((state) => {
state.hackReset = true
state.noticeShowData = row
state.editFlag = true
state.dialogEditVisible = true
})
},
handleDialogClose() { handleDialogClose() {
noticeStore.$patch((state) => { noticeStore.$patch((state) => {
state.dialogEditVisible = false state.dialogEditVisible = false

View File

@@ -40,18 +40,6 @@
</el-icon> </el-icon>
发布者 发布者
<span class="sender">{{ notice.sender.username }}</span> <span class="sender">{{ notice.sender.username }}</span>
<!-- <div class="check">-->
<!-- <el-button-->
<!-- type="info"-->
<!-- v-if="notice.isRead === 1"-->
<!-- @click.stop="changeIsRead"-->
<!-- >-->
<!-- <template #icon>-->
<!-- <input type="checkbox" :checked="isCheck" />-->
<!-- </template>-->
<!-- 标为未读-->
<!-- </el-button>-->
<!-- </div>-->
</div> </div>
</template> </template>
<p class="content">{{ contentSubstr(notice.content) }}</p> <p class="content">{{ contentSubstr(notice.content) }}</p>
@@ -62,19 +50,31 @@
:style="{ left: left + 'px', top: top + 'px' }" :style="{ left: left + 'px', top: top + 'px' }"
class="contextmenu" class="contextmenu"
> >
<li> <li v-if="rightClickNotice.top === 0" @click.stop="modifyTop(rightClickNotice)">
<el-icon :size="SIZE_ICON_MD()"> <el-icon :size="SIZE_ICON_MD()">
<icon-pinnacle-top /> <icon-pinnacle-top />
</el-icon> </el-icon>
置顶 置顶
</li> </li>
<li v-if="this.isRead" @click.stop="modifyStatus(this.rightClickNid, 1)"> <li v-if="rightClickNotice.top === 1" @click.stop="modifyTop(rightClickNotice)">
<el-icon :size="28">
<icon-pinnacle-cancel-top />
</el-icon>
取消置顶
</li>
<li
v-if="rightClickNotice.isRead === 0"
@click.stop="modifyStatus(rightClickNotice)"
>
<el-icon :size="SIZE_ICON_SM()"> <el-icon :size="SIZE_ICON_SM()">
<icon-pinnacle-flag /> <icon-pinnacle-flag />
</el-icon> </el-icon>
标为已读 标为已读
</li> </li>
<li v-if="!this.isRead" @click.stop="modifyStatus(this.rightClickNid, 0)"> <li
v-if="rightClickNotice.isRead === 1"
@click.stop="modifyStatus(rightClickNotice)"
>
<el-icon :size="SIZE_ICON_SM()"> <el-icon :size="SIZE_ICON_SM()">
<icon-pinnacle-flag /> <icon-pinnacle-flag />
</el-icon> </el-icon>
@@ -109,22 +109,28 @@
<script lang="ts"> <script lang="ts">
import { mapState } from 'pinia' import { mapState } from 'pinia'
import { useNoticeStore } from '@/store/notice' import { useNoticeStore } from '@/store/notice'
import { SIZE_ICON_MD, SIZE_ICON_SM } from '@/constants/Common.constants' import { SIZE_ICON_LG, SIZE_ICON_MD, SIZE_ICON_SM } from '@/constants/Common.constants'
const noticeStore = useNoticeStore() const noticeStore = useNoticeStore()
export default { export default {
data() { data() {
return { return {
isRead: true,
rightClickNid: '',
rightClickVisible: false, rightClickVisible: false,
rightClickNotice: {
id: '',
top: 0,
isRead: 0
},
top: 0, top: 0,
left: 0 left: 0
} }
}, },
props: [], props: [],
methods: { methods: {
SIZE_ICON_LG() {
return SIZE_ICON_LG
},
SIZE_ICON_MD() { SIZE_ICON_MD() {
return SIZE_ICON_MD return SIZE_ICON_MD
}, },
@@ -148,8 +154,8 @@ export default {
if (date == null) return null if (date == null) return null
return new Date(date).toLocaleString() return new Date(date).toLocaleString()
}, },
async modifyStatus(nid, status) { async modifyStatus(notice) {
await noticeStore.modifyNoticeIsRead(nid, status) await noticeStore.modifyNoticeIsRead(notice)
this.closeMenu() this.closeMenu()
let flag = 0 let flag = 0
if (this.currentViewPage === 'All') { if (this.currentViewPage === 'All') {
@@ -174,13 +180,25 @@ export default {
openMenu(e, notice) { openMenu(e, notice) {
this.left = e.pageX this.left = e.pageX
this.top = e.pageY this.top = e.pageY
this.isRead = notice.isRead === 0 this.rightClickNotice = notice
this.rightClickNid = notice.id
this.rightClickVisible = true this.rightClickVisible = true
}, },
// 关闭菜单 // 关闭菜单
closeMenu() { closeMenu() {
this.rightClickVisible = false this.rightClickVisible = false
},
async modifyTop(notice) {
await noticeStore.modifyTop(notice)
this.closeMenu()
let flag = 0
if (this.currentViewPage === 'All') {
flag = -1
} else if (this.currentViewPage === 'ToRead') {
flag = 0
} else if (this.currentViewPage === 'AlRead') {
flag = 1
}
await noticeStore.selectAllNoticeByUserId(flag)
} }
}, },
mounted() {}, mounted() {},
@@ -310,10 +328,11 @@ h4 {
.contextmenu li { .contextmenu li {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: left; justify-content: center;
padding: 7px 16px; padding: 7px 16px;
cursor: pointer; cursor: pointer;
} }
.contextmenu li:hover { .contextmenu li:hover {
background: #eee; background: #eee;
} }

View File

@@ -12,6 +12,31 @@ export interface IAddFormData {
content: string content: string
receivers: [] receivers: []
} }
export interface INotice {
content: string
createTime: string
endTime: string
id: string
modifyTime: string
priority: number
receivers: []
sendTime: string
title: string
top: number
isRead: number
noticeType: {
id: string
name: string
enable: number
}
sender: {
id: string
username: string
enable: number
}
senderId: string
typeId: string
}
export const useNoticeStore = defineStore('notice', { export const useNoticeStore = defineStore('notice', {
state: () => { state: () => {
return { return {
@@ -190,20 +215,30 @@ export const useNoticeStore = defineStore('notice', {
} }
}) })
}, },
async modifyNoticeIsRead(noticeId: string, readStatus: number) { async modifyNoticeIsRead(notice: INotice) {
await request await request.put('/notice/modifyNoticeIsRead', notice).then((response) => {
.get('/notice/modifyNoticeIsRead', { if (response.data.code === 20033) {
noticeId, ElMessage({
readStatus message: response.data.msg,
}) type: 'error'
.then((response) => { })
if (response.data.code === 20033) { }
ElMessage({ })
message: response.data.msg, },
type: 'error' async modifyTop(notice: INotice) {
}) await request.put('/notice/updateNoticeTop', notice).then((response) => {
} if (response.data.code === 20023) {
}) ElMessage({
message: response.data.msg,
type: 'success'
})
} else if (response.data.code === 20033) {
ElMessage({
message: response.data.msg,
type: 'error'
})
}
})
} }
} }
}) })