自动化立体仓库 - WMS系统
zyx
2024-02-18 16daa2a44e5fa705e671f5ff18631eb26ad70d40
src/main/webapp/static/js/pla/plaDetl.js
@@ -7,16 +7,14 @@
var checkStatus = [];
var dataCheck = [];
var admin;
var printData = [];
var layDate;
function getCol() {
    var cols = [
        {field: 'id', title: 'id', align: 'center',hide:true}
        ,{type: 'checkbox'}
        ,{field:'id', width:80, title: '', sort: true, totalRowText: '合计:',hide: true}
        ,{field: 'pakinTime$', title: '入库时间', align: 'center' , sort:true}
        ,{field: 'owner', align: 'center',title: '主体',edit:true}
        ,{field: 'type', align: 'center',title: '物资类别',hide:true,edit:true}
        ,{field: 'proOrderNo', align: 'center',title: '生产订单编号',hide:true,edit:true}
        ,{field: 'workshop', align: 'center',title: '生产车间',hide:true,edit:true}
        ,{field: 'line', align: 'center',title: '生产线',hide:true,edit:true}
        ,{field: 'matnr', align: 'center',title: '存货编码',hide:true,edit:true}
        ,{field: 'brand', align: 'center',title: '牌号',edit:true}
        ,{field: 'batch', align: 'center',title: '批号',edit:true, width: 150, sort:true}
@@ -25,7 +23,7 @@
        ,{field: 'weight', align: 'center',title: '重量KG',edit:true}
        ,{field: 'packageType', align: 'center',title: '包装类型',edit:true}
        ,{field: 'zpalletType', align: 'center',title: '托盘类型',edit:true}
        ,{field: 'filmWrap', align: 'center',title: '缠膜',edit:true}
        ,{field: 'filmWrap', align: 'center',title: '缠膜',edit:true,hide:true}
        ,{field: 'fingerMelting', align: 'center',title: '熔指,g/10min',edit:true}
        ,{field: 'water', align: 'center',title: '水分,ppm', hide:true,edit:true}
        ,{field: 'fusingPoint', align: 'center',title: '熔点,℃',edit:true}
@@ -44,15 +42,24 @@
        ,{field: 'str5', align: 'center',title: '半结晶时间,min',hide:true,edit:true}
        ,{field: 'str6', align: 'center',title: '结晶度.%',hide:true,edit:true}
        ,{field: 'massState', align: 'center',title: '质量状态',edit:true}
        ,{field: 'problem', align: 'center',title: '备注',edit:true}
        ,{field: 'direction', align: 'center',title: '应用方向',edit:true}
        ,{field: 'position', align: 'center',title: '存放位置',edit:true}
        ,{field: 'stash', align: 'center',title: '仓库',edit:true}
        ,{field: 'problem', align: 'center',title: '备注',edit:true,hide:true}
        ,{field: 'direction', align: 'center',title: '应用方向',edit:true,hide:true}
        ,{field: 'position', align: 'center',title: '存放位置',edit:true,hide:true}
        ,{field: 'stash', align: 'center',title: '仓库',edit:true,hide:true}
        ,{field: 'locNo', align: 'center',title: '库位',edit:true}
        ,{field: 'weightAnfme', align: 'center',title: '剩余重量(KG)',edit:true}
        ,{field: 'owner', align: 'center',title: '主体',edit:true}
        ,{field: 'type', align: 'center',title: '物资类别',hide:true,edit:true}
        ,{field: 'proOrderNo', align: 'center',title: '生产订单编号',hide:true,edit:true}
        ,{field: 'workshop', align: 'center',title: '生产车间',hide:true,edit:true}
        ,{field: 'line', align: 'center',title: '生产线',hide:true,edit:true}
        ,{field: 'weightAnfme', align: 'center',title: '剩余重量(KG)',edit:true,totalRow:true}
        ,{field: 'qtyAnfme', align: 'center',title: '待出库重量(KG)',hide:true}
        ,{field: 'status', align: 'center',title: '状态', templet: setState ,edit:true}
        ,{field: 'stockFreeze', align: 'center',title: '库存冻结', templet: '#stockFreezeTpl'}
        ,{field: 'stockFreezeBy', align: 'center',title: '操作人员',hide:true}
        ,{field: 'stockFreezeDate$', align: 'center',title: '操作日期',hide:true}
        ,{align: 'center', title: '流转明细', toolbar: '#tbLook'}
        ,{field: 'createTime$', title: '创建时间', align: 'center' , sort:true}
        // ,{field: 'orderNo', align: 'center',title: '单号', hide:true}
        // ,{field: 'pakoutTime', align: 'center',title: '出库时间', hide:true}
        // ,{field: 'orderWeight', align: 'center',title: '重量', hide:true}
@@ -83,15 +90,21 @@
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).extend({
    dropdown: 'dropdown/dropdown',
}).use(['table','laydate', 'form', 'admin', 'dropdown'], function() {
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
    var layDate = layui.laydate;
    laydate = layui.laydate;
    var form = layui.form;
    admin = layui.admin;
    // 日期时间范围
    laydate.render({
        elem: '#ID-laydate-range-datetime',
        type: 'datetime',
        range: true
    });
    // 数据渲染
    tableIns = table.render({
@@ -99,6 +112,13 @@
        headers: {token: localStorage.getItem('token')},
        url: baseUrl+'/pla/list/auth?step=2',
        page: true,
        totalRow: true, // 开启合计行
        height: function(){
            var otherHeight = $('.function-area').outerHeight() + $('#search-box').outerHeight(); // 自定义其他区域的高度
            console.log($(window).height() - otherHeight);
            return $(window).height() - otherHeight - 100; // 返回 number 类型
        },
        //height: 'full',
        limit: 16,
        limits: [16, 30, 50, 100, 200, 500],
        even: true,
@@ -115,13 +135,14 @@
                'code': res.code,
                'msg': res.msg,
                'count': res.data.total,
                'data': res.data.records
                'data': res.data.records,
            }
        },
        response: {
            statusCode: 200
        },
        done: function(res, curr, count) {
            //$(".lavui-table-grid-down").hide();
            if (res.code === 403) {
                top.location.href = baseUrl+"/";
            }
@@ -135,6 +156,15 @@
                    res.data[_index][data.value] = 'Y';
                }else{
                    res.data[_index][data.value] = 'N';
                }
            });
            let headerTop = $('.layui-table-header').offset().top; //获取表格头到文档顶部的距离
            let headerPage = $('.layui-table-page').offset().top; //获取表格底部文档顶部的距离
            $(window).scroll(function () {
                if ((headerTop - $(window).scrollTop()) < 0) { //超过了
                    $('.layui-table-header').addClass('table-header-fixed'); //添加样式,固定住表头
                } else { //没超过
                    $('.layui-table-header').removeClass('table-header-fixed'); //移除样式
                }
            });
        }
