jiazx0107@163.com
2023-06-08 08cea428e888b6fdd2a3c3783e87e4f828385783
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
//当前节点 入库登记
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
    initInoutWS(deptId, bizType, progress, userId);
});
 
window.onload = function () {
    initVideo(lprDto, null, null);
};
 
// 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") {
                alertError("没有获取到身份证信息!");
                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.close(index);
            alertError("身份证读取失败!");
        }
    });
}
 
//使用插件读取智慧卡号
function flushICCard() {
    var index = layer.load();
    $("#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) {
            layer.close(index);
            //console.log(json);
            var data = json.no;
            //console.log(data);
            if (data === "not found") {
                alertError("请重新读卡!");
            } else {
                $("#intelCard").val(data);
            }
        },
        error: function () {
            layer.close(index);
            alertError("IC卡读取出错!");
        }
    });
}
 
//读取车牌号
function getPlateNum() {
    var index = layer.load();
    $.ajax({
        type: "POST",
        url: "../../inout/api/get-plateNum",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(lprDto),
        success: function (result) {
            if (result.code != "0000") {
                alertError(result.msg);
            } else {
                $("#plateNum").val(result.data.plateNum);
                $("#plateNum2").val(result.data.plateNum);
            }
            layer.close(index);
        },
        error: function () {
            layer.close(index);
            alertError("车牌识别失败!");
        }
    });
}
 
// 表单清空
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");
}
 
// 当前完成
function submit() {
    var data = form.val("form-data");
    if (!data.userName) {
        alertError("承运人信息不能为空");
        return;
    }
    if (!data.plateNum) {
        alertError("车牌号不能为空");
        return;
    }
    if (!data.userId) {
        alertError("身份证号不能为空");
        return;
    }
 
    //系统抓拍
    layer.msg("系统自动抓拍记录……");
    snapData = {
        companyId: companyId,
        deptId: deptId,
        progress: progress,
        bizType: bizType,
        plateNum: data.plateNum,
        id1: lprDto.id
    };
    $.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") {
                alertError(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/submit-register",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(data),
        success: function (result) {
            layer.close(index);
            if (result.code != "0000") {
                notifyProgress(result.msg, result.data);
            } else {
                notifyProgress("数据提交成功", result.data);
                resetForm();
            }
        },
        error: function () {
            layer.close(index);
            alertError("提交失败,请重新尝试!!");
        }
    });
}