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.
260 lines
11 KiB
260 lines
11 KiB
|
3 years ago
|
<!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">
|
||
|
|
|
||
|
|
<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="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-xs data-count-edit" lay-event="applicationOut" >出库</a>
|
||
|
|
</script>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<script src="/static/lib/layui-v2.6.3/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: '/group/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
|
||
|
|
},
|
||
|
|
toolbar: '#toolbarDemo',
|
||
|
|
cols: [
|
||
|
|
[
|
||
|
|
{type: "checkbox", width: 50},
|
||
|
|
{field: 'gname', width: 150, title: '组合名称'},
|
||
|
|
{field: 'code', width: 150, title: '组合编码'},
|
||
|
|
{title: '拥有物料', width: 700, align: "center"},
|
||
|
|
{field: 'quantity', width: 200, title: '数量',edit:'quantity'},
|
||
|
|
{title: '操作', minWidth: 200, toolbar: '#currentTableBar', align: "center"},
|
||
|
|
]
|
||
|
|
],
|
||
|
|
limits: [10, 15, 20, 25, 50,100],
|
||
|
|
limit: 10,
|
||
|
|
page: true,
|
||
|
|
skin: 'line',
|
||
|
|
done: function (res, curr, count) {
|
||
|
|
$.each(res['data'], function (i, j) {
|
||
|
|
let materialSimple = j["materialSimple"];
|
||
|
|
let gid = j["id"];
|
||
|
|
let keys = Object.keys(materialSimple);
|
||
|
|
var materialItem = $("[lay-id='currentTableId'] tr:eq(" + (i+1) + ")").children()[3];
|
||
|
|
var aItem = materialItem.childNodes[0];
|
||
|
|
for (let k = 0; k < keys.length; k++) {
|
||
|
|
$(aItem).append('<button id='+ gid+' class="layui-btn layui-btn-primary layui-btn-xs" value='+materialSimple[keys[k]]+'>'+keys[k]+'</button>')
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
//监听表格复选框选择
|
||
|
|
table.on('checkbox(currentTableFilter)', function (obj) {
|
||
|
|
console.log(obj)
|
||
|
|
});
|
||
|
|
|
||
|
|
table.on('edit(currentTableFilter)', function(obj){ //注:edit是固定事件名,test是table原始容器的属性 lay-filter="对应的值"
|
||
|
|
|
||
|
|
var req = {};
|
||
|
|
req.gid = obj.data.id;
|
||
|
|
req.quantity = obj.data.quantity;
|
||
|
|
$.ajax({
|
||
|
|
url: "/group/groupQuantityIsTrue",
|
||
|
|
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 () {
|
||
|
|
obj.update({quantity:1})
|
||
|
|
});
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
/**
|
||
|
|
* toolbar监听事件
|
||
|
|
*/
|
||
|
|
table.on('toolbar(currentTableFilter)', function (obj) {
|
||
|
|
|
||
|
|
var checkStatus = table.checkStatus('currentTableId')
|
||
|
|
, data = checkStatus.data;
|
||
|
|
var req = {};
|
||
|
|
req.quantitys = [];
|
||
|
|
req.gids = [];
|
||
|
|
for (i = 0, len = data.length; i < len; i++) {
|
||
|
|
req.quantitys[i] = data[i].quantity;
|
||
|
|
req.gids[i] = data[i].id;
|
||
|
|
}
|
||
|
|
|
||
|
|
if(obj.event==='delete'){
|
||
|
|
if(req.gids.length > 0) {
|
||
|
|
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) {
|
||
|
|
$.ajax({
|
||
|
|
url: "/group/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
|
||
|
|
table.reload('currentTableId', {
|
||
|
|
url: '/group/applicant_multi_create',
|
||
|
|
page: {
|
||
|
|
curr: 1
|
||
|
|
}
|
||
|
|
}, 'data');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|
||
|
|
})
|
||
|
|
}else{
|
||
|
|
layer.msg("未选中记录,请确认!");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if(obj.event === 'applicationOut'){
|
||
|
|
req.type = "more";
|
||
|
|
$.ajax({
|
||
|
|
url:"/group/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,{
|
||
|
|
icon:0,
|
||
|
|
time:1000
|
||
|
|
});//失败的表情
|
||
|
|
return;
|
||
|
|
}else if(d.status === 1234){
|
||
|
|
layer.msg(d.data,{
|
||
|
|
icon:0,
|
||
|
|
time:1000
|
||
|
|
})
|
||
|
|
return
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
layer.msg("申请成功!", {
|
||
|
|
icon: 6,//成功的表情
|
||
|
|
time: 1000
|
||
|
|
}, //1秒关闭(如果不配置,默认是3秒)
|
||
|
|
function(){
|
||
|
|
//do something
|
||
|
|
table.reload('currentTableId', {
|
||
|
|
url: '/group/applicant_multi_create',
|
||
|
|
page: {
|
||
|
|
curr: 1
|
||
|
|
}
|
||
|
|
}, 'data');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
table.on('tool(currentTableFilter)', function (obj) {
|
||
|
|
let data = obj.data;
|
||
|
|
if(obj.event === 'applicationOut'){
|
||
|
|
// 出库申请
|
||
|
|
var req = data;
|
||
|
|
req.type = "one";
|
||
|
|
$.ajax({
|
||
|
|
url:"/group/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,{
|
||
|
|
icon:0,
|
||
|
|
time:1000
|
||
|
|
});//失败的表情
|
||
|
|
return;
|
||
|
|
} else {
|
||
|
|
layer.msg("申请成功!", {
|
||
|
|
icon: 6,//成功的表情
|
||
|
|
time: 1000
|
||
|
|
}, //1秒关闭(如果不配置,默认是3秒)
|
||
|
|
function(){
|
||
|
|
//do something
|
||
|
|
table.reload('currentTableId', {
|
||
|
|
url: '/group/applicant_multi_create',
|
||
|
|
page: {
|
||
|
|
curr: 1
|
||
|
|
}
|
||
|
|
}, 'data');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
});
|
||
|
|
});
|
||
|
|
</script>
|
||
|
|
|
||
|
|
</body>
|
||
|
|
</html>
|