@@ -208,6 +238,7 @@
    // 监听头工具栏事件
    table.on('toolbar(plaDetl)', function (obj) {
        var checkStatus = table.checkStatus(obj.config.id)
        printData = checkStatus;
        switch(obj.event) {
            case 'updateData':
                var data = checkStatus.data;
@@ -289,8 +320,149 @@
                        })
                    });
                }
                break;
            case 'freezeData':
                var data = checkStatus.data;
                if (data.length === 0){
                    layer.msg('请选择数据');
                } else {
                    layer.confirm('确定冻结'+(data.length===1?'此':data.length)+'条数据吗', function(){
                        $.ajax({
                            url: baseUrl+"/pla/updateStockFreeze",
                            headers: {'token': localStorage.getItem('token')},
                            data: JSON.stringify(data),
                            contentType:'application/json;charset=UTF-8',
                            method: 'POST',
                            traditional:true,
                            success: function (res) {
                                if (res.code === 200){
                                    layer.closeAll();
                                    tableReload(false);
                                    layer.msg(res.msg,{icon:1})
                                } else if (res.code === 403){
                                    top.location.href = baseUrl+"/";
                                } else {
                                    layer.msg(res.msg,{icon:2})
                                }
                            }
                        })
                    });
                }
                break;
            case 'disFreezeData':
                var data = checkStatus.data;
                if (data.length === 0){
                    layer.msg('请选择数据');
                } else {
                    layer.confirm('确定解除'+(data.length===1?'此':data.length)+'条数据的冻结吗', function(){
                        $.ajax({
                            url: baseUrl+"/pla/updateStockDisFreeze",
                            headers: {'token': localStorage.getItem('token')},
                            data: JSON.stringify(data),
                            contentType:'application/json;charset=UTF-8',
                            method: 'POST',
                            traditional:true,
                            success: function (res) {
                                if (res.code === 200){
                                    layer.closeAll();
                                    tableReload(false);
                                    layer.msg(res.msg,{icon:1})
                                } else if (res.code === 403){
                                    top.location.href = baseUrl+"/";
                                } else {
                                    layer.msg(res.msg,{icon:2})
                                }
                            }
                        })
                    });
                }
                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 () {
                        }
                    });
                }
                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;
        var templateDom = $("#templatePreview"+templateNo);
        var className = templateDom.attr("class");
        layer.closeAll();
        for (let i=0;i<printData.data.length;i++){
            if (className === 'template-barcode') {
                printData.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=1&param="+(printData.data[i].batch+";"+printData.data[i].packageNo)
            } else {
                printData.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=2&param="+(printData.data[i].batch+";"+printData.data[i].packageNo)
            }
        }
        var tpl = templateDom.html();
        var template = Handlebars.compile(tpl);
        var html = template(printData);
        var box = $("#box");
        box.html(html);box.show();
        box.print({mediaPrint:true});
        box.hide();
        // $.ajax({
        //     url: baseUrl+"/pla/print/auth",
        //     headers: {'token': localStorage.getItem('token')},
        //     data: JSON.stringify(printData.data),
        //     contentType:'application/json;charset=UTF-8',
        //     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&param="+res.data[i].matnr;
        //                 } else {
        //                     res.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=2&param="+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)
        //         }
        //     }
        // })
    });
    // 搜索栏搜索事件
    form.on('submit(search)', function (data) {
@@ -504,8 +676,12 @@
                brand = brand ? brand : data[i].brand;
                if( brand != data[i].brand){
                if(brand != data[i].brand){
                    layer.msg("选中的明细中含有多种牌号,请重新选择");
                    return;
                }
                if(data[i].stockFreeze === 0){
                    layer.msg("选中的明细中含有冻结的库存,请解冻后操作");
                    return;
                }
                dataSave.push(data[i]);
@@ -599,6 +775,42 @@
            }
        });
    })
    $(document).on('click','#updateOwner', function () {
        let data = table.cache.plaDetl;
        let dataSave = [];
        let dataOld = [];
        for(var i=0; i<data.length; i++){
            if(data[i].LAY_CHECKED){
                data[i].step = 1;
                dataSave.push(data[i]);
            }else {
                dataOld.push(data[i]);
            }
        }
        dataCheck = dataSave;
        if(!dataSave || dataSave.length < 1){
            layer.msg("未勾选,请先勾选需要更改的库存");
            return;
        }
        layer.open({
            type: 2,
            title: '变更主体',
            maxmin: true,
            area: ['500px', top.detailHeight],
            shadeClose: false,
            content: 'updateOwner.html',
            success: function(layero, index){
                layer.getChildFrame('#data-detail-submit-edit', index).hide();
                top.convertDisabled(layer.getChildFrame('#data-detail :input', index), false);
                layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
                var iframe = window['layui-layer-iframe' + index];
                iframe.child(dataSave)
            }
        });
    })
})