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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../static/css/cool.css" media="all">
    <link rel="stylesheet" href="../../static/css/common.css" media="all">
    <link rel="stylesheet" href="../../static/css/print.css" media="all">
 
</head>
<body>
<div>
    <div class="layui-form" style="padding: 8px">
        <span id="staNoSpan">出库口:</span>
        <div style="display: inline-block; width: 200px">
            <select id="staNoSelect" lay-verify="required">
                <option value="">请选择站点</option>
            </select>
        </div>
        <button class="layui-btn layui-btn-sm" style="display: inline-block" id="btn-outbound" lay-event="outbound"
                onclick="outbound()">启动出库
        </button>
    </div>
    <table class="layui-hide" id="stockOut" lay-filter="stockOut"></table>
</div>
 
<script type="text/template" id="takeSiteSelectTemplate">
    {{#each data}}
    <option value="{{siteId}}">{{desc}}</option>
    {{/each}}
</script>
 
</body>
<script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/js/handlebars/handlebars-v4.5.3.js"></script>
<script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script>
<script>
    var orderData = parent.getOrderData();
    var locData = [];
    var form;
 
 
    function getCol() {
        var cols = [
            {field: '', align: 'center', title: '', width: 50, type: 'numbers'}
            , {field: 'locNo$', align: 'center', title: '库位号'}
        ];
        cols.push.apply(cols, detlCols);
        cols.push({field: 'modiUser$', align: 'center', title: '修改人员', hide: true}
            , {field: 'modiTime$', align: 'center', title: '修改时间', hide: true})
        return cols;
    }
 
    layui.use(['table', 'laydate', 'form'], function () {
        var table = layui.table;
        var $ = layui.jquery;
        var layer = layui.layer;
        var layDate = layui.laydate;
        form = layui.form;
        // 数据渲染
        locDetlTableIns = table.render({
            elem: '#stockOut',
            headers: {token: localStorage.getItem('token')},
            url: baseUrl + '/outStock/query/locList?fbillNo=' + orderData.fbillNo,
            page: true,
            limit: 9999,
            limits: [9999],
            even: true,
//            cellMinWidth: 50,
            cols: [getCol()],
            request: {
                pageName: 'curr',
                pageSize: 'limit'
            },
            parseData: function (res) {
                return {
                    'data': res.data,
                    'code': res.code,
                }
            },
            response: {
                statusCode: 200
            },
            done: function (res, curr, count) {
                if (res.code === 403) {
                    top.location.href = baseUrl + "/";
                }
                locData = res.data;
            }
        });
 
        $.ajax({
            url: baseUrl + "/available/take/site",
            headers: {'token': localStorage.getItem('token')},
            method: 'POST',
            async: false,
            success: function (res) {
                if (res.code === 200) {
                    var tpl = $("#takeSiteSelectTemplate").html();
                    var template = Handlebars.compile(tpl);
                    var html = template(res);
                    $('#staNoSelect').append(html);
                    form.render('select');
                } else if (res.code === 403) {
                    top.location.href = baseUrl + "/";
                } else {
                    layer.msg(res.msg)
                }
            }
        });
    });
 
    /* 启动出库 */
    function outbound() {
        if (locData.length == 0) {
            layer.msg('请先添加库位物料');
            return;
        } else {
            var staNo = $("#staNoSelect").val();
            if (staNo === "" || staNo === null){
                layer.msg("请选择出库口");
                return;
            }
            var locDetls = [];
            locData.forEach(function(elem) {
                locDetls.push({locNo: elem.locNo, matnr: elem.matnr, count: elem.anfme});
            });
            let param = {
                outSite: staNo,
                locDetls: locDetls,
                fbillNo: orderData.fbillNo,
            }
 
            $.ajax({
                url: baseUrl+"/plate/outStock/start",
                headers: {'token': localStorage.getItem('token')},
                data: JSON.stringify(param),
                contentType:'application/json;charset=UTF-8',
                method: 'POST',
                success: function (res) {
                    if (res.code === 200){
                        parent.closeDetail(res.msg);
                    } else if (res.code === 403){
                        top.location.href = baseUrl+"/";
                    } else {
                        layer.msg(res.msg)
                    }
                }
            });
        }
    }
</script>
</html>