| | |
| | | var pageCurr; |
| | | var printMatCodeNos = []; |
| | | var admin; |
| | | |
| | | function getCol() { |
| | | var cols = [ |
| | | {type: 'checkbox'} |
| | | ,{field: 'tagId$', align: 'center',title: '归类', templet: '#tagTpl'} |
| | | ,{field: 'locType$', align: 'center',title: '库位类型'} |
| | | , {field: 'tagId$', align: 'center', title: '归类', templet: '#tagTpl'} |
| | | , {field: 'locType$', align: 'center', title: '库位类型'} |
| | | // ,{field: 'store_max', align: 'center',title: '库存上限'} |
| | | // ,{field: 'store_min', align: 'center',title: '库存下限'} |
| | | // ,{field: 'store_max_date', align: 'center',title: '库龄上限(天)'} |
| | | ]; |
| | | cols.push.apply(cols, matCols); |
| | | cols.push( |
| | | {fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:150} |
| | | {fixed: 'right', title: '操作', align: 'center', toolbar: '#operate', width: 150} |
| | | ) |
| | | return cols; |
| | | } |
| | |
| | | base: baseUrl + "/static/layui/lay/modules/" |
| | | }).extend({ |
| | | dropdown: 'dropdown/dropdown', |
| | | }).use(['table','laydate', 'form', 'treeTable', 'admin', 'xmSelect', 'dropdown', 'element'], function(){ |
| | | }).use(['table', 'laydate', 'form', 'treeTable', 'admin', 'xmSelect', 'dropdown', 'element'], function () { |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | |
| | | // 商品分类数据 |
| | | var insTb = treeTable.render({ |
| | | elem: '#tag', |
| | | url: baseUrl+'/tag/list/auth', |
| | | url: baseUrl + '/tag/list/auth', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | tree: { |
| | | iconIndex: 2, // 折叠图标显示在第几列 |
| | |
| | | tableIns = table.render({ |
| | | elem: '#mat', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | url: baseUrl+'/mat/list/auth', |
| | | url: baseUrl + '/mat/list/auth', |
| | | page: true, |
| | | limit: 16, |
| | | limits: [16, 30, 50, 100, 200, 500], |
| | |
| | | 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 + "/"; |
| | | } |
| | | pageCurr=curr; |
| | | pageCurr = curr; |
| | | limit(); |
| | | form.on('checkbox(tableCheckbox)', function (data) { |
| | | var _index = $(data.elem).attr('table-index')||0; |
| | | if(data.elem.checked){ |
| | | var _index = $(data.elem).attr('table-index') || 0; |
| | | if (data.elem.checked) { |
| | | res.data[_index][data.value] = 'Y'; |
| | | }else{ |
| | | } else { |
| | | res.data[_index][data.value] = 'N'; |
| | | } |
| | | }); |
| | |
| | | // 监听排序事件 |
| | | table.on('sort(locMast)', function (obj) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | $.each($('#search-box [name]').serializeArray(), function () { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | searchData['orderByField'] = obj.field; |
| | |
| | | }, |
| | | done: function (res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | top.location.href = baseUrl + "/"; |
| | | } |
| | | pageCurr=curr; |
| | | pageCurr = curr; |
| | | limit(); |
| | | } |
| | | }); |
| | |
| | | // 监听头工具栏事件 |
| | | table.on('toolbar(mat)', function (obj) { |
| | | var checkStatus = table.checkStatus(obj.config.id); |
| | | switch(obj.event) { |
| | | switch (obj.event) { |
| | | case 'addData': |
| | | showEditModel() |
| | | break; |
| | | case 'deleteData': |
| | | var data = checkStatus.data; |
| | | if (data.length === 0){ |
| | | if (data.length === 0) { |
| | | layer.msg('请选择数据'); |
| | | } else { |
| | | layer.confirm('确定删除'+(data.length===1?'此':data.length)+'条数据吗', function(){ |
| | | layer.confirm('确定删除' + (data.length === 1 ? '此' : data.length) + '条数据吗', function () { |
| | | $.ajax({ |
| | | url: baseUrl+"/mat/delete/auth", |
| | | url: baseUrl + "/mat/delete/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: {param: JSON.stringify(data)}, |
| | | method: 'POST', |
| | | traditional:true, |
| | | traditional: true, |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | if (res.code === 200) { |
| | | layer.closeAll(); |
| | | tableReload(false); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | } |
| | |
| | | } |
| | | break; |
| | | case 'exportData': |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | var titles=[]; |
| | | var fields=[]; |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function () { |
| | | var titles = []; |
| | | var fields = []; |
| | | obj.config.cols[0].map(function (col) { |
| | | if (col.type === 'normal' && col.hide === false && col.toolbar == null) { |
| | | titles.push(col.title); |
| | |
| | | } |
| | | }); |
| | | var exportData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | $.each($('#search-box [name]').serializeArray(), function () { |
| | | exportData[this.name] = this.value; |
| | | }); |
| | | var param = { |
| | |
| | | 'fields': fields |
| | | }; |
| | | $.ajax({ |
| | | url: baseUrl+"/mat/export/auth", |
| | | url: baseUrl + "/mat/export/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify(param), |
| | | dataType:'json', |
| | | contentType:'application/json;charset=UTF-8', |
| | | dataType: 'json', |
| | | contentType: 'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.closeAll(); |
| | | if (res.code === 200) { |
| | | table.exportFile(titles,res.data,'xls'); |
| | | table.exportFile(titles, res.data, 'xls'); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | } |
| | |
| | | case "btnPrintBatch": |
| | | printMatCodeNos = []; |
| | | var data = checkStatus.data; |
| | | if (data.length === 0){ |
| | | if (data.length === 0) { |
| | | layer.msg('请选择打印数据'); |
| | | } else { |
| | | layer.open({ |
| | | type: 1, |
| | | title: '批量打印 [数量'+ data.length +']', |
| | | title: '批量打印 [数量' + data.length + ']', |
| | | area: ['500px'], |
| | | shadeClose: true, |
| | | content: $('#printDataDiv'), |
| | | success: function(layero, index){ |
| | | for (var i = 0; i<data.length;i++) { |
| | | success: function (layero, index) { |
| | | for (var i = 0; i < data.length; i++) { |
| | | printMatCodeNos.push(data[i].matnr); |
| | | } |
| | | }, |
| | |
| | | }); |
| | | } |
| | | break; |
| | | case "batchModifties": |
| | | var selected = checkStatus.data; |
| | | if (selected.length === 0) { |
| | | layer.msg('请选择修改数据'); |
| | | } else { |
| | | let selIds = selected.map(item => { |
| | | return item.id |
| | | }); |
| | | layer.open({ |
| | | type: 1, |
| | | title: '批量修改', |
| | | area: ['500px'], |
| | | shadeClose: true, |
| | | content: $('#batchModifties'), |
| | | success: function (layero, index) { |
| | | layer.iframeAuto(index); |
| | | form.on('submit(batchModify)', function (data) { |
| | | let params = {...data?.field} |
| | | params.id = selIds |
| | | $.ajax({ |
| | | url: baseUrl + "/mat/batch/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify(params), |
| | | dataType: 'json', |
| | | contentType: 'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.closeAll(); |
| | | if (res.code === 200) { |
| | | |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | } |
| | | } |
| | | }); |
| | | layer.closeAll(); |
| | | }); |
| | | }, |
| | | end: function () { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | // 监听行工具事件 |
| | | table.on('tool(mat)', function(obj){ |
| | | table.on('tool(mat)', function (obj) { |
| | | var data = obj.data; |
| | | switch (obj.event) { |
| | | // 打印 |
| | |
| | | area: ['500px'], |
| | | shadeClose: true, |
| | | content: $('#printDataDiv'), |
| | | success: function(layero, index){ |
| | | success: function (layero, index) { |
| | | layer.iframeAuto(index); |
| | | printMatCodeNos.push(data.matnr); |
| | | }, |
| | |
| | | } |
| | | // 表单提交事件 |
| | | form.on('submit(editSubmit)', function (data) { |
| | | console.log(data) |
| | | data.field.tagId = insXmSel.getValue('valueStr'); |
| | | if (isEmpty(data.field.tagId)) { |
| | | layer.msg('分类不能为空', {icon: 2}); |
| | |
| | | } |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/mat/"+(mData?'update':'add')+"/auth", |
| | | url: baseUrl + "/mat/" + (mData ? 'update' : 'add') + "/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: data.field, |
| | | 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}); |
| | | $(".layui-laypage-btn")[0].click(); |
| | | } 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}); |
| | | } |
| | | } |
| | |
| | | // 模板选择 |
| | | form.on('radio(selectTemplateRadio)', function (data) { |
| | | $('.template-preview').hide(); |
| | | $('#template-preview-'+data.value).show(); |
| | | $('#template-preview-' + data.value).show(); |
| | | }); |
| | | |
| | | // 开始打印 |
| | | form.on('submit(doPrint)', function (data) { |
| | | var templateNo = data.field.selectTemplate; |
| | | $.ajax({ |
| | | url: baseUrl+"/mat/print/auth", |
| | | url: baseUrl + "/mat/print/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: {param: printMatCodeNos}, |
| | | method: 'POST', |
| | | async: false, |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | if (res.code === 200) { |
| | | layer.closeAll(); |
| | | for (let i=0;i<res.data.length;i++){ |
| | | var templateDom = $("#templatePreview"+templateNo); |
| | | for (let i = 0; i < res.data.length; i++) { |
| | | var templateDom = $("#templatePreview" + templateNo); |
| | | var className = templateDom.attr("class"); |
| | | if (className === 'template-barcode') { |
| | | res.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=1¶m="+res.data[i].matnr; |
| | | res.data[i]["barcodeUrl"] = baseUrl + "/mac/code/auth?type=1¶m=" + res.data[i].matnr; |
| | | } else { |
| | | res.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=2¶m="+res.data[i].matnr; |
| | | res.data[i]["barcodeUrl"] = baseUrl + "/mac/code/auth?type=2¶m=" + res.data[i].matnr; |
| | | } |
| | | } |
| | | var tpl = templateDom.html(); |
| | | var template = Handlebars.compile(tpl); |
| | | var html = template(res); |
| | | var box = $("#box"); |
| | | box.html(html);box.show(); |
| | | box.print({mediaPrint:true}); |
| | | box.html(html); |
| | | box.show(); |
| | | box.print({mediaPrint: true}); |
| | | box.hide(); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | }else { |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | } |
| | | } |
| | |
| | | }); |
| | | |
| | | // excel导入模板下载 |
| | | function excelMouldDownload(){ |
| | | layer.load(1, {shade: [0.1,'#fff']}); |
| | | function excelMouldDownload() { |
| | | layer.load(1, {shade: [0.1, '#fff']}); |
| | | location.href = baseUrl + "/mat/excel/import/mould"; |
| | | layer.closeAll('loading'); |
| | | } |
| | |
| | | function importExcel() { |
| | | $("#importExcel").trigger("click"); |
| | | } |
| | | function upload(obj){ |
| | | if(!obj.files) { |
| | | |
| | | 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']}); |
| | | admin.confirm('确认同步 [' + file.name + '] 文件吗?', function (index) { |
| | | layer.load(1, {shade: [0.1, '#fff']}); |
| | | var url = baseUrl + "/mat/excel/import/auth"; |
| | | var form = new FormData(); |
| | | form.append("file", file); |
| | |
| | | xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。 |
| | | xhr.setRequestHeader('token', localStorage.getItem('token')); |
| | | xhr.onload = uploadComplete; //请求完成 |
| | | xhr.onerror = uploadFailed; //请求失败 |
| | | xhr.onerror = uploadFailed; //请求失败 |
| | | xhr.onloadend = function () { // // 上传完成重置文件流 |
| | | layer.closeAll('loading'); |
| | | $("#importExcel").val(""); |
| | | }; |
| | | // xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】 |
| | | xhr.upload.onloadstart = function(){//上传开始执行方法 |
| | | xhr.upload.onloadstart = function () {//上传开始执行方法 |
| | | ot = new Date().getTime(); //设置上传开始时间 |
| | | oloaded = 0;//设置上传开始时,以上传的文件大小为0 |
| | | }; |
| | | xhr.send(form); |
| | | }, function(index){ |
| | | }, function (index) { |
| | | $("#importExcel").val(""); |
| | | }); |
| | | } |
| | | |
| | | function uploadComplete(evt) { |
| | | var res = JSON.parse(evt.target.responseText); |
| | | if(res.code === 200) { |
| | | 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}); |
| | |
| | | |
| | | function tableReload(child) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | $.each($('#search-box [name]').serializeArray(), function () { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | (child ? parent.tableIns : tableIns).reload({ |
| | |
| | | }, |
| | | done: function (res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | top.location.href = baseUrl + "/"; |
| | | } |
| | | pageCurr=curr; |
| | | pageCurr = curr; |
| | | if (res.data.length === 0 && count !== 0) { |
| | | tableIns.reload({ |
| | | where: searchData, |
| | | page: { |
| | | curr: pageCurr-1 |
| | | curr: pageCurr - 1 |
| | | } |
| | | }); |
| | | pageCurr -= 1; |