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

The modification which the function of fuzzy query has been completed.

This commit is contained in:
cccccyb
2023-06-04 00:54:34 +08:00
parent 9803e78a5f
commit 25690c0871
9 changed files with 175 additions and 289 deletions

View File

@@ -2,6 +2,7 @@ package com.cfive.pinnacle.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.cfive.pinnacle.entity.Notice; import com.cfive.pinnacle.entity.Notice;
import com.cfive.pinnacle.entity.common.ResponseCode; import com.cfive.pinnacle.entity.common.ResponseCode;
import com.cfive.pinnacle.entity.common.ResponseResult; import com.cfive.pinnacle.entity.common.ResponseResult;
@@ -35,32 +36,33 @@ public class NoticeController {
@Autowired @Autowired
private INoticeReceiveService noticeReceiveService; private INoticeReceiveService noticeReceiveService;
//分页查询所有公告或分页模糊查询
@GetMapping("/page")
@PreAuthorize("hasAuthority('notice:manage:get')")
public ResponseResult<List<Notice>> selectPageNotice(Integer currentPage, Integer pageSize, String title, String type, String startTime, String endTime) {
Page<Notice> noticePage = null;
if (null != currentPage && null != pageSize) {
noticePage = PageDTO.of(currentPage, pageSize);
} else {
// 不进行分页
noticePage = PageDTO.of(1, -1);
}
IPage<Notice> noticeIPage = noticeService.selectPageNotice(noticePage, title.trim(), type.trim(), startTime.trim(), endTime.trim());
int code = noticeIPage.getRecords() != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = noticeIPage.getRecords() != null ? String.valueOf(noticeIPage.getTotal()) : "数据查询失败,请重试!";
return ResponseResult.build(code, msg, noticeIPage.getRecords());
}
//根据公告id查公告信息及发布人 //根据公告id查公告信息及发布人
@GetMapping("/{nid}") @GetMapping("/{nid}")
@PreAuthorize("hasAuthority('notice:manage:get')") @PreAuthorize("hasAuthority('notice:manage:get')")
public ResponseResult<Notice> selectByNoticeId(@PathVariable Long nid) { public ResponseResult<Notice> selectByNoticeId(@PathVariable Long nid) {
Notice noticeById = noticeService.selectByNoticeId(nid); Notice noticeById = noticeService.selectByNoticeId(nid);
Integer code = noticeById != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR; int code = noticeById != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = noticeById != null ? "" : "数据查询失败,请重试!"; String msg = noticeById != null ? "" : "数据查询失败,请重试!";
return ResponseResult.build(code, msg, noticeById); return ResponseResult.build(code, msg, noticeById);
} }
//查询所有公告或模糊查询
@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)) {
noticeList = noticeService.selectAllNotice();
} else {
noticeList = noticeService.selectByCond(title, type, startTime, endTime);
}
int code = noticeList != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = noticeList != null ? "" : "数据查询失败,请重试!";
return ResponseResult.build(code, msg, noticeList);
}
//根据登录用户id查询所接收的公告 //根据登录用户id查询所接收的公告
@GetMapping("/self") @GetMapping("/self")
@PreAuthorize("hasAuthority('notice:self:get')") @PreAuthorize("hasAuthority('notice:self:get')")
@@ -83,16 +85,6 @@ public class NoticeController {
return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null); return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null);
} }
//更新公告
@PutMapping
@PreAuthorize("hasAuthority('notice:manage:modify')")
public ResponseResult<?> updateNotice(@RequestBody Notice 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") @PutMapping("/update_notice_top")
@PreAuthorize("hasAuthority('notice:self:get')") @PreAuthorize("hasAuthority('notice:self:get')")
@@ -103,13 +95,22 @@ public class NoticeController {
return ResponseResult.build(updateResult ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null); return ResponseResult.build(updateResult ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null);
} }
//更新公告
@PutMapping
@PreAuthorize("hasAuthority('notice:manage:modify')")
public ResponseResult<?> updateNotice(@RequestBody Notice notice) {
Boolean updateById = noticeService.updateNotice(notice);
String msg = updateById ? "" : "数据修改失败,请重试!";
return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null);
}
//添加公告 //添加公告
@PostMapping @PostMapping
@PreAuthorize("hasAuthority('notice:manage:add')") @PreAuthorize("hasAuthority('notice:manage:add')")
public ResponseResult<?> addNotice(@RequestBody Notice notice) { public ResponseResult<?> addNotice(@RequestBody Notice notice) {
Boolean insertNotice = noticeService.addNotice(notice); Boolean insertNotice = noticeService.addNotice(notice);
String msg = insertNotice ? "" : "数据添加失败,请重试!"; String msg = insertNotice ? "" : "数据添加失败,请重试!";
return ResponseResult.build(insertNotice ? ResponseCode.DATABASE_SAVE_OK : ResponseCode.DATABASE_SAVE_ERROR, msg,null); return ResponseResult.build(insertNotice ? ResponseCode.DATABASE_SAVE_OK : ResponseCode.DATABASE_SAVE_ERROR, msg, null);
} }
//删除公告 //删除公告
@@ -124,7 +125,7 @@ public class NoticeController {
//批量删除公告 //批量删除公告
@PostMapping("/batch") @PostMapping("/batch")
@PreAuthorize("hasAuthority('notice:manage:delete')") @PreAuthorize("hasAuthority('notice:manage:delete')")
public ResponseResult<?> deleteBatchByIds(@RequestBody List<String> noticeIds){ public ResponseResult<?> deleteBatchByIds(@RequestBody List<String> noticeIds) {
// List<String>转List<Long> // List<String>转List<Long>
List<Long> nIds = noticeIds.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList()); List<Long> nIds = noticeIds.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
Boolean deleteBatchByIds = noticeService.deleteBatchByIds(nIds); Boolean deleteBatchByIds = noticeService.deleteBatchByIds(nIds);
@@ -132,35 +133,12 @@ public class NoticeController {
return ResponseResult.build(deleteBatchByIds ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, null); 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<Notice> page = new Page();
if (null != currentPage && null != pageSize) {
page.setCurrent(currentPage.intValue());
page.setSize(pageSize.intValue());
} else {
// 不进行分页
page.setCurrent(1);
page.setSize(-1);
}
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);
}
int code = noticePageList.getRecords() != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = noticePageList.getRecords() != null ? String.valueOf(noticePageList.getTotal()) : "数据查询失败,请重试!";
return ResponseResult.build(code, msg, noticePageList.getRecords());
}
@GetMapping("/limit") @GetMapping("/limit")
public ResponseResult<List<Notice>> selectLimitByUserId(){ public ResponseResult<List<Notice>> selectLimitByUserId() {
List<Notice> selectLimitByUserId = noticeReceiveService.selectLimitByUserId(); List<Notice> selectLimitByUserId = noticeReceiveService.selectLimitByUserId();
String msg = (null!=selectLimitByUserId) ? "" : "数据查询失败,请重试!"; String msg = (null != selectLimitByUserId) ? "" : "数据查询失败,请重试!";
return ResponseResult.build((null!=selectLimitByUserId) ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, selectLimitByUserId); return ResponseResult.build((null != selectLimitByUserId) ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, selectLimitByUserId);
} }
} }

