YYC
2023-07-08 8b874a8b39dc8c5244e7615498af9b5f8d2d9427
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
//卡回收
var layer;
var form;
var recordData = null;
$(function () {
    layui.use(['layer', 'laydate', 'form', 'util'], function () {
        layer = layui.layer;
        form = layui.form;
        layui.laydate.render({
            elem: '#test1',
            theme: '#7b8e9f'
        });
 
    });
 
    showProgress();
});
 
//控制流程环节显示
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");
    }
}
 
//新的读卡方式
function flushICCard() {
    $("#intelCard").val(null);
    resetForm();
    $.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);
                flushData();
            }
        },
        error: function () {
            layer.alert("IC卡读取出错!", {offset: ['300px', '300px']});
        }
    });
}
 
// 使用插件获取省份证
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;
            }
            $("#userId").val(data.idNum);
            flushData();
        },
        error: function () {
            layer.alert("身份证读取失败,请手动录入!", {
                offset: ['300px', '300px']
            });
            layer.close(index);
        }
    });
}
 
// 打印过磅单
function printBill() {
    if (!recordData) {
        layer.alert("没有获取到业务数据,不支持打印!");
        return;
    }
 
    if (InoutProgress.CARD_BACK != recordData.progress) {
        layer.alert("当前数据不完整,不支持打印!");
        return;
    }
 
    //从后台获取模版并打印
    var index = layer.load();
    $.ajax({
        type: "POST",
        url: "../../basic/inout/report/bill-weight",
        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.msg("开始渲染打印单……");
                printWeight(result.data);
            }
            layer.close(index);
        },
        error: function () {
            layer.close(index);
            layer.msg("获取打印模版失败,请联系管理员查看原因!!");
        }
    });
}
 
// 打印抽样单
function showCheck() {
    if (null == recordData) {
        layer.alert("没有获取到业务数据,无法查看!");
    }
}
 
// 表单清空
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);
            layer.alert("查询失败,请重新尝试!!");
        }
    });
}
 
// 当前完成
function submit(data) {
    if (!recordData) {
        layer.alert("没有数据可以提交!!!");
        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("卡片回收失败,请重新尝试!!");
        }
    });
}