#
18516761980
2022-05-30 1baeb88125f264fa1949a17a83a2c83182f79499
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
var pageCurr = 1;
var limit = 16;
 
function getCol() {
    var cols = [];
    cols.push(
        {field: 'orderCode', align: 'center', title: '订单编号', width: 110}
        , {field: 'orderDate', align: 'center', title: '订单日期', width: 120}
        , {field: 'invCode', align: 'center', title: '物料编码', width: 130}
        , {field: 'invName', align: 'center', title: '物料名称', width: 350}
        , {field: 'invStd', align: 'center', title: '规格型号', width: 160}
        , {field: 'invUnit', align: 'center', title: '单位', width: 80, hide: true}
        , {field: 'orderQty', align: 'center', title: '订单数量', width: 120}
        , {field: 'izMrp', align: 'center', title: '大订单(mrp)',width: 115}
        , {field: 'productQty', align: 'center', title: '任务单', width: 110}
        , {field: 'izReceive', align: 'center', title: '小订单', width: 80}
        , {field: 'inQty', align: 'center', title: '入库数量', width: 110}
        , {field: 'disQty', align: 'center', title: '通知单', width: 110}
        , {field: 'outQty', align: 'center', title: '出库数量', width: 110}
        , {field: 'invoiceQty', align: 'center', title: '开票数量'}
        , {field: 'unInvoiceQty', align: 'center', title: '未开票数量'}
        , {field: 'deliveryDate', align: 'center', title: '交货日期'}
        , {field: 'personName', align: 'center', title: '业务员'}
    );
    return cols;
}
 
layui.use(['table', 'laydate', 'form', 'upload'], function () {
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
    var layDate = layui.laydate;
    var form = layui.form;
    var upload = layui.upload;
 
    // 数据渲染
    tableIns = table.render({
        elem: '#salesOrder',
        headers: {token: localStorage.getItem('token')},
        url: 'http://192.168.0.253:8073/api/report/getorderreport',
        height: 650,
        width: '100%',
        page: true,
        limit: limit,
        limits: [16, 50, 100, 200, 500],
        even: true,
        toolbar: '#toolbar',
        cellMinWidth: 50,
        cols: [getCol()],
        request: {
            pageName: 'curr',
            pageSize: 'limit'
        },
        parseData: function (res) {
            return {
                'code': res.code,
                'msg': res.msg,
                'count': res.data.total,
                'data': res.data.records
            }
        },
        response: {
            statusCode: 200
        },
        done: function (res, curr, count) {
            if (res.code === 403) {
                top.location.href = baseUrl + "/";
            }
            pageCurr = curr;
        }
    });
 
    // 搜索栏重置事件
    form.on('submit(reset)', function (data) {
        pageCurr = 1;
        clearFormVal($('#search-box'));
        debugger
 
        tableReload(false);
    });
 
    // 搜索栏搜索事件
    form.on('submit(search)', function (data) {
        pageCurr = 1;
        tableReload(false);
    });
 
 
    // 时间选择器
    layDate.render({
        elem: '.layui-laydate-range'
        ,style: 'width: 150px'
        , range: true
    });
});
 
/* 表格数据重载 */
function tableReload(child) {
    var searchData = {};
    $.each($('#search-box [name]').serializeArray(), function() {
        searchData[this.name] = this.value;
        if (this.name == 'orderTime') {
            searchData.startTime = this.value.substring(0, 10);
            searchData.endTime = this.value.substring(13, this.value.length);
        }
    });
    (child ? parent.tableIns : tableIns).reload({
        where: searchData,
        page: {
            curr: pageCurr
        },
        done: function (res, curr, count) {
            if (res.code === 403) {
                top.location.href = baseUrl+"/";
            }
            pageCurr=curr;
            if (res.data.length === 0 && count !== 0) {
                tableIns.reload({
                    where: searchData,
                    page: {
                        curr: pageCurr-1
                    }
                });
                pageCurr -= 1;
            }
            // limit(child);
        }
    });
}
// function tableReload(child) {
//     var searchData = {};
//     $.each($('#search-box [name]').serializeArray(), function () {
//         if (this.name == 'orderCode') {
//             searchData.orderCode = this.value;
//         }
//         if (this.name == 'orderTime') {
//             searchData.startTime = this.value.substring(0, 10);
//             searchData.endTime = this.value.substring(13, this.value.length);
//         }
//     });
//
//     console.log(searchData);
//
//     (child ? parent.tableIns : tableIns).reload({
//         where: searchData,
//         page: {
//             curr: pageCurr
//         },
//         done: function (res, curr, count) {
//             if (res.code === 403) {
//                 top.location.href = baseUrl + "/";
//             }
//             pageCurr = curr;
//             if (res.data.length === 0 && count !== 0) {
//                 tableIns.reload({
//                     where: searchData,
//                     page: {
//                         curr: pageCurr - 1
//                     }
//                 });
//                 pageCurr -= 1;
//             }
//             // limit(child);
//             // 当前分页数据存储
//             locNormalList = res.data;
//         }
//     });
// }
 
/* 监听回车事件 */
$('body').keydown(function () {
    if (event.keyCode === 13) {
        $("#search").click();
    }
});