View File

@@ -20,11 +20,5 @@ import java.util.List;
public interface NoticeMapper extends BaseMapper<Notice> { public interface NoticeMapper extends BaseMapper<Notice> {
Notice selectByNoticeId(Long nid); Notice selectByNoticeId(Long nid);
List<Notice> selectAllNotice(); IPage<Notice> selectPageNotice(IPage<?> page, String title, String type, LocalDateTime startTime, LocalDateTime endTime);
List<Notice> selectByCond(String title, String type, LocalDateTime startTime, LocalDateTime endTime);
IPage<Notice> selectPageAllNotice(IPage<?> page);
IPage<Notice> selectPageByCond(IPage<?> page, String title, String type, LocalDateTime startTime, LocalDateTime endTime);
} }

View File

@@ -17,10 +17,6 @@ import java.util.List;
public interface INoticeService extends IService<Notice> { public interface INoticeService extends IService<Notice> {
Notice selectByNoticeId(Long nid); Notice selectByNoticeId(Long nid);
List<Notice> selectAllNotice();
List<Notice> selectByCond(String title, String type, String startTime, String endTime);
Boolean deleteById(Long nid); Boolean deleteById(Long nid);
Boolean deleteBatchByIds(List<Long> noticeIds); Boolean deleteBatchByIds(List<Long> noticeIds);
@@ -31,7 +27,5 @@ public interface INoticeService extends IService<Notice> {
Boolean addNotice(Notice notice); Boolean addNotice(Notice notice);
IPage<Notice> selectPageAllNotice(IPage<Notice> page); IPage<Notice> selectPageNotice(IPage<Notice> 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

@@ -44,27 +44,15 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
} }
@Override @Override
public List<Notice> selectAllNotice() { public IPage<Notice> selectPageNotice(IPage<Notice> page, String title, String type, String startTime, String endTime) {
List<Notice> notices = noticeMapper.selectAllNotice(); LocalDateTime start=null,end=null;
return notices; if (startTime!=""&&endTime!=""){
} start= LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
@Override
public List<Notice> selectByCond(String title, String type, String startTime, String endTime) {
LocalDateTime start;
LocalDateTime end;
try {
start = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
end = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); end = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
} catch (Exception e) {
start = null;
end = null;
} }
List<Notice> notices = noticeMapper.selectByCond(title, type, start, end); return noticeMapper.selectPageNotice(page, title, type, start, end);
return notices;
} }
@Override @Override
public Boolean deleteById(Long nid) { public Boolean deleteById(Long nid) {
LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>();
@@ -81,7 +69,7 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>();
lqw.eq(NoticeReceive::getNoticeId, nid); lqw.eq(NoticeReceive::getNoticeId, nid);
flag = noticeReceiveMapper.delete(lqw) > 0; flag = noticeReceiveMapper.delete(lqw) > 0;
if (!flag){ if (!flag) {
break; break;
} }
} }
@@ -131,23 +119,5 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
return noticeFlag && noticeRecFlag; return noticeFlag && noticeRecFlag;
} }
@Override
public IPage<Notice> selectPageAllNotice(IPage<Notice> page) {
return noticeMapper.selectPageAllNotice(page);
}
@Override
public IPage<Notice> selectPageByCond(IPage<Notice> page, String title, String type, String startTime, String endTime) {
LocalDateTime start;
LocalDateTime end;
try {
start = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
end = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
} catch (Exception e) {
start = null;
end = null;
}
return noticeMapper.selectPageByCond(page, title, type, start, end);
}
} }

