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

add the function of fuzzy query item

This commit is contained in:
cccccyb
2023-06-04 02:27:47 +08:00
parent 6860f2bdac
commit fe876c5a36
9 changed files with 50 additions and 41 deletions

View File

@@ -39,15 +39,15 @@ public class NoticeController {
//分页查询所有公告或分页模糊查询 //分页查询所有公告或分页模糊查询
@GetMapping("/page") @GetMapping("/page")
@PreAuthorize("hasAuthority('notice:manage:get')") @PreAuthorize("hasAuthority('notice:manage:get')")
public ResponseResult<List<Notice>> selectPageNotice(Integer currentPage, Integer pageSize, String title, String type, String startTime, String endTime) { public ResponseResult<List<Notice>> selectPageNotice(Integer currentPage, Integer pageSize, String title, String type, String startTime, String endTime,String userName) {
Page<Notice> noticePage = null; Page<Notice> noticePage;
if (null != currentPage && null != pageSize) { if (null != currentPage && null != pageSize) {
noticePage = PageDTO.of(currentPage, pageSize); noticePage = PageDTO.of(currentPage, pageSize);
} else { } else {
// 不进行分页 // 不进行分页
noticePage = PageDTO.of(1, -1); noticePage = PageDTO.of(1, -1);
} }
IPage<Notice> noticeIPage = noticeService.selectPageNotice(noticePage, title.trim(), type.trim(), startTime.trim(), endTime.trim()); IPage<Notice> noticeIPage = noticeService.selectPageNotice(noticePage, title.trim(), type.trim(), startTime.trim(), endTime.trim(),userName.trim());
int code = noticeIPage.getRecords() != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR; int code = noticeIPage.getRecords() != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = noticeIPage.getRecords() != null ? String.valueOf(noticeIPage.getTotal()) : "数据查询失败,请重试!"; String msg = noticeIPage.getRecords() != null ? String.valueOf(noticeIPage.getTotal()) : "数据查询失败,请重试!";
return ResponseResult.build(code, msg, noticeIPage.getRecords()); return ResponseResult.build(code, msg, noticeIPage.getRecords());

View File

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

View File

@@ -27,5 +27,5 @@ public interface INoticeService extends IService<Notice> {
Boolean addNotice(Notice notice); Boolean addNotice(Notice notice);
IPage<Notice> selectPageNotice(IPage<Notice> page, String title, String type, String startTime, String endTime); IPage<Notice> selectPageNotice(IPage<Notice> page, String title, String type, String startTime, String endTime,String userName);
} }

View File

@@ -44,13 +44,13 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
} }
@Override @Override
public IPage<Notice> selectPageNotice(IPage<Notice> page, String title, String type, String startTime, String endTime) { public IPage<Notice> selectPageNotice(IPage<Notice> page, String title, String type, String startTime, String endTime,String userName) {
LocalDateTime start=null,end=null; LocalDateTime start=null,end=null;
if (startTime!=""&&endTime!=""){ if (startTime!=""&&endTime!=""){
start= LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); 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"));
} }
return noticeMapper.selectPageNotice(page, title, type, start, end); return noticeMapper.selectPageNotice(page, title, type, start, end,userName);
} }
@Override @Override

View File

