已废弃
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.
 
 
 
 
 
 

417 lines
18 KiB

<!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>
<style>
td .layui-form-select {
margin-top: -10px;
margin-left: -15px;
}
/* .laytable-cell-1-0-7 {
overflow: visible !important;
}
*/
</style>
<div class="layuimini-container">
<div class="layuimini-main">
<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="delete">删除</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" lay-event="applicationOut">出库申请
</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" lay-event="applicationIn">入库</a>
<a class="layui-btn layui-btn-xs data-count-edit" lay-event="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_unit_{{d.iid}}" value="-1">{{d.showUnit}}
</button>
</script>
<script id="selectLocation" type="text/html">
<button class="layui-btn layui-btn-primary layui-btn-xs" click_num="0" lay-event="selectLocation"
id="btn_placeCode_{{d.iid}}" value="{{d.placeCode}}">{{d.placeCode}}
</button>
</script>
</div>
</div>
<script src="/static/lib/layui-v2.8.6/layui.js" charset="utf-8"></script>
<script>
var data;
layui.use(['form', 'table'], function () {
var $ = layui.jquery,
form = layui.form,
table = layui.table;
table.render({
elem: "#currentTableId",
url: '/depositoryRecord/applicant_multi_create',
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
},
response: {
statusName: 'status' //规定数据状态的字段名称,默认:code
, statusCode: 200 //规定成功的状态码,默认:0
, msgName: 'message' //规定状态信息的字段名称,默认:msg
, countName: 'count' //规定数据总数的字段名称,默认:count
, dataName: 'data' //规定数据列表的字段名称,默认:data
},
height: 'full-255',//固定高度-即固定表头固定第一行首行
toolbar: '#toolbarDemo',
cols: [
[
{type: "checkbox", width: 50},
{field: 'mname', width: 150, title: '物料名称'},
{field: 'version', width: 150, title: '规格型号'},
{field: 'code', width: 200, title: '存货编码', sort: true},
{title: '所处位置', width: 200, templet: '#selectLocation', align: "center"},
{field: 'depositoryName', width: 150, title: '仓库名称'},
{title: '计量单位', width: 200, templet: '#changeUnit', align: "center"},
{field: 'quantity', width: 150, title: '数量', edit: 'quantity'},
{field: 'applyRemark', width: 150, title: '备注说明', edit: 'applyRemark'},
{title: '操作', minWidth: 250, toolbar: '#currentTableBar', align: "center"}
]
],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
skin: 'line',
done: function (res, curr, count) {
}
});
//监听表格复选框选择
table.on('checkbox(currentTableFilter)', function (obj) {
// console.log(obj)
});
table.on('edit(currentTableFilter)', function (obj) { //注:edit是固定事件名,test是table原始容器的属性 lay-filter="对应的值"
// console.log(obj.data); //所在行的所有相关数据
let data = obj.data;
let quantity = data.quantity;
let mcode = data.code;
let unit = data.unit;
let depositoryId = data.depositoryId;
let req = {};
req.mcode = mcode;
req.quantity = quantity;
req.unit = unit;
req.placeId = -1;
req.depositoryId = depositoryId;
MaterialQuantityIsTrue(req,obj);
});
/**
* toolbar监听事件
*/
table.on('toolbar(currentTableFilter)', function (obj) {
var checkStatus = table.checkStatus('currentTableId')
, data = checkStatus.data;
var req = {};
req.mids = [];
req.depositoryIds = [];
req.quantitys = [];
req.applyRemarks = [];
req.placeCodes = [];
req.iids = [];
req.units = [];
for (i = 0, len = data.length; i < len; i++) {
req.mids[i] = data[i].mid;
req.iids[i] = data[i].iid;
req.depositoryIds[i] = data[i].depositoryId;
req.quantitys[i] = data[i].quantity;
req.applyRemarks[i] = data[i].applyRemark;
req.placeCodes[i] = data[i].placeCode;
req.units[i] = data[i].unit;
}
if (obj.event === 'delete') {
if (req.mids.length > 0) {
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) {
for (i = 0, len = data.length; i < len; i++) {
req.placeCodes[i] = data[i].placeCodes.toString().replace(",", " ")
}
$.ajax({
url: "/depositoryRecord/deleteApplicationToRedis",
type: "post",
data: JSON.stringify(req),
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (d) {
layer.close(this.layerIndex);
if (d.status >= 300) {
layer.msg(d.statusInfo.message);//失败的表情
return;
} else {
layer.msg("删除成功!", {
icon: 6,//成功的表情
time: 1000
}, //1秒关闭(如果不配置,默认是3秒)
function () {
//do something
window.location = "/application_multi"
});
}
}
})
})
} else {
layer.msg("未选中记录,请确认!");
return false;
}
} else if (obj.event === 'applicationIn') {
req.type = 'in';
$.ajax({
url: "/depositoryRecord/createMultiApplications",
type: "post",
data: JSON.stringify(req),
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (d) {
layer.close(this.layerIndex);
if (d.status >= 300) {
layer.msg(d.statusInfo.message);//失败的表情
return;
} else {
layer.msg("申请成功!", {
icon: 6,//成功的表情
time: 1000
}, //1秒关闭(如果不配置,默认是3秒)
function () {
//do something
window.location = "/application_multi"
});
}
}
});
return false;
} else if (obj.event === 'applicationOut') {
req.type = 'out';
$.ajax({
url: "/depositoryRecord/createMultiApplications",
type: "post",
data: JSON.stringify(req),
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (d) {
layer.close(this.layerIndex);
if (d.status >= 300) {
layer.msg(d.statusInfo.detail, {
icon: 0,
time: 1000
}, function () {
obj.update({quantity: 1})
});//失败的表情
return;
} else if (d.status === 1234) {
layer.msg(d.data, {
icon: 0,
time: 1000
}, function () {
table.reloadData('currentTableId', {
url: '/depositoryRecord/applicant_multi_create',
page: {
curr: 1
},
});
});
return
} else {
layer.msg("申请成功!", {
icon: 6,//成功的表情
time: 1000
}, //1秒关闭(如果不配置,默认是3秒)
function () {
//do something
table.reloadData('currentTableId', {
url: '/depositoryRecord/applicant_multi_create',
page: {
curr: 1
},
});
});
}
}
});
return false;
}
});
table.on('tool(currentTableFilter)', function (obj) {
let data = obj.data;
if (obj.event === 'applicationIn') {
// 入库申请
var req = data;
req.type = "in";
$.ajax({
url: "/depositoryRecord/createMultiApplication",
type: "post",
data: JSON.stringify(req),
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (d) {
layer.close(this.layerIndex);
if (d.status >= 300) {
layer.msg(d.statusInfo.message);//失败的表情
return;
} else {
layer.msg("申请成功!", {
icon: 6,//成功的表情
time: 1000
}, //1秒关闭(如果不配置,默认是3秒)
function () {
//do something
window.location = "/application_multi"
});
}
}
});
return false;
} else if (obj.event === 'applicationOut') {
// 出库申请
var req = data;
req.type = "out";
$.ajax({
url: "/depositoryRecord/createMultiApplication",
type: "post",
data: JSON.stringify(req),
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (d) {
layer.close(this.layerIndex);
if (d.status >= 300) {
layer.msg(d.statusInfo.detail, {
icon: 0,
time: 1000
}, function () {
obj.update({quantity: 1});
});//失败的表情
} else {
layer.msg("申请成功!", {
icon: 6,//成功的表情
time: 1000
}, //1秒关闭(如果不配置,默认是3秒)
function () {
//do something
window.location = "/application_multi"
});
}
}
});
return false;
} else if (obj.event === 'changeUnit') {
let splitInfoList = data.splitInfoList;
let btn = $("#btn_unit_" + data.iid);
let clickNum = Number(btn.attr("click_num"));
if (splitInfoList.length > 0) {
if (clickNum < splitInfoList.length) {
let newUnit = splitInfoList[clickNum].newUnit;
btn.text(newUnit);
clickNum += 1;
btn.attr("click_num", clickNum);
obj.update({unit: newUnit})
} else {
btn.text(data.showUnit);
obj.update({unit: "-1"});
btn.attr("click_num", 0);
}
}
} else if (obj.event === 'selectLocation') {
let btn = $("#btn_placeCode_" + data.iid);
let placeCodes = data.placeCodes;
let clickNum = Number(btn.attr("click_num"));
if (clickNum === 0) {
clickNum += 1;
}
if (placeCodes.length > 1) {
if (clickNum < placeCodes.length) {
let placeCode = placeCodes[clickNum];
clickNum += 1;
btn.attr("click_num", clickNum);
btn.text(placeCode);
obj.update({placeCode: placeCode})
} else {
btn.text(placeCodes[0]);
obj.update({placeCode: placeCodes[0]});
btn.attr("click_num", 0);
}
}
}
});
// 用于判断当前数量是否合法
MaterialQuantityIsTrue = function (req, obj) {
let loading2 = layer.open({type: 3, shade: [0.25, '#000'], icon: 2, speed: 0});
$.ajax({
url: "/material/MaterialQuantityIsTrue",
type: "post",
data: JSON.stringify(req),
dataType: 'json',
contentType: "application/json;charset=utf-8",
success: function (res) {
var flag = res.data;
if (!flag) { // 如果当前数目不合适
layer.msg("当前单个仓库中物料数量不足", {icon: 0, time: 500}, function () {
layer.close(loading2);
obj.update({quantity: 1})
},
);
} else {
layer.close(loading2)
}
}
});
};
});
</script>
</body>
</html>