自动化立体仓库 - WMS系统
whycq
2024-07-04 09a482e8fb4d4dac63aed1503fd91e738ddb070d
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
var matCodeData = []
var tableIns, tableInsLoc;
// 搜索条件-库位号
var locNo = ''
// 库存明细
var locData = []
var form = null
layui.use(['table', 'form'], function () {
    var table = layui.table
    var $ = layui.jquery
    form = layui.form;
 
    // 获取出库口
    function fetchSelect() {
        $.ajax({
            url: baseUrl + "/locCombOutStartCheckSite/site",
            headers: {'token': localStorage.getItem('token')},
            method: 'POST',
            success: function (res) {
                if (res.code === 200) {
                    var html = res.data.map((item) => {
                        return `<option value="${item}">${item}</option>`
                    })
                    $('#putSiteSelect').append(html);
                    form.render('select');
                } else if (res.code === 403) {
                    top.location.href = baseUrl + "/";
                } else {
                    layer.msg(res.msg)
                }
            }
        })
    }
    // 加载出库口信息
    fetchSelect()
 
    // 库位物料
    tableInsLoc = table.render({
        elem: '#locDetail'
        , headers: {token: localStorage.getItem('token')}
        , url: baseUrl + '/locDetl/pageList/auth'
        , cols: [[ //标题栏
            {field: 'locNo', title: '库位', width: 120}
            , {field: 'maktx', title: '商品名', width: 300}
            , {field: 'matnr', title: '商品号', width: 200}
            , {field: 'specs', title: '规格', width: 300}
            , {field: 'anfme', title: '数量', width: 100}
        ]]
        , page: true //是否显示分页
        , request: {
            pageName: 'curr',
            pageSize: 'limit',
        },
        where: {'locNo': locNo}
        , limits: [5]
        , limit: 5, //每页默认显示的数量
        parseData: function (res) {
            if (res.code === 201) {
                return ''
            }
            locData = res.data.records
            return {
                'code': res.code,
                'msg': res.msg,
                'count': res.data.total,
                'data': res.data.records
            }
        },
        response: {
            statusCode: 200
        },
        done: function (res, curr, count) {
            if (res.code === 403) {
                top.location.href = baseUrl + "/";
            }
        }
    })
 
    // 新增物料
    tableIns = table.render({
        elem: '#chooseData',
        id: 'chooseData',
        data: [],
        limit: 500,
        cellMinWidth: 50,
        cols: [[
            {
                fixed: 'left',
                align: 'center',
                field: 'count',
                title: '数量',
                style: 'color: blue',
                width: 100,
                edit: 'text',
                width: 120,
                style: 'color: blue;font-weight: bold'
            },
            {field: 'matnr', align: 'center', title: '商品编号'},
            {field: 'maktx', align: 'center', title: '商品名称'},
            {field: 'specs', align: 'center', title: '规格'},
            {fixed: 'right', title: '操作', align: 'center', toolbar: '#operate', width: 200}
        ]]
    });
 
    // 监听table的移除事件
    table.on('tool(chooseData)', function (obj) {
        var data = obj.data;
        switch (obj.event) {
            case 'remove':
                const findIndex = matCodeData.findIndex(item => item.id === data.id)
                matCodeData.splice(findIndex, 1)
                tableIns.reload({data: matCodeData, limit: matCodeData.length});
                break;
        }
    });
 
    table.on('edit(chooseData)', function (obj) {
        matCodeData = matCodeData.map(item => {
            if (item.id === obj.data.id) {
                return {
                    ...item,
                    count: obj.value
                }
            }
            return item
        })
    });
 
    // 搜索按钮
    $("#searchFor").click(function () {
        table.reload('locDetail', {
            where: {'locNo': locNo},
            page: { // 分页参数
                curr: 1 // 重新从第一页开始
            },
            // 其他参数
        })
    })
})
// 获取输入框值
$("#locNo").on("input", function (e) {
    //获取input输入的值
    locNo = e.delegateTarget.value;
});
 
// 补料出库
$("#outbound").click(function () {
    if (locNo === "" || locNo.length != 7) {
        layer.msg("库位号错误");
        return;
    }
    //判断库位数据
    if (locData == null || locData.length === 0) {
        layer.msg("并板库位没有库存数据");
        return;
    }
    // 判断是否存在产品
    if (matCodeData.length === 0) {
        layer.msg("请先添加产品");
        return;
    }
    // 判断产品数量是否存在异常
    for (var i = 0; i < matCodeData.length; i++) {
        if (isNaN(matCodeData[i].count)) {
            layer.msg("请输入数字");
            return;
        }
        if (matCodeData[i].count === 0) {
            layer.msg("数量不能为零");
            return;
        }
    }
    // 判断出站口
    var outNo = $('#putSiteSelect').val()
    if (outNo.length === 0) {
        layer.msg("请选择出库口");
        return;
    }
 
    $.ajax({
        url: baseUrl + "/locComb/out/start",
        headers: {'token': localStorage.getItem('token')},
        data: JSON.stringify({
            locNo: locNo,
            devpNo: Number(outNo),
            list: matCodeData
        }),
        contentType: 'application/json;charset=UTF-8',
        method: 'POST',
        async: false,
        success: function (res) {
            if (res.code === 200) {
                layer.msg(res.msg);
                // 清空出库口选择
                $("#putSiteSelect").val('');
                form.render();
                // 清空输入的库位
                $("#locNo").val("");
                locNo = ''
                // 清空增加的明细数据
                matCodeData = [];
                tableIns.reload({data: []});
                // 清空库位明细数据
                tableInsLoc.reload({data: [], where: {'locNo': ''}});
                locData = []
            } else if (res.code === 403) {
                top.location.href = baseUrl + "/";
            } else {
                layer.msg(res.msg)
            }
        }
    })
})
 
// 提取物料
var matCodeLayerIdx;
 
// 打开商品弹窗
function getMat() {
    matCodeLayerIdx = layer.open({
        type: 2,
        title: '物料',
        shade: [0.3, '#000'],
        area: ['90%', '80%'],
        content: 'matQuery.html',
        success: function (layero, index) {
            $('.layui-layer-title').css('font-size', '16px');
        },
        end: function () {
            $('#addmatnr').focus();
        }
    });
}
 
// 打开商品弹窗
function getBomMat() {
    matCodeLayerIdx = layer.open({
        type: 2,
        title: 'Bom物料',
        shade: [0.3, '#000'],
        area: ['90%', '80%'],
        content: 'bomMatQuery.html',
        success: function (layero, index) {
            $('.layui-layer-title').css('font-size', '16px');
        },
        end: function () {
            $('#addBomMatnr').focus();
        }
    });
}
 
// 添加表格数据
var matData = [];
 
// 获取弹窗返回的值
function addTableData(data) {
    for (var i = 0; i < data.length; i++) {
        data[i]["count"] = 0
    }
    matCodeData = data
    // 对于options的各项参数有点迷惑,但是试了好多方法,发现加一条limit属性,取数据源长度即可
    tableIns.reload({data: matCodeData, limit: matCodeData.length});
    layer.close(matCodeLayerIdx);
}