jiazx0107@163.com
2023-05-17 620eab6cca2bc9ef9ea6d3067a0a5ba1deadbd1c
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
//当前节点 入库登记
var layer;
var form;
var curCheckItems;//当前化验列表
var curCheckData = null;// 当前化验数据
var table;
 
$(function () {
    layui.use(['layer', 'laydate', 'form', 'table'], function () {
        var laydate = layui.laydate;
        layer = layui.layer;
        form = layui.form;
        table = layui.table;
        laydate.render({
            elem: '#userBirthday'
        });
 
        // 监听仓库选择,选择后自动调用仓库的粮品种和产地信息
        form.on('select(select_depotId)', function(obj) {
            updateFoodVarietyByDepot(obj.value);
        });
    });
 
    var rightH = $(".rkbk-left-wrap").height();
    $(".rkbk-right-wrap").height(rightH);
 
    $(window).resize(function () {
        var rightH = $(".rkbk-left-wrap").height();
        $(".rkbk-right-wrap").height(rightH);
    });
 
    // 初始化WebSocket
    initInoutWS(companyId, bizType, progress, userId);
 
});
 
//根据选择的仓库信息,更新粮食品种
function updateFoodVarietyByDepot(selectId) {
    var selectDepot;
    $.each(listDepot, function (index, data) {
        if (data.id === selectId) {
            selectDepot = data;
            return false;
        }
    });
 
    if (selectDepot) {
        form.val("form-data", {
            foodVariety: selectDepot.foodVariety,
            foodLevel: selectDepot.foodLevel,
            foodLocation: selectDepot.foodLocation
        });
        form.render();
    }
}
 
//使用自己插件获取省份证
function flushIdCard() {
    var index = layer.load();
    $.ajax({
        type: "GET",
        async: true,
        url: "http://127.0.0.1:9111/IDCARD",
        data: {},
        dataType: "jsonp",
        jsonp: "callback",
        jsonpCallback: "jsonpCallback",
        success: function (json) {
            layer.close(index);
            //console.log(json);
            var data = json.content;
            //console.log(data);
            if (data === "not found") {
                layer.alert("没有获取到身份证信息!", {
                    offset: ['300px', '300px']
                });
                return;
            }
            //data = JSON.parse(data);
            // 临时赋值
            $("#userName").val(data.cnName);
            $("#userSex").val(data.sex);
            $("#userNation").val(data.nation);
            $("#userAddress").val(data.address);
            $("#userBirthday").val(data.birthdate);
            $("#userId").val(data.idNum);
            //$("#id_img_pers").attr("src",data.Image);
        },
        error: function () {
            layer.alert("身份证读取失败!", {
                offset: ['300px', '300px']
            });
            layer.close(index);
        }
    });
}
 
// 表单清空
function resetForm() {
    $("#form-data")[0].reset();
    form.render();
 
    // 身份证重置
    $("#id_img_pers").attr("src", "../../static/images/rkbk-photo_03.png");
}
 
// 当前完成
function submit() {
    var data = form.val("form-data");
    if (!data.userName) {
        notify("承运人信息不能为空", null);
        return;
    }
    if (!data.userId) {
        notify("身份证号不能为空", null);
        return;
    }
    if (!data.plateNum) {
        notify("车船号不能为空", null);
        return;
    }
    if (!data.customerId) {
        notify("往来单位不能为空", null);
        return;
    }
    if (!data.depotId) {
        notify("装卸仓库不能为空", null);
        return;
    }
    if (!data.foodVariety) {
        notify("粮食品种不能为空", null);
        return;
    }
 
    data.checkItems = curCheckItems;
    // 合并更新當前编辑数据
    Object.assign(data, curCheckData);
 
    var index = layer.load();
 
    $.ajax({
        type: "POST",
        url: "../../basic/inout/inout-ship-register",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(data),
        success: function (result) {
            layer.close(index);
            if (result.code != "0000") {
                notify(result.msg, result.data);
            } else {
                notify("数据提交成功", result.data);
                // 重置页面
                resetForm();
            }
        },
        error: function () {
            layer.close(index);
            layer.alert("提交失败,请重新尝试!!");
        }
    });
}
 
 
/**
 * 弹出提醒框
 * @param msg 提醒信息
 * @param data 数据信息,可能为空
 */
