自动化立体仓库 - WMS系统
lty
2026-01-22 35b1b26f1fe16550b4ee2881a26d599456fe59b4
src/main/webapp/static/js/locMast/locMast.js
@@ -6,6 +6,87 @@
    var layDate = layui.laydate;
    var form = layui.form;
    var doneCallback = function(res, curr, count) {
        if (res.code === 403) {
            top.location.href = baseUrl+"/";
        }
        pageCurr=curr;
        limit();
        if (typeof I18n !== 'undefined') {
            I18n.updatePage($('.layui-table-view'));
            I18n.updateLayuiPagination();
        }
    };
    // 获取表头配置
    function getCols() {
        return [[
            {type: 'checkbox', fixed: 'left'}
            // ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80}
            ,{field: 'locNo', align: 'center',title: I18n.t('location_no'),sort:true, hide:false}
            ,{field: 'locSts', align: 'center',title: I18n.t('location_status'),width:200, hide:false, templet: function(d) {
                var key = 'loc_status_' + d.locSts;
                var text = I18n.t(key);
                return text === key ? d.locSts$ : text;
            }}
            ,{field: 'whsType', align: 'center',title: I18n.t('location_type'),width:200, hide:false, templet: function(d) {
                var map = {
                    '1': 'standard_crane_whs',
                    '2': 'flat_whs',
                    '3': 'shuttle_board',
                    '4': 'four_way_vehicle',
                    '5': 'agv'
                };
                var key = map[d.whsType];
                return key ? I18n.t(key) : d.whsType$;
            }}
            // ,{field: 'pltType', align: 'center',title: ''}
            // ,{field: 'ctnType', align: 'center',title: ''}
            // ,{field: 'locSts', align: 'center',title: ''}
            // ,{field: 'sheetNo', align: 'center',title: ''}
            ,{field: 'crnNo', align: 'center',title: I18n.t('crane_no'), hide:false}
            ,{field: 'row1', align: 'center',title: I18n.t('row'), sort:true, hide:false}
            ,{field: 'bay1', align: 'center',title: I18n.t('bay'), sort:true, hide:false}
            ,{field: 'lev1', align: 'center',title: I18n.t('level'), sort:true, hide:false}
            ,{field: 'gro1', align: 'center',title: I18n.t('group'), sort:true, hide:false}
            ,{field: 'fullPlt', align: 'center',title: I18n.t('full_pallet'), templet:function(row){
                    var html = "<input value='fullPlt' type='checkbox' lay-skin='primary' lay-filter='tableCheckbox' disabled table-index='"+row.LAY_TABLE_INDEX+"'";
                    if(row.fullPlt === 'Y'){html += " checked ";}
                    html += ">";
                    return html;
                },width:80, hide:false}
            // ,{field: 'outEnable', align: 'center',title: ''}
            ,{field: 'ioTime$', align: 'center',title: 'ioTime', hide:true}
            // ,{field: 'firstTime$', align: 'center',title: '', hide:true}
            ,{field: 'modiUser$', align: 'center',title: I18n.t('modifier'), hide:true}
            ,{field: 'modiTime$', align: 'center',title: I18n.t('modify_time'), hide:true}
            ,{field: 'appeUser$', align: 'center',title: I18n.t('creator'),event: 'appeUser', style: 'text-decoration: underline;cursor:pointer', hide:true}
            ,{field: 'appeTime$', align: 'center',title: I18n.t('add_time'), hide:true}
            // ,{field: 'errorTime$', align: 'center',title: ''}
            // ,{field: 'errorMemo', align: 'center',title: ''}
            // ,{field: 'ctnKind', align: 'center',title: ''}
            // ,{field: 'scWeight', align: 'center',title: ''}
            // ,{field: 'invWh', align: 'center',title: ''}
            // ,{field: 'mk', align: 'center',title: ''}
            // ,{field: 'barcode', align: 'center',title: ''}
            // ,{field: 'PdcType', align: 'center',title: ''}
            // ,{field: 'ctnNo', align: 'center',title: ''}
            ,{field: 'locType1$', align: 'center',title: I18n.t('high_low_type'), hide:true}
            ,{field: 'locType2$', align: 'center',title: I18n.t('width_type'), hide:true}
            ,{field: 'locType3$', align: 'center',title: I18n.t('weight_type'), hide:true}
            ,{fixed: 'right', title: I18n.t('operation'), align: 'center', toolbar: '#operate', width:100}
        ]];
    }
    // 监听语言切换事件
    $(document).on('i18n:languageChanged', function() {
        tableIns.reload({
            cols: getCols(),
            done: doneCallback
        });
    });
    // 数据渲染
    tableIns = table.render({
        elem: '#locMast',
@@ -18,49 +99,7 @@
        // size: 'sm',
        toolbar: '#toolbar',
        cellMinWidth: 50,
        cols: [[
            {type: 'checkbox', fixed: 'left'}
//            ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80}
            ,{field: 'locNo', align: 'center',title: '库位号',sort:true, hide:false}
            ,{field: 'locSts$', align: 'center',title: '库位状态',width:200, hide:false}
            ,{field: 'whsType$', align: 'center',title: '库位类型',width:200, hide:false}
            // ,{field: 'pltType', align: 'center',title: ''}
            // ,{field: 'ctnType', align: 'center',title: ''}
            // ,{field: 'locSts', align: 'center',title: ''}
            // ,{field: 'sheetNo', align: 'center',title: ''}
            ,{field: 'crnNo', align: 'center',title: '堆垛机号', hide:false}
            ,{field: 'row1', align: 'center',title: '排', sort:true, hide:false}
            ,{field: 'bay1', align: 'center',title: '列', sort:true, hide:false}
            ,{field: 'lev1', align: 'center',title: '层', sort:true, hide:false}
            ,{field: 'gro1', align: 'center',title: '组', sort:true, hide:false}
            ,{field: 'fullPlt', align: 'center',title: '满板', templet:function(row){
                    var html = "<input value='fullPlt' type='checkbox' lay-skin='primary' lay-filter='tableCheckbox' disabled table-index='"+row.LAY_TABLE_INDEX+"'";
                    if(row.fullPlt === 'Y'){html += " checked ";}
                    html += ">";
                    return html;
                },width:80, hide:false}
            // ,{field: 'outEnable', align: 'center',title: ''}
            ,{field: 'ioTime$', align: 'center',title: 'ioTime', hide:true}
            // ,{field: 'firstTime$', align: 'center',title: '', hide:true}
            ,{field: 'modiUser$', align: 'center',title: '修改人员', hide:true}
            ,{field: 'modiTime$', align: 'center',title: '修改时间', hide:true}
            ,{field: 'appeUser$', align: 'center',title: '创建者',event: 'appeUser', style: 'text-decoration: underline;cursor:pointer', hide:true}
            ,{field: 'appeTime$', align: 'center',title: '添加时间', hide:true}
            // ,{field: 'errorTime$', align: 'center',title: ''}
            // ,{field: 'errorMemo', align: 'center',title: ''}
            // ,{field: 'ctnKind', align: 'center',title: ''}
            // ,{field: 'scWeight', align: 'center',title: ''}
            // ,{field: 'invWh', align: 'center',title: ''}
            // ,{field: 'mk', align: 'center',title: ''}
            // ,{field: 'barcode', align: 'center',title: ''}
            // ,{field: 'PdcType', align: 'center',title: ''}
            // ,{field: 'ctnNo', align: 'center',title: ''}
            ,{field: 'locType1$', align: 'center',title: '高低类型', hide:true}
            ,{field: 'locType2$', align: 'center',title: '宽窄类型', hide:true}
            ,{field: 'locType3$', align: 'center',title: '轻重类型', hide:true}
            ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:100}
        ]],
        cols: getCols(),
        request: {
            pageName: 'curr',
            pageSize: 'limit'
@@ -76,21 +115,7 @@
        response: {
            statusCode: 200
        },
        done: function(res, curr, count) {
            if (res.code === 403) {
                top.location.href = baseUrl+"/";
            }
            pageCurr=curr;
            limit();
            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';
                }
            });
        }
        done: doneCallback
    });
    // 监听排序事件
