已废弃
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

665 lines
32 KiB

2 years ago
<!DOCTYPE html>
<html lang="en" xmlns:checked="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>layui</title>
<meta content="webkit" name="renderer">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<link href="/static/lib/layui-v2.8.6/css/layui.css" media="all" rel="stylesheet">
2 years ago
<link href="/static/css/public.css" media="all" rel="stylesheet">
<link rel="stylesheet" href="/static/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
</head>
<body>
<div class="layuimini-container">
<div class="layuimini-main">
<div class="layui-collapse">
<div class="layui-colla-item">
<h2 class="layui-colla-title">搜索</h2>
<div class="layui-colla-content">
<div style="margin: 10px 10px 10px 10px">
<form action="" class="layui-form layui-form-pane">
<div class="layui-form-item">
<input id="parentId" style="display: none" th:value="${parentId}">
<div class="layui-inline">
<label class="layui-form-label">仓库</label>
<div class="layui-input-inline">
<select name="depositoryId">
<option selected value="">请选择仓库</option>
<option th:each="depository,iterStar:${depositories}"
th:text="${depository?.getDname()}"
th:value="${depository?.getId()}">外芯仓库
</option>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">仓库地址</label>
<div class="layui-input-inline">
<input autocomplete="off" class="layui-input" name="address" type="text">
</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 class="layui-btn layui-btn-primary" lay-filter="data-search-btn" lay-submit
type="submit"><i class="layui-icon"></i> 搜 索
</button>
</div>
2 years ago
</div>
</form>
2 years ago
</div>
</div>
2 years ago
</div>
</div>
2 years ago
<!-- 状态展示-->
<script id="switchTpl" type="text/html">
<input type="checkbox" name="state" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用"
lay-filter="changeState" {{ d.state== 1 ? 'checked' : '' }} >
</script>
<script id="selectManager" type="text/html">
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="manager">仓管员</a>
</script>
<script id="depositoryCode" type="text/html">
<a id="{{d.id}}" onclick="showDetail(this)">{{d.code}}</a>
2 years ago
</script>
<script id="toolbarDemo" type="text/html">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"
th:style="'display:'+${display}" id="display"> 添加
</button>
<button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"
th:style="'display:'+${display}"> 删除
</button>
2 years ago
</div>
</script>
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
<script id="currentTableBar" type="text/html">
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-subclass" lay-event="subclass">子仓</a>
<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" th:style="'display:'+${display}"
lay-event="delete">删除</a>
2 years ago
<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 charset="utf-8" src="/static/lib/layui-v2.8.6/layui.js"></script>
2 years ago
<script>
function showDetail() {
2 years ago
}
2 years ago
layui.use(['form', 'table'], function () {
var $ = layui.jquery,
form = layui.form,
table = layui.table;
var parentId = document.getElementById("parentId").value;
table.render({
elem: "#currentTableId",
url: '/repository/allWarehouseByParent?parentId=' + parentId,
parseData: function (res) { //res 即为原始返回的数据
return {
"status": res.status, //解析接口状态
"message": res.statusInfo.message, //解析提示文本
"count": res.count, //解析数据长度
"data": res.data //解析数据列表
};
},
height: 'full-60',//固定高度-即固定表头固定第一行首行
2 years ago
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: 'dcode', title: "仓库编码", width: 150, templet: '#depositoryCode'},
{field: 'dname', width: 120, title: '仓库名称'},
{field: 'cname', width: 200, title: '所处公司'},
{field: 'adminorgName', width: 150, title: '所属部门'},
{field: 'address', width: 120, title: '仓库地址'},
{field: 'introduce', width: 200, title: '仓库介绍'},
{field: 'maxNumber', width: 200, title: '最大存储量', sort: true},
{field: 'minNumber', width: 200, title: '最小存储量', sort: true},
{field: 'state', title: '状态', minWidth: 80, templet: '#switchTpl'},
{title: '仓管员', minWidth: 80, templet: '#selectManager', align: "center"},
{title: '操作', minWidth: 250, toolbar: '#currentTableBar', align: "center"}
]
2 years ago
],
limits: [13, 26, 39, 52, 100],
limit: 13,
2 years ago
page: true,
skin: 'line',
done: function () {
}
});
// 监听搜索操作
form.on('submit(data-search-btn)', function (data) {
var req = {};
data = data.field;
req.type = 1;
if (data.address !== '') {
req.address = data.address;
}
if (data.depositoryId !== '') {
req.depositoryId = data.depositoryId;
}
if (data.state !== '') {
req.state = data.state;
}
req.parentId = parentId;
//执行搜索重载
table.reloadData('currentTableId', {
2 years ago
url: '/repository/warehouseRecord',
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: '/depository_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].id;
}
if (req.ids.length > 0) {
2 years ago
$.ajax({
url: "/repository/findRelevancyByDepository",
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.reloadData('currentTableId', {
2 years ago
url: '/repository/warehouseRecord',
page: {
curr: 1
},
where: {"parentId": parentId}
});
})
} else {
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) {
$.ajax({
url: '/repository/depository_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);//失败的表情
return;
} else {
layer.msg("删除成功", {
icon: 6,//成功的表情
time: 500 //1秒关闭(如果不配置,默认是3秒)
});
//执行搜索重载
table.reloadData('currentTableId', {
2 years ago
url: '/repository/warehouseRecord',
page: {
curr: 1
}
}, 'data');
return false;
}
}
})
})
}
}
});
} else {
2 years ago
layer.msg("未选中记录,请确认!");
return false;
}
}
});
//监听表格复选框选择
table.on('checkbox(currentTableFilter)', function (obj) {
console.log(obj)
});
table.on('tool(currentTableFilter)', function (obj) {
let data = obj.data;
if (obj.event === 'subclass') {
var index = layer.open({
title: '分仓库',
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: true,
area: ['100%', '100%'],
content: '/findWareHouseByParentId?parentId=' + data.id
});
$(window).on("resize", function () {
layer.full(index);
});
return false;
} else if (obj.event === 'delete') { // 软删除
var req = {};
req.id = data.id;
$.ajax({
url: "/repository/findRelevancyByDepository",
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.reloadData('currentTableId', {
2 years ago
url: '/repository/warehouseRecord',
page: {
curr: 1
},
where: {"parentId": parentId}
});
})
} else {
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) {
$.ajax({
url: '/repository/depository_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);//失败的表情
return;
} else {
obj.del();
layer.msg("删除成功", {
icon: 6,//成功的表情
time: 500 //1秒关闭(如果不配置,默认是3秒)
});
}
}
})
})
}
}
});
} else if (obj.event === 'detail') {
var index = layer.open({
title: '仓库信息详情',
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: true,
area: ['100%', '100%'],
content: '/warehouse_view?id=' + data.id,
end: function () {
2 years ago
req = {};
req.parentId = parentId;
//执行搜索重载
table.reloadData('currentTableId', {
2 years ago
url: '/repository/warehouseRecord',
page: {
curr: 1
},
where: req
}, 'data');
return false;
}
});
$(window).on("resize", function () {
layer.full(index);
});
return false;
} else if (obj.event === 'realDelete') { // 彻底删除
var req = {};
req.id = data.id;
$.ajax({
url: "/repository/findRelevancyByDepository",
type: "post",
dataType: "json",
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (data) {
var hasSon = data.data
if (hasSon) { // 若当前仓库及子仓库有关联信息
layer.msg("该仓库尚有记录无法删除", {
icon: 7,
time: 500 //1秒关闭(如果不配置,默认是3秒)
}, function () {
// 执行重加载
table.reloadData('currentTableId', {
2 years ago
url: '/repository/warehouseRecord',
page: {
curr: 1
},
where: {"parentId": parentId}
});
})
} else {
layer.confirm('该操作会造成不可逆后果,是否继续?', {
btn: ['继续', '取消'] //按钮
}, function () {
$.ajax({
url: '/repository/realDeleteDepository',
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);//失败的表情
return;
} else {
obj.del();
layer.msg("删除成功", {
icon: 6,//成功的表情
time: 500 //1秒关闭(如果不配置,默认是3秒)
});
}
}
})
}, function () {
// 执行重加载
table.reloadData('currentTableId', {
2 years ago
url: '/repository/warehouseRecord',
page: {
curr: 1
},
where: {"parentId": parentId}
});
});
}
}
})
} else if (obj.event === 'manager') {
layer.open({
type: 2,
title: '仓管员信息',
shadeClose: true,
shade: false,
maxmin: true, //开启最大化最小化按钮
area: ['70%', '70%'],
content: '/ManagerView?id=' + data.id
});
}
});
//监听状态操作
form.on('switch(changeState)', function (obj) {
// 首先发送请求判断待禁用的仓库是否还有货物,如果没有就直接禁用,否则进行判断
let display = $("#display").css("display");
if (display !== "none") {
2 years ago
var hasMaterial = false;
var req = new Map;
if (obj.elem.checked) {
req["state"] = 1
}
req["id"] = this.value;
if (req["state"] === undefined) {// 如果禁用
$.ajax({
url: "/repository/findMaterialByDepository?depositoryId=" + this.value,
type: "get",
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (d) {
hasMaterial = d.data;
// 子仓库下是否有物品
if (hasMaterial) { // 有
layer.confirm('仓库下还有物品,确定封库?', {
btn: ['封库', '取消'] //按钮
},
function () {
req["envelop"] = 1; // 封库操作
$.ajax({
url: "/repository/EditDepositoryState",
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);//失败的表情
return;
} else {
layer.msg("封库成功", {
icon: 6,//成功的表情
time: 500 //1秒关闭(如果不配置,默认是3秒)
}, function () {
// 执行重加载
table.reloadData('currentTableId', {
2 years ago
url: '/repository/warehouseRecord',
page: {
curr: 1
},
where: {"parentId": parentId}
});
})
}
}
})
},
function () {
// 执行重加载
table.reloadData('currentTableId', {
2 years ago
url: '/repository/warehouseRecord',
page: {
curr: 1
},
where: {"parentId": parentId}
});
});
} else {
layer.confirm('确定封库?', {
btn: ['确定', '取消']
2 years ago
},
function () {
$.ajax({
url: "/repository/EditDepositoryState",
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);//失败的表情
return;
} else {
layer.msg("修改成功", {
icon: 6,//成功的表情
time: 500 //1秒关闭(如果不配置,默认是3秒)
}, function () {
// 执行重加载
table.reloadData('currentTableId', {
2 years ago
url: '/repository/warehouseRecord',
page: {
curr: 1
},
where: {"parentId": parentId}
});
})
}
}
})
},
function () {
// 执行重加载
table.reloadData('currentTableId', {
2 years ago
url: '/repository/warehouseRecord',
page: {
curr: 1
},
where: {"parentId": parentId}
});
})
}
}
})
} else { // 如果启用
2 years ago
$.ajax({
url: "/repository/EditDepositoryState",
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);//失败的表情
return;
} else {
layer.msg("修改成功", {
icon: 6,//成功的表情
time: 500 //1秒关闭(如果不配置,默认是3秒)
}, function () {
// window.location='/findWareHouseByParentId?parentId=0'+parentId
// 执行重加载
table.reloadData('currentTableId', {
2 years ago
url: '/repository/warehouseRecord',
page: {
curr: 1
},
where: {"parentId": parentId}
});
})
}
}
})
}
}
});
showDetail = function (obj) {
var index = layer.open({
title: '仓库信息详情',
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: true,
area: ['100%', '100%'],
content: '/warehouse_view?id=' + obj.id,
end: function () {
2 years ago
let req = {};
req.parentId = parentId;
//执行搜索重载
table.reloadData('currentTableId', {
2 years ago
url: '/repository/warehouseRecord',
page: {
curr: 1
},
where: req
}, 'data');
return false;
}
});
$(window).on("resize", function () {
layer.full(index);
});
return false;
}
$('body').on('click', '[data-refresh]', function () {
location.reload();
})
});
</script>
</body>
</html>