mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-04 22:41:24 +08:00
nitice manage module compeled
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
package com.cfive.pinnacle.controller;
|
||||
|
||||
import com.cfive.pinnacle.entity.Department;
|
||||
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||
import com.cfive.pinnacle.service.IDepartmentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门 前端控制器
|
||||
@@ -13,6 +22,17 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/department")
|
||||
@CrossOrigin
|
||||
public class DepartmentController {
|
||||
@Autowired
|
||||
IDepartmentService departmentService;
|
||||
|
||||
@GetMapping
|
||||
public ResponseResult getDepartAndUser(){
|
||||
List<Department> getDepartAndUser = departmentService.getDepartAndUser();
|
||||
Integer code = getDepartAndUser != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
|
||||
String msg = getDepartAndUser != null ? "" : "数据查询失败,请尝试!";
|
||||
return ResponseResult.build(code, msg, getDepartAndUser);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.cfive.pinnacle.controller;
|
||||
|
||||
import com.cfive.pinnacle.entity.Notice;
|
||||
import com.cfive.pinnacle.entity.NoticeReceive;
|
||||
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.Data;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@@ -25,7 +28,9 @@ import java.util.List;
|
||||
@CrossOrigin
|
||||
public class NoticeController {
|
||||
@Autowired
|
||||
INoticeService noticeService;
|
||||
private INoticeService noticeService;
|
||||
@Autowired
|
||||
private INoticeReceiveService noticeReceiveService;
|
||||
|
||||
//根据公告id查公告信息及发布人
|
||||
@GetMapping("/{nid}")
|
||||
@@ -36,16 +41,14 @@ public class NoticeController {
|
||||
return ResponseResult.build(code, msg, noticeById);
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
//添加公告
|
||||
//查询所有公告
|
||||
@GetMapping
|
||||
public ResponseResult selectAllNotice(String title) {
|
||||
public ResponseResult selectAllNotice(String title, String type, String startTime,String endTime) {
|
||||
List<Notice> noticeList;
|
||||
if (title == null) {
|
||||
if (!StringUtils.hasText(title) && !StringUtils.hasText(type) && !StringUtils.hasText(startTime) && !StringUtils.hasText(endTime)) {
|
||||
noticeList = noticeService.selectAllNotice();
|
||||
} else {
|
||||
noticeList = noticeService.selectByTitle(title);
|
||||
noticeList = noticeService.selectByCond(title, type, startTime,endTime);
|
||||
}
|
||||
|
||||
int code = noticeList != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
|
||||
@@ -54,22 +57,33 @@ public class NoticeController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping
|
||||
//更新公告
|
||||
@PutMapping
|
||||
public ResponseResult updateNotice(@RequestBody Notice notice) {
|
||||
notice.setId(null); //清除id,使新插入的数据id自增
|
||||
notice.setOriginId(notice.getId());
|
||||
boolean updateById = noticeService.save(notice);
|
||||
boolean updateById = noticeService.updateNotice(notice);
|
||||
String msg = updateById ? "" : "数据修改失败,请尝试!";
|
||||
return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateById);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
//添加公告
|
||||
@PostMapping
|
||||
public ResponseResult addNotice(@RequestBody Notice notice) {
|
||||
notice.setSenderId(1654151877520973826L);
|
||||
boolean insertNotice = noticeService.save(notice);
|
||||
String msg = insertNotice ? "" : "数据添加失败,请尝试!";
|
||||
return ResponseResult.build(insertNotice ? ResponseCode.DATABASE_SAVE_OK : ResponseCode.DATABASE_SAVE_ERROR, msg, insertNotice);
|
||||
Long noticeId = notice.getId();
|
||||
boolean flag = false;
|
||||
for (Long receiveId :
|
||||
notice.getReceivers()) {
|
||||
NoticeReceive noticeReceive = new NoticeReceive();
|
||||
noticeReceive.setNoticeId(noticeId);
|
||||
noticeReceive.setUserId(receiveId);
|
||||
flag = noticeReceiveService.save(noticeReceive);
|
||||
}
|
||||
String msg = (insertNotice && flag) ? "" : "数据添加失败,请尝试!";
|
||||
return ResponseResult.build((insertNotice && flag) ? ResponseCode.DATABASE_SAVE_OK : ResponseCode.DATABASE_SAVE_ERROR, msg, noticeId);
|
||||
}
|
||||
|
||||
//删除公告
|
||||
@DeleteMapping("/{nid}")
|
||||
public ResponseResult deleteByNoticeId(@PathVariable Long nid) {
|
||||
boolean removeById = noticeService.deleteById(nid);
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
package com.cfive.pinnacle.controller;
|
||||
|
||||
import com.cfive.pinnacle.entity.Notice;
|
||||
import com.cfive.pinnacle.entity.NoticeType;
|
||||
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||
import com.cfive.pinnacle.service.INoticeTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 公告类型 前端控制器
|
||||
@@ -13,6 +23,17 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/noticeType")
|
||||
@CrossOrigin
|
||||
public class NoticeTypeController {
|
||||
@Autowired
|
||||
INoticeTypeService noticeTypeService;
|
||||
|
||||
@GetMapping
|
||||
public ResponseResult selectTypeList(){
|
||||
List<NoticeType> selectTypeName = noticeTypeService.selectTypeList();
|
||||
Integer code = selectTypeName != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
|
||||
String msg = selectTypeName != null ? "" : "数据查询失败,请尝试!";
|
||||
return ResponseResult.build(code, msg, selectTypeName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.Version;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -56,4 +57,10 @@ public class Department implements Serializable {
|
||||
@TableField("version")
|
||||
@Version
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 部门成员
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<User> userList;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@ import com.baomidou.mybatisplus.annotation.Version;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
@@ -77,18 +79,21 @@ public class Notice implements Serializable {
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "UTC")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 发送时间
|
||||
*/
|
||||
@TableField("send_time")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "UTC")
|
||||
private LocalDateTime sendTime;
|
||||
|
||||
/**
|
||||
* 失效时间
|
||||
*/
|
||||
@TableField("end_time")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "UTC")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
@@ -107,6 +112,7 @@ public class Notice implements Serializable {
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField("modify_time")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "UTC")
|
||||
private LocalDateTime modifyTime;
|
||||
|
||||
/**
|
||||
@@ -130,5 +136,11 @@ public class Notice implements Serializable {
|
||||
@Version
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 公告接收者
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private List<Long> receivers;
|
||||
|
||||
}
|
||||
|
||||
@@ -41,11 +41,6 @@ public class NoticeReceive implements Serializable {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private User user;
|
||||
|
||||
/**
|
||||
* 公告Id
|
||||
@@ -54,12 +49,6 @@ public class NoticeReceive implements Serializable {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long noticeId;
|
||||
|
||||
/**
|
||||
* 公告
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Notice notice;
|
||||
|
||||
/**
|
||||
* 已读
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.cfive.pinnacle.service;
|
||||
import com.cfive.pinnacle.entity.Department;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门 服务类
|
||||
@@ -12,5 +14,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
public interface IDepartmentService extends IService<Department> {
|
||||
List<Department> getDepartAndUser();
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ public interface INoticeService extends IService<Notice> {
|
||||
|
||||
List<Notice> selectAllNotice();
|
||||
|
||||
List<Notice> selectByTitle(String title);
|
||||
List<Notice> selectByCond(String title,String type,String startTime,String endTime);
|
||||
|
||||
Boolean deleteById(Long nid);
|
||||
|
||||
Boolean updateNotice(Notice notice);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.cfive.pinnacle.service;
|
||||
import com.cfive.pinnacle.entity.NoticeType;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 公告类型 服务类
|
||||
@@ -12,5 +14,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
public interface INoticeTypeService extends IService<NoticeType> {
|
||||
List<NoticeType> selectTypeList();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
package com.cfive.pinnacle.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.cfive.pinnacle.entity.Department;
|
||||
import com.cfive.pinnacle.entity.User;
|
||||
import com.cfive.pinnacle.mapper.DepartmentMapper;
|
||||
import com.cfive.pinnacle.mapper.UserMapper;
|
||||
import com.cfive.pinnacle.service.IDepartmentService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门 服务实现类
|
||||
@@ -16,5 +23,19 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements IDepartmentService {
|
||||
|
||||
@Autowired
|
||||
private DepartmentMapper departmentMapper;
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
@Override
|
||||
public List<Department> getDepartAndUser() {
|
||||
List<Department> departments = departmentMapper.selectList(null);
|
||||
for (Department department:
|
||||
departments) {
|
||||
LambdaQueryWrapper<User> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(User::getDepartmentId, department.getId());
|
||||
department.setUserList(userMapper.selectList(lqw));
|
||||
}
|
||||
return departments;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.cfive.pinnacle.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.cfive.pinnacle.entity.Notice;
|
||||
import com.cfive.pinnacle.entity.NoticeReceive;
|
||||
import com.cfive.pinnacle.entity.NoticeType;
|
||||
import com.cfive.pinnacle.mapper.NoticeMapper;
|
||||
import com.cfive.pinnacle.mapper.NoticeReceiveMapper;
|
||||
import com.cfive.pinnacle.mapper.NoticeTypeMapper;
|
||||
@@ -11,7 +13,11 @@ import com.cfive.pinnacle.service.INoticeService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -40,14 +46,49 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
|
||||
@Override
|
||||
public List<Notice> selectAllNotice() {
|
||||
return noticeMapper.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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Notice> selectByTitle(String title) {
|
||||
LambdaQueryWrapper<Notice> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.like(Notice::getTitle, title);
|
||||
List<Notice> notices = noticeMapper.selectList(lqw);
|
||||
public List<Notice> selectByCond(String title, String type, String startTime,String endTime) {
|
||||
List<Notice> notices = new ArrayList<>();
|
||||
LocalDateTime start = null;
|
||||
LocalDateTime end = null;
|
||||
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) {
|
||||
startTime = null;
|
||||
endTime = 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);
|
||||
List<Notice> temp_notice = noticeMapper.selectList(lqw_notice);
|
||||
notices.addAll(temp_notice);
|
||||
}
|
||||
for (Notice n : notices
|
||||
) {
|
||||
n.setSender(userMapper.selectById(n.getSenderId()));
|
||||
@@ -68,4 +109,15 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
return noticeMapper.deleteById(nid) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateNotice(Notice notice) {
|
||||
noticeMapper.update(null, new UpdateWrapper<Notice>().eq("id", notice.getId()).set("old", 1)); //修改原始数据
|
||||
notice.setOriginId(notice.getId());
|
||||
notice.setId(null); //清除id,使新插入的数据id重新生成
|
||||
notice.setCreateTime(null);
|
||||
notice.setModifyTime(null);
|
||||
notice.setOld(0);
|
||||
return noticeMapper.insert(notice) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package com.cfive.pinnacle.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.cfive.pinnacle.entity.NoticeType;
|
||||
import com.cfive.pinnacle.mapper.NoticeTypeMapper;
|
||||
import com.cfive.pinnacle.service.INoticeTypeService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 公告类型 服务实现类
|
||||
@@ -16,5 +22,13 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class NoticeTypeServiceImpl extends ServiceImpl<NoticeTypeMapper, NoticeType> implements INoticeTypeService {
|
||||
|
||||
@Autowired
|
||||
NoticeTypeMapper noticeTypeMapper;
|
||||
@Override
|
||||
public List<NoticeType> selectTypeList() {
|
||||
LambdaQueryWrapper<NoticeType> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(NoticeType::getEnable, 1);
|
||||
List<NoticeType> noticeTypes = noticeTypeMapper.selectList(lqw);
|
||||
return noticeTypes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cfive.pinnacle.mapper.DepartmentMapper">
|
||||
|
||||
<select id="getDepartAndUser" resultMap="department">
|
||||
select d.id,name,u.id,username from t_department d,t_user u where d.id=u.department_id and d.deleted=0 and u.deleted=0
|
||||
</select>
|
||||
<resultMap id="department" type="department" autoMapping="true">
|
||||
<id column="id" property="id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
and type.id = n.type_id
|
||||
and n.deleted = 0
|
||||
and n.old = 0
|
||||
|
||||
order by create_time desc
|
||||
</select>
|
||||
<resultMap id="NoticeAllResultMap" type="notice" autoMapping="true">
|
||||
<id property="id" column="nid"/>
|
||||
@@ -70,4 +70,5 @@
|
||||
<result property="version" column="typeVe"/>
|
||||
</association>
|
||||
</resultMap>
|
||||
<!-- 模糊查询-->
|
||||
</mapper>
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
package com.cfive.pinnacle.notice;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.cfive.pinnacle.controller.NoticeController;
|
||||
import com.cfive.pinnacle.entity.Notice;
|
||||
import com.cfive.pinnacle.entity.NoticeReceive;
|
||||
import com.cfive.pinnacle.entity.NoticeType;
|
||||
import com.cfive.pinnacle.entity.User;
|
||||
import com.cfive.pinnacle.entity.*;
|
||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||
import com.cfive.pinnacle.service.IDepartmentService;
|
||||
import com.cfive.pinnacle.service.INoticeReceiveService;
|
||||
import com.cfive.pinnacle.service.INoticeTypeService;
|
||||
import com.cfive.pinnacle.service.IUserService;
|
||||
import com.cfive.pinnacle.service.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
public class NoticeTest {
|
||||
@Autowired
|
||||
private NoticeController noticeController;
|
||||
@Autowired
|
||||
private INoticeService iNoticeService;
|
||||
@Autowired
|
||||
private INoticeTypeService iNoticeTypeService;
|
||||
@Autowired
|
||||
private IDepartmentService iDepartmentService;
|
||||
@@ -34,52 +33,87 @@ public class NoticeTest {
|
||||
@Test
|
||||
void selectByIdTest() {
|
||||
ResponseResult selectByNoticeId = noticeController.selectByNoticeId(21L);
|
||||
System.out.println(selectByNoticeId.getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
void selectAllTest() {
|
||||
ResponseResult noticeList = noticeController.selectAllNotice(null);
|
||||
System.out.println(noticeList.getData());
|
||||
ResponseResult noticeList = noticeController.selectAllNotice(null, null,null,null);
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateTest() {
|
||||
ResponseResult notice = noticeController.selectByNoticeId(23L);
|
||||
ResponseResult updateNotice = noticeController.updateNotice((Notice) notice.getData());
|
||||
System.out.println(updateNotice.getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
void insertNoticeTest() {
|
||||
for (int i = 2; i < 20; i++) {
|
||||
for (int i = 20; i < 40; i++) {
|
||||
Notice notice = new Notice();
|
||||
notice.setTitle("title"+i);
|
||||
notice.setTypeId(1652684907554496514L);
|
||||
notice.setTitle("title" + i);
|
||||
notice.setTypeId(1654069011361476609L);
|
||||
notice.setSenderId(1652714496280469506L);
|
||||
LocalDateTime sendTime = LocalDateTime.parse("2023-05-11 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
LocalDateTime endTime = LocalDateTime.parse("2023-09-01 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
notice.setPriority(2);
|
||||
notice.setSendTime(sendTime);
|
||||
notice.setEndTime(endTime);
|
||||
notice.setContent("Content"+i);
|
||||
notice.setContent("Content" + i);
|
||||
noticeController.addNotice(notice);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void insertNoticeTypeTest(){
|
||||
NoticeType noticeType = new NoticeType();
|
||||
noticeType.setName("通知公告");
|
||||
iNoticeTypeService.save(noticeType);
|
||||
void insertNoticeTypeTest() {
|
||||
// NoticeType noticeType = new NoticeType();
|
||||
// noticeType.setName("调休公告");
|
||||
// iNoticeTypeService.save(noticeType);
|
||||
|
||||
// Department department=new Department();
|
||||
// department.setName("前端开发部");
|
||||
// department.setTel("123");
|
||||
// department.setAddress("潮州");
|
||||
// iDepartmentService.save(department);
|
||||
|
||||
User user = new User();
|
||||
user.setUsername("yrm");
|
||||
user.setPasswd("123");
|
||||
user.setDepartmentId(1654150127317569537L);
|
||||
user.setEnable(1);
|
||||
iUserService.save(user);
|
||||
}
|
||||
|
||||
@Test
|
||||
void insertNoticeRecTest(){
|
||||
void insertNoticeRecTest() {
|
||||
NoticeReceive receive = new NoticeReceive();
|
||||
receive.setNoticeId(1652734384348790786L);
|
||||
receive.setNoticeId(1654070031407886338L);
|
||||
receive.setUserId(1652714496280469506L);
|
||||
iNoticeReceiveService.save(receive);
|
||||
}
|
||||
|
||||
@Test
|
||||
void selectByConde() {
|
||||
List<Notice> notices = new ArrayList<>();
|
||||
LambdaQueryWrapper<Notice> lqw_notice = new LambdaQueryWrapper<>();
|
||||
LambdaQueryWrapper<NoticeType> lqw_type = new LambdaQueryWrapper<>();
|
||||
lqw_type.like(NoticeType::getName, "活动");
|
||||
List<NoticeType> noticeTypes = iNoticeTypeService.list(lqw_type);
|
||||
if (noticeTypes.isEmpty()) {
|
||||
} else {
|
||||
for (NoticeType type : noticeTypes
|
||||
) {
|
||||
lqw_notice.clear();
|
||||
lqw_notice.eq(Notice::getTypeId, type.getId()).like(Notice::getTitle, "2");
|
||||
List<Notice> temp_notice = iNoticeService.list(lqw_notice);
|
||||
notices.addAll(temp_notice);
|
||||
}
|
||||
for (Notice n:notices
|
||||
) {
|
||||
n.setSender(iUserService.getById(n.getSenderId()));
|
||||
n.setNoticeType(iNoticeTypeService.getById(n.getTypeId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
201
ui/src/components/notice/CommitForm.vue
Normal file
201
ui/src/components/notice/CommitForm.vue
Normal file
@@ -0,0 +1,201 @@
|
||||
<template>
|
||||
<el-form :model="addData" :rules="rules" ref="addData" label-width="100px">
|
||||
<el-form-item label="公告标题" prop="title">
|
||||
<el-input v-model="addData.title"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="公告类型" prop="typeId">
|
||||
<el-select v-model="addData.typeId" filterable placeholder="请选择公告类型">
|
||||
<el-option
|
||||
v-for="item in noticeTypeList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-row>
|
||||
<el-form-item label="生效时间" required>
|
||||
<el-col>
|
||||
<el-form-item prop="sendTime">
|
||||
<el-date-picker
|
||||
type="datetime"
|
||||
placeholder="选择生效日期"
|
||||
v-model="addData.sendTime"
|
||||
style="width: 100%"
|
||||
size="large"
|
||||
:picker-options="pickerOptions"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-form-item>
|
||||
<el-col :span="2"></el-col>
|
||||
<el-form-item label="失效时间" required>
|
||||
<el-col>
|
||||
<el-form-item prop="endTime">
|
||||
<el-date-picker
|
||||
type="datetime"
|
||||
placeholder="选择失效日期"
|
||||
v-model="addData.endTime"
|
||||
style="width: 100%"
|
||||
size="large"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-form-item>
|
||||
</el-row>
|
||||
<el-form-item label="是否置顶" prop="top">
|
||||
<el-switch v-model="addData.top" inline-prompt active-text="是" inactive-text="否" />
|
||||
</el-form-item>
|
||||
<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-cascader
|
||||
v-model="addData.receivers"
|
||||
collapse-tags
|
||||
clearable
|
||||
:options="departmentList"
|
||||
:props="{
|
||||
multiple: true,
|
||||
value: 'id',
|
||||
label: 'name',
|
||||
children: 'userList'
|
||||
}"
|
||||
placeholder="选择公告接收者"
|
||||
>
|
||||
<template #default="scope">
|
||||
<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">{{
|
||||
((scope.node.value = scope.data.id),
|
||||
(scope.node.label = scope.data.username))
|
||||
}}</span>
|
||||
</template>
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
<el-form-item label="公告内容" prop="content">
|
||||
<el-input type="textarea" v-model="addData.content"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitForm('addData')">发布</el-button>
|
||||
<el-button @click="resetForm()">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
export default {
|
||||
props:{
|
||||
departmentList: [],
|
||||
noticeTypeList: [],
|
||||
noticeEdit:{}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
addData: {
|
||||
title: '',
|
||||
typeId: '',
|
||||
sendTime: '',
|
||||
endTime: '',
|
||||
top: false,
|
||||
priority: 1,
|
||||
content: '',
|
||||
receivers:[]
|
||||
},
|
||||
pickerOptions: {},
|
||||
rules: {
|
||||
title: [
|
||||
{ required: true, message: '请输入公告标题', trigger: 'blur' },
|
||||
{ min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' }
|
||||
],
|
||||
type: [
|
||||
{ type:'array',required: true, message: '请选择公告类型', trigger: 'change' }
|
||||
],
|
||||
startTime: [
|
||||
{ type: 'date', required: true, message: '请选择生效时间', trigger: 'change' }
|
||||
],
|
||||
endTime: [
|
||||
{ type: 'date', required: true, message: '请选择失效时间', trigger: 'change' }
|
||||
],
|
||||
content: [
|
||||
{ required: true, message: '请填写公告内容', trigger: 'blur' }
|
||||
],
|
||||
receivers: [
|
||||
{ type:'array',required: true, message: '请选择公告接收者', trigger: 'change' }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
methods: {
|
||||
submitForm(formtitle) {
|
||||
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])
|
||||
}
|
||||
this.addData.receivers=receiveId
|
||||
this.$refs.addData.validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.noticeEdit){
|
||||
console.log("edit")
|
||||
this.$emit("handleUpdateNotice",this.addData)
|
||||
}else {
|
||||
console.log("add")
|
||||
this.$emit("handleAddNotice",this.addData)
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
resetForm() {
|
||||
this.$refs.addData.resetFields();
|
||||
}
|
||||
},
|
||||
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
|
||||
console.log(this.addData)
|
||||
}
|
||||
},
|
||||
updated() {
|
||||
if (this.noticeEdit) {
|
||||
this.addData = this.noticeEdit
|
||||
console.log(this.addData)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log("mounted")
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.el-button {
|
||||
margin: 0 auto;
|
||||
}
|
||||
.el-button--text {
|
||||
margin-right: 15px;
|
||||
}
|
||||
.el-select {
|
||||
width: 300px;
|
||||
}
|
||||
.el-input {
|
||||
width: 300px;
|
||||
}
|
||||
.el-slider {
|
||||
margin-left: 20px;
|
||||
}
|
||||
</style>
|
||||
13
ui/src/components/notice/NoticeAdd.vue
Normal file
13
ui/src/components/notice/NoticeAdd.vue
Normal file
@@ -0,0 +1,13 @@
|
||||
<template>
|
||||
<NoticeEdit />
|
||||
</template>
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'NoticeAdd',
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
methods: {}
|
||||
}
|
||||
</script>
|
||||
<style scoped></style>
|
||||
@@ -1,55 +0,0 @@
|
||||
<template>
|
||||
<el-form :model="form">
|
||||
<el-form-item label="Promotion name" :label-width="formLabelWidth">
|
||||
<el-input v-model="form.name" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Zones" :label-width="formLabelWidth">
|
||||
<el-select v-model="form.region" placeholder="Please select a zone">
|
||||
<el-option label="Zone No.1" value="shanghai" />
|
||||
<el-option label="Zone No.2" value="beijing" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogFormVisible = false">Cancel</el-button>
|
||||
<el-button type="primary" @click="dialogFormVisible = false"> Confirm </el-button>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
export default {
|
||||
name: 'NoticeEdit',
|
||||
data() {
|
||||
return {
|
||||
dialogFormVisible: false,
|
||||
formLabelWidth: '140px',
|
||||
form: [
|
||||
{
|
||||
name: '',
|
||||
region: '',
|
||||
date1: '',
|
||||
date2: '',
|
||||
delivery: false,
|
||||
type: [],
|
||||
resource: '',
|
||||
desc: ''
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.el-button--text {
|
||||
margin-right: 15px;
|
||||
}
|
||||
.el-select {
|
||||
width: 300px;
|
||||
}
|
||||
.el-input {
|
||||
width: 300px;
|
||||
}
|
||||
.dialog-footer button:first-child {
|
||||
margin-right: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,43 +1,99 @@
|
||||
<template>
|
||||
<div class="notice-head-layout">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="5">
|
||||
<el-input v-model="search_title" placeholder="请输入公告标题">
|
||||
<template #prefix>
|
||||
<el-icon :size="SIZE_ICON_MD()" :color="COLOR_PRODUCTION()">
|
||||
<icon-pinnacle-notice_search />
|
||||
</el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-col>
|
||||
<el-row>
|
||||
<el-col :span="2" :xs="3" :sm="2"
|
||||
><el-text
|
||||
class="mx-1"
|
||||
size="large"
|
||||
style="color: rgba(71, 138, 173, 0.85); font-weight: bolder"
|
||||
>公告标题:</el-text
|
||||
></el-col
|
||||
>
|
||||
<el-col :span="4">
|
||||
<el-button type="primary" @click="this.$emit('selectByTitle', search_title)"
|
||||
>搜索</el-button
|
||||
>
|
||||
<el-input v-model="search_info.title" placeholder="请输入公告标题"> </el-input>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<div class="gutter" />
|
||||
<el-col :span="1"></el-col>
|
||||
<el-col :span="2" :xs="3" :sm="2"
|
||||
><el-text
|
||||
class="mx-1"
|
||||
size="large"
|
||||
style="color: rgba(71, 138, 173, 0.85); font-weight: bolder"
|
||||
>公告类型:</el-text
|
||||
></el-col
|
||||
>
|
||||
<el-col :span="4">
|
||||
<el-input v-model="search_info.type" placeholder="请输入公告类型"> </el-input>
|
||||
</el-col>
|
||||
<el-col :span="1"></el-col>
|
||||
<el-col :span="5">
|
||||
<el-date-picker
|
||||
v-model="timeRang"
|
||||
type="datetimerange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
>
|
||||
</el-date-picker>
|
||||
</el-col>
|
||||
<el-col :span="2"></el-col>
|
||||
<el-col :span="3">
|
||||
<el-button type="primary" @click="selectByCondition">
|
||||
<el-icon :size="SIZE_ICON_SM()" style="color: white; margin-right: 5px">
|
||||
<icon-pinnacle-notice_search />
|
||||
</el-icon>
|
||||
搜索
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { COLOR_PRODUCTION, SIZE_ICON_MD } from '@/constants/Common.constants'
|
||||
import { COLOR_PRODUCTION, SIZE_ICON_MD, SIZE_ICON_SM } from '@/constants/Common.constants'
|
||||
import _ from 'lodash'
|
||||
|
||||
export default {
|
||||
name: 'NoticeHead',
|
||||
methods: {
|
||||
SIZE_ICON_SM() {
|
||||
return SIZE_ICON_SM
|
||||
},
|
||||
COLOR_PRODUCTION() {
|
||||
return COLOR_PRODUCTION
|
||||
},
|
||||
SIZE_ICON_MD() {
|
||||
return SIZE_ICON_MD
|
||||
},
|
||||
selectByCondition() {
|
||||
console.log(this.timeRang)
|
||||
if (!_.isEmpty(this.timeRang)) {
|
||||
this.search_info.startTime = this.handleDateFormatUTC(this.timeRang[0])
|
||||
this.search_info.endTime = this.handleDateFormatUTC(this.timeRang[1])
|
||||
}
|
||||
this.$emit('selectByCond', this.search_info)
|
||||
},
|
||||
handleDateFormatUTC(date) {
|
||||
let newFormat = ''
|
||||
const dateParse = new Date(Date.parse(date))
|
||||
const yy = dateParse.getUTCFullYear()
|
||||
const mm = _.padStart((dateParse.getUTCMonth() + 1).toString(), 2, '0')
|
||||
const dd = _.padStart(dateParse.getUTCDate().toString(), 2, '0')
|
||||
const hh = _.padStart(dateParse.getUTCHours().toString(), 2, '0')
|
||||
const mf = _.padStart(dateParse.getUTCMinutes().toString(), 2, '0')
|
||||
const ss = _.padStart(dateParse.getUTCSeconds().toString(), 2, '0')
|
||||
newFormat = yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss
|
||||
return newFormat
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
search_title: ''
|
||||
timeRang: [],
|
||||
search_info: {
|
||||
title: '',
|
||||
type: '',
|
||||
startTime: '',
|
||||
endTime: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +111,6 @@ export default {
|
||||
|
||||
.el-col {
|
||||
border-radius: 4px;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.grid-content {
|
||||
|
||||
45
ui/src/components/notice/NoticeShowDialog.vue
Normal file
45
ui/src/components/notice/NoticeShowDialog.vue
Normal file
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<el-descriptions direction="vertical" :column="3" border>
|
||||
<template #title>{{ this.noticeShow.title }}</template>
|
||||
<el-descriptions-item label="发布人"
|
||||
><el-tag size="large" type="success">{{
|
||||
this.noticeShow.sender.username
|
||||
}}</el-tag></el-descriptions-item
|
||||
>
|
||||
<el-descriptions-item label="生效时间">{{
|
||||
formatDate(this.noticeShow.sendTime)
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="优先级" :span="12">{{
|
||||
this.noticeShow.priority
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="公告类型">
|
||||
<el-tag size="large">{{ this.noticeShow.noticeType.name }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="失效时间">{{
|
||||
formatDate(this.noticeShow.endTime)
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="公告内容">{{ this.noticeShow.content }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-button type="primary" @click="handleShowDialog" style="margin: 50px 400px">确 定</el-button>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'NoticeShowDialog',
|
||||
props: ['noticeShow'],
|
||||
data() {
|
||||
return {
|
||||
showDialogVisible: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleShowDialog() {
|
||||
this.$emit('showDialogVisible', this.showDialogVisible)
|
||||
},
|
||||
formatDate(date) {
|
||||
if (date == null) return null
|
||||
return new Date(date).toLocaleString()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped></style>
|
||||
@@ -1,6 +1,13 @@
|
||||
<template>
|
||||
<el-button @click="clearFilter">清除筛选条件</el-button>
|
||||
<el-button
|
||||
size="large"
|
||||
@click="clearFilter"
|
||||
style="background-color: rgba(71, 138, 173, 0.85); color: white"
|
||||
>清除筛选条件
|
||||
</el-button>
|
||||
<el-table
|
||||
v-loading="getLoading"
|
||||
element-loading-text="加载中..."
|
||||
ref="tableRef"
|
||||
:data="selectData"
|
||||
style="width: 100%"
|
||||
@@ -20,8 +27,25 @@
|
||||
:formatter="formatter"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="noticeType.name" label="公告类别" width="180" />
|
||||
<el-table-column prop="noticeType.name" label="公告类别" width="180">
|
||||
<template #default="scope">
|
||||
<el-tag
|
||||
size="default"
|
||||
:type="scope.row.noticeType.name === '通知公告' ? 'warning' : 'success'"
|
||||
disable-transitions
|
||||
>
|
||||
{{ scope.row.noticeType.name }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="priority" label="优先级" width="180" />
|
||||
<el-table-column
|
||||
prop="createTime"
|
||||
label="创建时间"
|
||||
sortable
|
||||
width="180"
|
||||
:formatter="formatDate"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="sendTime"
|
||||
label="生效时间"
|
||||
@@ -34,7 +58,6 @@
|
||||
label="失效时间"
|
||||
sortable
|
||||
width="180"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
:formatter="formatDate"
|
||||
/>
|
||||
<el-table-column
|
||||
@@ -56,24 +79,36 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="操作">
|
||||
<template #default="scope">
|
||||
<el-button size="small" color="#626aef" @click="handleShow(scope.$index, scope.row)"
|
||||
>查看
|
||||
</el-button>
|
||||
<el-button size="small" type="primary" @click="handleEdit(scope.$index, scope.row)"
|
||||
>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="danger"
|
||||
@click="this.$emit('handleDelete', scope.row.id)"
|
||||
<el-button size="small" type="danger" @click="handleDelete(scope.row.id)"
|
||||
>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 编辑会话框-->
|
||||
<el-dialog v-model="dialogFormVisible">
|
||||
<template #title>
|
||||
{{ dialogFormTitle }}
|
||||
<el-dialog v-model="dialogEditVisible" center>
|
||||
<template #header>
|
||||
<h2 style="color: red">编辑公告</h2>
|
||||
</template>
|
||||
<notice-edit />
|
||||
<commitForm
|
||||
:noticeEdit="noticeEdit"
|
||||
:noticeTypeList="noticeTypeList"
|
||||
:departmentList="departmentList"
|
||||
@handleUpdateNotice="handleUpdateNotice"
|
||||
></commitForm>
|
||||
</el-dialog>
|
||||
<!-- 查看会话框-->
|
||||
<el-dialog v-model="dialogShowVisible" center>
|
||||
<template #header>
|
||||
<h2 style="color: red">查看公告</h2>
|
||||
</template>
|
||||
<notice-show-dialog @showDialogVisible="showDialogVisible" :noticeShow="noticeShow" />
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
@@ -82,11 +117,14 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
filterSenderName: [],
|
||||
dialogFormVisible: false,
|
||||
dialogFormTitle: ''
|
||||
dialogEditVisible: false,
|
||||
dialogShowVisible: false,
|
||||
noticeEdit: {},
|
||||
noticeShow: {},
|
||||
getLoading: true
|
||||
}
|
||||
},
|
||||
props: ['msg', 'selectData'],
|
||||
props: ['noticeTypeList', 'selectData', 'departmentList', 'dialogUpdateVisible', 'getLoading'],
|
||||
methods: {
|
||||
clearFilter() {
|
||||
this.$refs.tableRef.clearFilter(['senderName'])
|
||||
@@ -102,14 +140,25 @@ export default {
|
||||
// 获取单元格数据
|
||||
const data = row[column.property]
|
||||
if (data == null) return null
|
||||
|
||||
const dt = data.replace('T', ' ')
|
||||
return dt
|
||||
return new Date(data).toLocaleString()
|
||||
},
|
||||
handleEdit(index, row) {
|
||||
this.dialogFormVisible = true
|
||||
this.dialogFormTitle = row.title
|
||||
console.log(index + ' ' + row)
|
||||
this.dialogEditVisible = true
|
||||
this.noticeEdit = row
|
||||
},
|
||||
handleUpdateNotice(updateData) {
|
||||
this.$emit('handleUpdateNotice', updateData)
|
||||
this.dialogEditVisible = this.dialogUpdateVisible
|
||||
},
|
||||
handleShow(index, row) {
|
||||
this.dialogShowVisible = true
|
||||
this.noticeShow = row
|
||||
},
|
||||
handleDelete(deleteId) {
|
||||
this.$emit('handleDelete', deleteId)
|
||||
},
|
||||
showDialogVisible(visible) {
|
||||
this.dialogShowVisible = visible
|
||||
}
|
||||
},
|
||||
mounted() {},
|
||||
@@ -128,7 +177,7 @@ export default {
|
||||
senderName.value = newArr[j]
|
||||
this.filterSenderName.push(senderName)
|
||||
}
|
||||
console.log(this.filterSenderName)
|
||||
// console.log(this.filterSenderName)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -2,13 +2,35 @@
|
||||
<div class="notice-home-layout">
|
||||
<el-container>
|
||||
<el-header>
|
||||
<notice-head @selectByTitle="selectByTitle"></notice-head>
|
||||
<notice-head @selectByCond="selectByCond"></notice-head>
|
||||
</el-header>
|
||||
<el-main>
|
||||
<el-button
|
||||
size="large"
|
||||
style="background-color: rgba(71, 138, 173, 0.85); color: white"
|
||||
@click="dialogAddVisible = true"
|
||||
>发布公告</el-button
|
||||
>
|
||||
<!-- 添加公告对话框-->
|
||||
<el-dialog v-model="dialogAddVisible" center>
|
||||
<template #header>
|
||||
<h2 style="color: red">发布公告</h2>
|
||||
</template>
|
||||
<commitForm
|
||||
:noticeTypeList="this.noticeTypeList"
|
||||
:departmentList="this.departmentList"
|
||||
@handleAddNotice="handleAddNotice"
|
||||
></commitForm>
|
||||
</el-dialog>
|
||||
<notice-table
|
||||
:selectData="selectData"
|
||||
:noticeTypeList="noticeTypeList"
|
||||
:departmentList="departmentList"
|
||||
:dialogUpdateVisible="dialogUpdateVisible"
|
||||
:getLoading="getLoading"
|
||||
@handleDelete="handleDelete"
|
||||
@clearFilter="clearFilter"
|
||||
@handleUpdateNotice="handleUpdateNotice"
|
||||
></notice-table>
|
||||
</el-main>
|
||||
</el-container>
|
||||
@@ -17,36 +39,135 @@
|
||||
|
||||
<script lang="ts">
|
||||
import axios from 'axios'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import 'element-plus/theme-chalk/el-message.css'
|
||||
import 'element-plus/theme-chalk/el-message-box.css'
|
||||
|
||||
export default {
|
||||
name: 'NoticeHome',
|
||||
data() {
|
||||
return {
|
||||
selectData: []
|
||||
selectData: [],
|
||||
noticeTypeList: [],
|
||||
dialogAddVisible: false,
|
||||
dialogUpdateVisible: false,
|
||||
departmentList: [],
|
||||
getLoading: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
selectByTitle(searchTitle) {
|
||||
axios.get('http://localhost:8621/notice?title=' + searchTitle).then((response) => {
|
||||
this.selectData = response.data.data
|
||||
})
|
||||
selectByCond(search) {
|
||||
axios
|
||||
.get('http://localhost:8621/notice', {
|
||||
params: {
|
||||
title: search.title,
|
||||
type: search.type,
|
||||
startTime: search.startTime,
|
||||
endTime: search.endTime
|
||||
}
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.data.code === 20021) {
|
||||
this.selectData = response.data.data
|
||||
ElMessage({
|
||||
message: '查询成功.',
|
||||
type: 'success'
|
||||
})
|
||||
} else if (response.data.code === 20031) {
|
||||
ElMessage({
|
||||
message: response.data.msg,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
selectAllNotice() {
|
||||
axios.get('http://localhost:8621/notice').then((response) => {
|
||||
this.selectData = response.data.data
|
||||
if (this.selectData) {
|
||||
this.getLoading = false
|
||||
}
|
||||
})
|
||||
},
|
||||
handleDelete(deleteID) {
|
||||
axios.delete('http://localhost:8621/notice/' + deleteID).then((response) => {
|
||||
this.selectAllNotice()
|
||||
ElMessageBox.confirm('确定是否要删除?该操作将无法回退', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '我再想想',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
axios.delete('http://localhost:8621/notice/' + deleteID).then((response) => {
|
||||
if (response.data.code === 20024) {
|
||||
this.dialogAddVisible = false
|
||||
ElMessage({
|
||||
message: '删除成功.',
|
||||
type: 'success'
|
||||
})
|
||||
} else if (response.data.code === 20034) {
|
||||
ElMessage({
|
||||
message: response.data.msg,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
})
|
||||
this.$router.go(0)
|
||||
})
|
||||
.catch(() => {})
|
||||
},
|
||||
selectNoticeType() {
|
||||
axios.get('http://localhost:8621/noticeType').then((response) => {
|
||||
this.noticeTypeList = response.data.data
|
||||
})
|
||||
},
|
||||
selectDepartment() {
|
||||
axios.get('http://localhost:8621/department').then((response) => {
|
||||
this.departmentList = response.data.data
|
||||
})
|
||||
},
|
||||
handleAddNotice(addFormData) {
|
||||
axios.post('http://localhost:8621/notice', addFormData).then((response) => {
|
||||
if (response.data.code === 20022) {
|
||||
this.dialogAddVisible = false
|
||||
ElMessage({
|
||||
message: '发布成功.',
|
||||
type: 'success'
|
||||
})
|
||||
} else if (response.data.code === 20032) {
|
||||
ElMessage({
|
||||
message: response.data.msg,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
})
|
||||
this.$router.go(0)
|
||||
},
|
||||
handleUpdateNotice(updateNotice) {
|
||||
axios.put('http://localhost:8621/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()
|
||||
// this.selectAllNotice()
|
||||
// location.reload()
|
||||
this.$router.go(0)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.selectAllNotice()
|
||||
this.selectNoticeType()
|
||||
this.selectDepartment()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user