自动化立体仓库 - WMS系统
zhangchao
2024-11-08 940cab832331ab054d2a4c74f13aacc6847dd79d
src/main/webapp/static/js/report/workCountIn.js
@@ -1,16 +1,17 @@
var pageCurr;
function getCol() {
    var cols = [
        {field: 'oneday', align: 'center', title: '入库日期', width: 200}
        ,{field: 'matnr', align: 'center',title: '物料号'}
        ,{field: 'maktx', align: 'center',title: '物料名称'}
        ,{field: 'anfme', align: 'center',title: '数量'}
        , {field: 'matnr', align: 'center', title: '物料号'}
        , {field: 'maktx', align: 'center', title: '物料名称'}
        , {field: 'anfme', align: 'center', title: '数量'}
    ];
    return cols;
}
layui.use(['table','laydate', 'form'], function(){
layui.use(['table', 'laydate', 'form'], function () {
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
@@ -22,7 +23,7 @@
    tableIns = table.render({
        elem: '#workIn',
        headers: {token: localStorage.getItem('token')},
        url: baseUrl+'/report/viewWorkCountInList.action',
        url: baseUrl + '/report/viewWorkCountInList.action',
        page: true,
        limit: 16,
        limits: [16, 30, 50, 100, 200, 500],
@@ -45,12 +46,12 @@
        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();
        }
    });
@@ -58,7 +59,7 @@
    // 监听排序事件
    table.on('sort(workIn)', 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;
@@ -70,9 +71,9 @@
            },
            done: function (res, curr, count) {
                if (res.code === 403) {
                    top.location.href = baseUrl+"/";
                    top.location.href = baseUrl + "/";
                }
                pageCurr=curr;
                pageCurr = curr;
                limit();
            }
        });
@@ -81,43 +82,51 @@
    // 监听头工具栏事件
    table.on('toolbar(workIn)', function (obj) {
        var checkStatus = table.checkStatus(obj.config.id);
        switch(obj.event) {
        switch (obj.event) {
            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);
                            fields.push(col.field);
                        }
                    });
                    var param = '?';
                    var exportData = {};
                    $.each($('#search-box [name]').serializeArray(), function() {
                    $.each($('#search-box [name]').serializeArray(), function () {
                        exportData[this.name] = this.value;
                        param += this.name + '=' + this.value + '&';
                    });
                    var param = {
                        fields: fields,
                        exportData: exportData
                    };
                    $.ajax({
                        url: baseUrl+"/report/viewWorkInExport.action",
                        headers: {'token': localStorage.getItem('token')},
                        data: JSON.stringify(param),
                        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');
                            } else if (res.code === 403) {
                                top.location.href = baseUrl+"/";
                            } else {
                                layer.msg(res.msg)
                            }
                        }
                    });
                    window.location.href = baseUrl + "/report/download/countIn" + param;
                    layer.closeAll();
                    // var param = {
                    //     fields: fields,
                    //     exportData: exportData
                    // };
                    // $.ajax({
                    //     url: baseUrl + "/report/download/in",
                    //     headers: {'token': localStorage.getItem('token')},
                    //     data: JSON.stringify(param),
                    //     responseType: "blob",
                    //     contentType: 'application/json;charset=UTF-8',
                    //     method: 'POST',
                    //     success: function (res) {
                    //         layer.closeAll();
                    //         if (res.code === 200) {
                    //             var blob = new Blob([response], { type: 'application/vnd.ms-excel' });
                    //             var link = document.createElement('a');
                    //             link.href = URL.createObjectURL(blob);
                    //             link.download = 'exported_file.xls'; // 设置下载文件名
                    //             link.click();
                    //         } else if (res.code === 403) {
                    //             top.location.href = baseUrl + "/";
                    //         } else {
                    //             layer.msg(res.msg)
                    //         }
                    //     }
                    // });
                });
                break;
        }
@@ -136,19 +145,19 @@
    });
    layDate.render({
        elem: '.layui-laydate-range'
        ,type: 'datetime'
        ,range: true
        , type: 'datetime'
        , range: true
    });
});
// 关闭动作
$(document).on('click','#data-detail-close', function () {
$(document).on('click', '#data-detail-close', function () {
    parent.layer.closeAll();
});
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({
@@ -158,14 +167,14 @@
        },
        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;
@@ -179,9 +188,9 @@
    for (var val in data) {
        var find = el.find(":input[id='" + val + "']");
        find.val(data[val]);
        if (showImg){
        if (showImg) {
            var next = find.next();
            if (next.get(0)){
            if (next.get(0)) {
                if (next.get(0).localName === "img") {
                    find.hide();
                    next.attr("src", data[val]);
@@ -201,13 +210,13 @@
function detailScreen(index) {
    var detail = layer.getChildFrame('#data-detail', index);
    var height = detail.height()+60;
    if (height > ($(window).height()*0.9)) {
        height = ($(window).height()*0.9);
    var height = detail.height() + 60;
    if (height > ($(window).height() * 0.9)) {
        height = ($(window).height() * 0.9);
    }
    layer.style(index, {
        top: (($(window).height()-height)/3)+"px",
        height: height+'px'
        top: (($(window).height() - height) / 3) + "px",
        height: height + 'px'
    });
    $(".layui-layer-shade").remove();
}