jiazx0107@163.com
2023-07-04 785ce007ce4b7b2119a99aacc95cefe9da09e32e
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
var layer;
var form;
var snapData;//登记照片
 
$(function () {
    layui.use(['layer', 'laydate', 'form', 'util'], function () {
        var util = layui.util;
        var laydate = layui.laydate;
        layer = layui.layer;
        form = layui.form;
        laydate.render({
            elem: '#userBirthday'
        });
 
        // 右下角添加固定信息
        util.fixbar({
            bar1: true,
            css: {
                right: 10,
                bottom: 20
            },
            bgcolor: '#53adce',
            click: function (type) {
                if (type === 'bar1') {
                    layer.closeAll();
                    layer.open({
                        type: 2,
                        title: false,
                        shadeClose: true,
                        shade: 0.3,
                        closeBtn: 2,
                        offset: ['50px','50px'],
                        area: ['1000px', '640px'],
                        content: '../../basic/inout/inout-progress?type=' + type + "&t=" + Math.random()
                    });
                }
            }
        });
 
    });
 
    showProgress();
 
    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
    initWS(deptId, bizType, progress, userId);
});
 
window.onload = function () {
    // 加载视频
    initVideo(lprDto, null, null);
};
 
 
//控制流程环节显示
function showProgress() {
    if (!inoutProgress) {
        return;
    }
    if (inoutProgress.indexOf("REGISTER") == -1) {
        $("#progress-register").css("display", "none");
    }
    if (inoutProgress.indexOf("WEIGHT_FULL") == -1) {
        $("#progress-fullWeight").css("display", "none");
    }
    if (inoutProgress.indexOf("HANDLE") == -1) {
        $("#progress-hand").css("display", "none");
    }
    if (inoutProgress.indexOf("WEIGHT_EMPTY") == -1) {
        $("#progress-emptyWeight").css("display", "none");
    }
    if (inoutProgress.indexOf("CARD_BACK") == -1) {
        $("#progress-cardBack").css("display", "none");
    }
}
 
// socket信息返回處理
function socketOnMessage(packet) {
 
};
 
//使用插件读取身份证
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);
            var data = json.content;
            if (data === "not found") {
                layer.alert("没有获取到身份证信息!", {
                    offset: ['300px', '300px']
                });
                return;
            }
            // 临时赋值
            $("#userName").val(data.cnName);
            $("#userSex").val(data.sex);
            $("#userNation").val(data.nation);
            $("#userAddress").val(data.address);
            //$("#id_img_pers").attr("src",data.Image);
            var time = data.birthdate;
            if (time.length == 8) {
                time = time.substring(0, 4) + "-" + time.substring(4, 6) + "-" + time.substring(6);
            }
            $("#userBirthday").val(time);
            $("#userId").val(data.idNum);
            if (data.Image) {
                $("#id_img_pers").attr("src", data.Image);
            }
        },
        error: function () {
            layer.alert("身份证读取失败!", {
                offset: ['300px', '300px']
            });
            layer.close(index);
        }
    });
}
 
 
//使用插件读取智慧卡号
function flushICCard() {
    $("#intelCard").val(null);
    $.ajax({
        type: "GET",
        async: true,
        url: "http://127.0.0.1:9111/ICCARD",
        data: {},
        dataType: "jsonp",
        jsonp: "callback",
        jsonpCallback: "jsonpCallback",
        success: function (json) {
            //console.log(json);
            var data = json.no;
            //console.log(data);
            if (data === "not found") {
                layer.alert("请重新读卡!", {offset: ['300px', '300px']});
            } else {
                $("#intelCard").val(data);
            }
        },
        error: function () {
            layer.alert("IC卡读取出错!", {offset: ['300px', '300px']});
        }
    });
}
 
//读取车牌号
function flushPlateNum() {
    var param = JSON.stringify(lprDto);
    var index = layer.load();
    $.ajax({
        type: "POST",
        url: "../../inout/api/flush-lpr",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: param,
        success: function (result) {
            if (result.code != "0000") {
                layer.alert(result.msg, {
                    offset: ['300px', '300px']
                });
            } else {
                if (result.data.errorMsg) {
                    layer.alert(result.data.errorMsg, {
                        offset: ['300px', '300px']
                    });
                } else {
                    $("#plateNum").val(result.data.plateNum);
                }
            }
            layer.close(index);
        },
        error: function () {
            layer.close(index);
            layer.alert("车牌识别失败!", {
                offset: ['300px', '300px']
            });
        }
    });
}
 
///重置车牌识别信息
function resetPlateNum() {
    var index = layer.load();
    var param = JSON.stringify(lprDto);
    $.ajax({
        type: "POST",
        url: "../../inout/api/reset-lpr",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: param,
        success: function (result) {
            if (result.code != "0000") {
                layer.alert(result.msg, {
                    offset: ['300px', '300px']
                });
            } else {
                layer.alert("重置成功,请重新获取车牌信息", {
                    offset: ['300px', '300px']
                });
            }
            layer.close(index);
        },
        error: function () {
            layer.close(index);
            layer.alert("重置执行失败", {
                offset: ['300px', '300px']
            });
        }
    });
}
 
// 表单清空
function resetForm() {
    $("#form-data")[0].reset();
    form.render();
    // 身份证重置
    $("#id_img_pers").attr("src", "../../static/images/rkbk-photo_03.png");
    $("#pz-img").removeClass("kccz-r-img-red");
    $("#pz-text").text("自动抓拍");
}
 
// 当前完成
function submit() {
    var data = form.val("form-data");
    if (!data.userName) {
        notify("承运人信息不能为空", null);
        return;
    }
    if (!data.plateNum) {
        notify("车牌号不能为空", null);
        return;
    }
    if (!data.intelCard && !data.userId) {
        notify("智慧卡号与身份证号不能同时为空", null);
        return;
    }
 
    //系统抓拍
    layer.msg("系统自动抓拍记录……");
    snapData = {
        companyId: companyId,
        deptId: deptId,
        progress: progress,
        bizType: bizType,
        plateNum: data.plateNum,
        id1: (null != lprDto) ? lprDto.id : null
    };
    $.ajax({
        sync: false,
        type: "POST",
        url: "../../inout/api/snap-img",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(snapData),
        success: function (result) {
            if (result.code != "0000") {
                layer.alert(result.msg);
                submitData(data);
            } else {
                snapData = result.data;
 
                $("#pz-img").addClass("kccz-r-img-red");
                $("#pz-text").text("已拍照");
 
                submitData(data);
            }
        },
        error: function () {
            layer.msg("后台调用截图失败,请重新尝试!!");
            submitData(data);
        }
    });
}
 
//执行保存数据
function submitData(data) {
    var index = layer.load();
 
    var files = [{
        fileName: snapData.fileName1
    }];
    data.files = files;
 
    $.ajax({
        type: "POST",
        url: "../../basic/inout/inout-next-step",
        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']});
    }
}