@@ -106,13 +131,7 @@
            page: {
                curr: 1
            },
            done: function (res, curr, count) {
                if (res.code === 403) {
                    top.location.href = baseUrl+"/";
                }
                pageCurr=curr;
                limit();
            }
            done: doneCallback
        });
    });
@@ -123,9 +142,9 @@
            case 'addData':
                layer.open({
                    type: 2,
                    title: '新增',
                    title: I18n.t('add'),
                    maxmin: true,
                    area: ['500px', top.detailHeight],
                    area: ['2000px', top.detailHeight],
                    shadeClose: false,
                    content: 'locMast_detail.html',
                    success: function(layero, index){
@@ -147,9 +166,9 @@
            case 'deleteData':
                var data = checkStatus.data;
                if (data.length === 0){
                    layer.msg('请选择数据');
                    layer.msg(I18n.t('please_select_data'));
                } else {
                    layer.confirm('确定删除'+(data.length===1?'此':data.length)+'条数据吗', function(){
                    layer.confirm(I18n.t('confirm_delete_prefix') + (data.length===1 ? I18n.t('this') : data.length) + I18n.t('confirm_delete_suffix'), function(){
                        $.ajax({
                            url: baseUrl+"/locMast/delete/auth",
                            headers: {'token': localStorage.getItem('token')},
@@ -171,7 +190,7 @@
                }
                break;
            case 'exportData':
                layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){
                layer.confirm(I18n.t('confirm_export_excel'), {shadeClose: true}, function(){
                    var titles=[];
                    var fields=[];
                    obj.config.cols[0].map(function (col) {
@@ -209,12 +228,12 @@
                });
                break;
            case "init":
                layer.prompt({title: '请输入口令,并重置库位', formType: 1,   shadeClose: true}, function(pass, idx){
                layer.prompt({title: I18n.t('please_enter_password_reset_location'), formType: 1,   shadeClose: true}, function(pass, idx){
                    http.get(baseUrl+"/locMast/init/pwd", {pwd: pass}, function (res) {
                        if (res.data) {
                            layer.open({
                                type: 1,
                                title: '初始化库位',
                                title: I18n.t('init_location'),
                                area: ["400px"],
                                maxmin: true,
                                shadeClose: true,
@@ -224,7 +243,7 @@
                                }
                            })
                        } else {
                            layer.msg("口令错误");
                            layer.msg(I18n.t('password_error'));
                        }
                        layer.close(idx);
                    })
@@ -232,6 +251,36 @@
                break;
        }
    });
    // 翻译详情数据
    function translateDetailData(data) {
        var newData = $.extend({}, data);
        // 翻译 locSts
        if (newData.locSts) {
            var key = 'loc_status_' + newData.locSts;
            var text = I18n.t(key);
            if (text !== key) {
                newData.locSts$ = text;
            }
        }
        // 翻译 whsType
        if (newData.whsType) {
            var map = {
                '1': 'standard_crane_whs',
                '2': 'flat_whs',
                '3': 'shuttle_board',
                '4': 'four_way_vehicle',
                '5': 'agv'
            };
            var key = map[newData.whsType];
            if (key) {
                newData.whsType$ = I18n.t(key);
            }
        }
        return newData;
    }
    // 监听行工具事件
    table.on('tool(locMast)', function(obj){
@@ -241,7 +290,7 @@
            case 'detail':
                layer.open({
                    type: 2,
                    title: '详情',
                    title: I18n.t('detail'),
                    maxmin: true,
                    area: [top.detailWidth, top.detailHeight],
                    shadeClose: false,
@@ -261,9 +310,9 @@
            case 'edit':
                layer.open({
                    type: 2,
                    title: '修改',
                    title: I18n.t('modify'),
                    maxmin: true,
                    area: ['500px', top.detailHeight],
                    area: ['700px', '600px'],
                    shadeClose: false,
                    content: 'locMast_detail.html',
                    success: function(layero, index){
@@ -280,11 +329,11 @@
            case 'whsType':
                var param = top.reObject(data).whsType;
                if (param === undefined) {
                    layer.msg("无数据");
                    layer.msg(I18n.t('no_data_found'));
                } else {
                   layer.open({
                       type: 2,
                       title: '库位详情',
                       title: I18n.t('location_detail'),
                       maxmin: true,
                       area: [top.detailWidth, top.detailHeight],
                       shadeClose: false,
@@ -316,11 +365,11 @@
            case 'modiUser':
                var param = top.reObject(data).modiUser;
                if (param === undefined) {
                    layer.msg("无数据");
                    layer.msg(I18n.t('no_data_found'));
                } else {
                   layer.open({
                       type: 2,
                       title: '修改详情',
                       title: I18n.t('modify_detail'),
                       maxmin: true,
                       area: [top.detailWidth, top.detailHeight],
                       shadeClose: false,
@@ -353,11 +402,11 @@
            case 'appeUser':
                var param = top.reObject(data).appeUser;
                if (param === undefined) {
                    layer.msg("无数据");
                    layer.msg(I18n.t('no_data_found'));
                } else {
                   layer.open({
                       type: 2,
                       title: '创详情',
                       title: I18n.t('create_detail'),
                       maxmin: true,
                       area: [top.detailWidth, top.detailHeight],
                       shadeClose: false,
@@ -563,6 +612,10 @@
                pageCurr -= 1;
            }
            limit(child);
            if (typeof I18n !== 'undefined') {
                I18n.updatePage();
                I18n.updateLayuiPagination();
            }
        }
    });
}