|  |  |  | 
|---|
|  |  |  | <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/admin.css?v=318" 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; | 
|---|
|  |  |  | /*overflow: hidden;*/ | 
|---|
|  |  |  | } | 
|---|
|  |  |  | .layui-table-box { | 
|---|
|  |  |  | border-right: 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"> | 
|---|
|  |  |  | <label class="layui-form-label">物料编码:</label> | 
|---|
|  |  |  | <div class="layui-input-inline"> | 
|---|
|  |  |  | <input class="layui-input" type="text" name="mat_no" placeholder="请输入" autocomplete="off"> | 
|---|
|  |  |  | <div style="padding: 25px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;"> | 
|---|
|  |  |  | <span style="font-size: large; font-weight: bold">选择商品</span> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <div class="layui-card" style="padding: 0 20px; overflow: scroll;"> | 
|---|
|  |  |  | <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="matnr" placeholder="商品编号" autocomplete="off"> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <div class="layui-inline"> | 
|---|
|  |  |  | <div class="layui-input-inline"> | 
|---|
|  |  |  | <input class="layui-input" type="text" name="maktx" 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="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> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </fieldset> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!-- 待添加 --> | 
|---|
|  |  |  | <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 class="layui-form"> | 
|---|
|  |  |  | <table class="layui-hide" id="mat" lay-filter="mat"></table> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </fieldset> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <script type="text/html" id="toolbar"> | 
|---|
|  |  |  | <div class="layui-btn-container"> | 
|---|
|  |  |  | 
|---|
|  |  |  | </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> | 
|---|
|  |  |  | <script type="text/javascript" src="../../static/js/pakStore/pakStore.js" charset="utf-8"></script> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </body> | 
|---|
|  |  |  | <script> | 
|---|
|  |  |  | var initCountVal = 1; | 
|---|
|  |  |  | var matCodeData = []; | 
|---|
|  |  |  | var pageCurr; | 
|---|
|  |  |  | layui.use(['table','laydate', 'form'], function() { | 
|---|
|  |  |  | function getCol() { | 
|---|
|  |  |  | let 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | layui.config({ | 
|---|
|  |  |  | base: baseUrl + "/static/layui/lay/modules/" | 
|---|
|  |  |  | }).use(['table','laydate', 'form', 'admin'], function() { | 
|---|
|  |  |  | var table = layui.table; | 
|---|
|  |  |  | var $ = layui.jquery; | 
|---|
|  |  |  | var layer = layui.layer; | 
|---|
|  |  |  | var layDate = layui.laydate; | 
|---|
|  |  |  | var form = layui.form; | 
|---|
|  |  |  | var admin = layui.admin; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 物料查询数据表 | 
|---|
|  |  |  | matQueryTable = table.render({ | 
|---|
|  |  |  | elem: '#matCode', | 
|---|
|  |  |  | elem: '#mat', | 
|---|
|  |  |  | headers: {token: localStorage.getItem('token')}, | 
|---|
|  |  |  | url: baseUrl + '/matCode/list/auth', | 
|---|
|  |  |  | url: baseUrl + '/mat/list/auth', | 
|---|
|  |  |  | page: true, | 
|---|
|  |  |  | limit: 7, | 
|---|
|  |  |  | limits: [7, 10, 30,50,100], | 
|---|
|  |  |  | even: true, | 
|---|
|  |  |  | cellMinWidth: 50, | 
|---|
|  |  |  | toolbar: '#toolbar', | 
|---|
|  |  |  | cols: [[ | 
|---|
|  |  |  | {type: 'checkbox', fixed: 'left'}, | 
|---|
|  |  |  | {field: 'matNo', align: 'center', title: '物料编码', sort: 'true'}, | 
|---|
|  |  |  | {field: 'barcode', align: 'center', title: '条码'}, | 
|---|
|  |  |  | {field: 'matName', align: 'center', title: '物料名称'}, | 
|---|
|  |  |  | {field: 'str1', align: 'center', title: '物料单位'}, | 
|---|
|  |  |  | {field: 'str2', align: 'center', title: '物料规格'}, | 
|---|
|  |  |  | {field: 'count', title: '数量', align: 'center', edit:'text', width: 100} | 
|---|
|  |  |  | ]], | 
|---|
|  |  |  | cols: [getCol()], | 
|---|
|  |  |  | request: { | 
|---|
|  |  |  | pageName: 'curr', | 
|---|
|  |  |  | pageSize: 'limit' | 
|---|
|  |  |  | 
|---|
|  |  |  | if (res.code === 403) { | 
|---|
|  |  |  | top.location.href = baseUrl + "/"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | $('td[data-field=count] div').html("1"); | 
|---|
|  |  |  | setMatCodeData(res.data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 页面修改 | 
|---|
|  |  |  | table.on('edit(matCode)', function (obj) { | 
|---|
|  |  |  | updateMatCodeData(obj.data.matNo, Number(obj.value)); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 监听排序事件 | 
|---|
|  |  |  | table.on('sort(matCode)', function (obj) { | 
|---|
|  |  |  | var searchData = {}; | 
|---|
|  |  |  | $.each($('#search-box [name]').serializeArray(), function() { | 
|---|
|  |  |  | searchData[this.name] = this.value; | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | searchData['orderByField'] = obj.field; | 
|---|
|  |  |  | searchData['orderByType'] = obj.type; | 
|---|
|  |  |  | matQueryTable.reload({ | 
|---|
|  |  |  | where: searchData, | 
|---|
|  |  |  | page: { | 
|---|
|  |  |  | curr: 1 | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | done: function (res, curr, count) { | 
|---|
|  |  |  | if (res.code === 403) { | 
|---|
|  |  |  | top.location.href = baseUrl+"/"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | pageCurr=curr; | 
|---|
|  |  |  | limit(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 监听头工具栏事件 | 
|---|
|  |  |  | table.on('toolbar(matCode)', function (obj) { | 
|---|
|  |  |  | var checkStatus = table.checkStatus(obj.config.id); | 
|---|
|  |  |  | table.on('toolbar(mat)', function (obj) { | 
|---|
|  |  |  | let checkStatus = table.checkStatus(obj.config.id); | 
|---|
|  |  |  | let data = checkStatus.data; | 
|---|
|  |  |  | switch(obj.event) { | 
|---|
|  |  |  | case 'confirm': | 
|---|
|  |  |  | parent.layer.close(parent.matCodeLayerIdx); | 
|---|
|  |  |  | console.log(checkStatus); | 
|---|
|  |  |  | if (data.length === 0){ | 
|---|
|  |  |  | layer.msg("请选择数据", {icon: 2}); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | parent.addTableData(data); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 搜索栏搜索事件 | 
|---|
|  |  |  | form.on('submit(search)', function (data) { | 
|---|
|  |  |  | pageCurr = 1; | 
|---|
|  |  |  | tableReload(false); | 
|---|
|  |  |  | tableReload(); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 搜索栏重置事件 | 
|---|
|  |  |  | form.on('submit(reset)', function (data) { | 
|---|
|  |  |  | pageCurr = 1; | 
|---|
|  |  |  | clearFormVal($('#search-box')); | 
|---|
|  |  |  | tableReload(); | 
|---|
|  |  |  | layDate.render({ | 
|---|
|  |  |  | elem: '.layui-laydate-range' | 
|---|
|  |  |  | ,type: 'datetime' | 
|---|
|  |  |  | ,range: true | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function setMatCodeData(data) { | 
|---|
|  |  |  | matCodeData = data; | 
|---|
|  |  |  | for (var i=0;i<matCodeData.length;i++){ | 
|---|
|  |  |  | matCodeData[i]["count"] = initCountVal; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function updateMatCodeData(matNo, count) { | 
|---|
|  |  |  | for (var i=0;i<matCodeData.length;i++){ | 
|---|
|  |  |  | if (matCodeData[i]["matNo"] === matNo){ | 
|---|
|  |  |  | matCodeData[i]["count"] = count; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | console.log(matCodeData); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function tableReload(child) { | 
|---|
|  |  |  | function tableReload() { | 
|---|
|  |  |  | 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+"/"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | $('td[data-field=count] div').html("1"); | 
|---|
|  |  |  | setMatCodeData(res.data); | 
|---|
|  |  |  | pageCurr=curr; | 
|---|
|  |  |  | if (res.data.length === 0 && count !== 0) { | 
|---|
|  |  |  | tableIns.reload({ | 
|---|
|  |  |  | where: searchData, | 
|---|
|  |  |  | page: { | 
|---|
|  |  |  | curr: pageCurr-1 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | pageCurr -= 1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | where: searchData | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function clearFormVal(el) { | 
|---|
|  |  |  | $(':input', el) | 
|---|
|  |  |  | .val('') | 
|---|
|  |  |  | .removeAttr('checked') | 
|---|
|  |  |  | .removeAttr('selected'); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | </script> | 
|---|
|  |  |  | </html> | 
|---|
|  |  |  |  | 
|---|