自动化立体仓库 - WMS系统
zyx
2024-03-01 aa310a47a05110a393c508921c92fa17ea95b491
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
var initCountVal = 0;
var initAnfmeVal = "-";
var matCodeData = [];
var currLocNo;
var matCodeLayerIdx;
var data = [];
var checkStatus = [];
function getCol() {
    var cols = [
        {field: 'id', title: 'id', align: 'center',hide:true}
        ,{type: 'checkbox'}
        ,{field: 'pakinTime', title: '入库时间', align: 'center'}
        ,{field: 'batch', align: 'center',title: '批号', edit: true}
        ,{field: 'packageNo', align: 'center',title: '包号', edit: true}
        ,{field: 'brand', align: 'center',title: '牌号', edit: true}
        ,{field: 'weight', align: 'center',title: '重量(KG)', edit: true}
        ,{field: 'workshop', align: 'center',title: '生产车间', edit: true}
        ,{field: 'line', align: 'center',title: '生产线', edit: true}
        ,{field: 'packageType', align: 'center',title: '包装类型', edit: true}
        ,{field: 'zpalletType', align: 'center',title: '托盘类型', edit: true}
        ,{field: 'filmWrap', align: 'center',title: '缠膜', edit: true}
    ];
    return cols;
}
 
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).use(['table','laydate', 'form', 'admin'], function() {
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
    var layDate = layui.laydate;
    var form = layui.form;
    var admin = layui.admin;
 
    initSelector();
 
    tableIns = table.render({
        elem: '#productionInfoTable',
        data: [],
        even: true,
        limit: 500,
        cellMinWidth: 50,
        toolbar: '#toolbar',
        cols: [getCol()],
        done: function (res, curr, count) {
            limit();
        }
    });
 
 
    function initSelector(){
        $('#package').append('<option value="value">Text</option>');
 
        var selectDom = $('#package');
        $.ajax({
            url: baseUrl+"/configTypeQuery/auth",
            headers: {'token': localStorage.getItem('token')},
            data: {condition: ',packageType'},
            method: 'POST',
            traditional:true,
            success: function (res) {
                if (res.code === 200){
                    var list = res.data;
                    for (var i=0;i<list.length;i++){
                        var option = new Option(list[i].value, i);
                        selectDom.append($("<option></option>").attr("value",option["value"]));
                    }
 
                } else if (res.code === 403){
 
                }else {
                    layer.msg(res.msg, {icon: 2})
                }
            }
        })
        $('#packageCheck').val();
    }
 
    form.on('select(selectDemo1)', function (data) {
        debugger
        console.log(data.elem);
        var elem = $(data.elem);
        var trElem = elem.parents('tr');
        console.log(trElem);
        var tableData = table.cache.productionInfoTable; // 为table id
        console.log(tableData);
        // 更新到表格的缓存数据中,才能在获得选中行等等其他的方法中得到更新之后的值
        tableData[trElem.data('index')][elem.attr('name')] = data.value;
    });
 
    // 重置事件
    form.on('submit(reset)', function (data) {
        reset();
    });
 
    function reset() {
        clearFormVal($('#search-box'));
        matCodeData = [];
        tableReload();
        locTips(false);
    }
 
    // 重载表格
    function tableReload() {
        tableIns.reload({data: matCodeData});
    }
 
 
    $(document).on('click','#add', function () {
        var now = dateToStr(new Date())
        var newRow = {pakinTime : now};
        data = table.cache.productionInfoTable;
        data.push(newRow);
        table.reload('productionInfoTable',{
            data: data
        })
    })
 
    $(document).on('click','#delete', function () {
        let dataNew = [];
        let data = table.cache.productionInfoTable;
        for(var i=0; i<data.length; i++){
            if(!data[i].LAY_CHECKED){
                dataNew.push(data[i]);
            }
        }
        table.reload('productionInfoTable',{
            data: dataNew
        })
    })
 
    $(document).on('click','#submit', function () {
        let data = table.cache.productionInfoTable;
        let dataSave = [];
        let dataOld = [];
        for(var i=0; i<data.length; i++){
            if(data[i].LAY_CHECKED){
                if(!data[i].batch || !data[i].packageNo || !data[i].brand || !data[i].weight || !data[i].workshop || !data[i].line || !data[i].packageType || !data[i].zpalletType){
                    layer.msg("有未填写字段");
                    return;
                }
                data[i].step = 1;
                dataSave.push(data[i]);
            }else {
                dataOld.push(data[i]);
            }
        }
        if(!dataSave || dataSave.length < 1){
            layer.msg("未勾选提交项,无法提交");
            return;
        }
        $.ajax({
            url: baseUrl+"/pla/add/auth",
            headers: {'token': localStorage.getItem('token')},
            data: JSON.stringify(dataSave),
            contentType:'application/json;charset=UTF-8',
            method: 'POST',
            async: false,
            success: function (res) {
                if (res.code === 200){
                    layer.msg("提交成功");
                    table.reload('productionInfoTable',{
                        data: dataOld
                    })
                } else if (res.code === 403){
 
                }else {
                    layer.msg(res.msg, {icon: 2})
                }
            }
        })
    })
 
})