|
|
|
|
<!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.8.6/css/layui.css" media="all">
|
|
|
|
|
<link rel="stylesheet" href="/static/css/public.css" media="all">
|
|
|
|
|
<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">
|
|
|
|
|
<fieldset class="table-search-fieldset">
|
|
|
|
|
|
|
|
|
|
<legend>搜索信息</legend>
|
|
|
|
|
<div style="margin: 10px 10px 10px 10px">
|
|
|
|
|
<input style="display: none" th:value="${number}" id="number">
|
|
|
|
|
<input style="display: none" th:value="${display}" id="display">
|
|
|
|
|
<input style="display: none" th:value="${type}" id="selectDepositoryType">
|
|
|
|
|
<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-block">
|
|
|
|
|
<input type="text" placeholder="请选择仓库" class="layui-input" id="openSonByDepository"
|
|
|
|
|
readonly/>
|
|
|
|
|
<input type="text" name="depositoryId" class="layui-input" id="depositoryId"
|
|
|
|
|
style="display: none"/>
|
|
|
|
|
<input type="text" name="placeId" id="placeId" style="display: none">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="layui-inline">
|
|
|
|
|
<label class="layui-form-label">类型</label>
|
|
|
|
|
<div class="layui-input-block">
|
|
|
|
|
<input type="text" placeholder="请选择物料类型" class="layui-input" id="openSonByMateralType"
|
|
|
|
|
readonly/>
|
|
|
|
|
<input type="text" id="materialTypeId" placeholder="请选择物料类型" name="materialTypeId"
|
|
|
|
|
class="layui-input" style="display: none"/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="layui-inline">
|
|
|
|
|
<label class="layui-form-label">物料名称</label>
|
|
|
|
|
<div class="layui-input-block">
|
|
|
|
|
<input type="text" name="mname" autocomplete="off" class="layui-input"
|
|
|
|
|
placeholder="请填写物料名称">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="layui-inline">
|
|
|
|
|
<label class="layui-form-label">存货编码</label>
|
|
|
|
|
<div class="layui-input-block">
|
|
|
|
|
<input type="text" name="code" autocomplete="off" class="layui-input"
|
|
|
|
|
placeholder="请填写物料编码">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="layui-inline">
|
|
|
|
|
<label class="layui-form-label">型号</label>
|
|
|
|
|
<div class="layui-input-block">
|
|
|
|
|
<input type="text" class="layui-input" id="version" name="version" autocomplete="off"
|
|
|
|
|
placeholder="请填写物料型号"/>
|
|
|
|
|
</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 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">添加</button>
|
|
|
|
|
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="dispose">处理</button>
|
|
|
|
|
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" id="u_fileUpload"
|
|
|
|
|
lay-event="import">导入数据
|
|
|
|
|
</button>
|
|
|
|
|
<button class="layui-btn layui-btn-warm layui-btn-sm" lay-event="downloadFile">下载导入模板</button>
|
|
|
|
|
</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" mid="{{d.id}}" depository="{{d.depositoryId}}" lay-on="applicationIn">入库申请</a>
|
|
|
|
|
<a class="layui-btn layui-btn-xs data-count-edit" code="{{d.code}}" depository="{{d.depositoryId}}" lay-on="applicationOut" >出库申请</a>
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<!-- 用于计量单位的展示-->
|
|
|
|
|
<script id="changeUnit" type="text/html">
|
|
|
|
|
<button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="changeUnit" click_num="0"
|
|
|
|
|
id="btn_{{d.id}}" value="{{d.unit == d.baseUnit ? -1 : d.unit}}">{{d.unit}}
|
|
|
|
|
</button>
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<script id="changePlace" type="text/html" >
|
|
|
|
|
<span style="display: none">{{d.placeKingdeeCode}}</span>
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<script id="materialCode" type="text/html">
|
|
|
|
|
<a id="{{d.id}}" onclick="showDetail(this)">{{d.code}}</a>
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div id="showImportData"
|
|
|
|
|
style="height: 500px;width: 500px;position: absolute;overflow: auto;top: 10%;left: 25%;background: #ffffff;z-index: 1231234;display: none">
|
|
|
|
|
<div onclick="closeShowDataMessage()" style="position: absolute; right: 0; top: 2%; cursor: pointer;">
|
|
|
|
|
<i class="fa fa-window-close-o"></i>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="showDataContent"></div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<script src="/static/lib/layui-v2.8.6/layui.js" charset="utf-8"></script>
|
|
|
|
|
<script>
|
|
|
|
|
var data;
|
|
|
|
|
|
|
|
|
|
function changePlaceCode() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function changeUnit() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function bindTableToolbarFunction() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function closeShowDataMessage() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showDetail() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let socket = null;
|
|
|
|
|
|
|
|
|
|
let newIndexShade;
|
|
|
|
|
|
|
|
|
|
// 用于保证导入时点击只导入一次
|
|
|
|
|
let flagForImport = true;
|
|
|
|
|
|
|
|
|
|
let reqForPublic = {};
|
|
|
|
|
|
|
|
|
|
layui.use(['form', 'table', 'upload','util'], function () {
|
|
|
|
|
var $ = layui.jquery,
|
|
|
|
|
form = layui.form,
|
|
|
|
|
upload = layui.upload,
|
|
|
|
|
util = layui.util,
|
|
|
|
|
table = layui.table;
|
|
|
|
|
|
|
|
|
|
let display = $("#display").val();
|
|
|
|
|
|
|
|
|
|
$('#openSonByMateralType').on('click', function () {
|
|
|
|
|
|
|
|
|
|
layer.open({
|
|
|
|
|
type: 2,
|
|
|
|
|
title: '弹窗内容',
|
|
|
|
|
skin: 'layui-layer-rim',
|
|
|
|
|
maxmin: true,
|
|
|
|
|
shadeClose: true, //点击遮罩关闭层
|
|
|
|
|
area: ['70%', '70%'],
|
|
|
|
|
move: '.layui-layer-title',
|
|
|
|
|
fixed: false,
|
|
|
|
|
content: '/selectType',
|
|
|
|
|
success: function (layero, index) {
|
|
|
|
|
var children = layero.children();
|
|
|
|
|
var content = $(children[1]);
|
|
|
|
|
var iframeChildren = $(content.children());
|
|
|
|
|
content.css('height', '100%');
|
|
|
|
|
iframeChildren.css('height', '100%');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#openSonByDepository').on('click', function () {
|
|
|
|
|
let selectDepositoryType = $("#selectDepositoryType").val();
|
|
|
|
|
layer.open({
|
|
|
|
|
type: 2,
|
|
|
|
|
title: '弹窗内容',
|
|
|
|
|
skin: 'layui-layer-rim',
|
|
|
|
|
maxmin: true,
|
|
|
|
|
shadeClose: true, //点击遮罩关闭层
|
|
|
|
|
area: ['70%', '70%'],
|
|
|
|
|
move: '.layui-layer-title',
|
|
|
|
|
fixed: false,
|
|
|
|
|
content: '/selectDepository?type=' + selectDepositoryType,
|
|
|
|
|
success: function (layero, index) {
|
|
|
|
|
var children = layero.children();
|
|
|
|
|
var content = $(children[1]);
|
|
|
|
|
var iframeChildren = $(content.children());
|
|
|
|
|
content.css('height', '100%');
|
|
|
|
|
iframeChildren.css('height', '100%');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let cols = [
|
|
|
|
|
{type: "checkbox", width: 50},
|
|
|
|
|
{field: "code", title: '存货编码', width: 150, templet: '#materialCode'},
|
|
|
|
|
{field: 'mname', width: 200, title: '物料名称'},
|
|
|
|
|
{field: 'brand', width: 200, title: '品牌'},
|
|
|
|
|
{field: 'version', width: 200, title: '规格型号'},
|
|
|
|
|
{field: 'typeName', width: 200, title: '物料类型'},
|
|
|
|
|
{field: "unit", title: '计量单位', width: 200, templet: '#changeUnit', align: "center"},
|
|
|
|
|
{field: 'quantity', width: 200, title: '数量'},
|
|
|
|
|
{field: 'depositoryName', width: 200, title: '仓库名称'},
|
|
|
|
|
{field: 'depositoryCode', width: 200, title: '仓库编码'},
|
|
|
|
|
// {title: '所处库位', width: 200, templet: '#changePlace', align: "center"},
|
|
|
|
|
{field: "placeKingdeeCode", title: '所处库位', width: 200, templet: '#changePlace', align: "center"},
|
|
|
|
|
{field: 'warningCount', width: 200, title: '待过期数量', sort: true},
|
|
|
|
|
{field: 'price', title: '单价', width: 200, sort: true},
|
|
|
|
|
{field: 'amounts', title: '总金额', width: 200, sort: true},
|
|
|
|
|
{field: 'texture', width: 200, title: '材质',},
|
|
|
|
|
{field: 'iremark', width: 200, title: '备注',},
|
|
|
|
|
{title: '操作', minWidth: 250, toolbar: '#currentTableBar', align: "center"}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let flagForReload = true;
|
|
|
|
|
|
|
|
|
|
table.render({
|
|
|
|
|
elem: "#currentTableId",
|
|
|
|
|
url: '/material/findInventory',
|
|
|
|
|
parseData: function (res) { //res 即为原始返回的数据
|
|
|
|
|
return {
|
|
|
|
|
"status": res.status, //解析接口状态
|
|
|
|
|
"message": res.statusInfo.message, //解析提示文本
|
|
|
|
|
"count": res.count, //解析数据长度
|
|
|
|
|
"data": res.data //解析数据列表
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
height: 'full-255',//固定高度-即固定表头固定第一行首行
|
|
|
|
|
request: {
|
|
|
|
|
pageName: 'page', //页码的参数名称,默认:page
|
|
|
|
|
limitName: 'size' //每页数据量的参数名,默认:limit
|
|
|
|
|
},
|
|
|
|
|
response: {
|
|
|
|
|
statusName: 'status' //规定数据状态的字段名称,默认:code
|
|
|
|
|
, statusCode: 200 //规定成功的状态码,默认:0
|
|
|
|
|
, msgName: 'message' //规定状态信息的字段名称,默认:msg
|
|
|
|
|
, countName: 'count' //规定数据总数的字段名称,默认:count
|
|
|
|
|
, dataName: 'data' //规定数据列表的字段名称,默认:data
|
|
|
|
|
},
|
|
|
|
|
toolbar: '#toolbarDemo',
|
|
|
|
|
cols: [
|
|
|
|
|
[
|
|
|
|
|
{type: "checkbox", width: 50},
|
|
|
|
|
{title: '存货编码', width: 150, templet: '#materialCode'},
|
|
|
|
|
{field: 'mname', width: 200, title: '物料名称'},
|
|
|
|
|
{field: 'brand', width: 200, title: '品牌'},
|
|
|
|
|
{field: 'version', width: 200, title: '规格型号'},
|
|
|
|
|
{field: 'typeName', width: 200, title: '物料类型'},
|
|
|
|
|
{field: "unit", title: '计量单位', width: 200, templet: '#changeUnit', align: "center"},
|
|
|
|
|
{field: 'quantity', width: 200, title: '数量'},
|
|
|
|
|
{field: 'depositoryName', width: 200, title: '仓库名称'},
|
|
|
|
|
{field: 'depositoryCode', width: 200, title: '仓库编码'},
|
|
|
|
|
{title: '所处库位', width: 200, templet: '#changePlace', align: "center"},
|
|
|
|
|
{field: "placeKingdeeCode", title: '所处库位', width: 200, templet: '#changePlace', align: "center"},
|
|
|
|
|
{field: 'warningCount', width: 200, title: '待过期数量', sort: true},
|
|
|
|
|
{field: 'texture', width: 200, title: '材质',},
|
|
|
|
|
{field: 'iremark', width: 200, title: '备注',},
|
|
|
|
|
{title: '操作', minWidth: 250, toolbar: '#currentTableBar', align: "center"}
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
limits: [10, 20, 50, 100],
|
|
|
|
|
limit: 10,
|
|
|
|
|
page: true,
|
|
|
|
|
skin: 'line',
|
|
|
|
|
done: function (res, curr, count) {
|
|
|
|
|
bindTableToolbarFunction();
|
|
|
|
|
if (display !== "none") {
|
|
|
|
|
if (flagForReload) {
|
|
|
|
|
flagForReload = false;
|
|
|
|
|
table.reload("currentTableId", {cols: [cols]});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$.each(res['data'], function (i, j) {
|
|
|
|
|
let jElement = j['warningCount'];
|
|
|
|
|
let placeCode = j['placeCode'].split(" ");
|
|
|
|
|
let placeKingdeeCode = j['placeKingdeeCode'].split(" ");
|
|
|
|
|
let depositoryId = j['depositoryId'];
|
|
|
|
|
let mid = j['id'];
|
|
|
|
|
if (jElement !== null && jElement !== undefined) {
|
|
|
|
|
let flag = (Number(jElement) !== 0);
|
|
|
|
|
if (flag) {
|
|
|
|
|
Layui_SetDataTableRowColor('table', i + 1, '#b1070a');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 所处库位
|
|
|
|
|
var placeCodeItem = $("[lay-id='currentTableId'] tr:eq(" + (i + 1) + ")").children()[10];
|
|
|
|
|
//计量单位
|
|
|
|
|
// 用于库位的添加
|
|
|
|
|
var aItem = placeCodeItem.childNodes[0];
|
|
|
|
|
// 用于计量单位的添加
|
|
|
|
|
for (let k = 0; k < placeKingdeeCode.length; k++) {
|
|
|
|
|
if (placeKingdeeCode[k] !== "") {
|
|
|
|
|
$(aItem).append('<button code=' + placeCode[k] + ' id=' + mid + ' class="layui-btn layui-btn-primary layui-btn-xs" onclick="changePlaceCode(this)" value=' + depositoryId + '>' + placeKingdeeCode[k] + '</button>')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 用于给table行上色的方法
|
|
|
|
|
function Layui_SetDataTableRowColor(TabDivId, RowIndex, ColorString) {
|
|
|
|
|
try {
|
|
|
|
|
var div = $("[lay-id='currentTableId'] tr:eq(" + RowIndex + ")");
|
|
|
|
|
if (div != null) //找到对象了
|
|
|
|
|
{
|
|
|
|
|
// console.log(div);
|
|
|
|
|
div.css("color", ColorString);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
console.log('没有找到对象');
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log(e.message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//监听表格复选框选择
|
|
|
|
|
table.on('checkbox(currentTableFilter)', function (obj) {
|
|
|
|
|
console.log(obj)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 用于进行渲染库位编码
|
|
|
|
|
form.on('switch(createPlaceCode)', function (obj) {
|
|
|
|
|
console.log(obj)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 监听库位修改操作
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 监听搜索操作
|
|
|
|
|
form.on('submit(data-search-btn)', function (data) {
|
|
|
|
|
var req = {};
|
|
|
|
|
data = data.field;
|
|
|
|
|
if (data.mname !== '') {
|
|
|
|
|
req.mname = data.mname.trim();
|
|
|
|
|
}
|
|
|
|
|
if (data.depositoryId !== '') {
|
|
|
|
|
req.depositoryId = data.depositoryId;
|
|
|
|
|
}
|
|
|
|
|
if (data.placeId !== '') {
|
|
|
|
|
req.placeId = data.placeId;
|
|
|
|
|
}
|
|
|
|
|
if (data.code !== '') {
|
|
|
|
|
req.mcode = data.code.trim();
|
|
|
|
|
}
|
|
|
|
|
if (data.version !== '') {
|
|
|
|
|
req.version = data.version.trim();
|
|
|
|
|
}
|
|
|
|
|
if (data.materialTypeId !== '') {
|
|
|
|
|
req.materialTypeId = data.materialTypeId;
|
|
|
|
|
}
|
|
|
|
|
reqForPublic = req;
|
|
|
|
|
//执行搜索重载
|
|
|
|
|
table.reload('currentTableId', {
|
|
|
|
|
url: '/material/findInventory',
|
|
|
|
|
page: {
|
|
|
|
|
curr: 1
|
|
|
|
|
}
|
|
|
|
|
, where: req
|
|
|
|
|
}, 'data');
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* toolbar监听事件
|
|
|
|
|
*/
|
|
|
|
|
table.on('toolbar(currentTableFilter)', function (obj) {
|
|
|
|
|
if (obj.event === 'add') { // 监听入库申请操作
|
|
|
|
|
var checkStatus = table.checkStatus('currentTableId')
|
|
|
|
|
, data = checkStatus.data;
|
|
|
|
|
var req = {};
|
|
|
|
|
req.mids = [];
|
|
|
|
|
req.depositoryIds = [];
|
|
|
|
|
req.placeCodes = [];
|
|
|
|
|
for (i = 0, len = data.length; i < len; i++) {
|
|
|
|
|
req.mids[i] = data[i].id;
|
|
|
|
|
req.depositoryIds[i] = data[i].depositoryId;
|
|
|
|
|
req.placeCodes[i] = data[i].placeCode;
|
|
|
|
|
}
|
|
|
|
|
if (req.mids.length > 0) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/depositoryRecord/addApplicationToRedis",
|
|
|
|
|
type: "post",
|
|
|
|
|
data: JSON.stringify(req),
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: "application/json;charset=utf-8",
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === 201) {
|
|
|
|
|
layer.msg("添加成功", {
|
|
|
|
|
icon: 6,//成功的表情
|
|
|
|
|
time: 500 //1秒关闭(如果不配置,默认是3秒)
|
|
|
|
|
}, function () {
|
|
|
|
|
//执行搜索重载
|
|
|
|
|
table.reload('currentTableId', {
|
|
|
|
|
url: '/material/findInventory',
|
|
|
|
|
page: {
|
|
|
|
|
curr: 1
|
|
|
|
|
},
|
|
|
|
|
where:reqForPublic
|
|
|
|
|
}, 'data');
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
layer.msg("添加失败,请重试", {
|
|
|
|
|
icon: 2,
|
|
|
|
|
time: 200,
|
|
|
|
|
}, function () {
|
|
|
|
|
//执行搜索重载
|
|
|
|
|
table.reload('currentTableId', {
|
|
|
|
|
url: '/material/findInventory',
|
|
|
|
|
page: {
|
|
|
|
|
curr: 1
|
|
|
|
|
},
|
|
|
|
|
where:reqForPublic
|
|
|
|
|
}, 'data');
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
layer.msg("未选中记录,请确认!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else if (obj.event === 'dispose') {
|
|
|
|
|
var index = layer.open({
|
|
|
|
|
title: '批量处理',
|
|
|
|
|
type: 2,
|
|
|
|
|
shade: 0.2,
|
|
|
|
|
maxmin: true,
|
|
|
|
|
shadeClose: true,
|
|
|
|
|
area: ['100%', '100%'],
|
|
|
|
|
content: '/application_multi'
|
|
|
|
|
});
|
|
|
|
|
$(window).on("resize", function () {
|
|
|
|
|
layer.full(index);
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
} else if (obj.event === 'downloadFile') {
|
|
|
|
|
window.open("/download/inventoryImportDownload", "_self");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
table.on('tool(currentTableFilter)', function (obj) {
|
|
|
|
|
let data = obj.data;
|
|
|
|
|
if (obj.event === 'changeUnit') {
|
|
|
|
|
let showQuantity = data.showQuantity;
|
|
|
|
|
let btn = $("#btn_" + data.id);
|
|
|
|
|
let clickNum = Number(btn.attr("click_num"));
|
|
|
|
|
// 获取当前showQuantity 的长度
|
|
|
|
|
let length = Object.getOwnPropertyNames(showQuantity).length;
|
|
|
|
|
if (length > 0) {
|
|
|
|
|
if (clickNum < length) {
|
|
|
|
|
|
|
|
|
|
let keys = Object.keys(showQuantity);
|
|
|
|
|
|
|
|
|
|
let key = keys[clickNum];
|
|
|
|
|
btn.text(key);
|
|
|
|
|
|
|
|
|
|
clickNum += 1;
|
|
|
|
|
|
|
|
|
|
btn.attr("click_num", clickNum);
|
|
|
|
|
let show_quantity = showQuantity[key];
|
|
|
|
|
|
|
|
|
|
if (show_quantity !== undefined) {
|
|
|
|
|
obj.update({quantity: show_quantity});
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
obj.update({quantity: 0});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
btn.text(data.defaultUnit);
|
|
|
|
|
btn.attr("click_num", 0);
|
|
|
|
|
let showQuantity = data.defaultQuantity;
|
|
|
|
|
obj.update({quantity: showQuantity});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 事件
|
|
|
|
|
util.on('lay-on', {
|
|
|
|
|
'applicationIn': function(obj){
|
|
|
|
|
let mid = $(obj).attr('mid');
|
|
|
|
|
let depositoryId = $(obj).attr('depository');
|
|
|
|
|
layer.open({
|
|
|
|
|
type: 2,
|
|
|
|
|
offset: 'r',
|
|
|
|
|
anim: 'slideLeft', // 从右往左
|
|
|
|
|
area: ['40%', '100%'],
|
|
|
|
|
shade: 0.1,
|
|
|
|
|
title:"入库申请",
|
|
|
|
|
shadeClose: true,
|
|
|
|
|
id: 'ID-demo-layer-direction-r',
|
|
|
|
|
content: '/application_in_back?mid=' +mid + "&depositoryId=" + depositoryId
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
'applicationOut': function(obj){
|
|
|
|
|
let code = $(obj).attr('code');
|
|
|
|
|
let depositoryId = $(obj).attr('depository');
|
|
|
|
|
layer.open({
|
|
|
|
|
type: 2,
|
|
|
|
|
offset: 'r',
|
|
|
|
|
anim: 'slideLeft', // 从右往左
|
|
|
|
|
area: ['40%', '100%'],
|
|
|
|
|
shade: 0.1,
|
|
|
|
|
title:"出库申请",
|
|
|
|
|
shadeClose: true,
|
|
|
|
|
id: 'ID-demo-layer-direction-r',
|
|
|
|
|
content: '/application_out_back?code=' + code+ "&depositoryId=" + depositoryId
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 用于更改同一仓库下的库位
|
|
|
|
|
changePlaceCode = function (obj) {
|
|
|
|
|
var depositoryId = obj.value;
|
|
|
|
|
var placeCode = obj.getAttribute("code");
|
|
|
|
|
var mid = obj.id;
|
|
|
|
|
// 当前点击行中的计量单位按钮
|
|
|
|
|
let unitBtn = obj.parentNode.parentNode.parentNode.childNodes[6].childNodes[0].childNodes[1];
|
|
|
|
|
let unit = unitBtn.innerText;
|
|
|
|
|
var index = layer.open({
|
|
|
|
|
title: '选择库位',
|
|
|
|
|
type: 2,
|
|
|
|
|
shade: 0.2,
|
|
|
|
|
maxmin: true,
|
|
|
|
|
shadeClose: true,
|
|
|
|
|
area: ['70%', '70%'],
|
|
|
|
|
content: '/selectPlaceByDepository?depositoryId=' + depositoryId + '&mid=' + mid + '&placeCode=' + placeCode + '&unit=' + unit,
|
|
|
|
|
success: function (layero, index) {
|
|
|
|
|
var children = layero.children();
|
|
|
|
|
var content = $(children[1]);
|
|
|
|
|
var iframeChildren = $(content.children());
|
|
|
|
|
content.css('height', '100%');
|
|
|
|
|
iframeChildren.css('height', '100%');
|
|
|
|
|
},
|
|
|
|
|
end: function () {
|
|
|
|
|
//执行搜索重载
|
|
|
|
|
table.reload('currentTableId', {
|
|
|
|
|
url: '/material/findInventory',
|
|
|
|
|
page: {
|
|
|
|
|
curr: 1
|
|
|
|
|
}
|
|
|
|
|
, where:reqForPublic
|
|
|
|
|
}, 'data');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$(window).on("resize", function () {
|
|
|
|
|
layer.full(index);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//用于导入数据
|
|
|
|
|
function bindTableToolbarFunction() {
|
|
|
|
|
var upLoader = upload.render({
|
|
|
|
|
elem: "#u_fileUpload", // 绑定元素
|
|
|
|
|
url: '/excel/importInventory', // 上传接口
|
|
|
|
|
accept: 'file', // 允许上传的格式,
|
|
|
|
|
before: function (obj) { //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
|
|
|
|
|
layer.load(); //上传loading
|
|
|
|
|
},
|
|
|
|
|
exts: 'xls|xlsx|csv',
|
|
|
|
|
done: function (res) {
|
|
|
|
|
layer.closeAll('loading'); //关闭loading
|
|
|
|
|
//如果上传成功
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
var re = "";
|
|
|
|
|
let errMsgNum = res.data.errMsg.length;
|
|
|
|
|
if (errMsgNum > 0) {
|
|
|
|
|
re += "<h4>错误总数为:" + errMsgNum + "</h4>";
|
|
|
|
|
}
|
|
|
|
|
for (let i = 0; i < res.data.errMsg.length; i++) {
|
|
|
|
|
var show = "<p style='color: #ff211e'>" + res.data.errMsg[i] + "</p>";
|
|
|
|
|
re += show
|
|
|
|
|
}
|
|
|
|
|
let dataNum = res.data.dataList.length;
|
|
|
|
|
re += "<h4>待导入数据总数为:" + dataNum + "</h4>";
|
|
|
|
|
for (let i = 0; i < dataNum; i++) {
|
|
|
|
|
let dataListElement = res.data.dataList[i];
|
|
|
|
|
var code = dataListElement["code"] === null ? '' : dataListElement["code"];
|
|
|
|
|
var mname = dataListElement["mname"];
|
|
|
|
|
var version = dataListElement["version"] === null ? '' : dataListElement["version"];
|
|
|
|
|
var quantity = dataListElement["quantity"];
|
|
|
|
|
var remark = dataListElement["remark"] === null ? "" : dataListElement["remark"];
|
|
|
|
|
var show = "<p style='color: #00FF00'>" + code + ", " + mname + ", " + version + ", 数量为:" + quantity + "备注:" + remark + ":通过" + "</p>";
|
|
|
|
|
re += show
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("WebSocket" in window) {
|
|
|
|
|
let number = $("#number").val();
|
|
|
|
|
socket = new WebSocket('ws://127.0.0.1:11111/webSocket/' + number);
|
|
|
|
|
switch (socket.readyState) {
|
|
|
|
|
case WebSocket.CONNECTING:
|
|
|
|
|
// 连接中
|
|
|
|
|
socket.onopen = function () {
|
|
|
|
|
console.log("连接成功")
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case WebSocket.OPEN:
|
|
|
|
|
// 连接成功
|
|
|
|
|
break;
|
|
|
|
|
case WebSocket.CLOSING:
|
|
|
|
|
// 连接正在关闭。
|
|
|
|
|
break;
|
|
|
|
|
case WebSocket.CLOSED:
|
|
|
|
|
// 连接关闭。
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
// this never happens
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
socket.addEventListener('message', function (event) {
|
|
|
|
|
layer.close(newIndexShade);
|
|
|
|
|
let shadeItem = '<div class="layui-layer-shade" id=' + "layui-layer-shade-x" + newIndexShade + ' times="753951" style="z-index:1231233; background-color: rgb(0, 0, 0); opacity: 0.8;"></div>';
|
|
|
|
|
if ($("#" + "layui-layer-shade-x" + newIndexShade).length <= 0) {
|
|
|
|
|
$('body').append(shadeItem);
|
|
|
|
|
}
|
|
|
|
|
let jsonObject = JSON.parse(event.data);
|
|
|
|
|
let re = "";
|
|
|
|
|
$("#showImportData").show();
|
|
|
|
|
for (let i = 0; i < jsonObject.length; i++) {
|
|
|
|
|
var code = jsonObject[i]["code"] === null ? '' : jsonObject[i]["code"];
|
|
|
|
|
var mname = jsonObject[i]["mname"];
|
|
|
|
|
var version = jsonObject[i]["version"] === null ? '' : jsonObject[i]["version"];
|
|
|
|
|
var quantity = jsonObject[i]["quantity"];
|
|
|
|
|
var remark = jsonObject[i]["remark"];
|
|
|
|
|
var show = "<p style='color: #00FF00'>" + code + ", " + mname + ", " + version + ", 数量为:" + quantity + "备注:" + remark + ":通过" + "</p>";
|
|
|
|
|
re += show
|
|
|
|
|
}
|
|
|
|
|
$("#showDataContent").append(re);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newIndexShade = layer.open({
|
|
|
|
|
type: 1
|
|
|
|
|
, title: false //不显示标题栏
|
|
|
|
|
, closeBtn: false
|
|
|
|
|
, area: ['500px', '500px']
|
|
|
|
|
, shade: 0.8
|
|
|
|
|
, id: 'LAY_layuipro' //设定一个id,防止重复弹出
|
|
|
|
|
, resize: false
|
|
|
|
|
, btn: ['导入', '取消']
|
|
|
|
|
, btnAlign: 'c'
|
|
|
|
|
, moveType: 1 //拖拽模式,0或者1
|
|
|
|
|
, content: re
|
|
|
|
|
, yes: function (index, layero) {
|
|
|
|
|
if (flagForImport) {
|
|
|
|
|
flagForImport = false;
|
|
|
|
|
let loading2 = layer.open({
|
|
|
|
|
type: 3,
|
|
|
|
|
shade: [0.25, '#000'],
|
|
|
|
|
icon: 2,
|
|
|
|
|
speed: 0,
|
|
|
|
|
shadeClose: true
|
|
|
|
|
});
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/excel/realImportInventory",
|
|
|
|
|
type: "post",
|
|
|
|
|
data: JSON.stringify({"result": "yes"}),
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: "application/json;charset=utf-8",
|
|
|
|
|
success: function () {
|
|
|
|
|
if (socket !== null) {
|
|
|
|
|
socket.close();
|
|
|
|
|
} else {
|
|
|
|
|
layer.close(index);
|
|
|
|
|
}
|
|
|
|
|
flagForImport = true;
|
|
|
|
|
layer.alert("数据导入完成", {
|
|
|
|
|
icon: 0
|
|
|
|
|
}, function (indexForMsg, layero) {
|
|
|
|
|
layer.close(indexForMsg);
|
|
|
|
|
layer.close(loading2);
|
|
|
|
|
closeShowDataMessage();
|
|
|
|
|
table.reload('currentTableId', {
|
|
|
|
|
url: '/material/findInventory',
|
|
|
|
|
page: {
|
|
|
|
|
curr: 1
|
|
|
|
|
},
|
|
|
|
|
where:reqForPublic
|
|
|
|
|
}, 'data');
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
error: function () {
|
|
|
|
|
flagForImport = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//按钮【按钮一】的回调
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
, btn2: function (index, layero) {
|
|
|
|
|
//按钮【按钮二】的回调
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/excel/realImportInventory",
|
|
|
|
|
type: "post",
|
|
|
|
|
data: JSON.stringify({"result": "no"}),
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: "application/json;charset=utf-8",
|
|
|
|
|
success: function () {
|
|
|
|
|
if (socket !== null) {
|
|
|
|
|
socket.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
layer.msg(res.msg)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
error: function () {
|
|
|
|
|
layer.closeAll('loading'); //关闭loading
|
|
|
|
|
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()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
closeShowDataMessage = function () {
|
|
|
|
|
$("#layui-layer-shade-x" + newIndexShade).remove();
|
|
|
|
|
$("#showImportData").hide();
|
|
|
|
|
$("#showDataContent").empty();
|
|
|
|
|
if (socket !== null) {
|
|
|
|
|
socket.close();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showDetail = function (obj) {
|
|
|
|
|
var index = layer.open({
|
|
|
|
|
title: '库存信息详情',
|
|
|
|
|
type: 2,
|
|
|
|
|
shade: 0.2,
|
|
|
|
|
maxmin: true,
|
|
|
|
|
shadeClose: true,
|
|
|
|
|
area: ['100%', '100%'],
|
|
|
|
|
content: '/InventoryView?id=' + obj.id,
|
|
|
|
|
end: function () {
|
|
|
|
|
//执行搜索重载
|
|
|
|
|
table.reload('currentTableId', {
|
|
|
|
|
url: '/material/findInventory',
|
|
|
|
|
page: {
|
|
|
|
|
curr: 1
|
|
|
|
|
},
|
|
|
|
|
where:reqForPublic
|
|
|
|
|
}, 'data');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$(window).on("resize", function () {
|
|
|
|
|
layer.full(index);
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|