自动化立体仓库 - WMS系统
lty
2026-01-22 35b1b26f1fe16550b4ee2881a26d599456fe59b4
src/main/webapp/static/js/mat/mat.js
@@ -4,16 +4,16 @@
function getCol() {
    var cols = [
        {type: 'checkbox'}
        ,{field: 'tagId$', align: 'center',title: '归类', templet: '#tagTpl'}
        ,{field: 'store_max', align: 'center',title: '库存上限'}
        ,{field: 'store_min', align: 'center',title: '库存下限'}
        ,{field: 'store_max_date', align: 'center',title: '库龄上限(天)'}
        ,{field: 'areaId$', align: 'center',title: '区域', templet: '#areaTpl'}
        ,{field: 'tagId$', align: 'center',title: I18n.t('classification'), templet: '#tagTpl'}
        ,{field: 'store_max', align: 'center',title: I18n.t('stock_upper_limit')}
        ,{field: 'store_min', align: 'center',title: I18n.t('stock_lower_limit')}
        ,{field: 'store_max_date', align: 'center',title: I18n.t('stock_age_upper_limit_days')}
        ,{field: 'areaId$', align: 'center',title: I18n.t('area'), templet: '#areaTpl'}
    ];
    cols.push.apply(cols, matCols);
    cols.push.apply(cols, getMatCols());
    cols.push(
        {fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:150}
        {fixed: 'right', title: I18n.t('operation'), align: 'center', toolbar: '#operate', width:150}
    )
    return cols;
}
@@ -76,6 +76,26 @@
    });
    // 数据渲染
    var tableDone = 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';
            }
        });
        if (typeof I18n !== 'undefined') {
            I18n.updatePage();
            I18n.updateLayuiPagination();
        }
    };
    tableIns = table.render({
        elem: '#mat',
        headers: {token: localStorage.getItem('token')},
@@ -102,21 +122,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: tableDone
    });
    // 监听排序事件
@@ -132,13 +138,15 @@
            page: {
                curr: 1
            },
            done: function (res, curr, count) {
                if (res.code === 403) {
                    top.location.href = baseUrl+"/";
                }
                pageCurr=curr;
                limit();
            }
            done: tableDone
        });
    });
    // 监听语言切换
    $(document).on('i18n:languageChanged i18n:ready', function() {
        tableIns.reload({
            cols: [getCol()],
            done: tableDone
        });
    });
@@ -152,9 +160,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+"/mat/delete/auth",
                            headers: {'token': localStorage.getItem('token')},
@@ -176,7 +184,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) {
@@ -218,11 +226,11 @@
                printMatCodeNos = [];
                var data = checkStatus.data;
                if (data.length === 0){
                    layer.msg('请选择打印数据');
                    layer.msg(I18n.t('please_select_print_data'));
                } else {
                    layer.open({
                        type: 1,
                        title: '批量打印 [数量'+ data.length +']',
                        title: I18n.t('batch_print_count', {count: data.length}),
                        area: ['500px'],
                        shadeClose: true,
                        content: $('#printDataDiv'),
@@ -248,7 +256,7 @@
                printMatCodeNos = [];
                layer.open({
                    type: 1,
                    title: data.matnr + ' [数量:1]',
                    title: data.matnr + ' [' + I18n.t('count') + ':1]',
                    area: ['500px'],
                    shadeClose: true,
                    content: $('#printDataDiv'),
@@ -272,7 +280,7 @@
        admin.open({
            type: 1,
            area: '600px',
            title: (mData ? '修改' : '添加') + '商品',
            title: (mData ? I18n.t('edit') : I18n.t('add')) + I18n.t('material'),
            content: $('#editDialog').html(),
            success: function (layero, dIndex) {
                // 回显表单数据
@@ -289,7 +297,7 @@
                    data.field.tagId = insXmSel.getValue('valueStr');
                    data.field.areaId = areaXmSel.getValue('valueStr');
                    if (isEmpty(data.field.tagId)) {
                        layer.msg('分类不能为空', {icon: 2});
                        layer.msg(I18n.t('category_cannot_be_empty'), {icon: 2});
                        return false;
                    }
                    var loadIndex = layer.load(2);
@@ -334,8 +342,6 @@
                    }
                });
                // 渲染区域下拉选择
                console.log('准备渲染区域选择器,数据:', areaData);
                console.log('当前商品数据:', mData);
                var areaXmSel = xmSelect.render({
                    el: $(layero).find('#areaSel')[0],
                    height: '250px',
@@ -349,10 +355,8 @@
                    radio: true,
                    clickClose: true,
                    on: function(data) {
                        console.log('区域选择器事件:', data);
                    }
                });
                console.log('区域选择器渲染完成');
                // 弹窗不出现滚动条
                $(layero).children('.layui-layer-content').css('overflow', 'visible');
                layui.form.render('select');
@@ -392,6 +396,9 @@
                    var html = template(res);
                    var box = $("#box");
                    box.html(html);box.show();
                    if (typeof I18n !== 'undefined' && I18n.updatePage) {
                        I18n.updatePage(box[0]);
                    }
                    box.print({mediaPrint:true});
                    box.hide();
                } else if (res.code === 403){
@@ -445,7 +452,7 @@
        return;
    }
    var file = obj.files[0];
    admin.confirm('确认同步 [' + file.name +'] 文件吗?', function (index) {
    admin.confirm(I18n.t('confirm_sync_file', {filename: file.name}), function (index) {
        layer.load(1, {shade: [0.1,'#fff']});
        var url = baseUrl + "/mat/excel/import/auth";
        var form = new FormData();
@@ -514,6 +521,10 @@
                pageCurr -= 1;
            }
            limit(child);
            if (typeof I18n !== 'undefined') {
                I18n.updatePage();
                I18n.updateLayuiPagination();
            }
        }
    });
}