自动化立体仓库 - WMS系统
lty
3 天以前 8e943b7104561c3b14cf223016698709c5ade4b5
src/main/webapp/static/js/basWrkStatus/basWrkStatus.js
@@ -6,6 +6,35 @@
    var layDate = layui.laydate;
    var form = layui.form;
    // 定义列生成函数
    var getCol = function() {
        return [
            {type: 'checkbox', fixed: 'left'}
            ,{field: 'wrkSts', align: 'center', sort: true, title: I18n.t('code')}
            ,{field: 'wrkDesc', align: 'center', title: I18n.t('status_desc'), templet: function(d) {
                var key = 'wrk_status_' + d.wrkSts;
                var text = I18n.t(key);
                return text === key ? d.wrkDesc : text;
            }}
            ,{field: 'modiUser$', align: 'center', title: I18n.t('modifier')}
            ,{field: 'modiTime$', align: 'center', title: I18n.t('modify_time')}
            ,{fixed: 'right', title: I18n.t('operation'), align: 'center', toolbar: '#operate', width: 150}
        ];
    };
    // 定义通用done回调
    var tableDone = function(res, curr, count) {
        if (res.code === 403) {
            top.location.href = baseUrl + "/";
        }
        pageCurr = curr;
        limit();
        if (typeof I18n !== 'undefined') {
            I18n.updatePage();
            I18n.updateLayuiPagination();
        }
    };
    // 数据渲染
    tableIns = table.render({
        elem: '#basWrkStatus',
@@ -14,22 +43,10 @@
        page: true,
        limit: 16,
        limits: [16, 30, 50, 100, 200, 500],
        // skin: 'line',
        even: true,
        toolbar: '#toolbar',
        cellMinWidth: 50,
        cols: [[
            {type: 'checkbox', fixed: 'left'}
//            ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80}
            ,{field: 'wrkSts', align: 'center',sort:true,title: '代号'}
            ,{field: 'wrkDesc', align: 'center',title: '状态描述'}
            ,{field: 'modiUser$', align: 'center',title: '修改人员'}
            ,{field: 'modiTime$', align: 'center',title: '修改时间'}
            // ,{field: 'appeUser$', align: 'center',title: '创建者',event: 'appeUser', style: 'text-decoration: underline;cursor:pointer'}
            // ,{field: 'appeTime$', align: 'center',title: '添加时间'}
            ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:150}
        ]],
        cols: [getCol()],
        request: {
            pageName: 'curr',
            pageSize: 'limit'
@@ -45,13 +62,7 @@
        response: {
            statusCode: 200
        },
        done: function(res, curr, count) {
            if (res.code === 403) {
                top.location.href = baseUrl+"/";
            }
            pageCurr=curr;
            limit();
        }
        done: tableDone
    });
    // 监听排序事件
@@ -67,13 +78,16 @@
            page: {
                curr: 1
            },
            done: function (res, curr, count) {
                if (res.code === 403) {
                    top.location.href = baseUrl+"/";
                }
                pageCurr=curr;
                limit();
            }
            cols: [getCol()],
            done: tableDone
        });
    });
    // 监听语言切换
    $(document).on('i18n:languageChanged i18n:ready', function() {
        tableIns.reload({
            cols: [getCol()],
            done: tableDone
        });
    });
@@ -84,7 +98,7 @@
            case 'addData':
                layer.open({
                    type: 2,
                    title: '新增',
                    title: I18n.t('add'),
                    maxmin: true,
                    area: ['500px', top.detailHeight],
                    shadeClose: false,
@@ -100,16 +114,17 @@
                tableIns.reload({
                    page: {
                        curr: pageCurr
                    }
                    },
                    done: tableDone
                });
                limit();
                break;
            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'), {title: I18n.t('info')}, function(){
                        $.ajax({
                            url: baseUrl+"/basWrkStatus/delete/auth",
                            headers: {'token': localStorage.getItem('token')},
@@ -123,7 +138,7 @@
                                } else if (res.code === 403){
                                    top.location.href = baseUrl+"/";
                                } else {
                                    layer.msg(res.msg)
                                    layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2})
                                }
                            }
                        })
@@ -131,7 +146,7 @@
                }
                break;
            case 'exportData':
                layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){
                layer.confirm(I18n.t('confirm_export'), {title: I18n.t('info'), shadeClose: true}, function(){
                    var titles=[];
                    var fields=[];
                    obj.config.cols[0].map(function (col) {
@@ -162,7 +177,7 @@
                            } else if (res.code === 403) {
                                top.location.href = baseUrl+"/";
                            } else {
                                layer.msg(res.msg)
                                layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2})
                            }
                        }
                    });
@@ -179,7 +194,7 @@
            case 'detail':
                layer.open({
                    type: 2,
                    title: '详情',
                    title: I18n.t('detail'),
                    maxmin: true,
                    area: [top.detailWidth, top.detailHeight],
                    shadeClose: false,
@@ -198,7 +213,7 @@
            case 'edit':
                layer.open({
                    type: 2,
                    title: '修改',
                    title: I18n.t('edit'),
                    maxmin: true,
                    area: ['500px', top.detailHeight],
                    shadeClose: false,
@@ -216,11 +231,11 @@
            case 'modiUser':
                var param = top.reObject(data).modiUser;
                if (param === undefined) {
                    layer.msg("无数据");
                    layer.msg(I18n.t('no_data'));
                } else {
                   layer.open({
                       type: 2,
                       title: '修改详情',
                       title: I18n.t('modifier_detail'),
                       maxmin: true,
                       area: [top.detailWidth, top.detailHeight],
                       shadeClose: false,
@@ -241,7 +256,7 @@
                                   } else if (res.code === 403){
                                       parent.location.href = "/";
                                   }else {
                                       layer.msg(res.msg)
                                       layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2})
                                   }
                               }
                           })
@@ -252,11 +267,11 @@
            case 'appeUser':
                var param = top.reObject(data).appeUser;
                if (param === undefined) {
                    layer.msg("无数据");
                    layer.msg(I18n.t('no_data'));
                } else {
                   layer.open({
                       type: 2,
                       title: '创详情',
                       title: I18n.t('creator_detail'),
                       maxmin: true,
                       area: [top.detailWidth, top.detailHeight],
                       shadeClose: false,
@@ -276,7 +291,7 @@
                                   } else if (res.code === 403){
                                       parent.location.href = "/";
                                   }else {
                                       layer.msg(res.msg)
                                       layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2})
                                   }
                               }
                           })
@@ -331,7 +346,7 @@
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                }else {
                    layer.msg(res.msg)
                    layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2})
                }
                layer.close(index);
            }
@@ -394,48 +409,10 @@
                pageCurr -= 1;
            }
            limit(child);
        }
    });
}
function setFormVal(el, data, showImg) {
    for (var val in data) {
        var find = el.find(":input[id='" + val + "']");
        find.val(data[val]);
        if (showImg){
            var next = find.next();
            if (next.get(0)){
                if (next.get(0).localName === "img") {
                    find.hide();
                    next.attr("src", data[val]);
                    next.show();
                }
            var i18nObj = child ? parent.I18n : I18n;
            if (typeof i18nObj !== 'undefined') {
                 i18nObj.updateLayuiPagination();
            }
        }
    }
}
function clearFormVal(el) {
    $(':input', el)
        .val('')
        .removeAttr('checked')
        .removeAttr('selected');
}
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);
    }
    layer.style(index, {
//        top: (($(window).height()-height)/3)+"px",
        height: height+'px'
    });
}
$('body').keydown(function () {
    if (event.keyCode === 13) {
        $("#search").click();
    }
});
}