#
lsh
2024-09-05 8145b109ec0e9bb73d3930acf73e8dc18844adc2
zy-asrs-wms/src/main/webapp/static/js/locInPrintMat/locInPrintMat.js
@@ -24,20 +24,20 @@
        height: 'full-120',
        cols: [[
            {type: 'checkbox'}
            ,{field: 'id', align: 'center',title: ''}
            ,{field: 'uuid', align: 'center',title: ''}
            ,{field: 'status', align: 'center',title: ''}
            ,{field: 'createTime$', align: 'center',title: ''}
            ,{field: 'createBy', align: 'center',title: ''}
            ,{field: 'updateTime$', align: 'center',title: ''}
            ,{field: 'updateBy', align: 'center',title: ''}
            ,{field: 'memo', align: 'center',title: ''}
            ,{field: 'matnr', align: 'center',title: ''}
            ,{field: 'batch', align: 'center',title: ''}
            ,{field: 'anfme', align: 'center',title: ''}
            ,{field: 'locNo', align: 'center',title: ''}
            ,{field: 'maktx', align: 'center',title: ''}
            ,{field: 'ownerId', align: 'center',title: ''}
            ,{field: 'id', align: 'center',title: 'ID',hide : true}
            ,{field: 'uuid', align: 'center',title: '编号',hide: true}
            ,{field: 'status$', align: 'center',title: '打印情况', width:100,hide: false}
            ,{field: 'matnr', align: 'center',title: '品号', width:180,hide: false}
            // ,{field: 'batch', align: 'center',title: '批次', width:100,hide: false}
            // ,{field: 'anfme', align: 'center',title: '重量(kg)', width:100,hide: false}
            // ,{field: 'locNo', align: 'center',title: '库位号', width:120,hide: false}
            ,{field: 'maktx', align: 'center',title: '品名',hide: false}
            // ,{field: 'owner$', align: 'center',title: '货主',hide: false}
            // ,{field: 'createTime$', align: 'center',title: '入库时间', width:120,hide: false}
            // ,{field: 'createBy$', align: 'center',title: '入库人员', width:100,hide: false}
            ,{field: 'updateTime$', align: 'center',title: '打印时间', width:180,hide: false}
            ,{field: 'updateBy$', align: 'center',title: '打印人员',hide: false}
            ,{field: 'memo', align: 'center',title: '备注',hide: false}
            ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120}
        ]],
@@ -60,7 +60,7 @@
            if (res.code === 403) {
                top.location.href = baseUrl+"/";
            }
            pageCurr=curr;pageCount=count;
            pageCurr=curr;
            limit();
        }
    });
@@ -87,14 +87,14 @@
                showEditModel();
                break;
            case 'deleteData':
               if (checkStatus.length === 0) {
                   layer.msg('请选择要删除的数据', {icon: 2});
                   return;
               }
               del(checkStatus.map(function (d) {
                   return d.id;
               }));
               break;
                if (checkStatus.length === 0) {
                    layer.msg('请选择要删除的数据', {icon: 2});
                    return;
                }
                del(checkStatus.map(function (d) {
                    return d.id;
                }));
                break;
            case 'exportData':
                admin.confirm('确定导出Excel吗', {shadeClose: true}, function(){
                    var titles=[];
@@ -133,6 +133,29 @@
                    });
                });
                break;
            // 批量打印
            case "btnPrintBatch":
                printMatCodeNos = [];
                var data = checkStatus;
                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].id);
                            }
                        },
                        end: function () {
                        }
                    });
                }
                break;
        }
    });
@@ -140,6 +163,10 @@
    table.on('tool(locInPrintMat)', function(obj){
        var data = obj.data;
        switch (obj.event) {
            case 'btnPrint':
                layer.msg("废弃")
                break;
            // btnPrint(data.id, data.orderNo, 4);
            case 'edit':
                showEditModel(data);
                break;
@@ -154,11 +181,11 @@
        admin.open({
            type: 1,
            area: '600px',
            title: (mData ? '修改' : '添加') + '',
            title: (mData ? '修改' : '添加') + '订单状态',
            content: $('#editDialog').html(),
            success: function (layero, dIndex) {
                form.val('detail', mData);
                layDateRender(mData);
                form.val('detail', mData);
                form.on('submit(editSubmit)', function (data) {
                    var loadIndex = layer.load(2);
                    $.ajax({
@@ -218,40 +245,84 @@
    // 搜索
    form.on('submit(search)', function (data) {
        pageCurr = 1;
        tableReload(true);
        tableReload(false);
    });
    // 重置
    form.on('submit(reset)', function (data) {
        pageCurr = 1;
        clearFormVal($('#search-box'));
        tableReload(true);
        tableReload(false);
    });
    // 模板选择
    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+"/loc/in/mat/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&param="
                                +res.data[i].matnr+";" +res.data[i].batch+";"
                                +res.data[i].anfme+";" +res.data[i].locNo+";"
                                +res.data[i].ownerId+";"+res.data[i].maktx+";"
                                +res.data[i].id;
                        } else {
                            res.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=2&param="
                                +res.data[i].matnr+";" +res.data[i].batch+";"
                                +res.data[i].anfme+";" +res.data[i].locNo+";"
                                +res.data[i].ownerId+";"+res.data[i].maktx+";"
                                +res.data[i].id;
                        }
                    }
                    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)
                }
            }
        })
    });
    // 时间选择器
    function layDateRender(data) {
        setTimeout(function () {
            layDate.render({
                elem: '.layui-laydate-range'
                ,type: 'datetime'
                ,range: true
            });
            layDate.render({
                elem: '#createTime\\$',
                type: 'datetime',
                value: data!==undefined?data['createTime$']:null
                value: data!==undefined?data['createTime\\$']:null
            });
            layDate.render({
                elem: '#updateTime\\$',
                type: 'datetime',
                value: data!==undefined?data['updateTime$']:null
                value: data!==undefined?data['updateTime\\$']:null
            });
        }, 100);
        }, 300);
    }
    layDateRender();
});
@@ -260,17 +331,13 @@
    parent.layer.closeAll();
});
function tableReload(search) {
    if (pageCount === 0 || search) {
        let searchData = {};
        $.each($('#search-box [name]').serializeArray(), function() {
            searchData[this.name] = this.value;
        });
        tableIns.reload({
            where: searchData,
            page: {curr: pageCurr}
        });
    } else {
        $(".layui-laypage-btn")[0].click();
    }
function tableReload(child) {
    var searchData = {};
    $.each($('#search-box [name]').serializeArray(), function() {
        searchData[this.name] = this.value;
    });
    tableIns.reload({
        where: searchData,
        page: {curr: pageCurr}
    });
}