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
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
//称重-包括空车和满车称重
var layer;
var form;
var upload;
var recordData = null;// 业务数据信息
var paramIntelCard;//设备识别结果
var paramIdCard;//设备识别结果
var img1, img2, img3;// 页面中的图片上传名称
 
$(function () {
    layui.use(['layer', 'laydate', 'form', 'upload'], function () {
        upload = layui.upload;
        layer = layui.layer;
        form = layui.form;
 
        //上传
        upload.render({
            elem: '#kccz-r-btn1',
            url: '../file/update-file', //上传接口
            size: 4 * 1024, //限制文件大小,单位KB, 最大上传4MB
            accept: 'images',
            before: function (obj) {
                var plateNum = $("#plateNum").val();
                this.data = {"plateNum": plateNum, "type": "1"};//携带参数
                //预读本地文件示例,不支持ie8
                obj.preview(function (index, file, result) {
                    $('#kccz-r-img1').attr('src', result); //图片链接(base64)
                });
            },
            done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    layer.msg("图片上传失败!");
                }
                //上传成功
                img1 = res.msg;
                layer.msg("图片上传成功!");
                //console.log(img1);
            }
        });
        upload.render({
            elem: '#kccz-r-btn2',
            url: '../file/update-file', //上传接口
            size: 4 * 1024, //限制文件大小,单位KB, 最大上传4MB
            accept: 'images',
            before: function (obj) {
                var plateNum = $("#plateNum").val();
                this.data = {"plateNum": plateNum, "type": "1"};//携带参数
                //预读本地文件示例,不支持ie8
                obj.preview(function (index, file, result) {
                    $('#kccz-r-img2').attr('src', result); //图片链接(base64)
                });
            },
            done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    layer.msg("图片上传失败!");
                }
                //上传成功
                img2 = res.msg;
                layer.msg("图片上传成功!");
                // console.log(img2);
            }
        });
        upload.render({
            elem: '#kccz-r-btn3',
            url: '../file/update-file', //上传接口
            size: 4 * 1024, //限制文件大小,单位KB, 最大上传4MB
            accept: 'images',
            before: function (obj) {
                var plateNum = $("#plateNum").val();
                this.data = {"plateNum": plateNum}; //携带参数
                //预读本地文件示例,不支持ie8
                obj.preview(function (index, file, result) {
                    $('#kccz-r-img3').attr('src', result); //图片链接(base64)
                });
            },
            done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    layer.msg("图片上传失败!");
                }
                //上传成功
                img3 = res.msg;
                layer.msg("图片上传成功!");
            }
        });
 
    });
 
    //显示流程环节
    showProgress();
});
 
//读智慧卡
function flushICCard() {
    if (!cardDto.protocol) {
        flushICCard1();
    } else {
        flushICCard2();
    }
}
 
/**
 * 协议读取智慧卡
 */
function flushICCard2() {
    var index = layer.load();
    var param = JSON.stringify(cardDto);
    $.ajax({
        type: "POST",
        url: "../../inout/api/get-icCard",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: param,
        success: function (result) {
            layer.close(index);
            if (result.code != "0000") {
                alertError(result.msg);
            } else {
                paramIntelCard = data;
                $("#text-param").text("识别卡号:" + paramIntelCard);
                flushData(paramIntelCard, null);
            }
        },
        error: function () {
            layer.close(index);
            alertError("IC卡读取失败");
        }
    });
}
 
/**
 * 本地读取智慧卡
 */
function flushICCard1() {
    var index = layer.load();
    $("#text-param").val(null);
    $("#form-data")[0].reset();
    form.render();
    recordData = null;
    $.ajax({
        type: "GET",
        async: true,
        url: "http://127.0.0.1:9111/ICCARD",
        data: {},
        dataType: "jsonp",
        jsonp: "callback",
        jsonpCallback: "jsonpCallback",
        success: function (json) {
            var data = json.no;
            layer.close(index);
            if (data === "not found") {
                alertError("请重新读卡!");
            } else {
                paramIntelCard = data;
                $("#text-param").text("识别卡号:" + paramIntelCard);
                flushData(paramIntelCard, null);
            }
        },
        error: function () {
            layer.close(index);
            alertError("IC卡读取出错!");
        }
    });
}
 
// 使用插件获取身份证
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;
            }
            paramIdCard = data;
            $("#text-param").text("识别身份证:" + paramIdCard);
            flushData(null, paramIdCard);
        },
        error: function () {
            alertError("没有读取到身份证信息!");
            layer.close(index);
        }
    });
}
 
function flushByHand() {
    flushData(null, null);
}
 
// 表单清空
function resetForm() {
    $("#form-data")[0].reset();
    form.render();
    recordData = null;
    $("#text-param").val(null);
}
 
function flushPage() {
    layer.confirm('确定要刷新页面吗?', {icon: 3, title: '提示'}, function (index) {
        resetForm();
        layer.close(index);
    });
}
 
// --查询方法,获取身份证号、卡号、车牌号,进行查询
function flushData(intelCard, userIdCard) {
    var index = layer.load();
    var userIdCard = userIdCard;
    var intelCard = intelCard;
    var plateNum = $("#plateNum").val();
    var param = {
        type: type,
        progress: progress,
        intelCard: intelCard,
        userId: userIdCard,
        plateNum: plateNum
    };
    $.ajax({
        type: "POST",
        url: "../../basic/inout/inout-query",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(param),
        success: function (result) {
            layer.close(index);
            if (result.code != "0000") {
                notifyProgress(result.msg, result.data);
            } else {
                recordData = result.data;
                // 返回的数据进行赋值
                form.val("form-data", recordData);
                form.render();
            }
        },
        error: function () {
            layer.close(index);
            alertError("查询失败,请重新尝试");
        }
    });
}
 
// 当前完成
function submit() {
    if (!recordData) {
        alertError("没有业务数据信息,执行被拒绝");
        return;
    }
    var data = form.val("form-data");
 
    if (!data.handleUser) {
        alertError("提示:值仓人不可为空");
        return;
    }
 
    // 获取照片
    var files = [{
        fileName: snapData.fileName1
    }, {
        fileName: snapData.fileName2
    }, {
        fileName: snapData.fileName3
    }];
    data.files = files;
 
    var index = layer.load();
    $.ajax({
        type: "POST",
        url: "../../basic/inout/submit-handle",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(data),
        success: function (result) {
            if (result.code != "0000") {
                notify(result.msg, result.data);
            } else {
                notify("数据提交成功", result.data);
            }
            layer.close(index);
        },
        error: function () {
            layer.close(index);
            alertError("提交失败,请重新尝试");
        }
    });
}