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

delete the function of visitByMyself and optimize the loading of noticeReceiveBySelf

This commit is contained in:
cccccyb
2023-05-30 03:09:15 +08:00
parent 1cec2e191d
commit 3af559c5e4
8 changed files with 25 additions and 25 deletions

View File

@@ -69,13 +69,13 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
public Boolean deleteById(Long nid) { public Boolean deleteById(Long nid) {
LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>();
lqw.eq(NoticeReceive::getNoticeId, nid); lqw.eq(NoticeReceive::getNoticeId, nid);
Boolean flag = noticeReceiveMapper.delete(lqw) > 0; boolean flag = noticeReceiveMapper.delete(lqw) > 0;
return flag && noticeMapper.deleteById(nid) > 0; return flag && noticeMapper.deleteById(nid) > 0;
} }
@Override @Override
public Boolean deleteBatchByIds(List<Long> noticeIds) { public Boolean deleteBatchByIds(List<Long> noticeIds) {
Boolean flag = false; boolean flag = false;
for (Long nid : for (Long nid :
noticeIds) { noticeIds) {
LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>();
@@ -109,18 +109,12 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
@Override @Override
public Boolean addNotice(Notice notice) { public Boolean addNotice(Notice notice) {
Boolean noticeFlag, noticeRecFlag = false; boolean noticeFlag, noticeRecFlag = false;
notice.setSenderId(WebUtil.getLoginUser().getUser().getId()); notice.setSenderId(WebUtil.getLoginUser().getUser().getId());
// notice.setSenderId(1652714496280469506L); // notice.setSenderId(1652714496280469506L);
noticeFlag = noticeMapper.insert(notice) > 0; noticeFlag = noticeMapper.insert(notice) > 0;
Long noticeId = notice.getId(); 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 {
for (Long receiveId : for (Long receiveId :
notice.getReceivers()) { notice.getReceivers()) {
NoticeReceive noticeReceive = new NoticeReceive(); NoticeReceive noticeReceive = new NoticeReceive();
@@ -131,6 +125,8 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
break; break;
} }
} }
} else {
noticeFlag = false;
} }
return noticeFlag && noticeRecFlag; return noticeFlag && noticeRecFlag;
} }

View File

@@ -63,10 +63,7 @@
size="large" size="large"
/> />
</el-form-item> </el-form-item>
<el-form-item label="是否仅自己可见:"> <el-form-item label="发送至:" prop="receivers">
<el-switch v-model="visible" inline-prompt active-text="是" inactive-text="否" />
</el-form-item>
<el-form-item label="发送至:" prop="receivers" v-show="!visible">
<el-cascader <el-cascader
v-model="addData.receivers" v-model="addData.receivers"
collapse-tags collapse-tags
@@ -155,7 +152,7 @@ export default {
methods: { methods: {
submitForm() { submitForm() {
const receiveId = [] const receiveId = []
if (this.addData.receivers.length != null) { if (this.addData.receivers.length > 0) {
for (let i = 0; i < this.addData.receivers.length; i++) { for (let i = 0; i < this.addData.receivers.length; i++) {
receiveId.push(this.addData.receivers[i][1]) receiveId.push(this.addData.receivers[i][1])
} }

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="myTimeline"> <div class="myTimeline" v-loading="showLoading" element-loading-text="加载中...">
<el-timeline> <el-timeline>
<el-timeline-item <el-timeline-item
v-for="notice in selectData" v-for="notice in selectData"
@@ -219,7 +219,8 @@ export default {
'loading', 'loading',
'dialogShowVisible', 'dialogShowVisible',
'noticeShowData', 'noticeShowData',
'currentViewPage' 'currentViewPage',
'showLoading'
]) ])
}, },
watch: { watch: {

View File

@@ -10,10 +10,11 @@ export default {
}, },
methods: {}, methods: {},
mounted() { mounted() {
noticeStore.selectAllNoticeSelf(1)
noticeStore.$patch((state) => { noticeStore.$patch((state) => {
state.showLoading = true
state.currentViewPage = 'AlRead' state.currentViewPage = 'AlRead'
}) })
noticeStore.selectAllNoticeSelf(1)
} }
} }
</script> </script>

View File

@@ -3,6 +3,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { useNoticeStore } from '@/store/notice' import { useNoticeStore } from '@/store/notice'
import { mapState } from 'pinia'
const noticeStore = useNoticeStore() const noticeStore = useNoticeStore()
export default { export default {
data() { data() {
@@ -10,10 +11,14 @@ export default {
}, },
methods: {}, methods: {},
mounted() { mounted() {
noticeStore.selectAllNoticeSelf(-1)
noticeStore.$patch((state) => { noticeStore.$patch((state) => {
state.showLoading = true
state.currentViewPage = 'All' state.currentViewPage = 'All'
}) })
noticeStore.selectAllNoticeSelf(-1)
},
computed: {
...mapState(useNoticeStore, ['showLoading'])
} }
} }
</script> </script>

View File

@@ -111,7 +111,7 @@ export default {
message: '删除成功.', message: '删除成功.',
type: 'success' type: 'success'
}) })
noticeStore.selectAllNotice(1, 5) 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,

View File

@@ -10,10 +10,11 @@ export default {
}, },
methods: {}, methods: {},
mounted() { mounted() {
noticeStore.selectAllNoticeSelf(0)
noticeStore.$patch((state) => { noticeStore.$patch((state) => {
state.showLoading = true
state.currentViewPage = 'ToRead' state.currentViewPage = 'ToRead'
}) })
noticeStore.selectAllNoticeSelf(0)
} }
} }
</script> </script>

View File

@@ -76,6 +76,7 @@ export const useNoticeStore = defineStore('notice', {
} }
], ],
loading: true, loading: true,
showLoading: true,
dialogShowVisible: false, dialogShowVisible: false,
dialogAddVisible: false, dialogAddVisible: false,
dialogEditVisible: false, dialogEditVisible: false,
@@ -143,11 +144,9 @@ export const useNoticeStore = defineStore('notice', {
.then((response) => { .then((response) => {
if (response.data.code === 20021) { if (response.data.code === 20021) {
this.selectData = response.data.data this.selectData = response.data.data
if (this.selectData.length !== 0) { this.showLoading = false
this.loading = false
}
} else { } else {
this.loading = false this.showLoading = false
ElMessage({ ElMessage({
message: response.data.msg, message: response.data.msg,
type: 'error' type: 'error'