29 changed files with 1745 additions and 323 deletions
@ -0,0 +1,18 @@ |
|||
package com.dreamchaser.depository_manage.config.QyWx_template_card; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 文本卡片信息中的消息类 |
|||
*/ |
|||
@Data |
|||
public class TextCardContent { |
|||
// 标题,不超过128个字节,超过会自动截断(支持id转译)
|
|||
private String title; |
|||
// 描述,不超过512个字节,超过会自动截断(支持id转译)
|
|||
private String description; |
|||
// 点击后跳转的链接。最长2048字节,请确保包含了协议头(http/https)
|
|||
private String url; |
|||
//按钮文字。 默认为“详情”, 不超过4个文字,超过自动截断。
|
|||
private String btntxt; |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
package com.dreamchaser.depository_manage.config.QyWx_template_card; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class TextTemplateCard extends BaseMessage { |
|||
private TextCardContent textcard; |
|||
} |
|||
@ -1,27 +1,86 @@ |
|||
package com.dreamchaser.depository_manage.controller; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.dreamchaser.depository_manage.config.PortConfig; |
|||
import com.dreamchaser.depository_manage.config.QyWxConfig; |
|||
import com.dreamchaser.depository_manage.entity.UserByPort; |
|||
import com.dreamchaser.depository_manage.entity.qywxDepartment; |
|||
import com.dreamchaser.depository_manage.pojo.NoticeP; |
|||
import com.dreamchaser.depository_manage.pojo.RestResponse; |
|||
import com.dreamchaser.depository_manage.service.NoticeService; |
|||
import com.dreamchaser.depository_manage.service.impl.QyWxOperationService; |
|||
import com.dreamchaser.depository_manage.utils.CrudUtil; |
|||
import com.dreamchaser.depository_manage.utils.LinkInterfaceUtil; |
|||
import com.dreamchaser.depository_manage.utils.Md5; |
|||
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author Dreamchaser |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/notice") |
|||
public class NoticeController { |
|||
|
|||
|
|||
@Autowired |
|||
private NoticeService noticeService; |
|||
NoticeService noticeService; |
|||
|
|||
@Autowired |
|||
QyWxOperationService qyWxOperationService; |
|||
|
|||
@PostMapping("/notice") |
|||
public RestResponse addNotice(@RequestBody Map<String,Object> map){ |
|||
return CrudUtil.postHandle(noticeService.addNotice(map),1); |
|||
public RestResponse addNotice(@RequestBody Map<String,Object> map, HttpServletRequest request){ |
|||
UserByPort userByPort = (UserByPort) request.getAttribute("userToken"); |
|||
map.put("userId",userByPort.getId()); |
|||
map.put("state",1); |
|||
// 获取插入结果
|
|||
Integer integer = noticeService.addNotice(map); |
|||
if(Integer.compare(integer,1) == 0){ |
|||
// 如果成功插入
|
|||
|
|||
String header = request.getHeader("user-agent"); |
|||
String crypt = Md5.crypt(header); |
|||
|
|||
// 开启线程推送应用消息
|
|||
/*new Thread(new Runnable() { |
|||
@Override |
|||
public void run() { |
|||
qyWxOperationService.sendNoticeForAllUser(ObjectFormatUtil.toInteger(map.get("id")),crypt); |
|||
} |
|||
}).start();*/ |
|||
|
|||
} |
|||
@GetMapping("/notices") |
|||
public RestResponse findNotices(@RequestParam Map<String,Object> map){ |
|||
return new RestResponse(noticeService.findNoticeByCondition(map)); |
|||
return CrudUtil.postHandle(integer,1); |
|||
} |
|||
@GetMapping("/findAllNotices") |
|||
public RestResponse findNotices(@RequestParam Map<String,Object> map,HttpServletRequest request){ |
|||
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|||
String header = request.getHeader("user-agent"); |
|||
String crypt = Md5.crypt(header); |
|||
|
|||
// 获取当前用户部门对应在企业微信下的部门
|
|||
JSONObject userPortByQyWx = PortConfig.getUserPortByQyWx(userToken.getMaindeparment()); |
|||
String portName = userPortByQyWx.getString("name"); |
|||
Integer portByQyWxInteger = userPortByQyWx.getInteger("wechatorganizationid"); |
|||
|
|||
qywxDepartment qyWxDepartment = QyWxConfig.getQyWxDepartment(crypt, userToken.getMaindeparment()); |
|||
List<NoticeP> noticeByCondition = noticeService.findNoticeByCondition(map); |
|||
return new RestResponse(noticeByCondition); |
|||
} |
|||
|
|||
@PostMapping("/notice_del") |
|||
public RestResponse DelNotice(@RequestBody Map<String,Object> map,HttpServletRequest request){ |
|||
return null; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,45 @@ |
|||
package com.dreamchaser.depository_manage.pojo; |
|||
|
|||
import com.dreamchaser.depository_manage.entity.Notice; |
|||
import com.dreamchaser.depository_manage.utils.DateUtil; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class NoticeP { |
|||
/** 公告主键 */ |
|||
private Integer id; |
|||
|
|||
/** 公告标题 */ |
|||
private String title; |
|||
|
|||
/** 公告内容 */ |
|||
private String content; |
|||
|
|||
/** 发布时间 */ |
|||
private String time; |
|||
|
|||
/** |
|||
* 发布人员 |
|||
*/ |
|||
private Integer userId; |
|||
|
|||
/** |
|||
* 公告状态 |
|||
*/ |
|||
private Integer state; |
|||
|
|||
/** |
|||
* 发布人员名称 |
|||
*/ |
|||
private String userName; |
|||
|
|||
|
|||
public NoticeP(Notice notice) { |
|||
this.id = notice.getId(); |
|||
this.time = DateUtil.TimeStampToDateTime(notice.getTime()); |
|||
this.title = notice.getTitle(); |
|||
this.content = notice.getContent(); |
|||
this.userId = notice.getUserId(); |
|||
this.state = notice.getState(); |
|||
} |
|||
} |
|||
@ -0,0 +1,126 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<title>layui</title> |
|||
<meta name="renderer" content="webkit"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
|||
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> |
|||
<link rel="stylesheet" href="/static/css/public.css" media="all"> |
|||
<link rel="stylesheet" href="/static/css/inputTag.css"> |
|||
|
|||
</head> |
|||
<body> |
|||
<style> |
|||
.inputdiv { |
|||
display: flex; |
|||
background-color: #fff; |
|||
height: 38px; |
|||
line-height: 38px; |
|||
border: 1px solid rgb(238, 238, 238); |
|||
} |
|||
|
|||
|
|||
</style> |
|||
|
|||
<div class="layuimini-container"> |
|||
<div class="layuimini-main"> |
|||
<fieldset class="layui-elem-field"> |
|||
<legend style="font-size: 30px;padding-top: 20px;text-align: center">公告发布</legend> |
|||
<div class="layui-fluid"> |
|||
<div class="layui-card-body" style="padding: 0"> |
|||
<div class="layui-form" style="margin-top: 30px"> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">可见范围:</label> |
|||
<div class="layui-input-block"> |
|||
<div class="fairy-tag-container" style="border-style: none"> |
|||
<div class="inputdiv"> |
|||
<input type="text" id="viewRange" style="display: none" lay-verify="required"/> |
|||
<i class="layui-icon layui-icon-search" |
|||
style="display: inline;right: 0;position: absolute;" |
|||
id="selectDepartment"></i> |
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">公告标题:</label> |
|||
<div class="layui-input-block"> |
|||
<input name="title" type="text" placeholder="请输入公告标题..." class="layui-input" |
|||
lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">公告内容:</label> |
|||
<div class="layui-input-block"> |
|||
<textarea name="content" style="height: 30em" placeholder="请填写公告内容..." |
|||
class="layui-textarea" lay-verify="required"></textarea> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-form-item" style="margin-top: 20px"> |
|||
<div class="layui-input-block " style="text-align: center"> |
|||
<button class="layui-btn layui-btn-lg " style="width: 150px" lay-submit |
|||
lay-filter="noticeBtn">发布公告 |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</fieldset> |
|||
</div> |
|||
</div> |
|||
|
|||
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
|||
<script src="/static/js/lay-config.js?v=1.0.4" charset="utf-8"></script> |
|||
<script> |
|||
function selectDepartment(){ |
|||
|
|||
} |
|||
layui.use(['form', 'layer', 'laydate', 'inputTag'], function () { |
|||
var form = layui.form, |
|||
layer = layui.layer, |
|||
inputTag = layui.inputTag, |
|||
laydate = layui.laydate, |
|||
$ = layui.$; |
|||
|
|||
//日期 |
|||
laydate.render({ |
|||
elem: '#date' |
|||
}); |
|||
|
|||
//监听提交 |
|||
form.on('submit(noticeBtn)', function (data) { |
|||
$.ajax({ |
|||
url: "/notice/notice", |
|||
data: JSON.stringify(data.field), |
|||
type: "post", |
|||
dataType: 'json', |
|||
contentType: "application/json;charset=utf-8", |
|||
success: function (data) { |
|||
if (data.status >= 300) { |
|||
layer.msg(data.statusInfo.message);//失败的表情 |
|||
} else { |
|||
layer.msg("公告发布成功", { |
|||
icon: 6,//成功的表情 |
|||
time: 1000 //1秒关闭(如果不配置,默认是3秒) |
|||
}, function () { |
|||
window.location = "/notice_add" |
|||
}); |
|||
} |
|||
} |
|||
}); |
|||
return false; |
|||
}); |
|||
|
|||
selectDepartment = function () { |
|||
|
|||
} |
|||
|
|||
}); |
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,586 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<title>layui</title> |
|||
<meta name="renderer" content="webkit"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
|||
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> |
|||
<link rel="stylesheet" href="/static/css/public.css" media="all"> |
|||
</head> |
|||
<body> |
|||
<div class="layuimini-container"> |
|||
<div class="layuimini-main"> |
|||
<fieldset class="table-search-fieldset"> |
|||
<legend>搜索信息</legend> |
|||
<div style="margin: 10px 10px 10px 10px"> |
|||
<form class="layui-form layui-form-pane" action=""> |
|||
<div class="layui-form-item"> |
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">标题</label> |
|||
<div class="layui-input-inline"> |
|||
<input type="text" class="layui-input" id="title" name="title" autocomplete="off"/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">发布日期</label> |
|||
<div class="layui-input-inline" > |
|||
<input type="text" name="startDate" id="startDate" placeholder="请选择开始日期" autocomplete="off" class="layui-input"> |
|||
</div> |
|||
<div class="layui-form-mid">-</div> |
|||
<div class="layui-input-inline"> |
|||
<input type="text" name="endDate" id="endDate" placeholder="请选择开始日期" autocomplete="off" class="layui-input"> |
|||
</div> |
|||
</div> |
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">状态</label> |
|||
<div class="layui-input-inline"> |
|||
<select name="state"> |
|||
<option value="">请选择状态</option> |
|||
<option value="1">启用</option> |
|||
<option value="2">禁用</option> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
<div class="layui-inline"> |
|||
<button type="submit" class="layui-btn layui-btn-primary" lay-submit |
|||
lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索 |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
</fieldset> |
|||
|
|||
|
|||
<!-- 状态展示--> |
|||
<script type="text/html" id="switchTpl"> |
|||
<input type="checkbox" name="state" value="{{d.oldId}}" lay-skin="switch" lay-text="启用|禁用" |
|||
lay-filter="changeState" {{ d.state== 1 ? 'checked' : '' }} > |
|||
</script> |
|||
|
|||
<script type="text/html" id="toolbarDemo"> |
|||
<div class="layui-btn-container"> |
|||
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加</button> |
|||
<button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除</button> |
|||
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" id="u_fileUpload" |
|||
lay-event="import">导入数据 |
|||
</button> |
|||
</div> |
|||
</script> |
|||
|
|||
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table> |
|||
|
|||
<script type="text/html" id="currentTableBar"> |
|||
<a class="layui-btn layui-btn-xs data-count-edit" lay-event="detail">详情</a> |
|||
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a> |
|||
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" th:style="'display:'+${display}" |
|||
lay-event="realDelete">彻底删除</a> |
|||
</script> |
|||
|
|||
</div> |
|||
</div> |
|||
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
|||
<script> |
|||
layui.use(['form', 'table', 'upload','laydate'], function () { |
|||
var $ = layui.jquery, |
|||
form = layui.form, |
|||
laydate = layui.laydate, |
|||
upload = layui.upload, |
|||
table = layui.table; |
|||
|
|||
|
|||
laydate.render({ |
|||
elem: '#startDate' |
|||
}); |
|||
|
|||
laydate.render({ |
|||
elem: '#endDate' |
|||
}); |
|||
|
|||
table.render({ |
|||
elem: "#currentTableId", |
|||
url: '/notice/findAllNotices', |
|||
parseData: function (res) { //res 即为原始返回的数据 |
|||
return { |
|||
"status": res.status, //解析接口状态 |
|||
"message": res.statusInfo.message, //解析提示文本 |
|||
"count": res.count, //解析数据长度 |
|||
"data": res.data //解析数据列表 |
|||
}; |
|||
}, |
|||
request: { |
|||
pageName: 'page', //页码的参数名称,默认:page |
|||
limitName: 'size' //每页数据量的参数名,默认:limit |
|||
}, |
|||
where: { |
|||
type: "0", |
|||
}, |
|||
response: { |
|||
statusName: 'status' //规定数据状态的字段名称,默认:code |
|||
, statusCode: 200 //规定成功的状态码,默认:0 |
|||
, msgName: 'message' //规定状态信息的字段名称,默认:msg |
|||
, countName: 'count' //规定数据总数的字段名称,默认:count |
|||
, dataName: 'data' //规定数据列表的字段名称,默认:data |
|||
}, |
|||
toolbar: '#toolbarDemo', |
|||
defaultToolbar: ['filter', 'exports', 'print'], |
|||
cols: [ |
|||
[ |
|||
{type: "checkbox", width: 50}, |
|||
{field: 'title', width: 120, title: '标题'}, |
|||
{field: 'userName', width: 200, title: '发布人'}, |
|||
{field: 'time', width: 200, title: '发布时间'}, |
|||
{title: '状态', width: 100, templet: '#switchTpl', align: "center"}, |
|||
{title: '操作', minWidth: 200, toolbar: '#currentTableBar', align: "center"} |
|||
] |
|||
], |
|||
limits: [10, 15, 20, 25, 50, 100], |
|||
limit: 10, |
|||
page: true, |
|||
skin: 'line', |
|||
done: function () { |
|||
} |
|||
}); |
|||
|
|||
// 监听搜索操作 |
|||
form.on('submit(data-search-btn)', function (data) { |
|||
var req = {}; |
|||
data = data.field; |
|||
req.type = 1; |
|||
if (data.title !== '') { |
|||
req.title = data.title; |
|||
} |
|||
if (data.state !== '') { |
|||
req.state = data.state; |
|||
} |
|||
if(data.startDate !== ''){ |
|||
req.startDate = data.startDate; |
|||
} |
|||
if(data.endDate !== ''){ |
|||
req.endDate = data.endDate; |
|||
} |
|||
//执行搜索重载 |
|||
table.reload('currentTableId', { |
|||
url: '/notice/findAllNotices', |
|||
page: { |
|||
curr: 1 |
|||
}, |
|||
where: req |
|||
}, 'data'); |
|||
return false; |
|||
}); |
|||
|
|||
/** |
|||
* toolbar监听事件 |
|||
*/ |
|||
table.on('toolbar(currentTableFilter)', function (obj) { |
|||
if (obj.event === 'add') { // 监听添加操作 |
|||
var index = layer.open({ |
|||
title: '发布公告', |
|||
type: 2, |
|||
shade: 0.2, |
|||
maxmin: true, |
|||
shadeClose: true, |
|||
area: ['100%', '100%'], |
|||
content: '/notice_add', |
|||
}); |
|||
$(window).on("resize", function () { |
|||
layer.full(index); |
|||
}); |
|||
} else if (obj.event === 'delete') { // 监听删除操作 |
|||
var checkStatus = table.checkStatus('currentTableId') |
|||
, data = checkStatus.data; |
|||
var req = {}; |
|||
req.ids = []; |
|||
for (i = 0, len = data.length; i < len; i++) { |
|||
req.ids[i] = data[i].oldId; |
|||
} |
|||
if (req.ids.length > 0) { |
|||
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) { |
|||
$.ajax({ |
|||
url: '/notice/notice_del', |
|||
dataType: 'json', |
|||
type: 'POST', |
|||
contentType: "application/json;charset=utf-8", |
|||
data: JSON.stringify(req), |
|||
beforeSend: function () { |
|||
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
|||
}, |
|||
success: function (data) { |
|||
layer.close(this.layerIndex); |
|||
if (data.status >= 300) { |
|||
layer.msg(data.statusInfo.message);//失败的表情 |
|||
|
|||
} else { |
|||
layer.msg("删除成功", { |
|||
icon: 6,//成功的表情 |
|||
time: 500 //1秒关闭(如果不配置,默认是3秒) |
|||
}); |
|||
//执行搜索重载 |
|||
table.reload('currentTableId', { |
|||
url: '/materialType/materialTypeRecord', |
|||
page: { |
|||
curr: 1 |
|||
} |
|||
}, 'data'); |
|||
return false; |
|||
} |
|||
} |
|||
}) |
|||
}) |
|||
} else { |
|||
layer.msg("未选中记录,请确认!"); |
|||
return false; |
|||
} |
|||
} |
|||
}); |
|||
|
|||
|
|||
//用于导入数据 |
|||
var upLoader = upload.render({ |
|||
elem: "#u_fileUpload", // 绑定元素 |
|||
url: '/excel/importExcelByMT', // 上传接口 |
|||
accept: 'file', // 允许上传的格式, |
|||
exts: 'xls|xlsx|csv', |
|||
done: function (res) { |
|||
//如果上传成功 |
|||
if (res.code == 200) { |
|||
var re = ""; |
|||
for (let i = 0; i < res.data.errMsg.length; i++) { |
|||
var show = "<p style='color: #ff211e'>" + res.data.errMsg[i] + ":错误" + "</p>"; |
|||
re += show |
|||
} |
|||
for (let i = 0; i < res.data.dataList.length; i++) { |
|||
var tname = res.data.dataList[i]["tname"]; |
|||
var id = res.data.dataList[i]["oldId"]; |
|||
var parentId = res.data.dataList[i]["parentId"] == null ? "" : res.data.dataList[i]["parentId"]; |
|||
var introduce = res.data.dataList[i]["introduce"] == null ? "" : res.data.dataList[i]["introduce"]; |
|||
var show = "<p style='color: #00FF00'>" + tname + " " + id + " " + parentId + "成功" + "</p>"; |
|||
re += show |
|||
} |
|||
|
|||
layer.open({ |
|||
type: 1, |
|||
skin: 'layui-layer-rim', //加上边框 |
|||
area: ['500px', '500px'], //宽高 |
|||
content: re |
|||
}) |
|||
} else { |
|||
layer.msg(res.msg) |
|||
} |
|||
|
|||
}, |
|||
error: function () { |
|||
var demoText = $('#demoText'); |
|||
demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>'); |
|||
demoText.find('.demo-reload').on('click', function () { |
|||
upLoader.upload() |
|||
}) |
|||
} |
|||
}); |
|||
|
|||
//监听表格复选框选择 |
|||
table.on('checkbox(currentTableFilter)', function (obj) { |
|||
console.log(obj) |
|||
}); |
|||
|
|||
table.on('tool(currentTableFilter)', function (obj) { |
|||
let data = obj.data; |
|||
if (obj.event === 'detail') { |
|||
req = {}; |
|||
req.parentId = parentId; |
|||
var index = layer.open({ |
|||
title: '物料种类详情', |
|||
type: 2, |
|||
shade: 0.2, |
|||
maxmin: true, |
|||
shadeClose: true, |
|||
area: ['100%', '100%'], |
|||
content: '/materialType_detail?id=' + data.oldId, |
|||
end: function () { |
|||
//执行搜索重载 |
|||
table.reload('currentTableId', { |
|||
url: '/materialType/materialTypeRecord', |
|||
page: { |
|||
curr: 1 |
|||
}, |
|||
where: req |
|||
}, 'data'); |
|||
} |
|||
}); |
|||
$(window).on("resize", function () { |
|||
layer.full(index); |
|||
}); |
|||
return false; |
|||
} else if (obj.event === 'delete') { |
|||
var req = {}; |
|||
req.id = data.oldId; |
|||
$.ajax({ |
|||
url: "/materialType/findMaterialByMaterialTypeId", // 判断该类型下是否有物品 |
|||
type: "post", |
|||
data: JSON.stringify(req), |
|||
dataType: "json", |
|||
contentType: "application/json;charset=utf-8", |
|||
success: function (data) { |
|||
if (data.data) { |
|||
layer.msg("该类别下尚有记录无法删除", { |
|||
icon: 7, |
|||
time: 500 //1秒关闭(如果不配置,默认是3秒) |
|||
}, function () { |
|||
// 执行重加载 |
|||
table.reload('currentTableId', { |
|||
url: '/materialType/materialTypeRecord', |
|||
page: { |
|||
curr: 1 |
|||
}, |
|||
where: {"parentId": parentId} |
|||
}); |
|||
}) |
|||
} else { |
|||
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) { |
|||
$.ajax({ |
|||
url: '/materialType/materialType_del', |
|||
dataType: 'json', |
|||
type: 'POST', |
|||
contentType: "application/json;charset=utf-8", |
|||
data: JSON.stringify(req), |
|||
beforeSend: function () { |
|||
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
|||
}, |
|||
success: function (data) { |
|||
layer.close(this.layerIndex); |
|||
if (data.status >= 300) { |
|||
layer.msg(data.statusInfo.message);//失败的表情 |
|||
|
|||
} else { |
|||
obj.del(); |
|||
layer.msg("删除成功", { |
|||
icon: 6,//成功的表情 |
|||
time: 500 //1秒关闭(如果不配置,默认是3秒) |
|||
}); |
|||
} |
|||
} |
|||
}) |
|||
}); |
|||
} |
|||
} |
|||
}) |
|||
} else if (obj.event == 'subclass') { |
|||
var index = layer.open({ |
|||
title: '子类型', |
|||
type: 2, |
|||
shade: 0.2, |
|||
maxmin: true, |
|||
shadeClose: true, |
|||
area: ['100%', '100%'], |
|||
content: '/findMaterialTypeByParentId?parentId=' + data.oldId |
|||
}); |
|||
$(window).on("resize", function () { |
|||
layer.full(index); |
|||
}); |
|||
return false; |
|||
} else if (obj.event == 'realDelete') { // 彻底删除 |
|||
var req = {}; |
|||
req.id = data.oldId; |
|||
$.ajax({ |
|||
url: "/materialType/findMaterialByMaterialTypeId", // 判断该类型下是否有物品 |
|||
type: "post", |
|||
dataType: "json", |
|||
data: JSON.stringify(req), |
|||
contentType: "application/json;charset=utf-8", |
|||
success: function (data) { |
|||
if (data.data) { |
|||
layer.msg("该类别下尚有记录无法删除", { |
|||
icon: 7, |
|||
time: 500 //1秒关闭(如果不配置,默认是3秒) |
|||
}, function () { |
|||
// 执行重加载 |
|||
table.reload('currentTableId', { |
|||
url: '/materialType/materialTypeRecord', |
|||
page: { |
|||
curr: 1 |
|||
}, |
|||
where: {"parentId": parentId} |
|||
}); |
|||
}) |
|||
} else { |
|||
layer.confirm('该操作会造成不可逆后果,是否继续?', { |
|||
btn: ['继续', '取消'] //按钮 |
|||
}, function () { |
|||
$.ajax({ |
|||
url: '/materialType/realDeleteMaterialType', |
|||
dataType: 'json', |
|||
type: 'POST', |
|||
contentType: "application/json;charset=utf-8", |
|||
data: JSON.stringify(req), |
|||
beforeSend: function () { |
|||
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
|||
}, |
|||
success: function (data) { |
|||
layer.close(this.layerIndex); |
|||
if (data.status >= 300) { |
|||
layer.msg(data.statusInfo.message);//失败的表情 |
|||
|
|||
} else { |
|||
obj.del(); |
|||
layer.msg("删除成功", { |
|||
icon: 6,//成功的表情 |
|||
time: 500 //1秒关闭(如果不配置,默认是3秒) |
|||
}); |
|||
} |
|||
} |
|||
}) |
|||
}, function () { |
|||
// 执行重加载 |
|||
table.reload('currentTableId', { |
|||
url: '/materialType/materialTypeRecord', |
|||
page: { |
|||
curr: 1 |
|||
}, |
|||
where: {"parentId": parentId} |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
}) |
|||
} |
|||
}); |
|||
|
|||
//监听状态操作 |
|||
form.on('switch(changeState)', function (obj) { |
|||
var req = new Map; |
|||
if (obj.elem.checked) { |
|||
req["state"] = 1; |
|||
} |
|||
req["id"] = this.value; |
|||
var hasMaterial = false; |
|||
if (req["state"] === undefined) { //如果禁用 |
|||
$.ajax({ |
|||
url: "/materialType/findMaterialByMaterialTypeId", // 判断该类型下是否有物品 |
|||
type: "post", |
|||
dataType: "json", |
|||
data: JSON.stringify(req), |
|||
contentType: "application/json;charset=utf-8", |
|||
success: function (data) { |
|||
hasMaterial = data.data; |
|||
if (hasMaterial) { // 如果有物品 |
|||
layer.confirm('该种类下还有物品,确定禁用?', { |
|||
btn: ['禁用', '取消'] //按钮 |
|||
}, function () { |
|||
$.ajax({ |
|||
url: "/materialType/EditMaterialTypeState", // 禁用 |
|||
type: 'post', |
|||
dataType: 'json', |
|||
contentType: "application/json;charset=utf-8", |
|||
data: JSON.stringify(req), |
|||
beforeSend: function () { |
|||
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
|||
}, |
|||
success: function (data) { |
|||
layer.close(this.layerIndex); |
|||
if (data.status >= 300) { |
|||
layer.msg(data.statusInfo.message);//失败的表情 |
|||
|
|||
} else { |
|||
layer.msg("修改成功", { |
|||
icon: 6,//成功的表情 |
|||
time: 500 //1秒关闭(如果不配置,默认是3秒) |
|||
}, function () { |
|||
table.reload('currentTableId', { |
|||
url: '/materialType/materialTypeRecord', |
|||
page: { |
|||
curr: 1 |
|||
}, |
|||
where: {"parentId": parentId} |
|||
}); |
|||
}) |
|||
} |
|||
} |
|||
}) |
|||
}, function () { |
|||
table.reload('currentTableId', { |
|||
url: '/materialType/materialTypeRecord', |
|||
page: { |
|||
curr: 1 |
|||
}, |
|||
where: {"parentId": parentId} |
|||
}); |
|||
}); |
|||
} else { // 如果没有物品 |
|||
$.ajax({ |
|||
url: "/materialType/EditMaterialTypeState", |
|||
type: 'post', |
|||
dataType: 'json', |
|||
contentType: "application/json;charset=utf-8", |
|||
data: JSON.stringify(req), |
|||
beforeSend: function () { |
|||
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
|||
}, |
|||
success: function (data) { |
|||
layer.close(this.layerIndex); |
|||
if (data.status >= 300) { |
|||
layer.msg(data.statusInfo.message);//失败的表情 |
|||
|
|||
} else { |
|||
layer.msg("修改成功", { |
|||
icon: 6,//成功的表情 |
|||
time: 500 //1秒关闭(如果不配置,默认是3秒) |
|||
}, function () { |
|||
// 执行表格重加载 |
|||
table.reload('currentTableId', { |
|||
url: '/materialType/materialTypeRecord', |
|||
page: { |
|||
curr: 1 |
|||
}, |
|||
where: {"parentId": parentId} |
|||
}); |
|||
|
|||
}) |
|||
} |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
}) |
|||
} else { // 如果启用 |
|||
$.ajax({ |
|||
url: "/materialType/EditMaterialTypeState", |
|||
type: 'post', |
|||
dataType: 'json', |
|||
contentType: "application/json;charset=utf-8", |
|||
data: JSON.stringify(req), |
|||
beforeSend: function () { |
|||
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
|||
}, |
|||
success: function (data) { |
|||
layer.close(this.layerIndex); |
|||
if (data.status >= 300) { |
|||
layer.msg(data.statusInfo.message);//失败的表情 |
|||
|
|||
} else { |
|||
layer.msg("修改成功", { |
|||
icon: 6,//成功的表情 |
|||
time: 500 //1秒关闭(如果不配置,默认是3秒) |
|||
}, function () { |
|||
// 执行表格重加载 |
|||
table.reload('currentTableId', { |
|||
url: '/materialType/materialTypeRecord', |
|||
page: { |
|||
curr: 1 |
|||
}, |
|||
where: {"parentId": parentId} |
|||
}); |
|||
}) |
|||
} |
|||
} |
|||
}) |
|||
} |
|||
|
|||
}); |
|||
}); |
|||
</script> |
|||
|
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,72 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<title>layui</title> |
|||
<meta name="renderer" content="webkit"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
|||
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> |
|||
<link rel="stylesheet" href="/static/css/public.css" media="all"> |
|||
|
|||
</head> |
|||
<body> |
|||
<div class="layuimini-container"> |
|||
<div class="layuimini-main"> |
|||
<fieldset class="layui-elem-field" > |
|||
<legend style="font-size: 30px;padding-top: 20px;text-align: center" |
|||
th:text="${record.getTitle()}"></legend> |
|||
<div class="layui-fluid"> |
|||
<div class="layui-card-body" style="padding: 0"> |
|||
<form class="layui-form" style="margin-top: 30px"> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">发布人:</label> |
|||
<div class="layui-input-block"> |
|||
<input name="title" type="text" placeholder="请输入公告标题..." readonly class="layui-input" |
|||
th:value="${record.getUserName()}"/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">发布时间:</label> |
|||
<div class="layui-input-block"> |
|||
<input name="title" type="text" placeholder="请输入公告标题..." readonly class="layui-input" |
|||
th:value="${record.getTime()}"/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">公告内容:</label> |
|||
<div class="layui-input-block"> |
|||
<textarea name="content" readonly style="height: 30em" placeholder="请填写公告内容..." |
|||
class="layui-textarea" lay-verify="required" |
|||
th:text="${record.getContent()}"></textarea> |
|||
</div> |
|||
</div> |
|||
|
|||
</form> |
|||
</div> |
|||
</div> |
|||
</fieldset> |
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
|||
<script> |
|||
layui.use(['form', 'layer', 'laydate'], function () { |
|||
var form = layui.form, |
|||
layer = layui.layer, |
|||
laydate = layui.laydate, |
|||
$ = layui.$; |
|||
|
|||
//日期 |
|||
laydate.render({ |
|||
elem: '#date' |
|||
}); |
|||
|
|||
//监听提交 |
|||
|
|||
|
|||
}); |
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,55 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en"> |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<title>Title</title> |
|||
</head> |
|||
<body> |
|||
<div id="test2" class="demo-tree"></div> |
|||
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
|||
<script> |
|||
var data; |
|||
layui.use(['layer', 'tree'], function () { |
|||
var $ = layui.jquery, |
|||
tree = layui.tree; |
|||
|
|||
test = tree.render({ |
|||
elem: '#test2' |
|||
, data: [] |
|||
, click: function (obj) { |
|||
if (obj.data.children !== undefined) { |
|||
return false |
|||
} |
|||
var windowParent = $("#"+clickObj,window.parent.document)[0]; |
|||
var children = windowParent.childNodes[5]; |
|||
var materialItem = children.childNodes[3].childNodes[1].childNodes; |
|||
var materialName = materialItem[1]; |
|||
var materialId = materialName.parentNode.parentNode.childNodes[3]; |
|||
materialName.value = obj.data.title; |
|||
materialId.value = obj.data.id; |
|||
var index = parent.layer.getFrameIndex(window.name); |
|||
parent.layer.close(index); |
|||
} |
|||
}); |
|||
|
|||
$.ajax({ |
|||
url: "/company/departmentTreeMenus", |
|||
data: JSON.stringify(req), |
|||
type: 'post', |
|||
dataType: 'json', |
|||
contentType: "application/json;charset=utf-8", |
|||
beforeSend:function () { |
|||
this.layerIndex = layer.load(0, { shade: [0.5, '#393D49'] }); |
|||
}, |
|||
success: function (d) { |
|||
layer.close(this.layerIndex); |
|||
var data2 = d.data; |
|||
test.reload({ |
|||
data: data2 |
|||
}); |
|||
} |
|||
}); |
|||
}) |
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -1,15 +0,0 @@ |
|||
package com.dreamchaser.depository_manage; |
|||
|
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
|
|||
@SpringBootTest |
|||
@RunWith(SpringRunner.class) |
|||
public class TestOther { |
|||
@Test |
|||
public void Test(){ |
|||
System.out.println(Integer.compare(3, 0) == 0 ); |
|||
} |
|||
} |
|||
@ -0,0 +1,100 @@ |
|||
package com.dreamchaser.depository_manage; |
|||
|
|||
import com.dreamchaser.depository_manage.config.QyWxConfig; |
|||
import com.dreamchaser.depository_manage.entity.ThreeAboutMan; |
|||
import com.dreamchaser.depository_manage.entity.qywxDepartment; |
|||
import com.dreamchaser.depository_manage.service.impl.QyWxOperationService; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.concurrent.Callable; |
|||
|
|||
@SpringBootTest |
|||
@RunWith(SpringRunner.class) |
|||
public class TestQyWxAdministration { |
|||
|
|||
|
|||
|
|||
@Test |
|||
public void Test(){ |
|||
List<qywxDepartment> qyWxDepartmentList = QyWxConfig.getQyWxDepartmentList("8b283ea8ba44697a18c763443c257db5", 51); |
|||
|
|||
System.out.println(qyWxDepartmentList); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 用于创建部门树结构 |
|||
*/ |
|||
class InitDepartmentTree implements Callable<Object>{ |
|||
|
|||
/** |
|||
* 用于开启线程的部门列表 |
|||
*/ |
|||
List<qywxDepartment> qywxDepartmentList; |
|||
|
|||
/** |
|||
* 全部部门列表 |
|||
*/ |
|||
List<qywxDepartment> qywxDepartmentListAll; |
|||
|
|||
@Override |
|||
public Object call() throws Exception { |
|||
|
|||
return null; |
|||
} |
|||
} |
|||
|
|||
class buildDepartmentTree implements Callable<Object>{ |
|||
|
|||
// 所有部门列表
|
|||
List<qywxDepartment> qywxDepartmentList; |
|||
// 当前部门
|
|||
qywxDepartment qywxDepartment; |
|||
|
|||
@Override |
|||
public Object call() throws Exception { |
|||
List<Object> result = new ArrayList<>(); |
|||
for (qywxDepartment department : qywxDepartmentList) { |
|||
// 如果该部门是当前部门的子部门
|
|||
if(Integer.compare(qywxDepartment.getId(),department.getParentid()) == 0){ |
|||
Map<String, Object> stringObjectMap = InitTree(qywxDepartment, null); |
|||
result.add(stringObjectMap); |
|||
} |
|||
} |
|||
return result; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 用于构造树形模板 |
|||
* @param qywxDepartment |
|||
* @param children |
|||
* @return |
|||
*/ |
|||
public Map<String,Object> InitTree(qywxDepartment qywxDepartment, List<Object> children){ |
|||
if (qywxDepartment != null) { |
|||
Map<String, Object> map = new HashMap<>(); |
|||
map.put("title", qywxDepartment.getName()); |
|||
map.put("id", qywxDepartment.getId()); |
|||
map.put("children", children); |
|||
return map; |
|||
} else { |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
Loading…
Reference in new issue