自动化立体仓库 - WMS系统
lty
2026-01-29 539a56279625242c497b4b4093f2defbb9d80334
src/main/webapp/static/js/handWrkMast/handWrkMast.js
@@ -1,11 +1,78 @@
var pageCurr;
var wrkNo;
var tableIns;
var tableIns1;
var tableReload;
layui.use(['table','laydate', 'form'], function(){
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
    var layDate = layui.laydate;
    var form = layui.form;
    function getCols() {
        var t = function(key, def) {
            return (typeof I18n !== 'undefined' && typeof I18n.t === 'function') ? I18n.t(key) : def;
        };
        return [[
            {field: 'wrkNo', align: 'center',title: t('work_no', '工作号'),sort: true}
            ,{field: 'ioTime$', align: 'center',title: t('work_time', '工作时间'),sort: true, hide:true}
            ,{field: 'wrkSts$', align: 'center',title: t('work_status', '工作状态'), templet: function(d){
                return (typeof I18n !== 'undefined' && d.wrkSts != null) ? I18n.t('wrk_status_' + d.wrkSts) : d.wrkSts$;
            }}
            ,{field: 'ioType$', align: 'center',title: t('transaction_type', '入出库类型'), templet: function(d){
                return (typeof I18n !== 'undefined' && d.ioType != null) ? I18n.t('io_type_' + d.ioType) : d.ioType$;
            }}
            ,{field: 'crnNo$', align: 'center',title: t('crane', '堆垛机'), hide:true}
            ,{field: 'sourceStaNo$', align: 'center',title: t('source_station', '源站'), hide:true}
            ,{field: 'staNo$', align: 'center',title: t('target_station', '目标站'), hide:true}
            ,{field: 'sourceLocNo$', align: 'center',title: t('source_location', '源库位'), hide:true}
            ,{field: 'locNo$', align: 'center',title: t('target_location', '目标库位'), hide:true}
            ,{field: 'barcode', align: 'center',title: t('barcode', '条码'), hide:true}
            ,{field: 'manuType', align: 'center',title: t('handling_mode', '处理方式'), templet: function(d){
                if (typeof I18n === 'undefined') return d.manuType;
                if (d.manuType === '手动取消') return I18n.t('handling_mode_manual_cancel');
                if (d.manuType === '手动完成') return I18n.t('handling_mode_manual_complete');
                return d.manuType;
            }}
            ,{field: 'modiUser$', align: 'center',title: t('operator', '操作人员')}
            ,{field: 'modiUser$', align: 'center',title: t('operator', '操作人员')}
            ,{field: 'modiTime$', align: 'center',title: t('operation_time', '操作时间')}
            ,{fixed: 'right', title: t('operation', '操作'), align: 'center', templet: function(d) {
                var detailText = (typeof I18n !== 'undefined' && I18n.t) ? I18n.t('detail') : '明细';
                return '<a class="layui-btn layui-btn-sm btn-detlShow" lay-event="detlShow">' + detailText + '</a>';
            }, width:100}
        ]];
    }
    function getDetlCols() {
        var t = function(key, def) {
            return (typeof I18n !== 'undefined' && typeof I18n.t === 'function') ? I18n.t(key) : def;
        };
        return [[
            {type: 'checkbox'}
            ,{field: 'wrkNo', align: 'center',title: t('work_no', '工作号')}
            ,{field: 'ioTime$', align: 'center',title: t('work_time', '工作时间')}
            ,{field: 'matnr', align: 'center',title: t('material', '物料')}
            ,{field: 'lgnum', align: 'center',title: t('warehouse_no', '仓库号')}
            ,{field: 'tbnum', align: 'center',title: t('transfer_req_no', '转储请求编号')}
            ,{field: 'tbpos', align: 'center',title: t('line_item', '行项目')}
            ,{field: 'zmatid', align: 'center',title: t('material_label_id', '物料标签ID')}
            ,{field: 'maktx', align: 'center',title: t('material_desc', '物料描述')}
            ,{field: 'werks', align: 'center',title: t('factory', '工厂')}
            ,{field: 'anfme', align: 'center',title: t('quantity', '数量')}
            ,{field: 'altme', align: 'center',title: t('unit', '单位')}
            ,{field: 'zpallet', align: 'center',title: t('pallet_barcode', '托盘条码')}
            ,{field: 'bname', align: 'center',title: t('user_id', '用户ID')}
            ,{field: 'memo', align: 'center',title: t('memo', '备注')}
            ,{fixed: 'right', title: t('operation', '操作'), align: 'center', toolbar: '#operate', width:50}
        ]];
    }
    // 数据渲染
    tableIns = table.render({
@@ -19,26 +86,7 @@
        even: true,
        toolbar: '#toolbar',
        cellMinWidth: 50,
        cols: [[
            // {type: 'checkbox'}
            {field: 'wrkNo', align: 'center',title: '工作号',sort: true}
            ,{field: 'ioTime$', align: 'center',title: '工作时间',sort: true, hide:true}
            ,{field: 'wrkSts$', align: 'center',title: '工作状态'}
            ,{field: 'ioType$', align: 'center',title: '入出库类型'}
            ,{field: 'crnNo$', align: 'center',title: '堆垛机', hide:true}
            ,{field: 'sourceStaNo$', align: 'center',title: '源站', hide:true}
            ,{field: 'staNo$', align: 'center',title: '目标站', hide:true}
            ,{field: 'sourceLocNo$', align: 'center',title: '源库位', hide:true}
            ,{field: 'locNo$', align: 'center',title: '目标库位', hide:true}
            ,{field: 'barcode', align: 'center',title: '条码', hide:true}
            ,{field: 'manuType', align: 'center',title: '处理方式'}
            ,{field: 'modiUser$', align: 'center',title: '操作人员'}
            ,{field: 'modiTime$', align: 'center',title: '操作时间'}
            ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:100}
        ]],
        cols: getCols(),
        request: {
            pageName: 'curr',
            pageSize: 'limit'
@@ -60,6 +108,54 @@
            }
            pageCurr=curr;
            limit();
            if (typeof I18n !== 'undefined' && typeof I18n.updateLayuiPagination === 'function') {
                I18n.updateLayuiPagination();
            }
        }
    });
    // 监听语言切换事件
    $(document).off('i18n:languageChanged').on('i18n:languageChanged', function() {
        if (typeof I18n !== 'undefined') {
            I18n.updatePage($('#search-box'));
        }
        layDateRender();
        tableIns.reload({
            cols: getCols(),
            done: function(res, curr, count) {
                if (res.code === 403) {
                    top.location.href = baseUrl+"/";
                }
                pageCurr=curr;
                limit();
                if (typeof I18n !== 'undefined' && typeof I18n.updateLayuiPagination === 'function') {
                    I18n.updateLayuiPagination();
                }
            }
        });
        // 如果明细表已初始化且可见,也刷新它
        if (typeof tableIns1 !== 'undefined' && $('#detlTable').is(':visible')) {
            tableIns1.reload({
                cols: getDetlCols(),
                done: function(res, curr, count) {
                    if (res.code === 403) {
                        top.location.href = baseUrl+"/";
                    }
                    pageCur=curr;
                    form.on('checkbox(tableCheckbox)', function (data) {
                        var _index = $(data.elem).attr('table-index')||0;
                        if(data.elem.checked){
                            res.data[_index][data.value] = 'Y';
                        }else{
                            res.data[_index][data.value] = 'N';
                        }
                    });
                    if (typeof I18n !== 'undefined' && typeof I18n.updateLayuiPagination === 'function') {
                        I18n.updateLayuiPagination();
                    }
                }
            });
        }
    });
