New file |
| | |
| | | |
| | | var initCountVal = 0; |
| | | var matCodeData = []; |
| | | function getCol() { |
| | | var cols = [ |
| | | {fixed: 'left', field: 'count', title: '数量(必填)', align: 'center', edit:'text', width: 120, style:'color: blue;font-weight: bold'} |
| | | ]; |
| | | cols.push.apply(cols, matCols); |
| | | cols.push({fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:80}) |
| | | return cols; |
| | | } |
| | | |
| | | layui.use(['table','laydate', 'form'], function() { |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var layDate = layui.laydate; |
| | | var form = layui.form; |
| | | |
| | | tableIns = table.render({ |
| | | elem: '#chooseData', |
| | | data: [], |
| | | even: true, |
| | | limit: 500, |
| | | cellMinWidth: 50, |
| | | toolbar: '#toolbar', |
| | | cols: [getCol()], |
| | | done: function (res, curr, count) { |
| | | $('td[data-field=count] div').html(initCountVal); |
| | | setMatCodeData(res.data); |
| | | limit(); |
| | | getInBound(); |
| | | } |
| | | }); |
| | | |
| | | // 页面修改 |
| | | table.on('edit(chooseData)', function (obj) { |
| | | updateMatCodeData(obj.data.matNo, Number(obj.value)); |
| | | }); |
| | | |
| | | // 监听头工具栏事件 |
| | | table.on('toolbar(chooseData)', function (obj) { |
| | | var checkStatus = table.checkStatus(obj.config.id); |
| | | var data = checkStatus.data; |
| | | switch(obj.event) { |
| | | case 'comb': |
| | | // 判断是否存在物料 |
| | | if (matCodeData.length === 0) { |
| | | layer.msg("请先添加物料"); |
| | | return; |
| | | } |
| | | // 判断物料数量是否存在异常 |
| | | for (var i=0;i<matCodeData.length;i++){ |
| | | if (isNaN(matCodeData[i].count)) { |
| | | layer.msg("请输入数字"); |
| | | return; |
| | | } |
| | | if (matCodeData[i].count === 0){ |
| | | layer.msg("数量不能为零"); |
| | | return; |
| | | } |
| | | } |
| | | $.ajax({ |
| | | url: baseUrl+"/full/store/put/start", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify({ |
| | | devpNo: Number($('#putSiteSelect').val()), |
| | | list: matCodeData |
| | | }), |
| | | contentType:'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | async: false, |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | layer.msg("入库启动成功,目标库位:" + res.data); |
| | | matCodeData = []; |
| | | tableIns.reload({data: matCodeData,done:function (res) { limit(); getInBound();}}); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | }else { |
| | | layer.msg(res.msg) |
| | | } |
| | | } |
| | | }) |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | // 监听行工具事件 |
| | | table.on('tool(chooseData)', function(obj){ |
| | | var data = obj.data; |
| | | switch (obj.event) { |
| | | case 'remove': |
| | | for (var i = matCodeData.length - 1; i >= 0; i--) { |
| | | if (matCodeData[i].matNo === data.matNo) { |
| | | matCodeData.splice(i, 1); |
| | | } |
| | | } |
| | | tableIns.reload({data: matCodeData,done:function (res) { |
| | | limit(); |
| | | getInBound(); |
| | | // 覆盖render方法的done |
| | | }}); |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | function setMatCodeData(data) { |
| | | matCodeData = data; |
| | | for (var i=0;i<matCodeData.length;i++){ |
| | | matCodeData[i]["count"] = initCountVal; |
| | | } |
| | | } |
| | | |
| | | function updateMatCodeData(matNo, count) { |
| | | if (isNaN(count)) { |
| | | layer.msg("请输入数字"); |
| | | } else { |
| | | if (count > 0) { |
| | | for (var i=0;i<matCodeData.length;i++){ |
| | | if (matCodeData[i]["matNo"] === matNo){ |
| | | matCodeData[i]["count"] = count; |
| | | } |
| | | } |
| | | } else { |
| | | layer.msg("数量必须大于零"); |
| | | } |
| | | } |
| | | |
| | | tableIns.reload({data: matCodeData,done:function (res) { |
| | | limit(); |
| | | getInBound(); |
| | | // 覆盖render方法的done |
| | | }}); |
| | | } |
| | | |
| | | // 获取可用入库站点 |
| | | function getInBound() { |
| | | $.ajax({ |
| | | url: baseUrl + "/available/put/site", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200) { |
| | | var tpl = $("#putSiteSelectTemplate").html(); |
| | | var template = Handlebars.compile(tpl); |
| | | var html = template(res); |
| | | $('#putSiteSelect').append(html); |
| | | form.render('select'); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | |
| | | }); |
| | | |
| | | // 提取物料 |
| | | var matCodeLayerIdx; |
| | | function getMat() { |
| | | matCodeLayerIdx = layer.open({ |
| | | type: 2, |
| | | title: '提取物料', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: true, |
| | | content: 'matQuery.html', |
| | | success: function(layero, index){ |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 添加表格数据 |
| | | function addTableData(data) { |
| | | for (var i=0;i<data.length;i++){ |
| | | let pass = false; |
| | | for (var j=0;j<matCodeData.length;j++){ |
| | | if (data[i].matNo === matCodeData[j].matNo) { |
| | | pass = true; |
| | | break; |
| | | } |
| | | } |
| | | if (pass) { |
| | | data.splice(i--, 1); |
| | | } else { |
| | | data[i]["count"] = initCountVal; |
| | | } |
| | | } |
| | | matCodeData.push.apply(matCodeData, data); |
| | | tableIns.reload({data: matCodeData}); |
| | | layer.close(matCodeLayerIdx); |
| | | } |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html lang="en"> |
| | | <head> |
| | | <meta charset="utf-8"> |
| | | <title></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/layui/css/layui.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/cool.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/common.css" media="all"> |
| | | <style> |
| | | body { |
| | | padding: 0 20px; |
| | | } |
| | | .layui-table-box { |
| | | border-right: 1px solid #9F9F9F; |
| | | border-left: 1px solid #9F9F9F; |
| | | } |
| | | </style> |
| | | </head> |
| | | <body> |
| | | |
| | | <!-- 搜索栏 --> |
| | | <fieldset class="layui-elem-field site-demo-button" style="margin: 20px;"> |
| | | <legend>搜索栏</legend> |
| | | <div id="search-box" class="layui-form layui-card-header"> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline"> |
| | | <input class="layui-input" type="text" name="mat_no" placeholder="物料编码" autocomplete="off"> |
| | | </div> |
| | | </div> |
| | | <!-- 日期范围 --> |
| | | <div class="layui-inline" style="width: 300px"> |
| | | <div class="layui-input-inline"> |
| | | <input class="layui-input layui-laydate-range" name="modi_time" type="text" placeholder="起始时间 - 终止时间" autocomplete="off" style="width: 300px"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline"> |
| | | <input class="layui-input" type="text" name="str2" placeholder="物料类别" autocomplete="off"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline"> |
| | | <input class="layui-input" type="text" name="str3" placeholder="规格型号" autocomplete="off"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline"> |
| | | <input class="layui-input" type="text" name="condition" placeholder="请输入" autocomplete="off"> |
| | | </div> |
| | | </div> |
| | | <!-- 待添加 --> |
| | | <div id="data-search-btn" class="layui-btn-container layui-form-item" style="display: inline-block"> |
| | | <button id="search" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="search">搜索</button> |
| | | <button id="reset" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="reset">重置</button> |
| | | </div> |
| | | </div> |
| | | </fieldset> |
| | | |
| | | <script type="text/html" id="toolbar"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn" id="btn-confirm" lay-event="confirm" style="">提取</button> |
| | | </div> |
| | | </script> |
| | | |
| | | <div class="layui-form"> |
| | | <table class="layui-hide" id="matCode" lay-filter="matCode"></table> |
| | | </div> |
| | | |
| | | <script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script> |
| | | <script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/handlebars/handlebars-v4.5.3.js"></script> |
| | | |
| | | </body> |
| | | <script> |
| | | function getCol() { |
| | | var cols = [ |
| | | {type: 'checkbox', fixed: 'left'} |
| | | ]; |
| | | cols.push.apply(cols, matCols); |
| | | cols.push( |
| | | {field: 'modiUser$', align: 'center',title: '修改人员', hide: true}, |
| | | {field: 'modiTime$', align: 'center',title: '修改时间'} |
| | | ) |
| | | return cols; |
| | | } |
| | | var pageCurr; |
| | | layui.use(['table','laydate', 'form'], function() { |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var layDate = layui.laydate; |
| | | var form = layui.form; |
| | | // 物料查询数据表 |
| | | matQueryTable = table.render({ |
| | | elem: '#matCode', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | url: baseUrl + '/mat/list/auth', |
| | | page: true, |
| | | limit: 7, |
| | | limits: [7, 10, 30,50,100], |
| | | even: true, |
| | | cellMinWidth: 50, |
| | | toolbar: '#toolbar', |
| | | cols: [getCol()], |
| | | request: { |
| | | pageName: 'curr', |
| | | pageSize: 'limit' |
| | | }, |
| | | parseData: function (res) { |
| | | return { |
| | | 'code': res.code, |
| | | 'msg': res.msg, |
| | | 'count': res.data.total, |
| | | 'data': res.data.records |
| | | } |
| | | }, |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | done: function (res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } |
| | | } |
| | | }); |
| | | |
| | | // 监听头工具栏事件 |
| | | table.on('toolbar(matCode)', function (obj) { |
| | | var checkStatus = table.checkStatus(obj.config.id); |
| | | var data = checkStatus.data; |
| | | switch(obj.event) { |
| | | case 'confirm': |
| | | if (data.length === 0){ |
| | | layer.msg("请选择数据"); |
| | | return; |
| | | } |
| | | parent.addTableData(data); |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | // 搜索栏搜索事件 |
| | | form.on('submit(search)', function (data) { |
| | | pageCurr = 1; |
| | | tableReload(false); |
| | | }); |
| | | |
| | | // 搜索栏重置事件 |
| | | form.on('submit(reset)', function (data) { |
| | | pageCurr = 1; |
| | | clearFormVal($('#search-box')); |
| | | tableReload(); |
| | | }); |
| | | |
| | | layDate.render({ |
| | | elem: '.layui-laydate-range' |
| | | ,type: 'datetime' |
| | | ,range: true |
| | | }); |
| | | }) |
| | | |
| | | function tableReload(child) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | matQueryTable.reload({ |
| | | where: searchData, |
| | | page: { |
| | | curr: pageCurr |
| | | }, |
| | | done: function (res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | if (res.data.length === 0 && count !== 0) { |
| | | tableIns.reload({ |
| | | where: searchData, |
| | | page: { |
| | | curr: pageCurr-1 |
| | | } |
| | | }); |
| | | pageCurr -= 1; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function clearFormVal(el) { |
| | | $(':input', el) |
| | | .val('') |
| | | .removeAttr('checked') |
| | | .removeAttr('selected'); |
| | | } |
| | | </script> |
| | | </html> |
| | | |
| | |
| | | font-size: 13px; |
| | | } |
| | | |
| | | #btn-comb { |
| | | margin-left: 60px; |
| | | #btn-inbound { |
| | | margin-left: 20px; |
| | | display: none; |
| | | } |
| | | </style> |
| | |
| | | <script type="text/html" id="toolbar"> |
| | | <div class="layui-form"> |
| | | <div class="layui-btn-container"> |
| | | <!-- 1.选择入库口 --> |
| | | <span id="staNoSpan">入库口:</span> |
| | | <select id="putSiteSelect" lay-verify="required"> |
| | | <option value="">请选择站点</option> |
| | | </select> |
| | | <!-- 2.启动出库 --> |
| | | <button class="layui-btn layui-btn-normal layui-btn-lg" id="btn-comb" lay-event="comb" style="">启动入库</button> |
| | | <!-- 启动出库 --> |
| | | <button class="layui-btn layui-btn-lg" id="btn-inbound" lay-event="comb" style="">确认入库</button> |
| | | </div> |
| | | </div> |
| | | </script> |
| | |
| | | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/handlebars/handlebars-v4.5.3.js"></script> |
| | | <script type="text/javascript" src="../../static/js/pakStore/pakStore.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/ioWorks/stockIn.js" charset="utf-8"></script> |
| | | |
| | | <script type="text/template" id="putSiteSelectTemplate"> |
| | | {{#each data}} |
| | |
| | | <!-- <option value="">请选择站点</option>--> |
| | | <!-- </select>--> |
| | | <!-- 2.启动出库 --> |
| | | <button class="layui-btn layui-btn-lg" id="btn-outbound" lay-event="outbound">启动出库</button> |
| | | <button class="layui-btn layui-btn-lg layui-btn-normal" id="btn-outbound" lay-event="outbound">确认出库</button> |
| | | </div> |
| | | </div> |
| | | </script> |