自动化立体仓库 - WMS系统
chen.llin
2025-12-24 75c252bce336b9f1bd024cc186ce09992a0b01bc
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
var insTbCount = 0;
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).use(['layer', 'form', 'table', 'util', 'admin', 'laydate'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var table = layui.table;
    var util = layui.util;
    var admin = layui.admin;
    var layDate = layui.laydate;
    var laytpl = layui.laytpl;
 
    // 渲染搜索模板
    $.ajax({
        url: baseUrl + "/docType/list/auth",
        headers: { 'token': localStorage.getItem('token') },
        data: {
            limit: 9999,
            pakout: 1
        },
        method: 'POST',
        success: function (res) {
            if (res.code === 200) {
                let template = Handlebars.compile($('#docTypeTpl').html());
                $('#docType-query').html(template(res.data));
                layui.form.render('select');
            } else if (res.code === 403) {
                top.location.href = baseUrl + "/";
            } else {
                layer.msg(res.msg, { icon: 2 })
            }
        }
    })
 
    // 渲染表格
    var insTb = table.render({
        elem: '#order',
        url: baseUrl + '/order/pakoutLog/order/head/page/auth',
        method: 'POST',
        headers: { token: localStorage.getItem('token') },
        page: true,
        cellMinWidth: 100,
        cols: [[
            { type: 'numbers' },
            { field: 'orderNo', title: '单据编号', templet: '#orderNoTpl' },
            { field: 'orderTime', align: 'center', title: '业务时间' },
            { field: 'cstmrName', align: 'center', title: '客户' },
            { field: 'docType$', align: 'center', title: '类型', minWidth: 160, width: 160 },
            { align: 'center', title: '明细', toolbar: '#tbLook', minWidth: 160, width: 160 },
            { field: 'createTime$', title: '创建时间', minWidth: 200, width: 200 },
            { field: 'settle$', align: 'center', title: '状态', templet: '#settleTpl', minWidth: 160, width: 160 },
            { field: 'memo', align: 'center', title: '备注', hide: true }
        ]],
        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) {
            limit();
            if (res.code === 403) {
                top.location.href = baseUrl + "/";
            }
            insTbCount = count;
        }
    });
 
    // 搜索
    form.on('submit(tbSearch)', function (data) {
        insTb.reload({ where: data.field, page: { curr: 1 } });
    });
 
    // 工具条点击事件
    table.on('tool(order)', function (obj) {
        var data = obj.data;
        var layEvent = obj.event;
        if (layEvent === 'wrkTrace') {
            showWrkTrace(data.id);
        } else if (layEvent === 'look') {
            var $a = $(obj.tr).find('a[lay-event="look"]');
            var offset = $a.offset();
            var top = offset.top;
            var left = offset.left;
            layer.open({
                type: 1,
                title: false,
                area: '820px',
                offset: [top + 'px', (left - 530 + $a.outerWidth()) + 'px'],
                shade: .01,
                shadeClose: true,
                fixed: false,
                content: '<table id="lookSSXMTable" lay-filter="lookSSXMTable"></table>',
                success: function (layero) {
                    table.render({
                        elem: '#lookSSXMTable',
                        method: 'POST',
                        headers: { token: localStorage.getItem('token') },
                        url: baseUrl + '/order/pakoutLog/orderDetl/list/auth',
                        where: {
                            order_id: data.id
                        },
                        page: true,
                        cellMinWidth: 100,
                        cols: [[
                            { type: 'numbers' },
                            { field: 'matnr', title: '商品编码', width: 160 },
                            { field: 'maktx', title: '商品名称', width: 160 },
                            { field: 'batch', title: '批号' },
                            { field: 'anfme', title: '数量' },
                            { field: 'workQty', title: '作业数量' },
                            { field: 'qty', title: '完成数量', style: 'font-weight: bold' },
                            { field: 'specs', title: '规格' }
                        ]],
                        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 () {
                            $(layero).find('.layui-table-view').css('margin', '0');
                        },
                        size: ''
                    });
                }
            });
        }
    });
 
    // 任务追溯
    function showWrkTrace(orderId) {
        let loadIndex = layer.msg('请求中...', { icon: 16, shade: 0.01, time: false });
        $.ajax({
            url: baseUrl + "/order/pakoutLog/order/wrk/trace/auth",
            headers: { 'token': localStorage.getItem('token') },
            data: {
                orderId: orderId
            },
            method: 'POST',
            success: function (res) {
                layer.close(loadIndex);
                if (res.code === 200) {
                    laytpl(wrkTraceDialog.innerHTML).render(res.data, function (html) {
                        admin.open({
                            type: 1,
                            title: '任务追溯',
                            area: ['800px', '450px'],
                            shadeClose: true,
                            content: html,
                            success: function (layero, dIndex) {
                                $(layero).children('.layui-layer-content').css('overflow', 'visible');
                                /** 统计图表 */
                                var traceCharts = echarts.init(document.getElementById('wrkTraceCharts'));
                                var traceOptions = {
                                    title: {
                                        text: '总量/作业/完成', x: 'center', y: '38%',
                                        textStyle: { fontSize: 18, color: '#262626', fontWeight: 'normal' },
                                        subtextStyle: { fontSize: 36, color: '#10B4E8' },
                                        itemGap: 20
                                    },
                                    color: ['#10B4E8', '#E0E0E0', '#FF0000'],
                                    tooltip: { trigger: 'item' },
                                    series: [{ name: '数量', type: 'pie', radius: ['75%', '80%'], label: { normal: { show: false } } }]
                                };
                                traceCharts.setOption(traceOptions);
                                // 赋值
                                traceCharts.setOption({
                                    title: {
                                        subtext: res.data.totalQty + "/" + res.data.wrkQty + "/" + res.data.endQty
                                    },
                                    series: [
                                        {
                                            data: [
                                                { name: '已作业', value: res.data.wrkQty },
                                                { name: '未作业', value: res.data.totalQty - res.data.wrkQty - res.data.lackQty },
                                                { name: '库存不足', value: res.data.lackQty },
                                            ]
                                        }
                                    ]
                                });
                            }
                        });
                    });
                } else if (res.code === 403) {
                    top.location.href = baseUrl + "/";
                } else {
                    layer.msg(res.msg, { icon: 2 });
                }
            }
        })
    }
 
    layDate.render({
        elem: '.layui-laydate-range'
        , type: 'datetime'
        , range: true
    });
});