@@ -42,16 +42,19 @@
left join t_user u on n.sender_id = u.id left join t_user u on n.sender_id = u.id
<where> <where>
<if test="null!=title and title!=''"> <if test="null!=title and title!=''">
and instr(title,#{title})&gt;0 and instr(n.title,#{title})&gt;0
</if> </if>
<if test="null!=type and type!=''"> <if test="null!=type and type!=''">
and instr(type.name,#{type})&gt;0 and instr(type.name,#{type})&gt;0
</if> </if>
<if test="null!=startTime"> <if test="null!=startTime">
and send_time &gt;= #{startTime} and n.send_time &gt;= #{startTime}
</if> </if>
<if test="null !=endTime"> <if test="null !=endTime">
and end_time &lt; #{endTime} and n.end_time &lt; #{endTime}
</if>
<if test="null!=userName and userName!=''">
and u.username = #{userName}
</if> </if>
and n.deleted = 0 and n.deleted = 0
and n.old = 0 and n.old = 0

View File

@@ -108,9 +108,11 @@ export default {
title: '', title: '',
type: '', type: '',
startTime: '', startTime: '',
endTime: '' endTime: '',
userName: ''
} }
}) })
this.$emit('selectByCond')
} }
}, },
computed: { computed: {

View File

@@ -77,7 +77,7 @@
/> />
<el-table-column <el-table-column
prop="sender.username" prop="sender.username"
label="发布" label="发布"
width="100" width="100"
column-key="sender.username" column-key="sender.username"
:filters="filterSenderName" :filters="filterSenderName"
@@ -196,10 +196,6 @@ export default {
state.multiDeleteSelection = val state.multiDeleteSelection = val
}) })
}, },
clearFilter() {
this.$refs.tableRef.clearFilter(['senderName'])
this.$emit('clearFilter')
},
formatterTitle(title) { formatterTitle(title) {
if (title.length > 10) { if (title.length > 10) {
return title.substring(0, 10) + ' ...' return title.substring(0, 10) + ' ...'
@@ -207,8 +203,19 @@ export default {
return title return title
} }
}, },
filterTag(value, row) { filterTag(value) {
return row.sender.username === value noticeStore.$patch((state) => {
state.search.userName = value
})
noticeStore.selectAllNotice(
this.currentPage,
this.pageSize,
this.search.title,
this.search.type,
this.search.startTime,
this.search.endTime,
this.search.userName
)
}, },
formatDate(row, column) { formatDate(row, column) {
// 获取单元格数据 // 获取单元格数据
@@ -253,7 +260,8 @@ export default {
this.search.title, this.search.title,
this.search.type, this.search.type,
this.search.startTime, this.search.startTime,
this.search.endTime this.search.endTime,
this.search.userName
) )
}, },
handleCurrentChange(currentPage) { handleCurrentChange(currentPage) {
@@ -267,12 +275,13 @@ export default {
this.search.title, this.search.title,
this.search.type, this.search.type,
this.search.startTime, this.search.startTime,
this.search.endTime this.search.endTime,
this.search.userName
) )
} }
}, },
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

@@ -1,7 +1,7 @@
<template> <template>
<el-container> <el-container>
<el-header> <el-header>
<notice-head @selectByCond="selectByCond"></notice-head> <notice-head @selectByCond="getLoading"></notice-head>
</el-header> </el-header>
<el-main> <el-main>
<el-button <el-button
@@ -63,16 +63,6 @@ export default {
SIZE_ICON_MD() { SIZE_ICON_MD() {
return SIZE_ICON_MD return SIZE_ICON_MD
}, },
selectByCond() {
noticeStore.selectAllNotice(
this.currentPage,
this.pageSize,
this.search.title,
this.search.type,
this.search.startTime,
this.search.endTime
)
},
handleDialogClose() { handleDialogClose() {
noticeStore.$patch((state) => { noticeStore.$patch((state) => {
state.dialogEditVisible = false state.dialogEditVisible = false
@@ -101,6 +91,7 @@ export default {
'', '',
'', '',
'', '',
'',
'' ''
) )
} else if (response.data.code === 20034) { } else if (response.data.code === 20034) {
@@ -127,7 +118,8 @@ export default {
this.search.title, this.search.title,
this.search.type, this.search.type,
this.search.startTime, this.search.startTime,
this.search.endTime this.search.endTime,
this.search.userName
) )
}, },
deleteBatchByIds() { deleteBatchByIds() {
@@ -154,6 +146,7 @@ export default {
'', '',
'', '',
'', '',
'',
'' ''
) )
} else if (response.data.code === 20034) { } else if (response.data.code === 20034) {

View File

@@ -52,7 +52,8 @@ export const useNoticeStore = defineStore('notice', {
title: '', title: '',
type: '', type: '',
startTime: '', startTime: '',
endTime: '' endTime: '',
userName: ''
}, },
selectData: [ selectData: [
{ {
@@ -126,7 +127,8 @@ export const useNoticeStore = defineStore('notice', {
title: string, title: string,
type: string, type: string,
startTime: string, startTime: string,
endTime: string endTime: string,
userName: string
) { ) {
void request void request
.get('/notice/page', { .get('/notice/page', {
@@ -135,15 +137,14 @@ export const useNoticeStore = defineStore('notice', {
title, title,
type, type,
startTime, startTime,
endTime endTime,
userName
}) })
.then((response) => { .then((response) => {
if (response.data.code === 20021) { if (response.data.code === 20021) {
this.selectData = response.data.data this.selectData = response.data.data
this.total = parseInt(response.data.msg) this.total = parseInt(response.data.msg)
if (this.selectData.length !== 0) { this.loading = false
this.loading = false
}
} else { } else {
this.loading = false this.loading = false
ElMessage({ ElMessage({
@@ -191,7 +192,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) => {
@@ -209,7 +210,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) {