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.
282 lines
11 KiB
282 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">
|
||
|
|
|
||
|
|
<!-- 状态展示-->
|
||
|
|
<input th:value="${mid}" style="display: none" id="mid">
|
||
|
|
<input style="display: none" id="barCodeList">
|
||
|
|
<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"> 删除</button>
|
||
|
|
</div>
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
|
||
|
|
|
||
|
|
<script type="text/html" id="currentTableBar">
|
||
|
|
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
|
||
|
|
</script>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
|
||
|
|
<script>
|
||
|
|
|
||
|
|
var barCode = [];
|
||
|
|
function notice(){
|
||
|
|
|
||
|
|
};
|
||
|
|
function addBarCodeByMid(){
|
||
|
|
|
||
|
|
};
|
||
|
|
|
||
|
|
layui.use(['form', 'table','upload'], function () {
|
||
|
|
var $ = layui.jquery,
|
||
|
|
form = layui.form,
|
||
|
|
table = layui.table,
|
||
|
|
upload = layui.upload;
|
||
|
|
|
||
|
|
var mid = $("#mid").val();
|
||
|
|
table.render({
|
||
|
|
elem: "#currentTableId",
|
||
|
|
url: '/material/findMaterialBarCode',
|
||
|
|
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: {
|
||
|
|
mid:mid
|
||
|
|
},
|
||
|
|
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: 'id',width:50,title:'id'},
|
||
|
|
{field: 'mcode',width: 150,title: '存货编码',sort: true},
|
||
|
|
{field: 'bmcode',width: 150,title: '条形码',sort: true},
|
||
|
|
{field: 'mname', width: 120, title: '物料名称', sort: false},
|
||
|
|
{field: 'version',width: 200,title: '规格型号',sort: false},
|
||
|
|
{field: 'texture',width: 100,title: '材质'},
|
||
|
|
{field: 'unit',width: 150,title: '计量单位'},
|
||
|
|
{title: '操作', minWidth: 200, toolbar: '#currentTableBar', align: "center"}
|
||
|
|
]],
|
||
|
|
limits: [10, 15, 20, 25, 50],
|
||
|
|
limit: 10,
|
||
|
|
page: true,
|
||
|
|
skin: 'line',
|
||
|
|
done:function () {
|
||
|
|
$("[data-field='id']").css('display','none');
|
||
|
|
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
//监听表格复选框选择
|
||
|
|
table.on('checkbox(currentTableFilter)', function (obj) {
|
||
|
|
console.log(obj)
|
||
|
|
});
|
||
|
|
|
||
|
|
// 用于添加关联
|
||
|
|
addBarCodeByMid = function(){
|
||
|
|
var mid = $("#mid").val();
|
||
|
|
var req = {};
|
||
|
|
req.mid = mid;
|
||
|
|
req.barCodeList = barCode ;
|
||
|
|
$.ajax({
|
||
|
|
url:"/material/addBarCodeByMaterial",
|
||
|
|
type:"post",
|
||
|
|
data:JSON.stringify(req),
|
||
|
|
dataType:"json",
|
||
|
|
contentType: "application/json;charset=utf-8",
|
||
|
|
success:function (d) {
|
||
|
|
table.reload('currentTableId', {
|
||
|
|
url: '/material/findMaterialBarCode',
|
||
|
|
page: {
|
||
|
|
curr: 1
|
||
|
|
},
|
||
|
|
where:{"mid":mid}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
})
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
notice = function(obj){
|
||
|
|
//用于弹出扫码的结果
|
||
|
|
var context = "<div style='padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;'><ul>";
|
||
|
|
for (let i = 0; i < obj.length; i++) {
|
||
|
|
context += "<li>"+obj[i]+"</li>";
|
||
|
|
}
|
||
|
|
context += "</ul></div>";
|
||
|
|
layer.open({
|
||
|
|
type: 1
|
||
|
|
,title: false //不显示标题栏
|
||
|
|
,closeBtn: false
|
||
|
|
,area: '300px;'
|
||
|
|
,shade: 0.8
|
||
|
|
,id: 'LAY_layuipro' //设定一个id,防止重复弹出
|
||
|
|
,btn: ['确定', '取消']
|
||
|
|
,btnAlign: 'c'
|
||
|
|
,moveType: 1 //拖拽模式,0或者1
|
||
|
|
,content: context
|
||
|
|
,success: function(layero){
|
||
|
|
var btn = layero.find('.layui-layer-btn');
|
||
|
|
btn.find('.layui-layer-btn0').attr({
|
||
|
|
onclick:"addBarCodeByMid()"
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* toolbar监听事件
|
||
|
|
*/
|
||
|
|
table.on('toolbar(currentTableFilter)', function (obj) {
|
||
|
|
if (obj.event === 'add') { // 监听添加操作
|
||
|
|
layer.open({
|
||
|
|
type: 2,
|
||
|
|
title: '扫码',
|
||
|
|
skin: 'layui-layer-rim',
|
||
|
|
maxmin: true,
|
||
|
|
shadeClose: true, //点击遮罩关闭层
|
||
|
|
area: ['100%', '100%'],
|
||
|
|
move: '.layui-layer-title',
|
||
|
|
fixed: false,
|
||
|
|
content: '/scanBarCodeByNew',
|
||
|
|
end: function () {
|
||
|
|
var barCodeList = $("#barCodeList").val();
|
||
|
|
// 根据&符合分割字符串并删除空
|
||
|
|
var strings = barCodeList.split(",");
|
||
|
|
strings = strings.filter(item => item && item.trim());
|
||
|
|
barCode = strings;
|
||
|
|
notice(strings);
|
||
|
|
table.reload('currentTableId', {
|
||
|
|
url: '/material/findMaterialBarCode',
|
||
|
|
page: {
|
||
|
|
curr: 1
|
||
|
|
},
|
||
|
|
where:{"mid":mid}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
$(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/delBarCodeByMaterial',
|
||
|
|
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.reload('currentTableId', {
|
||
|
|
url: '/material/findMaterialBarCode',
|
||
|
|
page: {
|
||
|
|
curr: 1
|
||
|
|
},
|
||
|
|
where:{"mid":mid}
|
||
|
|
});
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|
||
|
|
})
|
||
|
|
}else{
|
||
|
|
layer.msg("未选中记录,请确认!");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|
||
|
|
|
||
|
|
table.on('tool(currentTableFilter)', function (obj) {
|
||
|
|
let data = obj.data;
|
||
|
|
|
||
|
|
if (obj.event === 'delete') {
|
||
|
|
var req={};
|
||
|
|
req.id=data.id;
|
||
|
|
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) {
|
||
|
|
$.ajax({
|
||
|
|
url: '/material/delBarCodeByMaterial',
|
||
|
|
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秒)
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
});
|
||
|
|
</script>
|
||
|
|
|
||
|
|
</body>
|
||
|
|
</html>
|