View File

@@ -18,8 +18,8 @@
<association property="noticeType" javaType="noticeType" autoMapping="true"/> <association property="noticeType" javaType="noticeType" autoMapping="true"/>
</resultMap> </resultMap>
<!-- 查询所有公告 --> <!-- 分页查询所有公告及模糊查询-->
<select id="selectAllNotice" resultMap="NoticeAllResultMap"> <select id="selectPageNotice" resultMap="NoticeAllResultMap" resultType="notice">
select u.id uid, select u.id uid,
u.username, u.username,
n.id nid, n.id nid,
@@ -40,35 +40,22 @@
from t_notice n from t_notice n
left join t_notice_type type on n.type_id = type.id left join t_notice_type type on n.type_id = type.id
left join t_user u on n.sender_id = u.id left join t_user u on n.sender_id = u.id
where n.deleted = 0 <where>
and n.old = 0 <if test="null!=title and title!=''">
order by n.top desc, n.create_time desc and instr(title,#{title})&gt;0
</select> </if>
<if test="null!=type and type!=''">
<!-- 分页查询所有公告 --> and instr(type.name,#{type})&gt;0
<select id="selectPageAllNotice" resultMap="NoticeAllResultMap" resultType="notice"> </if>
select u.id uid, <if test="null!=startTime">
u.username, and send_time &gt;= #{startTime}
n.id nid, </if>
n.title, <if test="null !=endTime">
n.content, and end_time &lt; #{endTime}
n.type_id, </if>
n.sender_id, and n.deleted = 0
n.create_time,
n.send_time,
n.end_time,
n.priority,
n.top,
n.modify_time,
n.origin_id,
type.id typeId,
type.name,
type.enable
from t_notice n
left join t_notice_type type on n.type_id = type.id
left join t_user u on n.sender_id = u.id
where n.deleted = 0
and n.old = 0 and n.old = 0
</where>
order by n.top desc, n.create_time desc order by n.top desc, n.create_time desc
</select> </select>
<resultMap id="NoticeAllResultMap" type="notice" autoMapping="true"> <resultMap id="NoticeAllResultMap" type="notice" autoMapping="true">
@@ -80,85 +67,4 @@
<id property="id" column="typeId"/> <id property="id" column="typeId"/>
</association> </association>
</resultMap> </resultMap>
<!-- 模糊查询公告-->
<select id="selectByCond" resultMap="NoticeAllResultMap">
select u.id uid,
u.username,
n.id nid,
n.title,
n.content,
n.type_id,
n.sender_id,
n.create_time,
n.send_time,
n.end_time,
n.priority,
n.top,
n.modify_time,
n.origin_id,
type.id typeId,
type.name,
type.enable
from t_notice n
left join t_notice_type type on n.type_id = type.id
left join t_user u on n.sender_id = u.id
<where>
<if test="null!=title and title!=''">
and instr(title,#{title})&gt;0
</if>
<if test="null!=type and type!=''">
and instr(type.name,#{type})&gt;0
</if>
<if test="null!=startTime">
and send_time &gt;= #{startTime}
</if>
<if test="null !=endTime">
and end_time &lt; #{endTime}
</if>
and n.deleted = 0
and n.old = 0
</where>
order by n.top desc, n.create_time desc
</select>
<!-- 分页模糊查询公告-->
<select id="selectPageByCond" resultMap="NoticeAllResultMap" resultType="notice">
select u.id uid,
u.username,
n.id nid,
n.title,
n.content,
n.type_id,
n.sender_id,
n.create_time,
n.send_time,
n.end_time,
n.priority,
n.top,
n.modify_time,
n.origin_id,
type.id typeId,
type.name,
type.enable
from t_notice n
left join t_notice_type type on n.type_id = type.id
left join t_user u on n.sender_id = u.id
<where>
<if test="null!=title and title!=''">
and instr(title,#{title})&gt;0
</if>
<if test="null!=type and type!=''">
and instr(type.name,#{type})&gt;0
</if>
<if test="null!=startTime">
and send_time &gt;= #{startTime}
</if>
<if test="null !=endTime">
and end_time &lt; #{endTime}
</if>
and n.deleted = 0
and n.old = 0
</where>
order by n.top desc, n.create_time desc
</select>
</mapper> </mapper>

View File

@@ -1,7 +1,7 @@
<template> <template>
<el-form <el-form
:inline="true" :inline="true"
:model="search_info" :model="search"
class="demo-form-inline" class="demo-form-inline"
label-width="auto" label-width="auto"
ref="searchForm" ref="searchForm"
@@ -10,12 +10,12 @@
<el-row :span="24"> <el-row :span="24">
<el-col :span="5"> <el-col :span="5">
<el-form-item label="公告标题:" prop="title"> <el-form-item label="公告标题:" prop="title">
<el-input v-model="search_info.title" placeholder="请输入公告标题"></el-input> <el-input v-model="search.title" placeholder="请输入公告标题"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="5"> <el-col :span="5">
<el-form-item label="公告类型:" prop="type"> <el-form-item label="公告类型:" prop="type">
<el-select v-model="search_info.type" placeholder="请选择公告类型"> <el-select v-model="search.type" placeholder="请选择公告类型">
<el-option <el-option
v-for="item in enableNoticeTypeList" v-for="item in enableNoticeTypeList"
:key="item.id" :key="item.id"
@@ -59,19 +59,15 @@
<script lang="ts"> <script lang="ts">
import { COLOR_PRODUCTION, SIZE_ICON_MD, SIZE_ICON_SM } from '@/constants/Common.constants' import { COLOR_PRODUCTION, SIZE_ICON_MD, SIZE_ICON_SM } from '@/constants/Common.constants'
import _ from 'lodash' import _ from 'lodash'
import { useNoticeTypeStore } from '@/store/notice' import { useNoticeStore, useNoticeTypeStore } from '@/store/notice'
import { mapState } from 'pinia' import { mapState } from 'pinia'
const noticeStore = useNoticeStore()
export default { export default {
name: 'NoticeHead', name: 'NoticeHead',
data() { data() {
return { return {
timeRang: [], timeRang: []
search_info: {
title: '',
type: '',
startTime: '',
endTime: ''
}
} }
}, },
methods: { methods: {
@@ -86,10 +82,12 @@ export default {
}, },
selectByCondition() { selectByCondition() {
if (!_.isEmpty(this.timeRang)) { if (!_.isEmpty(this.timeRang)) {
this.search_info.startTime = this.handleDateFormatUTC(this.timeRang[0]) noticeStore.$patch((state) => {
this.search_info.endTime = this.handleDateFormatUTC(this.timeRang[1]) state.search.startTime = this.handleDateFormatUTC(this.timeRang[0])
this.search.endTime = this.handleDateFormatUTC(this.timeRang[1])
})
} }
this.$emit('selectByCond', 1, 5, this.search_info) this.$emit('selectByCond')
}, },
handleDateFormatUTC(date) { handleDateFormatUTC(date) {
let newFormat = '' let newFormat = ''
@@ -105,10 +103,18 @@ export default {
}, },
resetForm() { resetForm() {
this.timeRang = [] this.timeRang = []
this.$refs.searchForm.resetFields() noticeStore.$patch((state) => {
state.search = {
title: '',
type: '',
startTime: '',
endTime: ''
}
})
} }
}, },
computed: { computed: {
...mapState(useNoticeStore, ['currentPage', 'pageSize', 'search']),
...mapState(useNoticeTypeStore, ['enableNoticeTypeList']) ...mapState(useNoticeTypeStore, ['enableNoticeTypeList'])
} }
} }

View File

@@ -169,7 +169,8 @@ export default {
'hackReset', 'hackReset',
'currentPage', 'currentPage',
'pageSize', 'pageSize',
'multiDeleteSelection' 'multiDeleteSelection',
'search'
]) ])
}, },
emits: ['clearFilter', 'handleDeleteById'], emits: ['clearFilter', 'handleDeleteById'],
@@ -246,18 +247,32 @@ export default {
noticeStore.$patch((state) => { noticeStore.$patch((state) => {
state.pageSize = pageSize state.pageSize = pageSize
}) })
noticeStore.selectAllNotice(this.currentPage, parseInt(pageSize)) noticeStore.selectAllNotice(
this.currentPage,
parseInt(pageSize),
this.search.title,
this.search.type,
this.search.startTime,
this.search.endTime
)
}, },
handleCurrentChange(currentPage) { handleCurrentChange(currentPage) {
// currentPage当前第几页 // currentPage当前第几页
noticeStore.$patch((state) => { noticeStore.$patch((state) => {
state.currentPage = currentPage state.currentPage = currentPage
}) })
noticeStore.selectAllNotice(parseInt(currentPage), this.pageSize) noticeStore.selectAllNotice(
parseInt(currentPage),
this.pageSize,
this.search.title,
this.search.type,
this.search.startTime,
this.search.endTime
)
} }
}, },
mounted() { mounted() {
noticeStore.selectAllNotice(this.currentPage, this.pageSize) noticeStore.selectAllNotice(this.currentPage, this.pageSize, '', '', '', '')
}, },
updated() { updated() {
this.$refs.tableRef.clearFilter(['sender.username']) this.$refs.tableRef.clearFilter(['sender.username'])

View File

@@ -63,31 +63,15 @@ export default {
SIZE_ICON_MD() { SIZE_ICON_MD() {
return SIZE_ICON_MD return SIZE_ICON_MD
}, },
selectByCond(currentPage, pageSize, search) { selectByCond() {
request noticeStore.selectAllNotice(
.get('/notice/page', { this.currentPage,
currentPage, this.pageSize,
pageSize, this.search.title,
title: search.title, this.search.type,
type: search.type, this.search.startTime,
startTime: search.startTime, this.search.endTime
endTime: search.endTime )
})
.then((response) => {
if (response.data.code === 20021) {
noticeStore.selectData = response.data.data
noticeStore.total = parseInt(response.data.msg)
ElMessage({
message: '查询成功.',
type: 'success'
})
} else if (response.data.code === 20031) {
ElMessage({
message: response.data.msg,
type: 'error'
})
}
})
}, },
handleDialogClose() { handleDialogClose() {
noticeStore.$patch((state) => { noticeStore.$patch((state) => {
@@ -111,7 +95,14 @@ export default {
message: '删除成功.', message: '删除成功.',
type: 'success' type: 'success'
}) })
noticeStore.selectAllNotice(this.currentPage, this.pageSize) noticeStore.selectAllNotice(
this.currentPage,
this.pageSize,
'',
'',
'',
''
)
} else if (response.data.code === 20034) { } else if (response.data.code === 20034) {
ElMessage({ ElMessage({
message: response.data.msg, message: response.data.msg,
@@ -130,7 +121,14 @@ export default {
}, },
getLoading() { getLoading() {
noticeStore.loading = true noticeStore.loading = true
noticeStore.selectAllNotice(this.currentPage, this.pageSize) noticeStore.selectAllNotice(
this.currentPage,
this.pageSize,
this.search.title,
this.search.type,
this.search.startTime,
this.search.endTime
)
}, },
deleteBatchByIds() { deleteBatchByIds() {
const multiDeleteIds = [] const multiDeleteIds = []
@@ -150,7 +148,14 @@ export default {
message: '删除成功.', message: '删除成功.',
type: 'success' type: 'success'
}) })
noticeStore.selectAllNotice(this.currentPage, this.pageSize) noticeStore.selectAllNotice(
this.currentPage,
this.pageSize,
'',
'',
'',
''
)
} else if (response.data.code === 20034) { } else if (response.data.code === 20034) {
ElMessage({ ElMessage({
message: response.data.msg, message: response.data.msg,
@@ -176,7 +181,8 @@ export default {
'dialogAddVisible', 'dialogAddVisible',
'currentPage', 'currentPage',
'pageSize', 'pageSize',
'multiDeleteSelection' 'multiDeleteSelection',
'search'
]) ])
} }
} }

View File

@@ -48,6 +48,12 @@ export const useNoticeStore = defineStore('notice', {
total: 0, total: 0,
pageSize: 5, pageSize: 5,
currentPage: 1, currentPage: 1,
search: {
title: '',
type: '',
startTime: '',
endTime: ''
},
selectData: [ selectData: [
{ {
content: '', content: '',
@@ -114,11 +120,22 @@ export const useNoticeStore = defineStore('notice', {
}, },
getters: {}, getters: {},
actions: { actions: {
async selectAllNotice(currentPage: number, pageSize: number) { async selectAllNotice(
currentPage: number,
pageSize: number,
title: string,
type: string,
startTime: string,
endTime: string
) {
void request void request
.get('/notice/page', { .get('/notice/page', {
currentPage, currentPage,
pageSize pageSize,
title,
type,
startTime,
endTime
}) })
.then((response) => { .then((response) => {
if (response.data.code === 20021) { if (response.data.code === 20021) {
@@ -174,7 +191,7 @@ export const useNoticeStore = defineStore('notice', {
}) })
} }
}) })
await this.selectAllNotice(1, 5) await this.selectAllNotice(1, 5, '', '', '', '')
}, },
async handleUpdateNotice(updateNotice: IAddNoticeData) { async handleUpdateNotice(updateNotice: IAddNoticeData) {
await request.put('/notice', updateNotice).then((response) => { await request.put('/notice', updateNotice).then((response) => {
@@ -192,7 +209,7 @@ export const useNoticeStore = defineStore('notice', {
}) })
} }
}) })
await this.selectAllNotice(1, 5) await this.selectAllNotice(1, 5, '', '', '', '')
this.hackReset = false this.hackReset = false
}, },
async modifyNoticeIsRead(notice: INotice) { async modifyNoticeIsRead(notice: INotice) {