|  |  |  | 
|---|
|  |  |  | ]; | 
|---|
|  |  |  | cols.push.apply(cols, matCols); | 
|---|
|  |  |  | cols.push( | 
|---|
|  |  |  |  | 
|---|
|  |  |  | {fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:150} | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | return cols; | 
|---|
|  |  |  | 
|---|
|  |  |  | {field: 'parentName', align: 'center',title: '库区', hide: false}, | 
|---|
|  |  |  | {field: 'createBy$', align: 'center',title: '创建人', hide: false}, | 
|---|
|  |  |  | {field: 'createTime$', align: 'center',title: '创建时间', hide: false}, | 
|---|
|  |  |  | // {field: 'status', align: 'center',title: '库位冻结', templet: '#stockFreezeTpl'}, | 
|---|
|  |  |  | {field: 'type$', align: 'center',title: '类型', templet: '#tagTpl', hide: false} | 
|---|
|  |  |  | ]], | 
|---|
|  |  |  | request: { | 
|---|
|  |  |  | 
|---|
|  |  |  | if (res.code === 403) { | 
|---|
|  |  |  | top.location.href = baseUrl+"/"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | tableData = table.cache.mat; | 
|---|
|  |  |  | pageCurr=curr; | 
|---|
|  |  |  | limit(); | 
|---|
|  |  |  | form.on('checkbox(tableCheckbox)', function (data) { | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | // 批量打印 | 
|---|
|  |  |  | case "btnPrintBatch": | 
|---|
|  |  |  | printMatCodeNos = []; | 
|---|
|  |  |  | var data = checkStatus.data; | 
|---|
|  |  |  | if (data.length === 0){ | 
|---|
|  |  |  | layer.msg('请选择打印数据'); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | layer.open({ | 
|---|
|  |  |  | type: 1, | 
|---|
|  |  |  | title: '批量打印 [数量'+ data.length +']', | 
|---|
|  |  |  | area: ['500px'], | 
|---|
|  |  |  | shadeClose: true, | 
|---|
|  |  |  | content: $('#printDataDiv'), | 
|---|
|  |  |  | success: function(layero, index){ | 
|---|
|  |  |  | for (var i = 0; i<data.length;i++) { | 
|---|
|  |  |  | printMatCodeNos.push(data[i].matnr); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | end: function () { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | case "printBatch": | 
|---|
|  |  |  | var checkRows = checkStatus.data; | 
|---|
|  |  |  | printContent = []; | 
|---|
|  |  |  | if (checkRows.length === 0) { | 
|---|
|  |  |  | layer.msg('请选择要打印的数据'); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | printContent = checkRows.map(function (d) { | 
|---|
|  |  |  | if (!d.LAY_INDETERMINATE && d.type === 3) { | 
|---|
|  |  |  | return d.name; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | layer.open({ | 
|---|
|  |  |  | type: 1, | 
|---|
|  |  |  | title: '批量打印 [数量'+ printContent.length +']', | 
|---|
|  |  |  | area: ['500px'], | 
|---|
|  |  |  | shadeClose: true, | 
|---|
|  |  |  | content: $('#printDataDiv'), | 
|---|
|  |  |  | success: function(layero, index){ | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | end: function () { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 模板选择 | 
|---|
|  |  |  | form.on('radio(selectTemplateRadio)', function (data) { | 
|---|
|  |  |  | $('.template-preview').hide(); | 
|---|
|  |  |  | $('#template-preview-'+data.value).show(); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 监听行工具事件 | 
|---|
|  |  |  | 
|---|
|  |  |  | // 开始打印 | 
|---|
|  |  |  | form.on('submit(doPrint)', function (data) { | 
|---|
|  |  |  | var templateNo = data.field.selectTemplate; | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | url: baseUrl+"/node/print/auth", | 
|---|
|  |  |  | headers: {'token': localStorage.getItem('token')}, | 
|---|
|  |  |  | data: {param: printMatCodeNos}, | 
|---|
|  |  |  | method: 'POST', | 
|---|
|  |  |  | async: false, | 
|---|
|  |  |  | success: function (res) { | 
|---|
|  |  |  | if (res.code === 200){ | 
|---|
|  |  |  | layer.closeAll(); | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | 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.hide(); | 
|---|
|  |  |  | } else if (res.code === 403){ | 
|---|
|  |  |  | top.location.href = baseUrl+"/"; | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | layer.msg(res.msg) | 
|---|
|  |  |  | var data = []; | 
|---|
|  |  |  | var type = 1; | 
|---|
|  |  |  | for (var i = 0; i<printContent.length; i ++) { | 
|---|
|  |  |  | if (printContent[i] != null && printContent[i] !== '') { | 
|---|
|  |  |  | var barcodeUrl; | 
|---|
|  |  |  | var templateDom = $("#templatePreview"+templateNo); | 
|---|
|  |  |  | var className = templateDom.attr("class"); | 
|---|
|  |  |  | type = className === 'template-barcode' ? 1 : 2; | 
|---|
|  |  |  | if (type === 1) { | 
|---|
|  |  |  | barcodeUrl = baseUrl+"/mac/code/auth?type="+type+"¶m="+printContent[i]+"&width="+200+"&height="+70; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | barcodeUrl = baseUrl+"/mac/code/auth?type="+2+"¶m="+printContent[i]+"&width="+400+"&height="+180; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | data.push({ | 
|---|
|  |  |  | item: printContent[i], | 
|---|
|  |  |  | barcodeUrl: barcodeUrl | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | var templateDom = $("#templatePreview"+templateNo); | 
|---|
|  |  |  | var tpl = templateDom.html(); | 
|---|
|  |  |  | var template = Handlebars.compile(tpl); | 
|---|
|  |  |  | var html = template({data: data}); | 
|---|
|  |  |  | var box = $("#box"); | 
|---|
|  |  |  | box.html(html); | 
|---|
|  |  |  | box.show(); | 
|---|
|  |  |  | box.print({mediaPrint:true}); | 
|---|
|  |  |  | box.hide(); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 搜索栏搜索事件 | 
|---|
|  |  |  | 
|---|
|  |  |  | elem: '#updateTime\\$', | 
|---|
|  |  |  | type: 'datetime' | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | //库位冻结 | 
|---|
|  |  |  | form.on('switch(stockFreezeSwitch)', function (obj) { | 
|---|
|  |  |  | let index  = obj.othis.parents('tr').attr("data-index"); | 
|---|
|  |  |  | console.log(index); | 
|---|
|  |  |  | let data = tableData[index]; | 
|---|
|  |  |  | data[this.stockFreeze] = obj.elem.checked?1:0; | 
|---|
|  |  |  | http.post(baseUrl + "/node/updateStatus", { | 
|---|
|  |  |  | name: data.name, | 
|---|
|  |  |  | status: data[this.stockFreeze] | 
|---|
|  |  |  | }, function (res) { | 
|---|
|  |  |  | layer.msg(res.msg, {icon: 1}); | 
|---|
|  |  |  | tableIns.reload(); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }); | 
|---|