mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-04 22:41:24 +08:00
use pinia to modify notice update function and add pagination to noticeManage page
This commit is contained in:
@@ -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.Notice;
|
||||
import com.cfive.pinnacle.entity.NoticeReceive;
|
||||
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||
@@ -40,7 +42,7 @@ public class NoticeController {
|
||||
return ResponseResult.build(code, msg, noticeById);
|
||||
}
|
||||
|
||||
//查询所有公告
|
||||
//查询所有公告或模糊查询
|
||||
@GetMapping
|
||||
public ResponseResult selectAllNotice(String title, String type, String startTime, String endTime) {
|
||||
List<Notice> noticeList;
|
||||
@@ -88,4 +90,27 @@ public class NoticeController {
|
||||
return ResponseResult.build(removeById ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, removeById);
|
||||
}
|
||||
|
||||
//分页查询所有公告或分页模糊查询
|
||||
@GetMapping("/page")
|
||||
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){
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.cfive.pinnacle.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cfive.pinnacle.entity.Notice;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@@ -22,4 +23,8 @@ public interface NoticeMapper extends BaseMapper<Notice> {
|
||||
List<Notice> selectAllNotice();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.cfive.pinnacle.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cfive.pinnacle.entity.Notice;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@@ -18,11 +19,15 @@ public interface INoticeService extends IService<Notice> {
|
||||
|
||||
List<Notice> selectAllNotice();
|
||||
|
||||
List<Notice> selectByCond(String title,String type,String startTime,String endTime);
|
||||
List<Notice> selectByCond(String title, String type, String startTime, String endTime);
|
||||
|
||||
Boolean deleteById(Long nid);
|
||||
|
||||
Boolean updateNotice(Notice notice);
|
||||
|
||||
Boolean addNotice(Notice notice);
|
||||
|
||||
IPage<Notice> selectPageAllNotice(IPage<?> page);
|
||||
|
||||
IPage<Notice> selectPageByCond(IPage<?> page, String title, String type, String startTime, String endTime);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.cfive.pinnacle.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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;
|
||||
@@ -48,20 +49,6 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
@Override
|
||||
public List<Notice> selectAllNotice() {
|
||||
List<Notice> notices = noticeMapper.selectAllNotice();
|
||||
// if (null != notices) {
|
||||
// for (Notice notice :
|
||||
// notices) {
|
||||
// LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>();
|
||||
// lqw.eq(NoticeReceive::getNoticeId, notice.getId());
|
||||
// List<NoticeReceive> noticeReceives = noticeReceiveMapper.selectList(lqw);
|
||||
// List<Long> receiverIdList = new ArrayList<>();
|
||||
// for (NoticeReceive noticeReceive :
|
||||
// noticeReceives) {
|
||||
// receiverIdList.add(noticeReceive.getUserId());
|
||||
// }
|
||||
// notice.setReceivers(receiverIdList);
|
||||
// }
|
||||
// }
|
||||
return notices;
|
||||
}
|
||||
|
||||
@@ -105,8 +92,8 @@ 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&¬iceMapper.deleteById(nid) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,21 +109,48 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
@Override
|
||||
public Boolean addNotice(Notice notice) {
|
||||
Boolean noticeFlag,noticeRecFlag=false;
|
||||
// notice.setSenderId(WebUtil.getLoginUser().getUser().getId());
|
||||
notice.setSenderId(1652714496280469506L);
|
||||
notice.setSenderId(WebUtil.getLoginUser().getUser().getId());
|
||||
// notice.setSenderId(1652714496280469506L);
|
||||
noticeFlag = noticeMapper.insert(notice)>0;
|
||||
Long noticeId = notice.getId();
|
||||
for (Long receiveId :
|
||||
notice.getReceivers()) {
|
||||
if (notice.getReceivers().size()==0){
|
||||
//该公告仅发布者自己可见
|
||||
NoticeReceive noticeReceive = new NoticeReceive();
|
||||
noticeReceive.setNoticeId(noticeId);
|
||||
noticeReceive.setUserId(receiveId);
|
||||
noticeReceive.setUserId(WebUtil.getLoginUser().getUser().getId());
|
||||
noticeRecFlag = noticeReceiveMapper.insert(noticeReceive)>0;
|
||||
if (!noticeRecFlag){
|
||||
break;
|
||||
}else {
|
||||
for (Long receiveId :
|
||||
notice.getReceivers()) {
|
||||
NoticeReceive noticeReceive = new NoticeReceive();
|
||||
noticeReceive.setNoticeId(noticeId);
|
||||
noticeReceive.setUserId(receiveId);
|
||||
noticeRecFlag = noticeReceiveMapper.insert(noticeReceive)>0;
|
||||
if (!noticeRecFlag){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return noticeFlag && noticeRecFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<Notice> selectPageAllNotice(IPage<?> page) {
|
||||
return noticeMapper.selectPageAllNotice(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<Notice> selectPageByCond(IPage<?> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,21 +21,48 @@
|
||||
<!-- 查询所有公告 -->
|
||||
<select id="selectAllNotice" resultMap="NoticeAllResultMap">
|
||||
select u.id uid,
|
||||
username,
|
||||
u.username,
|
||||
n.id nid,
|
||||
title,
|
||||
content,
|
||||
type_id,
|
||||
sender_id,
|
||||
create_time,
|
||||
send_time,
|
||||
end_time,
|
||||
priority,
|
||||
top,
|
||||
modify_time,
|
||||
origin_id,
|
||||
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,
|
||||
name,
|
||||
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
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<!-- 分页查询所有公告 -->
|
||||
<select id="selectPageAllNotice" 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
|
||||
@@ -53,22 +80,62 @@
|
||||
<id property="id" column="typeId"/>
|
||||
</association>
|
||||
</resultMap>
|
||||
<!-- 模糊查询-->
|
||||
<!-- 模糊查询公告-->
|
||||
<select id="selectByCond" resultMap="NoticeAllResultMap">
|
||||
select u.id uid,
|
||||
username,
|
||||
u.username,
|
||||
n.id nid,
|
||||
title,
|
||||
content,
|
||||
type_id,
|
||||
sender_id,
|
||||
create_time,
|
||||
send_time,
|
||||
end_time,
|
||||
priority,
|
||||
top,
|
||||
modify_time,
|
||||
origin_id,
|
||||
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})>0
|
||||
</if>
|
||||
<if test="null!=type and type!=''">
|
||||
and instr(type.name,#{type})>0
|
||||
</if>
|
||||
<if test="null!=startTime">
|
||||
and send_time >= #{startTime}
|
||||
</if>
|
||||
<if test="null !=endTime">
|
||||
and end_time < #{endTime}
|
||||
</if>
|
||||
and n.deleted = 0
|
||||
and n.old = 0
|
||||
</where>
|
||||
</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
|
||||
|
||||
@@ -40,7 +40,7 @@ public class NoticeTest {
|
||||
|
||||
@Test
|
||||
void selectAllTest() {
|
||||
ResponseResult noticeList = noticeController.selectAllNotice(null, null,null,null);
|
||||
// ResponseResult noticeList = noticeController.selectAllNotice(null, null,null,null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-form :model="addData" :rules="rules" ref="addData" label-width="100px">
|
||||
<el-form :model="addData" :rules="rules" ref="addData" label-width="150px">
|
||||
<el-form-item label="公告标题" prop="title">
|
||||
<el-input v-model="addData.title"></el-input>
|
||||
</el-form-item>
|
||||
@@ -24,7 +24,6 @@
|
||||
v-model="addData.sendTime"
|
||||
style="width: 100%"
|
||||
size="large"
|
||||
:picker-options="pickerOptions"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -50,7 +49,10 @@
|
||||
<el-form-item label="公告优先级" prop="priority">
|
||||
<el-slider v-model="addData.priority" show-input show-stops :max="15" size="large" />
|
||||
</el-form-item>
|
||||
<el-form-item label="发送至:" prop="receivers">
|
||||
<el-form-item label="是否仅自己可见:">
|
||||
<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
|
||||
v-model="addData.receivers"
|
||||
collapse-tags
|
||||
@@ -65,10 +67,10 @@
|
||||
placeholder="选择公告接收者"
|
||||
>
|
||||
<template #default="scope">
|
||||
<span v-if="scope.node.level == 1">{{
|
||||
<span v-if="scope.node.level === 1">{{
|
||||
((scope.node.value = scope.data.id), (scope.node.label = scope.data.name))
|
||||
}}</span>
|
||||
<span v-if="scope.node.level == 2">{{
|
||||
<span v-if="scope.node.level === 2">{{
|
||||
((scope.node.value = scope.data.id),
|
||||
(scope.node.label = scope.data.username))
|
||||
}}</span>
|
||||
@@ -92,13 +94,11 @@ import { mapState } from 'pinia'
|
||||
const noticeStore = useNoticeStore()
|
||||
export default {
|
||||
computed:{
|
||||
...mapState(useNoticeStore,['noticeTypeList','departmentList'])
|
||||
},
|
||||
props:{
|
||||
noticeEdit:{}
|
||||
...mapState(useNoticeStore,['noticeTypeList','departmentList','noticeShowData'])
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible:false,
|
||||
addData: {
|
||||
title: '',
|
||||
typeId: '',
|
||||
@@ -109,7 +109,6 @@ export default {
|
||||
content: '',
|
||||
receivers:[]
|
||||
},
|
||||
pickerOptions: {},
|
||||
rules: {
|
||||
title: [
|
||||
{ required: true, message: '请输入公告标题', trigger: 'blur' },
|
||||
@@ -126,10 +125,10 @@ export default {
|
||||
],
|
||||
content: [
|
||||
{ required: true, message: '请填写公告内容', trigger: 'blur' }
|
||||
],
|
||||
receivers: [
|
||||
{ type:'array',required: true, message: '请选择公告接收者', trigger: 'change' }
|
||||
]
|
||||
// receivers: [
|
||||
// { type:'array',required: true, message: '请选择公告接收者', trigger: 'change' }
|
||||
// ]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,15 +137,19 @@ export default {
|
||||
submitForm() {
|
||||
this.addData.top=this.addData.top?1:0;
|
||||
const receiveId=[]
|
||||
for (let i = 0; i < this.addData.receivers.length; i++) {
|
||||
receiveId.push(this.addData.receivers[i][1])
|
||||
if (this.addData.receivers!==[]){
|
||||
for (let i = 0; i < this.addData.receivers.length; i++) {
|
||||
receiveId.push(this.addData.receivers[i][1])
|
||||
}
|
||||
}
|
||||
this.addData.receivers=receiveId
|
||||
this.$refs.addData.validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.noticeEdit){
|
||||
this.$emit("handleUpdateNotice",this.addData)
|
||||
if (noticeStore.editFlag===true){
|
||||
// 编辑操作
|
||||
noticeStore.handleUpdateNotice(this.addData)
|
||||
}else {
|
||||
// 添加操作
|
||||
noticeStore.handleAddNotice(this.addData)
|
||||
}
|
||||
} else {
|
||||
@@ -157,6 +160,9 @@ export default {
|
||||
closeForm(){
|
||||
noticeStore.$patch(state=>{
|
||||
state.dialogAddVisible=false
|
||||
state.dialogEditVisible=false
|
||||
state.hackReset=false
|
||||
state.editFlag=false
|
||||
})
|
||||
},
|
||||
resetForm() {
|
||||
@@ -164,34 +170,19 @@ export default {
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.pickerOptions.disabledDate=(time)=> {
|
||||
if (this.addData.sendTime !== '') {
|
||||
const tempTime = 3600 * 1000 * 24 * 2;
|
||||
const timer = new Date(this.currentDate).getTime();
|
||||
const minTime = timer - tempTime;
|
||||
const maxTime = timer + tempTime;
|
||||
return time.getTime() < minTime || time.getTime() > Date.now() || time.getTime() > maxTime;
|
||||
}
|
||||
}
|
||||
if (this.noticeEdit) {
|
||||
this.addData = this.noticeEdit
|
||||
// 判断是否置顶
|
||||
this.addData.top=this.noticeEdit.top===1;
|
||||
// 编辑操作
|
||||
if (noticeStore.editFlag===true) {
|
||||
this.addData = noticeStore.noticeShowData
|
||||
console.log("created")
|
||||
console.log(this.addData)
|
||||
}
|
||||
},
|
||||
updated() {
|
||||
if (this.noticeEdit) {
|
||||
this.addData = this.noticeEdit
|
||||
// 判断是否置顶
|
||||
this.addData.top=this.noticeEdit.top===1;
|
||||
console.log(this.addData)
|
||||
this.addData.top=(noticeStore.noticeShowData.top===1);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log("mounted")
|
||||
noticeStore.selectDepartment()
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
@@ -91,7 +91,7 @@ export default {
|
||||
this.search_info.startTime = this.handleDateFormatUTC(this.timeRang[0])
|
||||
this.search_info.endTime = this.handleDateFormatUTC(this.timeRang[1])
|
||||
}
|
||||
this.$emit('selectByCond', this.search_info)
|
||||
this.$emit('selectByCond', 1, 5, this.search_info)
|
||||
},
|
||||
handleDateFormatUTC(date) {
|
||||
let newFormat = ''
|
||||
|
||||
@@ -10,16 +10,17 @@
|
||||
element-loading-text="加载中..."
|
||||
ref="tableRef"
|
||||
:data="selectData"
|
||||
style="width: 100%"
|
||||
border
|
||||
highlight-current-row
|
||||
@selection-change="handleSelectionChange"
|
||||
:header-cell-style="{
|
||||
background: 'darksalmon',
|
||||
'text-align': 'center',
|
||||
color: '#fff',
|
||||
'font-size': '20px'
|
||||
}"
|
||||
>
|
||||
><el-table-column type="selection" width="55" />
|
||||
<el-table-column type="index" label="序号" width="70" />
|
||||
<el-table-column
|
||||
prop="title"
|
||||
label="公告标题"
|
||||
@@ -91,17 +92,32 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页条-->
|
||||
<div class="pagination">
|
||||
<el-pagination
|
||||
style="text-align: center"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
background
|
||||
:page-sizes="[5, 10, 20, 40]"
|
||||
:total="total"
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
>
|
||||
</el-pagination>
|
||||
</div>
|
||||
<!-- 编辑会话框-->
|
||||
<el-dialog v-model="dialogEditVisible" center>
|
||||
<el-dialog
|
||||
v-model="dialogEditVisible"
|
||||
center
|
||||
v-if="hackReset"
|
||||
:before-close="handleDialogClose"
|
||||
>
|
||||
<template #header>
|
||||
<h2 style="color: red">编辑公告</h2>
|
||||
</template>
|
||||
<commitForm
|
||||
:noticeEdit="noticeEdit"
|
||||
:noticeTypeList="noticeTypeList"
|
||||
:departmentList="departmentList"
|
||||
@handleUpdateNotice="handleUpdateNotice"
|
||||
></commitForm>
|
||||
<commitForm />
|
||||
</el-dialog>
|
||||
<!-- 查看会话框-->
|
||||
<el-dialog v-model="dialogShowVisible" center>
|
||||
@@ -120,26 +136,34 @@ const noticeStore = useNoticeStore()
|
||||
export default {
|
||||
computed: {
|
||||
...mapState(useNoticeStore, [
|
||||
'total',
|
||||
'selectData',
|
||||
'loading',
|
||||
'dialogShowVisible',
|
||||
'noticeShowData'
|
||||
'noticeShowData',
|
||||
'dialogEditVisible',
|
||||
'hackReset'
|
||||
])
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
filterSenderName: [],
|
||||
dialogEditVisible: false,
|
||||
noticeEdit: {}
|
||||
multipleSelection: [],
|
||||
currentPage: 1,
|
||||
pageSize: 5
|
||||
}
|
||||
},
|
||||
props: ['noticeTypeList', 'departmentList', 'dialogUpdateVisible'],
|
||||
props: [],
|
||||
methods: {
|
||||
handleSelectionChange(val) {
|
||||
// val的值为所勾选行的数组对象
|
||||
this.multipleSelection = val
|
||||
},
|
||||
clearFilter() {
|
||||
this.$refs.tableRef.clearFilter(['senderName'])
|
||||
this.$emit('clearFilter')
|
||||
},
|
||||
formatter(row, column) {
|
||||
formatter(row) {
|
||||
return row.title
|
||||
},
|
||||
filterTag(value, row) {
|
||||
@@ -152,12 +176,19 @@ export default {
|
||||
return new Date(data).toLocaleString()
|
||||
},
|
||||
handleEdit(index, row) {
|
||||
this.dialogEditVisible = true
|
||||
this.noticeEdit = row
|
||||
noticeStore.$patch((state) => {
|
||||
state.hackReset = true
|
||||
state.noticeShowData = row
|
||||
state.editFlag = true
|
||||
state.dialogEditVisible = true
|
||||
})
|
||||
},
|
||||
handleUpdateNotice(updateData) {
|
||||
this.$emit('handleUpdateNotice', updateData)
|
||||
this.dialogEditVisible = this.dialogUpdateVisible
|
||||
handleDialogClose() {
|
||||
noticeStore.$patch((state) => {
|
||||
state.dialogEditVisible = false
|
||||
state.editFlag = false
|
||||
state.hackReset = false
|
||||
})
|
||||
},
|
||||
handleShow(index, row) {
|
||||
noticeStore.$patch((state) => {
|
||||
@@ -167,14 +198,20 @@ export default {
|
||||
},
|
||||
handleDeleteById(deleteId) {
|
||||
this.$emit('handleDeleteById', deleteId)
|
||||
},
|
||||
handleSizeChange(pageSize) {
|
||||
// pageSize:每页多少条数据
|
||||
noticeStore.selectAllNotice(this.currentPage, parseInt(pageSize))
|
||||
},
|
||||
handleCurrentChange(currentPage) {
|
||||
// currentPage:当前第几页
|
||||
noticeStore.selectAllNotice(parseInt(currentPage), this.pageSize)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log('mounted')
|
||||
noticeStore.selectAllNotice()
|
||||
noticeStore.selectAllNotice(this.currentPage, this.pageSize)
|
||||
},
|
||||
updated() {
|
||||
console.log('updated')
|
||||
this.$refs.tableRef.clearFilter(['sender.username'])
|
||||
this.filterSenderName = []
|
||||
const nameArray = []
|
||||
@@ -194,4 +231,8 @@ export default {
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
<style scoped>
|
||||
.pagination {
|
||||
margin: 30px 400px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -18,10 +18,8 @@
|
||||
<commitForm />
|
||||
</el-dialog>
|
||||
<notice-manage-table
|
||||
:dialogUpdateVisible="dialogUpdateVisible"
|
||||
@handleDeleteById="handleDeleteById"
|
||||
@clearFilter="clearFilter"
|
||||
@handleUpdateNotice="handleUpdateNotice"
|
||||
></notice-manage-table>
|
||||
</el-main>
|
||||
</el-container>
|
||||
@@ -39,14 +37,14 @@ const noticeStore = useNoticeStore()
|
||||
export default {
|
||||
name: 'NoticeHome',
|
||||
data() {
|
||||
return {
|
||||
dialogUpdateVisible: false
|
||||
}
|
||||
return {}
|
||||
},
|
||||
methods: {
|
||||
selectByCond(search) {
|
||||
selectByCond(currentPage, pageSize, search) {
|
||||
request
|
||||
.get('/notice', {
|
||||
.get('/notice/page', {
|
||||
currentPage,
|
||||
pageSize,
|
||||
title: search.title,
|
||||
type: search.type,
|
||||
startTime: search.startTime,
|
||||
@@ -80,7 +78,7 @@ export default {
|
||||
message: '删除成功.',
|
||||
type: 'success'
|
||||
})
|
||||
noticeStore.selectAllNotice()
|
||||
noticeStore.selectAllNotice(1, 5)
|
||||
} else if (response.data.code === 20034) {
|
||||
ElMessage({
|
||||
message: response.data.msg,
|
||||
@@ -94,25 +92,9 @@ export default {
|
||||
openAddNoticeDialog() {
|
||||
noticeStore.$patch((state) => {
|
||||
state.dialogAddVisible = true
|
||||
state.editFlag = false
|
||||
})
|
||||
},
|
||||
handleUpdateNotice(updateNotice) {
|
||||
request.put('/notice', updateNotice).then((response) => {
|
||||
if (response.data.code === 20023) {
|
||||
this.dialogUpdateVisible = false
|
||||
ElMessage({
|
||||
message: '发布成功.',
|
||||
type: 'success'
|
||||
})
|
||||
} else if (response.data.code === 20033) {
|
||||
ElMessage({
|
||||
message: response.data.msg,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
})
|
||||
this.$router.go(0)
|
||||
},
|
||||
clearFilter() {
|
||||
// this.selectAllNotice()
|
||||
// location.reload()
|
||||
|
||||
@@ -15,44 +15,65 @@ export interface IAddFormData {
|
||||
export const useNoticeStore = defineStore('notice', {
|
||||
state: () => {
|
||||
return {
|
||||
total: 0,
|
||||
selectData: [],
|
||||
loading: true,
|
||||
dialogShowVisible: false,
|
||||
dialogAddVisible: false,
|
||||
dialogEditVisible: false,
|
||||
editFlag: false,
|
||||
hackReset: true,
|
||||
noticeTypeList: [],
|
||||
departmentList: [],
|
||||
noticeShowData: {
|
||||
content: String,
|
||||
createTime: String,
|
||||
endTime: String,
|
||||
id: String,
|
||||
priority: Number,
|
||||
content: '',
|
||||
createTime: '',
|
||||
endTime: '',
|
||||
id: '',
|
||||
modifyTime: '',
|
||||
priority: 0,
|
||||
receivers: [],
|
||||
sendTime: String,
|
||||
title: String,
|
||||
top: Number,
|
||||
sendTime: '',
|
||||
title: '',
|
||||
top: 0,
|
||||
noticeType: {
|
||||
id: String,
|
||||
name: String,
|
||||
enable: Number
|
||||
id: '',
|
||||
name: '',
|
||||
enable: 0
|
||||
},
|
||||
sender: {
|
||||
id: String,
|
||||
username: String
|
||||
}
|
||||
id: '',
|
||||
username: '',
|
||||
enable: 0
|
||||
},
|
||||
senderId: '',
|
||||
typeId: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
getters: {},
|
||||
actions: {
|
||||
selectAllNotice() {
|
||||
console.log('selectAll')
|
||||
void request.get('/notice').then((response) => {
|
||||
this.selectData = response.data.data
|
||||
if (this.selectData.length !== 0) {
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
// selectAllNotice() {
|
||||
// void request.get('/notice/page').then((response) => {
|
||||
// this.selectData = response.data.data
|
||||
// if (this.selectData.length !== 0) {
|
||||
// this.loading = false
|
||||
// }
|
||||
// })
|
||||
// },
|
||||
selectAllNotice(currentPage: number, pageSize: number) {
|
||||
void request
|
||||
.get('/notice/page', {
|
||||
currentPage,
|
||||
pageSize
|
||||
})
|
||||
.then((response) => {
|
||||
this.selectData = response.data.data
|
||||
this.total = parseInt(response.data.msg)
|
||||
if (this.selectData.length !== 0) {
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
},
|
||||
async selectAllNoticeByUserId() {
|
||||
await request.get('/notice/ByUserId').then((response) => {
|
||||
@@ -87,7 +108,25 @@ export const useNoticeStore = defineStore('notice', {
|
||||
})
|
||||
}
|
||||
})
|
||||
this.selectAllNotice()
|
||||
this.selectAllNotice(1, 5)
|
||||
},
|
||||
async handleUpdateNotice(updateNotice: IAddFormData) {
|
||||
await request.put('/notice', updateNotice).then((response) => {
|
||||
if (response.data.code === 20023) {
|
||||
this.dialogEditVisible = false
|
||||
ElMessage({
|
||||
message: '修改成功.',
|
||||
type: 'success'
|
||||
})
|
||||
} else if (response.data.code === 20033) {
|
||||
ElMessage({
|
||||
message: response.data.msg,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
})
|
||||
this.selectAllNotice(1, 5)
|
||||
this.hackReset = false
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user