function notify(msg, data) {
    if (data) {
        //赋值
        $("#resultMsg").text(msg);
        $("#resultUserName").text(data.userName);
        $("#resultPlateNum").text(data.plateNum);
        if ("IN" == data.type) {
            $("#resultType").text("入库-" + INOUT_PROGRESS_MSG(data.progress));
        } else {
            $("#resultType").text("出库-" + INOUT_PROGRESS_MSG(data.progress));
        }
        $("#resultIntelCard").text(data.intelCard);
 
        layer.open({
            type: 1,
            offset: ['150px', '200px'],
            area: '450px;',
            shade: 0.8,
            id: 'dialog_notify_info',
            btn: ['确定'],
            content: $('#dialog-from-notify'),
            yes: function (index) {
                layer.closeAll();
            }
        });
    } else {
        layer.alert(msg, {offset: ['300px', '300px']});
    }
}
 
// ---------------------------往来人员操作-开始 -------------------//
// 弹出往来单位下拉框
function showNotice() {
    var index = layer.load();
    var param = {
        type: type
    };
    // 渲染往来单位列表
    table.render({
        elem: '#tableNotice',
        url: '../../basic/inout/list-notice—out',
        page: false,
        // skin : "nob",
        // size : 'sm',
        even: true,
        method: 'POST',
        contentType: "application/json;charset=UTF-8",
        cols: [[{
            field: 'customerName',
            title: '收货单位'
        }, {
            field: 'depotName',
            title: '仓库名称',
            width: '20%'
        }, {
            field: 'foodVarietyName',
            title: '粮食品种',
            width: '20%'
        }, {
            field: 'year',
            title: '年份',
            width: '15%'
        }]],
        where: param,
        parseData: function (res) {
            if ("0000" == res.code) {
                return {
                    "code": "0",
                    "msg": res.msg,
                    "data": res.data
                }
            } else {
                return {
                    "code": "1",
                    "msg": res.msg
                }
            }
        },
        done: function (res) {
            layer.close(index);
        }
    });
 
    //双击显示选中数据
    table.on('rowDouble(tableNotice)', function (obj) {
        var data = obj.data;
        form.val("form-data", {
            customerId: data.customerId,
            customerName: data.customerName,
            noticeId: data.id,
            depotId: data.depotId,
            foodLevel: data.foodLevel,
            foodVariety: data.foodVariety
        });
        updateFoodVarietyByDepot(data.depotId);
        // 关闭
        layer.closeAll();
    });
 
    // 弹出对话框
    layer.open({
        type: 1,
        title: "出库通知单",
        area: ['700px', '600px'],
        shade: 0,
        content: $('#listNotice'),
        btn: 0,
        btn: ['取消'],
        yes: function () {
            layer.closeAll();
        },
        closeBtn: 0
    });
}
 
// ---------------------------粮食产地 -开始 -------------------//
// 弹出粮食产地下拉框
function showFoodLocation() {
    var index = layer.load();
    // 渲染往来单位列表
    table.render({
        elem : '#tableFoodLoaction',
        url : '../../basic/common/page-food-location',
        page : false,
        toolbar : '#toolbarFoodLocaton',
        even : true,
        method : 'POST',
        contentType : "application/json;charset=UTF-8",
        cols : [ [ {
            field : 'code',
            title : '编码'
        }, {
            field : 'simple',
            title : '简拼'
        }, {
            field : 'name',
            title : '名称',
            width : '60%'
        } ] ],
        where : {
            "page" : 1,
            "limit" : 100
        },
        parseData : function(res) {
            if ("0000" == res.code) {
                return {
                    "code" : "0",
                    "msg" : res.msg,
                    "count" : res.data.total,
                    "data" : res.data.records
                }
            } else {
                return {
                    "code" : "1",
                    "msg" : res.msg
                }
            }
        },
        done : function(res) {
            layer.close(index);
        }
    });
 
    //双击显示选中数据
    table.on('rowDouble(tableFoodLoaction)', function(obj){
        var data = obj.data;
        // 赋值
        form.val("form-data", {
            foodLocation : data.name,
        });
        // 关闭
        layer.close(index2);
    });
 
    // 弹出对话框
    var index2 = layer.open({
        type : 1,
        title : "选择粮产地",
        area : [ '600px', '600px' ],
        shade : 0,
        content : $('#listFoodLocation'),
        btn : 0,
        btn : [ '取消' ],
        yes : function() {
            // 关闭
            layer.close(index2);
        },
        closeBtn : 0
    });
 
}
 
// 刷新
function flushFoodLocation() {
    var key = $("#key2").val();
    table.reload('tableFoodLoaction', {
        url : "../../basic/common/page-food-location",
        where : {
            key : key
        },
        done : function(res) {
            if (key) {
                $("#key2").val(key);
            }
        }
    });
}