czt
2025-05-23 bb1b4579482abc4b2bc5ba244f68bc5d0ab87f2e
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
// 粮情批量导出EXCEL
function exportBatch() {
    layer.msg("暂未开放!");
    return;
    // 弹出选择框
    layer.open({
        type: 1,
        title: '批量导出报表',
        area: ['730px', '450px'],
        shade: 0,
        content: $('#batchExportSelect'),
        btn: ['全选', '反选', '重选', '执行导出', '取消导出'],
        yes: function () {
            var name;
            $('#batchExportSelect input').each(function () {
                name = $(this).prop("name");
                if (name == "printCheckDate2" || $(this).prop("disabled")) {
 
                } else {
                    $(this).prop("checked", true);
                }
            });
            form.render();
        },
        btn2: function () {
            var name;
            $('#batchExportSelect input').each(function () {
                name = $(this).prop("name");
                if (name == "printCheckDate2" || $(this).prop("disabled")) {
                    // doNothing
                } else {
                    if ($(this).prop("checked")) {
                        $(this).prop("checked", false);
                    } else {
                        $(this).prop("checked", false);
                    }
                }
            });
            form.render();
            return false;
        },
        btn3: function () {
            var name;
            $('#batchExportSelect input').each(function () {
                name = $(this).prop("name");
                if (name == "printCheckDate2" || $(this).prop("disabled")) {
                    // doNothing
                } else {
                    $(this).prop("checked", false);
                }
            });
            form.render();
            return false;
        },
        btn4: function () {
            exportBatchTodo();
        },
        btn5: function () {
            layer.close(0);
        },
        closeBtn: 0
    });
 
    // 默认调用获取数据更新
    if (grainData) {
        $("#printCheckDate2").prop("value", grainData.receiveDate.substr(0, 10));
    } else {
        $("#printCheckDate2").prop("value", dateFtt("yyyy-MM-dd", new Date()));
    }
};
 
function exportBatchTodo() {
    var depotIds = "";
    $('#batchExportSelect input').each(function () {
        if ($(this).prop("checked")) {
            depotIds += $(this).val() + ",";
        }
    });
 
    if (depotIds == "") {
        layer.alert("请选择需要导出的仓库……");
        return false;
    }
 
    layer.load();
    // 调用后台批量检测
    var checkDate = $("#printCheckDate2").val();
    var data = {
        companyId: companyId,
        deptId: deptId,
        depotIds: depotIds,
        checkDate: checkDate
    };
 
    $.ajax({
        type: "POST",
        url: "../../basic/grain/export-batch",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(data),
        success: function (result) {
            layer.closeAll('loading');
            if (result.code != "ORDER_SUCCESS") {
                layer.alert("导出模版失败:" + result.msg);
                return false;
            } else {
                layer.closeAll('loading');
                downLoadExcel(result.msg);
                return true;
            }
        },
        error: function () {
            layer.closeAll('loading');
            layer.alert("粮情导出EXCEl执行出错,请从新执行");
            return false;
        }
    });
    return true;
}
 
/**
 * 创建一个A标签执行下载
 * @param fileName
 */
function downLoadExcel(fileName) {
    var url = "../../basic/file/download-temp?companyId=" + companyId + "&fileName=" + fileName;
    var link = document.createElement('a');
    link.style.display = 'none';
    link.href = url;
    document.body.appendChild(link)
    link.click();
}