自动化立体仓库 - WMS系统
pang.jiabao
2025-02-25 6b218973dcf03a3601373ebe13fddd7a8896d68f
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
/**
 * 搜索自动补全 -- 局外点击隐藏
 */
$(function(){
    $(document).on("click",function(e){
        if(!$(e.target).parents(".cool-auto-complete").length){
            $(".cool-auto-complete-window").hide();
        }
    });
});
 
 
/**
 * 搜索自动补全 -- div
 */
function autoShow(id) {
    var cac = document.getElementById(id).parentNode;
    var cacw = cac.getElementsByClassName("cool-auto-complete-window")[0];
    if (cacw.style.display === "none" || cacw.style.display === ""){
        cacw.style.display = "block";
        var cacwi = cacw.getElementsByClassName("cool-auto-complete-window-input")[0];
        cacwi.focus();
        autoLoad(cacwi.getAttribute('data-key'));
    }else {
        cacw.style.display = "none";
    }
}
 
function test() {
 
}
 
/**
 * 搜索自动补全 -- input
 */
function autoLoad(val) {
    var inputDomVal = document.querySelector("input[data-key="+val+"]").value;
    var selectDom = document.querySelector("select[data-key="+val+"Select]");
    var type = document.querySelector("input[data-key="+val+"]").getAttribute('data-value');
    if(type){
        inputDomVal = inputDomVal + "," + type;
    }
    if(getForeignKeyQuery(val) === 'orderDetlQuery'){
        inputDomVal = inputDomVal + "," + $('#orderNo').val();
    }
    //debugger;
    selectDom.length = 0;
    var defaultOption = new Option("取消选择", "");
    defaultOption.title = "";
    selectDom.appendChild(defaultOption);
    selectDom.style.display='none';
    $.ajax({
        url: baseUrl+"/"+getForeignKeyQuery(val)+"/auth",
        headers: {'token': localStorage.getItem('token')},
        data: {condition: inputDomVal},
        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);
                    option.title = list[i].id;
                    option.addr = list[i].addr;
                    option.phone = list[i].phone;
                    option.customer = list[i].customer;
                    option.allocate = list[i].allocate;
                    option.weight =  list[i].weight;
                    option.type = list[i].type;
                    selectDom.options[i+1] = option;
                }
                selectDom.style.display='block';
            } else if (res.code === 403){
                top.location.href = baseUrl+"/";
            } else {
                layer.msg(res.msg)
            }
        }
    });
}
 
/**
 * 搜索自动补全 -- select
 */
function confirmed(val){
    var inputDom = $("input[data-key="+val.substring(0,val.length - 6)+"]");
    var selectDom = $("select[data-key="+val+"]");
 
    selectDom.dblclick(function(){
        inputDom.focus();
        selectDom.css("display","none");
    });
 
    // 修饰字段
    var cacw = inputDom.parent();
    cacw.css("display", "none");
    var cacd = cacw.parent().find(".cool-auto-complete-div");
    var realDom = cacd.prev();
    // id字段
    var selectOptionDom = selectDom.find("option:selected");
    var html = selectOptionDom.html();
    if (html === "取消选择"){
        cacd.val("");
        realDom.val("");
    } else {
        cacd.val(selectOptionDom.html());
        realDom.val(selectOptionDom.attr("title"));
        if(selectOptionDom[0].type === "docType"){
            $('#weight').val("");
            $('#maktxV').val("");
        }
        if(selectOptionDom[0].type === "order" || selectOptionDom[0].type === "locOwner"){
            $('#allocate').val(selectOptionDom[0].allocate ? selectOptionDom[0].allocate : "");
            $('#customer').val(selectOptionDom[0].customer ? selectOptionDom[0].customer : "");
            $('#phone').val(selectOptionDom[0].phone ? selectOptionDom[0].phone : "");
            $('#addr').val(selectOptionDom[0].addr ? selectOptionDom[0].addr : "");
        }
        if(selectOptionDom[0].type === "returned"){
            $('#customer').val(selectOptionDom[0].customer ? selectOptionDom[0].customer : "");
            tableReload();
        }
 
        if(selectOptionDom[0].type === "orderDetl"){
            $('#weight').val(selectOptionDom[0].weight);
            // 根据牌号选择进行过滤
            checkData = firstData.filter(item => item.brand === $('#maktxV').val())
            var allWeight = 0;
            for (var i in checkData){
                allWeight += (checkData[i].weightAnfme - checkData[i].qtyAnfme)
            }
            // 根据牌号重新渲染
            $('#qtyWeight').val(allWeight);
        }
    }
    inputDom.val("");
}
 
function tableReload(){
    layui.use(['table','laydate', 'form'], function(){
        var form = layui.form;
        var layer = layui.layer;
        var table = layui.table;
        var orderNo = $('#orderNoV').val();
        table.render({
            elem: '#formSSXMTable',
            height: 312,
            headers: {token: localStorage.getItem('token')},
            url: baseUrl+'/plaQty/orderDetail/auth',
            where: {
                orderNo: orderNo
            },
            page: true,
            limit: 16,
            limits: [16, 30, 50, 100, 200, 500],
            cols: [[
                {type: 'checkbox'},
                {field: 'id', title: 'id', hide:true},
                {field: 'batch', title: '批号'},
                {field: 'packageNo', title: '包号'},
                {field: 'orderWeight', title: '重量',edit:true}
 
            ]],
            request: {
                pageName: 'curr',
                pageSize: 'limit'
            },
            parseData: function (res) {
                console.log(res)
                return {
                    'code': res.code,
                    'msg': res.msg,
                    'count': res.data.total,
                    'data': res.data
                }
            },
            response: {
                statusCode: 200
            },
            done: function(res, curr, count) {
                if (res.code === 403) {
                    top.location.href = baseUrl+"/";
                }
                tableData = table.cache.locDetl;
                console.log(tableData);
                pageCurr=curr;
                limit();
                form.on('checkbox(tableCheckbox)', function (data) {
                    var _index = $(data.elem).attr('table-index')||0;
                    if(data.elem.checked){
                        res.data[_index][data.value] = 'Y';
                    }else{
                        res.data[_index][data.value] = 'N';
                    }
                });
            }
        });
    })
 
}
 
function reviewImg(src) {
    window.open().document.write("<img src="+src+" />");
}
 
/**
 * 截取By之前的字符串
 */
function getForeignKeyQuery(str) {
    var index = str.indexOf('By');
    if (index !== -1){
        return str.substring(0, index);
    }
    return str;
}
 
// 表单值清空
function clearFormVal(el) {
    $(':input', el)
        .val('')
        .removeAttr('checked')
        .removeAttr('selected');
}
 
var banMsg;
var tips;
// 主键校验
function check(id, domain) {
    var param = {
        key: id,
        val: $('#'+id).val()
    };
    $.ajax({
        url: baseUrl+"/"+domain+"/check/column/auth",
        headers: {'token': localStorage.getItem('token')},
        data: JSON.stringify(param),
        dataType:'json',
        contentType:'application/json;charset=UTF-8',
        method: 'POST',
        success: function (res) {
            if (res.code === 200) {
                layer.close(tips);
                banMsg = null;
            } else if (res.code === 403) {
                top.location.href = baseUrl+"/";
            } else if (res.code === 407) {
                banMsg = res.data + "不可用";
                tips = layer.tips(
                    "<span style='color:red;'>已存在</span>",
                    '#'+id,
                    {
                        // tipsMore: true,
                        tips: [2,'#fff'],
                        time:0
                        ,area: 'auto'
                        ,maxWidth:500
                    });
            }
        }
    });
}