|
|
|
|
<!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/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="layuimini-container">
|
|
|
|
|
<div class="layuimini-main">
|
|
|
|
|
<input style="display:none;" id="nowDay" th:value="${nowDay}">
|
|
|
|
|
<input style="display:none;" id="display" th:value="${display}">
|
|
|
|
|
<input style="display: none" th:value="${number}" id="number">
|
|
|
|
|
|
|
|
|
|
<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-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" class="layui-input" id="version" name="version" autocomplete="off"
|
|
|
|
|
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">
|
|
|
|
|
<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.id}}" 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"
|
|
|
|
|
th:style="'display:'+${display}"> 删除
|
|
|
|
|
</button>
|
|
|
|
|
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="applicationIn"> 入库申请
|
|
|
|
|
</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" style="margin-top: 123px"></table>
|
|
|
|
|
|
|
|
|
|
<script id="materialCode" type="text/html">
|
|
|
|
|
<a id="{{d.id}}" onclick="showDetail(this)">{{d.code}}</a>
|
|
|
|
|
</script>
|
|
|
|
|
<script type="text/html" id="currentTableBar">
|
|
|
|
|
<a class="layui-btn layui-btn-normal 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>
|
|
|
|
|
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" th:style="'display:'+${display}"
|
|
|
|
|
lay-event="realDelete">彻底删除</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.6.3/layui.js" charset="utf-8"></script>
|
|
|
|
|
<script>
|
|
|
|
|
function bindTableToolbarFunction() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showDetail() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function closeShowDataMessage() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let socket;
|
|
|
|
|
|
|
|
|
|
let newIndexShade;
|
|
|
|
|
|
|
|
|
|
layui.use(['form', 'table', 'upload'], function () {
|
|
|
|
|
var $ = layui.jquery,
|
|
|
|
|
form = layui.form,
|
|
|
|
|
table = layui.table,
|
|
|
|
|
upload = layui.upload;
|
|
|
|
|
|
|
|
|
|
$('#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%');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let cols = [
|
|
|
|
|
{type: "checkbox", width: 50},
|
|
|
|
|
{title: '存货编码', width: 150, templet: '#materialCode'},
|
|
|
|
|
{field: 'mname', width: 120, title: '物料名称', sort: false},
|
|
|
|
|
{field: 'typeName', width: 150, title: '物料种类'},
|
|
|
|
|
{field: 'version', width: 200, title: '规格型号', sort: false},
|
|
|
|
|
{field: 'unit', width: 150, title: '计量单位'},
|
|
|
|
|
{field: 'state', title: '状态', minWidth: 100, templet: '#switchTpl'},
|
|
|
|
|
{title: '操作', minWidth: 200, toolbar: '#currentTableBar', align: "center"},
|
|
|
|
|
{field: 'texture', width: 100, title: '材质'},
|
|
|
|
|
{field: 'brand', width: 150, title: '品牌'},
|
|
|
|
|
{field: 'shelfLife', width: 150, title: '保质期'},
|
|
|
|
|
{field: 'productionPlace', width: 150, title: '产地'},
|
|
|
|
|
{field: 'remark', width: 150, title: '备注'},
|
|
|
|
|
|
|
|
|
|
];
|
|
|
|
|
let flagForRelod = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
table.render({
|
|
|
|
|
elem: "#currentTableId",
|
|
|
|
|
url: '/material/material',
|
|
|
|
|
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'],
|
|
|
|
|
height: 'full-255',//固定高度-即固定表头固定第一行首行
|
|
|
|
|
cols: [
|
|
|
|
|
[
|
|
|
|
|
{type: "checkbox", width: 50},
|
|
|
|
|
{field: 'code', width: 150, title: '存货编码', sort: true},
|
|
|
|
|
{field: 'mname', width: 120, title: '物料名称', sort: false},
|
|
|
|
|
{field: 'typeName', width: 150, title: '物料种类'},
|
|
|
|
|
{field: 'version', width: 200, title: '规格型号', sort: false},
|
|
|
|
|
{field: 'unit', width: 150, title: '计量单位'},
|
|
|
|
|
{field: 'state', title: '状态', minWidth: 100, templet: '#switchTpl'},
|
|
|
|
|
{title: '操作', minWidth: 200, toolbar: '#currentTableBar', align: "center"},
|
|
|
|
|
{field: 'texture', width: 100, title: '材质'},
|
|
|
|
|
{field: 'brand', width: 150, title: '品牌'},
|
|
|
|
|
{field: 'shelfLife', width: 150, title: '保质期'},
|
|
|
|
|
{field: 'productionPlace', width: 150, title: '产地'},
|
|
|
|
|
{field: 'remark', width: 150, title: '备注'},
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
limits: [10, 15, 20, 25, 50, 100],
|
|
|
|
|
limit: 10,
|
|
|
|
|
page: true,
|
|
|
|
|
skin: 'line',
|
|
|
|
|
done: function (res, curr, count) {
|
|
|
|
|
bindTableToolbarFunction();
|
|
|
|
|
let display = $("#display").val();
|
|
|
|
|
if ("inline-block" === display) {
|
|
|
|
|
if (flagForRelod) {
|
|
|
|
|
flagForRelod = false;
|
|
|
|
|
let col = {field: 'price', width: 150, title: '物料单价'};
|
|
|
|
|
cols.splice(6, 0, col);
|
|
|
|
|
table.reload('currentTableId', {cols: [cols]});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//用于导入数据
|
|
|
|
|
function bindTableToolbarFunction() {
|
|
|
|
|
var upLoader = upload.render({
|
|
|
|
|
elem: "#u_fileUpload", // 绑定元素
|
|
|
|
|
url: '/excel/importExcelByMaterial', // 上传接口
|
|
|
|
|
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 = "";
|
|
|
|
|
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 mname = res.data.dataList[i]["mname"];
|
|
|
|
|
var code = res.data.dataList[i]["code"] == null || res.data.dataList[i]["code"] === undefined ? "" : res.data.dataList[i]["code"];
|
|
|
|
|
var version = res.data.dataList[i]["version"] == null || res.data.dataList[i]["version"] === undefined ? "" : res.data.dataList[i]["version"];
|
|
|
|
|
var texture = res.data.dataList[i]["texture"] == null || res.data.dataList[i]["texture"] === undefined ? "" : res.data.dataList[i]["texture"];
|
|
|
|
|
var unit = res.data.dataList[i]["unit"] == null || res.data.dataList[i]["unit"] === undefined ? "" : res.data.dataList[i]["unit"];
|
|
|
|
|
var typeId = res.data.dataList[i]["typeId"] == null || res.data.dataList[i]["typeId"] === undefined ? "" : res.data.dataList[i]["typeId"];
|
|
|
|
|
var show = "<p style='color: #00FF00'>" + mname + " " + version + " " + code + " " + texture + " " + unit + " " + typeId + " :通过" + "</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 mname = jsonObject[i]["mname"];
|
|
|
|
|
var code = jsonObject[i]["code"] == null || jsonObject[i]["code"] === undefined ? "" : jsonObject[i]["code"];
|
|
|
|
|
var version = jsonObject[i]["version"] == null || jsonObject[i]["version"] === undefined ? "" : jsonObject[i]["version"];
|
|
|
|
|
var texture = jsonObject[i]["texture"] == null || jsonObject[i]["texture"] === undefined ? "" : jsonObject[i]["texture"];
|
|
|
|
|
var unit = jsonObject[i]["unit"] == null || jsonObject[i]["unit"] === undefined ? "" : jsonObject[i]["unit"];
|
|
|
|
|
var typeId = jsonObject[i]["typeId"] == null || jsonObject[i]["typeId"] === undefined ? "" : jsonObject[i]["typeId"];
|
|
|
|
|
var show = "<p style='color: #00FF00'>" + mname + " " + version + " " + code + " " + texture + " " + unit + " " + typeId + " :成功" + "</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) {
|
|
|
|
|
//按钮【按钮一】的回调
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/excel/realImportMaterial",
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
layer.alert("数据导入完成", {
|
|
|
|
|
icon: 0
|
|
|
|
|
},function (indexForMsg,layero) {
|
|
|
|
|
closeShowDataMessage();
|
|
|
|
|
layer.close(indexForMsg);
|
|
|
|
|
table.reload('currentTableId', {
|
|
|
|
|
url: '/material/material',
|
|
|
|
|
page: {
|
|
|
|
|
curr: 1
|
|
|
|
|
},
|
|
|
|
|
}, 'data');
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
, btn2: function (index, layero) {
|
|
|
|
|
//按钮【按钮二】的回调
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/excel/realImportMaterial",
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 监听搜索操作
|
|
|
|
|
form.on('submit(data-search-btn)', function (data) {
|
|
|
|
|
var req = {};
|
|
|
|
|
data = data.field;
|
|
|
|
|
req.type = 1;
|
|
|
|
|
if (data.mname !== '') {
|
|
|
|
|
req.mname = data.mname;
|
|
|
|
|
}
|
|
|
|
|
if (data.version !== '') {
|
|
|
|
|
req.version = data.version;
|
|
|
|
|
}
|
|
|
|
|
if (data.materialTypeId !== '') {
|
|
|
|
|
req.materialTypeId = data.materialTypeId;
|
|
|
|
|
}
|
|
|
|
|
if (data.state !== '') {
|
|
|
|
|
req.state = data.state;
|
|
|
|
|
}
|
|
|
|
|
if (data.code !== '') {
|
|
|
|
|
req.code = data.code
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//执行搜索重载
|
|
|
|
|
table.reload('currentTableId', {
|
|
|
|
|
url: '/material/material',
|
|
|
|
|
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: '/material_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) {
|
|
|
|
|
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '/material/material_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: '/material/material',
|
|
|
|
|
page: {
|
|
|
|
|
curr: 1
|
|
|
|
|
}
|
|
|
|
|
}, 'data');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
layer.msg("未选中记录,请确认!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (obj.event === 'applicationIn') {
|
|
|
|
|
// 入库申请
|
|
|
|
|
var checkStatus = table.checkStatus('currentTableId')
|
|
|
|
|
, data = checkStatus.data;
|
|
|
|
|
var req = {};
|
|
|
|
|
req.mids = [];
|
|
|
|
|
// 获取所有选中的id
|
|
|
|
|
for (i = 0, len = data.length; i < len; i++) {
|
|
|
|
|
req.mids[i] = data[i].id;
|
|
|
|
|
}
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/material/temporaryValueForMaterial",
|
|
|
|
|
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 (d) {
|
|
|
|
|
layer.close(this.layerIndex);
|
|
|
|
|
if (d.status === 200) {
|
|
|
|
|
layer.open({
|
|
|
|
|
type: 2,
|
|
|
|
|
title: '入库',
|
|
|
|
|
skin: 'layui-layer-rim',
|
|
|
|
|
maxmin: true,
|
|
|
|
|
shadeClose: true, //点击遮罩关闭层
|
|
|
|
|
area: ['100%', '100%'],
|
|
|
|
|
move: '.layui-layer-title',
|
|
|
|
|
fixed: false,
|
|
|
|
|
content: '/applicationInByMaterial',
|
|
|
|
|
end: function () {
|
|
|
|
|
var index = parent.layer.getFrameIndex(window.name);
|
|
|
|
|
parent.layer.close(index);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
else if (obj.event === 'downloadFile') {
|
|
|
|
|
window.open("/download/materialImportDownload", "_self");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//监听表格复选框选择
|
|
|
|
|
table.on('checkbox(currentTableFilter)', function (obj) {
|
|
|
|
|
console.log(obj)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
table.on('tool(currentTableFilter)', function (obj) {
|
|
|
|
|
let data = obj.data;
|
|
|
|
|
|
|
|
|
|
if (obj.event === 'detail') {
|
|
|
|
|
var index = layer.open({
|
|
|
|
|
title: '物料信息详情',
|
|
|
|
|
type: 2,
|
|
|
|
|
shade: 0.2,
|
|
|
|
|
maxmin: true,
|
|
|
|
|
shadeClose: true,
|
|
|
|
|
area: ['100%', '100%'],
|
|
|
|
|
content: '/material_view?id=' + data.id,
|
|
|
|
|
end: function () {
|
|
|
|
|
//执行搜索重载
|
|
|
|
|
table.reload('currentTableId', {
|
|
|
|
|
url: '/material/material',
|
|
|
|
|
page: {
|
|
|
|
|
curr: 1
|
|
|
|
|
}
|
|
|
|
|
}, 'data');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$(window).on("resize", function () {
|
|
|
|
|
layer.full(index);
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
} else if (obj.event === 'delete') {
|
|
|
|
|
var req = {};
|
|
|
|
|
req.id = data.id;
|
|
|
|
|
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '/material/material_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 === 'realDelete') { //彻底删除
|
|
|
|
|
var req = {};
|
|
|
|
|
req.id = data.id;
|
|
|
|
|
layer.confirm('该操作会造成不可逆后果,是否继续?', {
|
|
|
|
|
btn: ['继续', '取消'] //按钮
|
|
|
|
|
}, function () {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '/material/realDeleteMaterial',
|
|
|
|
|
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: '/repository/warehouseRecord',
|
|
|
|
|
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;
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/material/material_edit",
|
|
|
|
|
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 () {
|
|
|
|
|
window.location = '/material_out'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showDetail = function (obj) {
|
|
|
|
|
var index = layer.open({
|
|
|
|
|
title: '物料信息详情',
|
|
|
|
|
type: 2,
|
|
|
|
|
shade: 0.2,
|
|
|
|
|
maxmin: true,
|
|
|
|
|
shadeClose: true,
|
|
|
|
|
area: ['100%', '100%'],
|
|
|
|
|
content: '/material_view?id=' + obj.id,
|
|
|
|
|
end: function () {
|
|
|
|
|
//执行搜索重载
|
|
|
|
|
table.reload('currentTableId', {
|
|
|
|
|
url: '/material/material',
|
|
|
|
|
page: {
|
|
|
|
|
curr: 1
|
|
|
|
|
}
|
|
|
|
|
}, 'data');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$(window).on("resize", function () {
|
|
|
|
|
layer.full(index);
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|