@@ -83,6 +179,9 @@
                }
                pageCurr=curr;
                limit();
                if (typeof I18n !== 'undefined' && typeof I18n.updateLayuiPagination === 'function') {
                    I18n.updateLayuiPagination();
                }
            }
        });
    });
@@ -92,7 +191,7 @@
        var checkStatus = table.checkStatus(obj.config.id);
        switch(obj.event) {
            case 'exportData':
                layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){
                layer.confirm((typeof I18n !== 'undefined' && I18n.t) ? I18n.t('confirm_export_excel') : '确定导出Excel吗', {shadeClose: true}, function(){
                    var titles=[];
                    var fields=[];
                    obj.config.cols[0].map(function (col) {
@@ -144,7 +243,7 @@
                // 弹层显示
                layer.open({
                    type: 2,
                    title: '工作档明细',
                    title: (typeof I18n !== 'undefined' && I18n.t) ? I18n.t('work_order_detail') : '工作档明细',
                    maxmin: true,
                    area: [top.detailWidth, top.detailHeight],
                    shadeClose: true,
@@ -328,14 +427,29 @@
        elem: '#logErrTime\\$',
        type: 'datetime'
    });
    layDate.render({
        elem: '.layui-laydate-range'
        ,type: 'datetime'
        ,range: true
    });
    function layDateRender() {
        var lang = (typeof I18n !== 'undefined' && I18n.getLanguage().indexOf('en') > -1) ? 'en' : 'cn';
        setTimeout(function () {
            $('.layui-laydate-range').each(function() {
                var $this = $(this);
                var val = $this.val();
                var $newElem = $this.clone();
                $newElem.removeAttr('lay-key');
                $newElem.val(val);
                $this.replaceWith($newElem);
                layDate.render({
                    elem: $newElem[0],
                    type: 'datetime',
                    range: true,
                    lang: lang
                });
            });
        }, 300);
    }
    layDateRender();
    var pageCur;
    function locDetl(param){
    window.locDetl = function(param){
        $('#detlTable').css("display", 'block');
        // 数据渲染
        $('#wrkNo').val(param);
@@ -351,25 +465,7 @@
            even: true,
            toolbar: '#toolbar',
            cellMinWidth: 50,
            cols: [[
                {type: 'checkbox'}
                ,{field: 'wrkNo', align: 'center',title: '工作号'}
                ,{field: 'ioTime$', align: 'center',title: '工作时间'}
                ,{field: 'matnr', align: 'center',title: '物料'}
                ,{field: 'lgnum', align: 'center',title: '仓库号'}
                ,{field: 'tbnum', align: 'center',title: '转储请求编号'}
                ,{field: 'tbpos', align: 'center',title: '行项目'}
                ,{field: 'zmatid', align: 'center',title: '物料标签ID'}
                ,{field: 'maktx', align: 'center',title: '物料描述'}
                ,{field: 'werks', align: 'center',title: '工厂'}
                ,{field: 'anfme', align: 'center',title: '数量'}
                ,{field: 'altme', align: 'center',title: '单位'}
                ,{field: 'zpallet', align: 'center',title: '托盘条码'}
                ,{field: 'bname', align: 'center',title: '用户ID'}
                ,{field: 'memo', align: 'center',title: '备注'}
                ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:50}
            ]],
            cols: getDetlCols(),
            request: {
                pageName: 'curr',
                pageSize: 'limit'
@@ -398,6 +494,41 @@
                        res.data[_index][data.value] = 'N';
                    }
                });
                if (typeof I18n !== 'undefined' && typeof I18n.updateLayuiPagination === 'function') {
                    I18n.updateLayuiPagination();
                }
            }
        });
    }
    tableReload = function(child) {
        var searchData = {};
        $.each($('#search-box [name]').serializeArray(), function() {
            searchData[this.name] = this.value;
        });
        (child ? parent.tableIns : tableIns).reload({
            where: searchData,
            page: {
                curr: pageCurr
            },
            done: function (res, curr, count) {
                if (res.code === 403) {
                    top.location.href = baseUrl+"/";
                }
                pageCurr=curr;
                if (res.data.length === 0 && count !== 0) {
                    tableIns.reload({
                        where: searchData,
                        page: {
                            curr: pageCurr-1
                        }
                    });
                    pageCurr -= 1;
                }
                limit(child);
                if (typeof I18n !== 'undefined' && typeof I18n.updateLayuiPagination === 'function') {
                    I18n.updateLayuiPagination();
                }
            }
        });
    }
@@ -408,35 +539,6 @@
$(document).on('click','#data-detail-close', function () {
    parent.layer.closeAll();
});
function tableReload(child) {
    var searchData = {};
    $.each($('#search-box [name]').serializeArray(), function() {
        searchData[this.name] = this.value;
    });
    (child ? parent.tableIns : tableIns).reload({
        where: searchData,
        page: {
            curr: pageCurr
        },
        done: function (res, curr, count) {
            if (res.code === 403) {
                top.location.href = baseUrl+"/";
            }
            pageCurr=curr;
            if (res.data.length === 0 && count !== 0) {
                tableIns.reload({
                    where: searchData,
                    page: {
                        curr: pageCurr-1
                    }
                });
                pageCurr -= 1;
            }
            limit(child);
        }
    });
}
function setFormVal(el, data, showImg) {
    for (var val in data) {