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
//卡回收
var layer;
var form;
var recordData = null;
$(function () {
    layui.use(['layer', 'laydate', 'form'], function () {
        layer = layui.layer;
        form = layui.form;
        layui.laydate.render({
            elem: '#test1',
            theme: '#7b8e9f'
        });
 
    });
 
    showProgress();
});
 
//使用插件读取智慧卡号
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);
            var data = json.no;
            if (data === "not found") {
                alertError("请重新读卡!");
            } else {
                $("#intelCard").val(data);
 
                //直接刷新数据
                flushData();
            }
        },
        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;
            }
            $("#userId").val(data.idNum);
            console.log(data)
            flushData();
        },
        error: function () {
            layer.close(index);
            alertError("身份证读取失败!");
        }
    });
}
 
// 表单清空
function resetForm() {
    $("#form-data")[0].reset();
    $("#form-basic")[0].reset();
 
    form.render();
 
    recordData = null;
}
 
// 更新数据信息
function flushData() {
    var index = layer.load();
    var plateNum = $("#plateNum").val();
    var userId2 = $("#userId").val();
    var intelCard = $("#intelCard").val();
 
    var param = {
        type: type,
        progress: progress,
        userId: userId2,
        intelCard: intelCard,
        plateNum: plateNum
    };
 
    $.ajax({
        type: "POST",
        url: "../../basic/inout/inout-query-back",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(param),
        success: function (result) {
            if (result.code != "0000") {
                layer.alert(result.msg);
            } else {
                recordData = result.data;
                // 返回的数据进行赋值
                form.val("form-data", recordData);
                form.val("form-basic", recordData);
                form.render();
            }
            layer.close(index);
        },
        error: function () {
            layer.close(index);
            alertError("查询失败,请重新尝试!")
        }
    });
}
 
// 当前完成
function submitData() {
    if (!recordData) {
        alertError("没有数据可以提交!");
        return;
    }
 
    // 提交数据比较特殊,不用考虑基本信息提交
    var index = layer.load();
    var data = form.val("form-data");
    Object.assign(recordData, data);
 
    $.ajax({
        type: "POST",
        url: "../../basic/inout/submit-card-back",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(recordData),
        success: function (result) {
            if (result.code != "0000") {
                layer.msg(result.msg);
            } else {
                layer.alert("卡片回收成功!");
                // 重置页面
                resetForm();
            }
            layer.close(index);
        },
        error: function () {
            layer.close(index);
            layer.msg("卡片回收失败,请重新尝试!!");
        }
    });
}