mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 06:51:23 +08:00
the function of modify top have been completed and modify the manageTable index
This commit is contained in:
@@ -67,13 +67,12 @@ public class NoticeController {
|
||||
}
|
||||
|
||||
//修改登录用户所接收公告的阅读状态
|
||||
@GetMapping("/modifyNoticeIsRead")
|
||||
public ResponseResult modifyNoticeIsRead(String noticeId,Integer readStatus){
|
||||
Long nid=null;
|
||||
if (StringUtils.hasText(noticeId)){
|
||||
nid = Long.parseLong(noticeId);
|
||||
@PutMapping("/modifyNoticeIsRead")
|
||||
public ResponseResult modifyNoticeIsRead(@RequestBody Notice notice) {
|
||||
boolean updateById = false;
|
||||
if (null != notice) {
|
||||
updateById = noticeReceiveService.modifyNoticeIsRead(notice);
|
||||
}
|
||||
boolean updateById = noticeReceiveService.modifyNoticeIsRead(nid,readStatus);
|
||||
String 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);
|
||||
}
|
||||
|
||||
//更新公告置顶
|
||||
@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
|
||||
public ResponseResult addNotice(@RequestBody Notice notice) {
|
||||
@@ -105,13 +113,13 @@ public class NoticeController {
|
||||
|
||||
//分页查询所有公告或分页模糊查询
|
||||
@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;
|
||||
Page<?> page = new Page();
|
||||
if (null!=currentPage&&null!=pageSize){
|
||||
if (null != currentPage && null != pageSize) {
|
||||
page.setCurrent(currentPage.intValue());
|
||||
page.setSize(pageSize.intValue());
|
||||
}else {
|
||||
} else {
|
||||
// 不进行分页
|
||||
page.setCurrent(1);
|
||||
page.setSize(-1);
|
||||
@@ -119,7 +127,7 @@ public class NoticeController {
|
||||
if (!StringUtils.hasText(title) && !StringUtils.hasText(type) && !StringUtils.hasText(startTime) && !StringUtils.hasText(endTime)) {
|
||||
noticePageList = noticeService.selectPageAllNotice(page);
|
||||
} 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;
|
||||
String msg = noticePageList.getRecords() != null ? String.valueOf(noticePageList.getTotal()) : "数据查询失败,请重试!";
|
||||
|
||||
@@ -17,5 +17,5 @@ import java.util.List;
|
||||
public interface INoticeReceiveService extends IService<NoticeReceive> {
|
||||
List<Notice> selectByUserId(Integer readStatus);
|
||||
|
||||
Boolean modifyNoticeIsRead(Long noticeId,Integer readStatus);
|
||||
Boolean modifyNoticeIsRead(Notice notice);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ public interface INoticeService extends IService<Notice> {
|
||||
|
||||
Boolean updateNotice(Notice notice);
|
||||
|
||||
Boolean updateNoticeTop(Notice notice);
|
||||
|
||||
Boolean addNotice(Notice notice);
|
||||
|
||||
IPage<Notice> selectPageAllNotice(IPage<?> page);
|
||||
|
||||
@@ -31,10 +31,14 @@ public class NoticeReceiveServiceImpl extends ServiceImpl<NoticeReceiveMapper, N
|
||||
}
|
||||
|
||||
@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<>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cfive.pinnacle.entity.Notice;
|
||||
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.NoticeReceiveMapper;
|
||||
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 org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -109,6 +108,12 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
return this.addNotice(notice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateNoticeTop(Notice notice) {
|
||||
notice.setTop(notice.getTop() == 1 ? 0 : 1);
|
||||
return noticeMapper.updateById(notice) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean addNotice(Notice notice) {
|
||||
Boolean noticeFlag,noticeRecFlag=false;
|
||||
|
||||
1
ui/src/assets/svg/cancelTop.svg
Normal file
1
ui/src/assets/svg/cancelTop.svg
Normal 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 |
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-button size="large" @click="clearFilter" type="primary">清除筛选条件 </el-button>
|
||||
<el-button size="large" @click="clearFilter" type="primary">清除筛选条件</el-button>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
element-loading-text="加载中..."
|
||||
@@ -15,8 +15,15 @@
|
||||
color: '#fff',
|
||||
'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
|
||||
prop="title"
|
||||
label="公告标题"
|
||||
@@ -139,6 +146,7 @@
|
||||
import _ from 'lodash'
|
||||
import { mapState } from 'pinia'
|
||||
import { useNoticeStore } from '@/store/notice'
|
||||
|
||||
const noticeStore = useNoticeStore()
|
||||
|
||||
export default {
|
||||
@@ -153,6 +161,7 @@ export default {
|
||||
'hackReset'
|
||||
])
|
||||
},
|
||||
emits: ['clearFilter', 'handleDeleteById'],
|
||||
data() {
|
||||
return {
|
||||
filterSenderName: [],
|
||||
@@ -163,6 +172,9 @@ export default {
|
||||
},
|
||||
props: [],
|
||||
methods: {
|
||||
computeIndex(index) {
|
||||
return (this.currentPage - 1) * this.pageSize + index + 1
|
||||
},
|
||||
handleSelectionChange(val) {
|
||||
// val的值为所勾选行的数组对象
|
||||
this.multipleSelection = val
|
||||
@@ -247,6 +259,7 @@ export default {
|
||||
.el-table {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
margin: 30px 400px;
|
||||
}
|
||||
|
||||
@@ -105,14 +105,7 @@ export default {
|
||||
noticeStore.selectNoticeType()
|
||||
}, 800)
|
||||
},
|
||||
handleEdit(index, row) {
|
||||
noticeStore.$patch((state) => {
|
||||
state.hackReset = true
|
||||
state.noticeShowData = row
|
||||
state.editFlag = true
|
||||
state.dialogEditVisible = true
|
||||
})
|
||||
},
|
||||
handleEdit(index, row) {},
|
||||
handleDialogClose() {
|
||||
noticeStore.$patch((state) => {
|
||||
state.dialogEditVisible = false
|
||||
|
||||
@@ -40,18 +40,6 @@
|
||||
</el-icon>
|
||||
发布者:
|
||||
<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>
|
||||
</template>
|
||||
<p class="content">{{ contentSubstr(notice.content) }}</p>
|
||||
@@ -62,19 +50,31 @@
|
||||
:style="{ left: left + 'px', top: top + 'px' }"
|
||||
class="contextmenu"
|
||||
>
|
||||
<li>
|
||||
<li v-if="rightClickNotice.top === 0" @click.stop="modifyTop(rightClickNotice)">
|
||||
<el-icon :size="SIZE_ICON_MD()">
|
||||
<icon-pinnacle-top />
|
||||
</el-icon>
|
||||
置顶
|
||||
</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()">
|
||||
<icon-pinnacle-flag />
|
||||
</el-icon>
|
||||
标为已读
|
||||
</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()">
|
||||
<icon-pinnacle-flag />
|
||||
</el-icon>
|
||||
@@ -109,22 +109,28 @@
|
||||
<script lang="ts">
|
||||
import { mapState } from 'pinia'
|
||||
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()
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
isRead: true,
|
||||
rightClickNid: '',
|
||||
rightClickVisible: false,
|
||||
rightClickNotice: {
|
||||
id: '',
|
||||
top: 0,
|
||||
isRead: 0
|
||||
},
|
||||
top: 0,
|
||||
left: 0
|
||||
}
|
||||
},
|
||||
props: [],
|
||||
methods: {
|
||||
SIZE_ICON_LG() {
|
||||
return SIZE_ICON_LG
|
||||
},
|
||||
SIZE_ICON_MD() {
|
||||
return SIZE_ICON_MD
|
||||
},
|
||||
@@ -148,8 +154,8 @@ export default {
|
||||
if (date == null) return null
|
||||
return new Date(date).toLocaleString()
|
||||
},
|
||||
async modifyStatus(nid, status) {
|
||||
await noticeStore.modifyNoticeIsRead(nid, status)
|
||||
async modifyStatus(notice) {
|
||||
await noticeStore.modifyNoticeIsRead(notice)
|
||||
this.closeMenu()
|
||||
let flag = 0
|
||||
if (this.currentViewPage === 'All') {
|
||||
@@ -174,13 +180,25 @@ export default {
|
||||
openMenu(e, notice) {
|
||||
this.left = e.pageX
|
||||
this.top = e.pageY
|
||||
this.isRead = notice.isRead === 0
|
||||
this.rightClickNid = notice.id
|
||||
this.rightClickNotice = notice
|
||||
this.rightClickVisible = true
|
||||
},
|
||||
// 关闭菜单
|
||||
closeMenu() {
|
||||
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() {},
|
||||
@@ -310,10 +328,11 @@ h4 {
|
||||
.contextmenu li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: left;
|
||||
justify-content: center;
|
||||
padding: 7px 16px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.contextmenu li:hover {
|
||||
background: #eee;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,31 @@ export interface IAddFormData {
|
||||
content: string
|
||||
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', {
|
||||
state: () => {
|
||||
return {
|
||||
@@ -190,20 +215,30 @@ export const useNoticeStore = defineStore('notice', {
|
||||
}
|
||||
})
|
||||
},
|
||||
async modifyNoticeIsRead(noticeId: string, readStatus: number) {
|
||||
await request
|
||||
.get('/notice/modifyNoticeIsRead', {
|
||||
noticeId,
|
||||
readStatus
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.data.code === 20033) {
|
||||
ElMessage({
|
||||
message: response.data.msg,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
})
|
||||
async modifyNoticeIsRead(notice: INotice) {
|
||||
await request.put('/notice/modifyNoticeIsRead', notice).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'
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user