| | |
| | | var pageCurr; |
| | | var admin; |
| | | layui.config({ |
| | | base: baseUrl + "/static/layui/lay/modules/" |
| | | }).use(['table','laydate', 'form', 'element', 'admin', 'xmSelect'], function(){ |
| | | }).use(['table', 'laydate', 'form', 'element', 'admin', 'xmSelect'], function () { |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var layDate = layui.laydate; |
| | | var form = layui.form; |
| | | var element = layui.element; |
| | | var admin = layui.admin; |
| | | admin = layui.admin; |
| | | var xmSelect = layui.xmSelect; |
| | | |
| | | |
| | | // 数据渲染 |
| | | tableIns = table.render({ |
| | | elem: '#safeSto', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | url: baseUrl+'/safeSto/list/auth', |
| | | url: baseUrl + '/safeSto/list/auth', |
| | | page: true, |
| | | limit: 16, |
| | | limits: [16, 30, 50, 100, 200, 500], |
| | |
| | | cellMinWidth: 50, |
| | | cols: [[ |
| | | {type: 'numbers', fixed: 'left'} |
| | | ,{field: 'locNo$', align: 'center',title: '库位'} |
| | | ,{field: 'matnr', align: 'center',title: '品号'} |
| | | ,{field: 'maktx', align: 'center',title: '名称'} |
| | | ,{field: 'progress', align: 'center',title: '使用情况', templet: '#progressTpl', width: 350} |
| | | ,{field: 'status', align: 'center',title: '警报', templet: '#statusTpl', width: 100} |
| | | ,{field: 'safeQua', align: 'center',title: '安全库存量', style: 'font-weight: bold'} |
| | | ,{field: 'amount', align: 'center',title: '当前库存量', style: 'font-weight: bold; color: #2d8cf0'} |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120} |
| | | , {field: 'locNo$', align: 'center', title: '库位'} |
| | | , {field: 'matnr', align: 'center', title: '品号'} |
| | | , {field: 'maktx', align: 'center', title: '名称'} |
| | | , {field: 'progress', align: 'center', title: '使用情况', templet: '#progressTpl', width: 350} |
| | | , {field: 'status', align: 'center', title: '警报', templet: '#statusTpl', width: 100} |
| | | , {field: 'safeQua', align: 'center', title: '安全库存量', style: 'font-weight: bold'} |
| | | , {field: 'amount', align: 'center', title: '当前库存量', style: 'font-weight: bold; color: #2d8cf0'} |
| | | , {fixed: 'right', title: '操作', align: 'center', toolbar: '#operate', width: 120} |
| | | ]], |
| | | request: { |
| | | pageName: 'curr', |
| | |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | done: function(res, curr, count) { |
| | | done: function (res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | top.location.href = baseUrl + "/"; |
| | | } |
| | | element.render('progress') |
| | | pageCurr=curr; |
| | | pageCurr = curr; |
| | | limit(); |
| | | } |
| | | }); |
| | |
| | | // 监听头工具栏事件 |
| | | table.on('toolbar(safeSto)', function (obj) { |
| | | var checkStatus = table.checkStatus(obj.config.id); |
| | | switch(obj.event) { |
| | | switch (obj.event) { |
| | | case 'add': |
| | | showEditModel(); |
| | | break; |
| | | case 'exportData': |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | window.location.href = baseUrl + '/safeSto/excel/export/auth?token='+localStorage.getItem('token'); |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function () { |
| | | window.location.href = baseUrl + '/safeSto/excel/export/auth?token=' + localStorage.getItem('token'); |
| | | layer.closeAll(); |
| | | }); |
| | | break; |
| | |
| | | }); |
| | | |
| | | // 监听行工具事件 |
| | | table.on('tool(safeSto)', function(obj){ |
| | | table.on('tool(safeSto)', function (obj) { |
| | | var data = obj.data; |
| | | switch (obj.event) { |
| | | // 修改 |
| | |
| | | break; |
| | | // 补仓 |
| | | case 'allot': |
| | | layer.confirm(data.node_name +'补仓 '+ data.matnr + ',数量:' + (data.safe_qua - data.amount), function(){ |
| | | var index = layer.load(1, {shade: [0.1,'#000']}); |
| | | layer.confirm(data.node_name + '补仓 ' + data.matnr + ',数量:' + (data.safe_qua - data.amount), function () { |
| | | var index = layer.load(1, {shade: [0.1, '#000']}); |
| | | $.ajax({ |
| | | url: baseUrl+"/work/stock/transfer", |
| | | url: baseUrl + "/work/stock/transfer", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | contentType:'application/json;charset=UTF-8', |
| | | contentType: 'application/json;charset=UTF-8', |
| | | data: JSON.stringify({ |
| | | node_id: data.node_id, |
| | | matnr: data.matnr, |
| | | safe_qua: data.safe_qua, |
| | | amount: data.amount |
| | | }), |
| | | dataType:'json', |
| | | dataType: 'json', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200) { |
| | | layer.msg(res.msg, {icon: 1}) |
| | | $(".layui-laypage-btn")[0].click(); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}) |
| | | } |
| | |
| | | data.field.matId = matXmSelect.getValue()[0] ? matXmSelect.getValue()[0].value : null; |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/safeSto/"+(mData?'update':'add')+"/auth", |
| | | url: baseUrl + "/safeSto/" + (mData ? 'update' : 'add') + "/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify(data.field), |
| | | contentType:'application/json;charset=UTF-8', |
| | | contentType: 'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | if (res.code === 200) { |
| | | layer.close(dIndex); |
| | | layer.msg(res.msg, {icon: 1}); |
| | | tableReload(); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | }else { |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | |
| | | el: '#locNo', |
| | | radio: true, |
| | | autoRow: true, |
| | | toolbar: { show: true }, |
| | | toolbar: {show: true}, |
| | | filterable: true, |
| | | remoteSearch: true, |
| | | remoteMethod: function(val, cb, show){ |
| | | remoteMethod: function (val, cb, show) { |
| | | //这里如果val为空, 则不触发搜索 |
| | | // if(!val){ |
| | | // return cb([]); |
| | | // } |
| | | $.ajax({ |
| | | url: baseUrl+"/locMast/all/get/kv", |
| | | url: baseUrl + "/locMast/all/get/kv", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: { |
| | | condition: val |
| | | }, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | if (res.code === 200) { |
| | | cb(res.data) |
| | | } else { |
| | | cb([]); |
| | |
| | | el: '#mat', |
| | | radio: true, |
| | | autoRow: true, |
| | | toolbar: { show: true }, |
| | | toolbar: {show: true}, |
| | | filterable: true, |
| | | remoteSearch: true, |
| | | remoteMethod: function(val, cb, show){ |
| | | remoteMethod: function (val, cb, show) { |
| | | //这里如果val为空, 则不触发搜索 |
| | | // if(!val){ |
| | | // return cb([]); |
| | | // } |
| | | $.ajax({ |
| | | url: baseUrl+"/mat/all/get/kv", |
| | | url: baseUrl + "/mat/all/get/kv", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: { |
| | | condition: val |
| | | }, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | if (res.code === 200) { |
| | | cb(res.data) |
| | | } else { |
| | | cb([]); |
| | |
| | | layer.close(i); |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/safeSto/delete/auth", |
| | | url: baseUrl + "/safeSto/delete/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify(params), |
| | | contentType:'application/json;charset=UTF-8', |
| | | contentType: 'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | if (res.code === 200) { |
| | | layer.msg(res.msg, {icon: 1}); |
| | | $(".layui-laypage-btn")[0].click(); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | |
| | | }); |
| | | |
| | | // 关闭动作 |
| | | $(document).on('click','#data-detail-close', function () { |
| | | $(document).on('click', '#data-detail-close', function () { |
| | | parent.layer.closeAll(); |
| | | }); |
| | | |
| | | function tableReload() { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | $.each($('#search-box [name]').serializeArray(), function () { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | tableIns.reload({ |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | $('body').keydown(function () { |
| | | if (event.keyCode === 13) { |
| | | $("#search").click(); |
| | | } |
| | | }); |
| | | |
| | | // excel导入模板下载 |
| | | function downloadData() { |
| | | layer.load(1, {shade: [0.1, '#fff']}); |
| | | location.href = baseUrl + "/safeSto/excel/import/mould"; |
| | | layer.closeAll('loading'); |
| | | } |
| | | |
| | | // excel导入 |
| | | function importData() { |
| | | $("#btn-import").trigger("click"); |
| | | } |
| | | |
| | | function upload(obj) { |
| | | if (!obj.files) { |
| | | return; |
| | | } |
| | | var file = obj.files[0]; |
| | | admin.confirm('确认同步 [' + file.name + '] 文件吗?', function (index) { |
| | | layer.load(1, {shade: [0.1, '#fff']}); |
| | | var url = baseUrl + "/safeSto/excel/import/auth"; |
| | | var form = new FormData(); |
| | | form.append("file", file); |
| | | xhr = new XMLHttpRequest(); |
| | | xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。 |
| | | xhr.setRequestHeader('token', localStorage.getItem('token')); |
| | | xhr.onload = uploadComplete; //请求完成 |
| | | xhr.onerror = uploadFailed; //请求失败 |
| | | xhr.onloadend = function () { // // 上传完成重置文件流 |
| | | layer.closeAll('loading'); |
| | | $("#importExcel").val(""); |
| | | }; |
| | | // xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】 |
| | | xhr.upload.onloadstart = function () {//上传开始执行方法 |
| | | ot = new Date().getTime(); //设置上传开始时间 |
| | | oloaded = 0;//设置上传开始时,以上传的文件大小为0 |
| | | }; |
| | | xhr.send(form); |
| | | }, function (index) { |
| | | $("#btn-import").val(""); |
| | | }); |
| | | } |
| | | |
| | | function uploadComplete(evt) { |
| | | var res = JSON.parse(evt.target.responseText); |
| | | if(res.code === 200) { |
| | | layer.msg(res.msg, {icon: 1}); |
| | | loadTree(""); |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | |
| | | function uploadFailed(evt) { |
| | | var res = JSON.parse(evt.target.responseText); |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |