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

modify the function of paging the noticeType

This commit is contained in:
cccccyb
2023-05-28 18:21:46 +08:00
parent e6e9ce9965
commit 10d3d0e4e8
12 changed files with 194 additions and 86 deletions

View File

@@ -7,12 +7,13 @@ import com.cfive.pinnacle.entity.common.ResponseCode;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.service.INoticeReceiveService;
import com.cfive.pinnacle.service.INoticeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
@@ -26,6 +27,7 @@ import java.util.List;
@RestController
@RequestMapping("/notice")
@CrossOrigin
@Slf4j
public class NoticeController {
@Autowired
private INoticeService noticeService;
@@ -34,7 +36,6 @@ public class NoticeController {
//根据公告id查公告信息及发布人
@GetMapping("/{nid}")
@PreAuthorize("hasAuthority('notice:manage:get')")
public ResponseResult<Notice> selectByNoticeId(@PathVariable Long nid) {
Notice noticeById = noticeService.selectByNoticeId(nid);
Integer code = noticeById != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
@@ -44,7 +45,6 @@ public class NoticeController {
//查询所有公告或模糊查询
@GetMapping
@PreAuthorize("hasAuthority('notice:manage:get')")
public ResponseResult<List<Notice>> selectAllNotice(String title, String type, String startTime, String endTime) {
List<Notice> noticeList;
if (!StringUtils.hasText(title) && !StringUtils.hasText(type) && !StringUtils.hasText(startTime) && !StringUtils.hasText(endTime)) {
@@ -60,7 +60,6 @@ public class NoticeController {
//根据登录用户id查询所接收的公告
@GetMapping("/self")
@PreAuthorize("hasAuthority('notice:self:get')")
public ResponseResult<List<Notice>> selectByUserId(Integer readStatus) {
List<Notice> noticesByUserId = noticeReceiveService.selectByUserId(readStatus);
Integer code = noticesByUserId != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
@@ -70,9 +69,8 @@ public class NoticeController {
//修改登录用户所接收公告的阅读状态
@PutMapping("/modify_notice_read")
@PreAuthorize("hasAuthority('notice:self:get')")
public ResponseResult<?> modifyNoticeIsRead(@RequestBody Notice notice) {
boolean updateById = false;
Boolean updateById = false;
if (null != notice) {
updateById = noticeReceiveService.modifyNoticeIsRead(notice);
}
@@ -84,24 +82,22 @@ public class NoticeController {
//更新公告
@PutMapping
public ResponseResult<?> updateNotice(@RequestBody Notice notice) {
boolean updateById = noticeService.updateNotice(notice);
Boolean updateById = noticeService.updateNotice(notice);
String msg = updateById ? "" : "数据修改失败,请重试!";
return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null);
}
//修改公告置顶状态
@PutMapping("/update_notice_top")
@PreAuthorize("hasAuthority('notice:self:get')")
public ResponseResult<?> updateNoticeTop(@RequestBody Notice notice) {
String operationMessage = notice.getTop() == 1 ? "取消置顶" : "置顶";
boolean updateResult = noticeService.updateNoticeTop(notice);
Boolean updateResult = noticeService.updateNoticeTop(notice);
String msg = updateResult ? "已成功" + operationMessage : operationMessage + "失败,请重试!";
return ResponseResult.build(updateResult ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null);
}
//添加公告
@PostMapping
@PreAuthorize("hasAuthority('notice:manage:add')")
public ResponseResult<?> addNotice(@RequestBody Notice notice) {
Boolean insertNotice = noticeService.addNotice(notice);
String msg = insertNotice ? "" : "数据添加失败,请重试!";
@@ -110,19 +106,27 @@ public class NoticeController {
//删除公告
@DeleteMapping("/{nid}")
@PreAuthorize("hasAuthority('notice:manage:modify')")
public ResponseResult<?> deleteByNoticeId(@PathVariable Long nid) {
boolean removeById = noticeService.deleteById(nid);
Boolean removeById = noticeService.deleteById(nid);
String msg = removeById ? "" : "数据删除失败,请重试!";
return ResponseResult.build(removeById ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, null);
}
//批量删除公告
@PostMapping("/batch")
public ResponseResult<?> deleteBatchByIds(@RequestBody List<String> noticeIds){
// List<String>转List<Long>
List<Long> nIds = noticeIds.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
Boolean deleteBatchByIds = noticeService.deleteBatchByIds(nIds);
String msg = deleteBatchByIds ? "" : "数据删除失败,请重试!";
return ResponseResult.build(deleteBatchByIds ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, null);
}
//分页查询所有公告或分页模糊查询
@GetMapping("/page")
@PreAuthorize("hasAuthority('notice:manage:get')")
public ResponseResult<List<Notice>> selectPageAllNotice(Integer currentPage, Integer pageSize, String title, String type, String startTime, String endTime) {
IPage<Notice> noticePageList;
Page<?> page = new Page();
Page<Notice> page = new Page();
if (null != currentPage && null != pageSize) {
page.setCurrent(currentPage.intValue());
page.setSize(pageSize.intValue());

View File

@@ -1,5 +1,7 @@
package com.cfive.pinnacle.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cfive.pinnacle.entity.NoticeType;
import com.cfive.pinnacle.entity.common.ResponseCode;
import com.cfive.pinnacle.entity.common.ResponseResult;
@@ -49,6 +51,24 @@ public class NoticeTypeController {
return ResponseResult.build(code, msg, selectTypeList);
}
//分页查询所有公告类型
@GetMapping("/page")
public ResponseResult<List<NoticeType>> selectPageTypeList(Integer currentPage, Integer pageSize){
Page<NoticeType> noticeTypePage=new Page<>();
if (null != currentPage && null != pageSize) {
noticeTypePage.setCurrent(currentPage.intValue());
noticeTypePage.setSize(pageSize.intValue());
} else {
// 不进行分页
noticeTypePage.setCurrent(1);
noticeTypePage.setSize(-1);
}
IPage<NoticeType> selectPageTypeList = noticeTypeService.selectPageTypeList(noticeTypePage);
Integer code = selectPageTypeList.getRecords() != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = selectPageTypeList.getRecords() != null ? String.valueOf(selectPageTypeList.getTotal()) : "数据查询失败,请重试!";
return ResponseResult.build(code, msg, selectPageTypeList.getRecords());
}
//修改公告类型启用或禁用
@GetMapping("/update")
@PreAuthorize("hasAuthority('notice:type:modify')")

View File

@@ -23,13 +23,15 @@ public interface INoticeService extends IService<Notice> {
Boolean deleteById(Long nid);
Boolean deleteBatchByIds(List<Long> noticeIds);
Boolean updateNotice(Notice notice);
Boolean updateNoticeTop(Notice notice);
Boolean addNotice(Notice notice);
IPage<Notice> selectPageAllNotice(IPage<?> page);
IPage<Notice> selectPageAllNotice(IPage<Notice> page);
IPage<Notice> selectPageByCond(IPage<?> page, String title, String type, String startTime, String endTime);
IPage<Notice> selectPageByCond(IPage<Notice> page, String title, String type, String startTime, String endTime);
}

View File

@@ -1,5 +1,6 @@
package com.cfive.pinnacle.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cfive.pinnacle.entity.NoticeType;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -15,6 +16,8 @@ import java.util.List;
*/
public interface INoticeTypeService extends IService<NoticeType> {
List<NoticeType> selectTypeList();
IPage<NoticeType> selectPageTypeList(IPage<NoticeType> page);
List<NoticeType> selectEnableTypeList();
Boolean updateTypeEnableById(Long typeId, Integer enable);

View File

@@ -50,7 +50,7 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
}
@Override
public List<Notice> selectByCond(String title, String type, String startTime,String endTime) {
public List<Notice> selectByCond(String title, String type, String startTime, String endTime) {
LocalDateTime start;
LocalDateTime end;
try {
@@ -60,27 +60,7 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
start = null;
end = null;
}
// LambdaQueryWrapper<Notice> lqw_notice = new LambdaQueryWrapper<>();
// LambdaQueryWrapper<NoticeType> lqw_type = new LambdaQueryWrapper<>();
// lqw_type.like(null != type, NoticeType::getName, type);
// List<NoticeType> noticeTypes = noticeTypeMapper.selectList(lqw_type);
// for (NoticeType noticeType : noticeTypes
// ) {
// lqw_notice.clear();
// lqw_notice.eq(!noticeTypes.isEmpty(), Notice::getTypeId, noticeType.getId()).like(null != title, Notice::getTitle, title);
// lqw_notice.ge(StringUtils.hasText(startTime), Notice::getSendTime, start);
// lqw_notice.le(StringUtils.hasText(endTime), Notice::getEndTime, end);
// lqw_notice.eq(Notice::getOld, 0);
// List<Notice> temp_notice = noticeMapper.selectList(lqw_notice);
// notices.addAll(temp_notice);
// }
// for (Notice n : notices
// ) {
// n.setSender(userMapper.selectById(n.getSenderId()));
// n.setNoticeType(noticeTypeMapper.selectById(n.getTypeId()));
// }
List<Notice> notices=noticeMapper.selectByCond(title, type, start, end);
List<Notice> notices = noticeMapper.selectByCond(title, type, start, end);
return notices;
}
@@ -89,8 +69,23 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
public Boolean deleteById(Long nid) {
LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>();
lqw.eq(NoticeReceive::getNoticeId, nid);
Boolean flag=noticeReceiveMapper.delete(lqw)>0;
return flag&&noticeMapper.deleteById(nid) > 0;
Boolean flag = noticeReceiveMapper.delete(lqw) > 0;
return flag && noticeMapper.deleteById(nid) > 0;
}
@Override
public Boolean deleteBatchByIds(List<Long> noticeIds) {
Boolean flag = false;
for (Long nid :
noticeIds) {
LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>();
lqw.eq(NoticeReceive::getNoticeId, nid);
flag = noticeReceiveMapper.delete(lqw) > 0;
if (!flag){
break;
}
}
return flag && noticeMapper.deleteBatchIds(noticeIds) > 0;
}
@Override
@@ -114,25 +109,25 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
@Override
public Boolean addNotice(Notice notice) {
Boolean noticeFlag,noticeRecFlag=false;
Boolean noticeFlag, noticeRecFlag = false;
notice.setSenderId(WebUtil.getLoginUser().getUser().getId());
// notice.setSenderId(1652714496280469506L);
noticeFlag = noticeMapper.insert(notice)>0;
noticeFlag = noticeMapper.insert(notice) > 0;
Long noticeId = notice.getId();
if (notice.getReceivers().size()==0){
if (notice.getReceivers().size() == 0) {
//该公告仅发布者自己可见
NoticeReceive noticeReceive = new NoticeReceive();
noticeReceive.setNoticeId(noticeId);
noticeReceive.setUserId(WebUtil.getLoginUser().getUser().getId());
noticeRecFlag = noticeReceiveMapper.insert(noticeReceive)>0;
}else {
noticeRecFlag = noticeReceiveMapper.insert(noticeReceive) > 0;
} else {
for (Long receiveId :
notice.getReceivers()) {
NoticeReceive noticeReceive = new NoticeReceive();
noticeReceive.setNoticeId(noticeId);
noticeReceive.setUserId(receiveId);
noticeRecFlag = noticeReceiveMapper.insert(noticeReceive)>0;
if (!noticeRecFlag){
noticeRecFlag = noticeReceiveMapper.insert(noticeReceive) > 0;
if (!noticeRecFlag) {
break;
}
}
@@ -141,12 +136,12 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
}
@Override
public IPage<Notice> selectPageAllNotice(IPage<?> page) {
public IPage<Notice> selectPageAllNotice(IPage<Notice> page) {
return noticeMapper.selectPageAllNotice(page);
}
@Override
public IPage<Notice> selectPageByCond(IPage<?> page, String title, String type, String startTime, String endTime) {
public IPage<Notice> selectPageByCond(IPage<Notice> page, String title, String type, String startTime, String endTime) {
LocalDateTime start;
LocalDateTime end;
try {
@@ -156,7 +151,7 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
start = null;
end = null;
}
return noticeMapper.selectPageByCond(page,title, type, start, end);
return noticeMapper.selectPageByCond(page, title, type, start, end);
}
}

View File

@@ -1,8 +1,8 @@
package com.cfive.pinnacle.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cfive.pinnacle.entity.NoticeType;
import com.cfive.pinnacle.mapper.NoticeTypeMapper;
import com.cfive.pinnacle.service.INoticeTypeService;
@@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
@@ -32,6 +31,13 @@ public class NoticeTypeServiceImpl extends ServiceImpl<NoticeTypeMapper, NoticeT
return noticeTypeMapper.selectList(lqw);
}
@Override
public IPage<NoticeType> selectPageTypeList(IPage<NoticeType> page) {
LambdaQueryWrapper<NoticeType> lqw = new LambdaQueryWrapper<>();
lqw.orderByDesc(NoticeType::getId);
return noticeTypeMapper.selectPage(page, lqw);
}
@Override
public List<NoticeType> selectEnableTypeList() {
LambdaQueryWrapper<NoticeType> lqw = new LambdaQueryWrapper<>();

View File

@@ -1,5 +1,4 @@
<template>
<el-button size="large" @click="clearFilter" type="primary">清除筛选条件</el-button>
<el-table
v-loading="loading"
element-loading-text="加载中..."
@@ -29,10 +28,11 @@
prop="title"
label="公告标题"
width="200"
:formatter="formatter"
show-overflow-tooltip
align="center"
/>
>
<template #default="scope"> {{ formatterTitle(scope.row.title) }} </template>
</el-table-column>
<el-table-column prop="noticeType.name" label="公告类别" width="160" align="center">
<template #default="scope">
<el-tag
@@ -166,16 +166,16 @@ export default {
'dialogShowVisible',
'noticeShowData',
'dialogEditVisible',
'hackReset'
'hackReset',
'currentPage',
'pageSize',
'multiDeleteSelection'
])
},
emits: ['clearFilter', 'handleDeleteById'],
data() {
return {
filterSenderName: [],
multipleSelection: [],
currentPage: 1,
pageSize: 5
filterSenderName: []
}
},
props: [],
@@ -191,14 +191,20 @@ export default {
},
handleSelectionChange(val) {
// val的值为所勾选行的数组对象
this.multipleSelection = val
noticeStore.$patch((state) => {
state.multiDeleteSelection = val
})
},
clearFilter() {
this.$refs.tableRef.clearFilter(['senderName'])
this.$emit('clearFilter')
},
formatter(row) {
return row.title
formatterTitle(title) {
if (title.length > 10) {
return title.substring(0, 10) + ' ...'
} else {
return title
}
},
filterTag(value, row) {
return row.sender.username === value
@@ -237,10 +243,16 @@ export default {
},
handleSizeChange(pageSize) {
// pageSize每页多少条数据
noticeStore.$patch((state) => {
state.pageSize = pageSize
})
noticeStore.selectAllNotice(this.currentPage, parseInt(pageSize))
},
handleCurrentChange(currentPage) {
// currentPage当前第几页
noticeStore.$patch((state) => {
state.currentPage = currentPage
})
noticeStore.selectAllNotice(parseInt(currentPage), this.pageSize)
}
},

View File

@@ -15,7 +15,7 @@
color: '#fff'
}"
><el-table-column type="selection" width="65" align="center" />
<el-table-column type="index" label="序号" width="80" align="center" />
<el-table-column type="index" label="序号" width="80" align="center" :index="indexFormat" />
<el-table-column label="类型名称" prop="name" width="500" align="center" />
<el-table-column label="是否启用" prop="enable" width="350" align="center">
<template #default="scope">
@@ -84,8 +84,7 @@
<script lang="ts">
import { mapState } from 'pinia'
import { useNoticeStore, useNoticeTypeStore } from '@/store/notice'
const noticeStore = useNoticeStore()
import { useNoticeTypeStore } from '@/store/notice'
const noticeTypeStore = useNoticeTypeStore()
export default {
@@ -93,6 +92,8 @@ export default {
computed: {
...mapState(useNoticeTypeStore, [
'total',
'currentPage',
'pageSize',
'dialogEditTypeVisible',
'noticeTypeList',
'dataLoading',
@@ -105,8 +106,6 @@ export default {
return {
filterSenderName: [],
multipleSelection: [],
currentPage: 1,
pageSize: 5,
search: ''
}
},
@@ -116,10 +115,13 @@ export default {
// val的值为所勾选行的数组对象
this.multipleSelection = val
},
indexFormat(index) {
return (this.currentPage - 1) * this.pageSize + index + 1
},
switchChang(id, value) {
noticeTypeStore.updateNoticeTypeEnable(id, value)
setTimeout(() => {
noticeTypeStore.selectNoticeType()
noticeTypeStore.selectNoticeType(this.currentPage, this.pageSize)
}, 800)
},
handleOpenEditDialog(row) {
@@ -137,11 +139,17 @@ export default {
},
handleSizeChange(pageSize) {
// pageSize每页多少条数据
noticeStore.selectAllNotice(this.currentPage, parseInt(pageSize))
noticeTypeStore.$patch((state) => {
state.pageSize = pageSize
})
noticeTypeStore.selectNoticeType(this.currentPage, parseInt(pageSize))
},
handleCurrentChange(currentPage) {
// currentPage当前第几页
noticeStore.selectAllNotice(parseInt(currentPage), this.pageSize)
noticeTypeStore.$patch((state) => {
state.currentPage = currentPage
})
noticeTypeStore.selectNoticeType(parseInt(currentPage), this.pageSize)
},
submitEditForm() {
this.$refs.editForm.$refs.addTypeData.validate((valid) => {
@@ -163,7 +171,7 @@ export default {
},
mounted() {
noticeTypeStore.dataLoading = true
noticeTypeStore.selectNoticeType()
noticeTypeStore.selectNoticeType(1, 5)
},
updated() {}
}

View File

@@ -13,6 +13,16 @@
<icon-pinnacle-add /> </el-icon
>发布公告</el-button
>
<el-button type="primary" :size="'large'" @click="deleteBatchByIds"
><el-icon :size="SIZE_ICON_MD()" style="color: white; margin-right: 3px">
<icon-pinnacle-delete /> </el-icon
>批量删除</el-button
>
<el-button type="primary" :size="'large'" @click="getLoading"
><el-icon :size="SIZE_ICON_MD()" style="color: white; margin-right: 3px">
<icon-pinnacle-reset /> </el-icon
>刷新数据</el-button
>
<!-- 添加公告对话框-->
<el-dialog
v-model="dialogAddVisible"
@@ -27,7 +37,7 @@
</el-dialog>
<notice-manage-table
@handleDeleteById="handleDeleteById"
@clearFilter="clearFilter"
ref="manageTable"
></notice-manage-table>
</el-main>
</el-container>
@@ -118,17 +128,51 @@ export default {
state.editFlag = false
})
},
clearFilter() {
// this.selectAllNotice()
// location.reload()
this.$router.go(0)
getLoading() {
noticeStore.loading = true
noticeStore.selectAllNotice(this.currentPage, this.pageSize)
},
deleteBatchByIds() {
const multiDeleteIds = []
if (this.multiDeleteSelection.length > 0) {
for (let i = 0; i < this.multiDeleteSelection.length; i++) {
multiDeleteIds.push(this.multiDeleteSelection[i].id)
}
ElMessageBox.confirm('确定是否要批量删除?该操作将无法回退', '警告', {
confirmButtonText: '确定',
cancelButtonText: '我再想想',
type: 'warning'
})
.then(() => {
request.post('/notice/batch', multiDeleteIds).then((response) => {
if (response.data.code === 20024) {
ElMessage({
message: '删除成功.',
type: 'success'
})
noticeStore.selectAllNotice(this.currentPage, this.pageSize)
} else if (response.data.code === 20034) {
ElMessage({
message: response.data.msg,
type: 'error'
})
}
})
})
.catch(() => {})
}
}
},
mounted() {
noticeTypeStore.selectEnableNoticeType()
},
computed: {
...mapState(useNoticeStore, ['dialogAddVisible'])
...mapState(useNoticeStore, [
'dialogAddVisible',
'currentPage',
'pageSize',
'multiDeleteSelection'
])
}
}
</script>

View File

@@ -61,7 +61,9 @@ export default {
'dialogEditTypeVisible',
'editFlag',
'hackReset',
'addTypeData'
'addTypeData',
'currentPage',
'pageSize'
])
},
data() {
@@ -73,7 +75,7 @@ export default {
},
getLoadData() {
noticeTypeStore.dataLoading = true
noticeTypeStore.selectNoticeType()
noticeTypeStore.selectNoticeType(this.currentPage, this.pageSize)
},
handleOpenAddDialog() {
noticeTypeStore.$patch((state) => {
@@ -115,7 +117,7 @@ export default {
message: '删除成功.',
type: 'success'
})
noticeTypeStore.selectNoticeType()
noticeTypeStore.selectNoticeType(this.currentPage, this.pageSize)
} else if (response.data.code === 20034) {
ElMessage({
message: response.data.msg,

View File

@@ -4,6 +4,7 @@ const noticeRouter = {
meta: {
title: '公告',
icon: shallowRef(IconPinnacleNotice),
requiresMenu: true,
requiresScrollbar: false,
requiresPadding: true
},
@@ -16,6 +17,7 @@ const noticeRouter = {
meta: {
title: '公告查看',
requiresScrollbar: false,
requiresMenu: true,
requiresPadding: true
},
children: [
@@ -42,6 +44,7 @@ const noticeRouter = {
name: 'noticeManage',
meta: {
title: '公告管理',
requiresMenu: true,
requiresScrollbar: false,
requiresPadding: true
}
@@ -52,6 +55,7 @@ const noticeRouter = {
name: 'noticeTypeManage',
meta: {
title: '公告类型管理',
requiresMenu: true,
requiresScrollbar: false,
requiresPadding: true
}

View File

@@ -46,6 +46,8 @@ export const useNoticeStore = defineStore('notice', {
state: () => {
return {
total: 0,
pageSize: 5,
currentPage: 1,
selectData: [
{
content: '',
@@ -81,6 +83,7 @@ export const useNoticeStore = defineStore('notice', {
currentViewPage: 'All',
hackReset: true,
departmentList: [],
multiDeleteSelection: [],
noticeShowData: {
content: '',
createTime: '',
@@ -225,6 +228,8 @@ export const useNoticeTypeStore = defineStore('notice_type', {
state: () => {
return {
total: 0,
pageSize: 5,
currentPage: 1,
dataLoading: true,
dialogAddTypeVisible: false,
dialogEditTypeVisible: false,
@@ -256,11 +261,14 @@ export const useNoticeTypeStore = defineStore('notice_type', {
this.enableNoticeTypeList = response.data.data
})
},
async selectNoticeType() {
await request.get('/notice_type').then((response) => {
async selectNoticeType(currentPage: number, pageSize: number) {
await request.get('/notice_type/page', { currentPage, pageSize }).then((response) => {
if (response.data.code === 20021) {
this.noticeTypeList = response.data.data
this.dataLoading = false
this.total = parseInt(response.data.msg)
if (this.noticeTypeList.length !== 0) {
this.dataLoading = false
}
} else {
this.dataLoading = false
ElMessage({
@@ -305,7 +313,7 @@ export const useNoticeTypeStore = defineStore('notice_type', {
})
}
})
await this.selectNoticeType()
await this.selectNoticeType(1, 5)
},
async handleUpdateNoticeType(updateNotice: IAddNoticeTypeData) {
await request.put('/notice_type', updateNotice).then((response) => {
@@ -329,7 +337,7 @@ export const useNoticeTypeStore = defineStore('notice_type', {
})
}
})
await this.selectNoticeType()
await this.selectNoticeType(this.currentPage, this.pageSize)
}
}
})