czt
2 天以前 51faf3e9c3c613e7fb12db6c88356946f2429e0c
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
//称重-包括空车和满车称重
var layer;
var form;
var table;
var upload;
var recordData = null;// 业务数据信息
var img1, img2, img3;// 页面中的图片上传名称
 
$(function () {
    layui.use(['layer', 'laydate', 'form','table', 'upload'], function () {
        upload = layui.upload;
        layer = layui.layer;
        form = layui.form;
        table = layui.table;
 
        //监听选择数据事件
        table.on('tool(tableListProgressData)', function (obj) {
            var data = obj.data;
            if (obj.event === 'select') {
                //清空表单
                resetForm();
                flushData(data.id, null);
                $("#listProgressData").css("display", "none");
                layer.closeAll();
            }
        });
 
        //上传
        upload.render({
            elem: '#kccz-r-btn1',
            url: '/basic/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: '/basic/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: '/basic/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("图片上传成功!");
            }
        });
 
    });
 
    //显示流程环节
    updateEditAndProgress();
});
 
/**
 * 手动选择,获取待称重的数据,弹出选择
 */
function selectByHand() {
    var param = {
        deptId: deptId,
        type: type,
        progress: curProgress,
        timer: Math.random()
    };
    $.ajax({
        type: "POST",
        url: "/basic/inout/list-handle-data",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(param),
        success: function (result) {
            if (result.code != "0000") {
                layer.msg(result.msg);
            } else {
                renderTableProgressData(result.data);
            }
        },
        error: function () {
            layer.msg("系统获取数据出现异常,重新尝试");
        }
    });
}
 
 
/**
 * 车辆选择弹窗
 * @param list
 */
function renderTableProgressData(list) {
    // 清空数据
    $("#tableListProgressData").empty();
    layer.open({
        type: 1,
        title: "选择值仓中车辆",
        offset: ['240px', '100px'],
        area: ['1000px', '560px'],
        cancel: function (index, layero) {
            $("#listProgressData").css("display", "none");
        },
        shade: 0,
        scrollbar: 0,
        content: $('#listProgressData'),
        closeBtn: 1
    });
    table.render({
        elem: '#tableListProgressData',
        data: list,
        page: false,
        even: true,
        cols: [[
            {
                type: 'numbers',
                title: '序号'
            }, {
                field: 'id',
                title: '单据号',
                align: 'center'
            }, {
                field: 'userName',
                title: '承运人',
                align: 'center'
            }, {
                field: 'plateNum',
                title: '车牌号',
                align: 'center'
            }, {
                field: 'progress',
                title: '流程进度',
                align: 'center',
                style: 'font-weight: bold',
                templet: function (item) {
                    return INOUT_PROGRESS_MSG(item.progress);
                }
            }, {
                fixed: 'right',
                title: '选择操作',
                align: 'center',
                toolbar: '#barSelectProgress'
            }
        ]]
    });
    $("thead tr").css({
        "border-bottom": "2px solid #53adce",
        "background": "#eff4f6"
    });
}
 
// 表单清空
function resetForm() {
    $("#form-data")[0].reset();
    $('#kccz-r-img1').removeAttr('src');
    $('#kccz-r-img2').removeAttr('src');
    $('#kccz-r-img3').removeAttr('src');
    form.render();
    recordData = null;
    $("#text-param").val(null);
}
 
/**
 * 页面刷新
 */
function flushPage() {
    layer.confirm('确定要刷新页面吗?', {icon: 3, title: '提示'}, function (index) {
        resetForm();
        layer.close(index);
    });
}
 
/**
 * 查询数据
 * @param id
 * @param plateNum
 */
function flushData(id, plateNum) {
    var index = layer.load();
    var param = {
        type: type,
        progress: curProgress,
        id: id,
        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();
 
                updateEditAndProgress();
            }
        },
        error: function () {
            layer.close(index);
            alertError("查询失败,请重新尝试");
        }
    });
}
 
// 当前完成
function submit() {
    if (!recordData) {
        alertError("没有业务数据信息,执行被拒绝");
        return;
    }
    var data = form.val("form-data");
    //合并数据
    Object.assign(recordData, data);
    // 获取照片
    var files = [{
        fileName: img1
    }, {
        fileName: img2
    }, {
        fileName: img3
    }];
    recordData.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(recordData),
        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);
            alertError("提交失败,请重新尝试");
        }
    });
}
 
/**
 * 根据业务数据更新页面中的状态
 */
function updateEditAndProgress() {
    //显示当前流程
    if (type === "IN") {
        $("#rk-progress-register").addClass("active");
        $("#rk-progress-fullWeight").addClass("active");
        $("#rk-progress-hand").addClass("active");
        $("#rk-progress-emptyWeight").removeClass("active");
    }
    if (type === "OUT") {
        $("#ck-progress-register").addClass("active");
        $("#ck-progress-emptyWeight").addClass("active");
        $("#ck-progress-hand").addClass("active");
        $("#ck-progress-fullWeight").removeClass("active");
    }
    //流程显示
    if (inoutProgress) {
        if (inoutProgress.indexOf("REGISTER") === -1) {
            $("#rk-progress-register").css("display", "none");
            $("#ck-progress-register").css("display", "none");
        }
        if (inoutProgress.indexOf("WEIGHT_FULL") === -1) {
            $("#rk-progress-fullWeight").css("display", "none");
            $("#ck-progress-fullWeight").css("display", "none");
        }
        if (inoutProgress.indexOf("HANDLE") === -1) {
            $("#rk-progress-hand").css("display", "none");
            $("#ck-progress-hand").css("display", "none");
        }
        if (inoutProgress.indexOf("WEIGHT_EMPTY") === -1) {
            $("#rk-progress-emptyWeight").css("display", "none");
            $("#ck-progress-emptyWeight").css("display", "none");
        }
        if (inoutProgress.indexOf("CARD_BACK") === -1) {
            $("#rk-progress-cardBack").css("display", "none");
            $("#ck-progress-cardBack").css("display", "none");
        }
 
        if (type === "IN") {
            $("#rk_progress").css("display", "block");
            $("#ck_progress").css("display", "none");
        }
        if (type === "OUT") {
            $("#ck_progress").css("display", "block");
            $("#rk_progress").css("display", "none");
        }
    }
}
 
/**
 * 弹出提醒框
 * @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));
        }
 
        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']});
    }
}