自动化立体仓库 - WMS系统
lty
2 天以前 d907a822a940c7ec0fb7de0ca845472bda52229b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
var pageCurr = 0;
var tableIns;
 
function getCol() {
    var cols = [
        {field: 'locNo', align: 'center',title: typeof I18n !== 'undefined' ? I18n.t('location_no') : '库位号', merge: true, style: 'font-weight: bold'}
    ];
    var dCols = [];
    if (typeof getDetlCols === 'function') {
        dCols = getDetlCols();
    } else {
        dCols = typeof detlCols !== 'undefined' ? detlCols.slice() : [];
    }
    cols.push.apply(cols, dCols);
    return cols;
}
 
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).use(['table','laydate', 'form', 'tableMerge'], function() {
    var table = layui.table;
    var $ = layui.jquery;
    var form = layui.form;
    var tableMerge = layui.tableMerge;
 
    window.initTable = function() {
        // 数据渲染
        tableIns = table.render({
            elem: '#locMatCode',
            headers: {token: localStorage.getItem('token')},
            // url: baseUrl+'/locDetl/list/auth',
            data:[],
            page: true,
            limit: 16,
            limits: [16, 50, 100, 200, 500],
            even: true,
            cellMinWidth: 50,
            cols: [getCol()],
            text: {
                none: typeof I18n !== 'undefined' ? I18n.t('no_data') : '暂无相关数据'
            },
            request: {
                pageName: 'curr',
                pageSize: 'limit'
            },
            parseData: function (res) {
                return {
                    'code': res.code,
                    'msg': res.msg,
                    'count': res.data.total,
                    'data': res.data.records
                }
            },
            response: {
                statusCode: 200
            },
            done: function(res, curr, count) {
                tableMerge.render(this);
                if (res.code === 403) {
                    top.location.href = baseUrl+"/";
                }
                pageCurr=curr;
                limit();
                clearSelect();
                if (typeof I18n !== 'undefined') {
                    I18n.updatePage();
                    setTimeout(function() {
                        I18n.updateLayuiPagination();
                    }, 50);
                }
            }
        });
    };
 
    if (typeof I18n !== 'undefined' && I18n.isReady()) {
        initTable();
    } else {
        $(document).on('i18n:ready', initTable);
    }
 
    $(document).on('i18n:languageChanged', function() {
        initTable();
        $('[data-i18n-placeholder]').each(function() {
            var key = $(this).attr('data-i18n-placeholder');
            $(this).attr('placeholder', I18n.t(key));
        });
        I18n.updatePage();
        form.render('select');
    });
 
});
 
// 搜索库位物料
function getLoc(el) {
    tableIns.reload({
        url: baseUrl+'/manLocDetl/list'
        , where: {loc_no: el.value}
        , done:function (res) {
            limit();
            clearSelect();
            // 获取同一堆垛机的空库位
            http.post(baseUrl + "/work/empty/stock", {sourceLocNo: el.value}, function (res) {
                if (res.data != null) {
                    var tpl = $("#emptyLocStock").html();
                    var template = Handlebars.compile(tpl);
                    var html = template(res);
                    $('#targetLocNo').append(html);
                    layui.form.render('select');
                }
            });
        }
    });
}
 
// 移库启动
function locMove() {
    var sourceLocNo = $("#sourceLocNo").val();
    var targetLocNo = $("#targetLocNo").val();
    if (sourceLocNo === null || sourceLocNo === ""){
        $("#sourceLocNo").css("border-color", "red");
        setTimeout(function () {
            $("#sourceLocNo").css("border-color", "#b8b8b8");
        }, 1000);
        layer.msg("请输入源库位");
        return;
    }
    if (targetLocNo === null || targetLocNo === "") {
        $(".layui-select-title .layui-input").css("border-color", "red");
        setTimeout(function () {
            $(".layui-select-title .layui-input").css("border-color", "#b8b8b8");
        }, 1000);
        layer.msg("请输入目标库位");
        return;
    }
    $.ajax({
        url: baseUrl + "/work/move/start",
        headers: {'token': localStorage.getItem('token')},
        dataType: 'json',
        data: {
            sourceLocNo: sourceLocNo,
            targetLocNo: targetLocNo
        },
        method: 'POST',
        success: function (res) {
            if (res.code === 200) {
                $("#sourceLocNo").val("");
                $("#targetLocNo").empty();
                layui.form.render('select');
                tableIns.reload({
                    data: [],
                    url: '',
                    done:function (res) {
                        limit();clearSelect();
                    }
                });
                layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2});
            } else if (res.code === 403) {
                top.location.href = baseUrl + "/";
            } else {
                layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2});
            }
        }
    })
}
 
function clearSelect() {
    $("#targetLocNo").empty();
    layui.form.render('select');
}