wxw
2025-05-12 c7c2f7aa20427204944ba80a2704232b2f281582
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>周期报表</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
        <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
        <style type="text/css">
            .layui-form-item .layui-inline {
                margin-bottom: 1px;
                margin-right: 1px;
            }
            
        </style>
        
    </head>
    <body>
 
        <div class="layui-fluid" style="padding-bottom: 0;">
            <div class="layui-card">
                <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                    <div class="layui-form-item" style="margin-bottom: 0px;">
                        <div class="layui-inline">
                            <label class="layui-form-label">选择日期</label>
                            <div class="layui-input-inline">
                                <input type="text" autocomplete="off" name="StartTime" id="StartTime" class="layui-input"
                                    placeholder="开始日期">
                            </div>
                        </div>
                        <div class="layui-inline sousuo">
                            <button class="layui-btn layui-btn-sm layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>搜索
                            </button>
                            <button class="layui-btn layui-btn-sm layuiadmin-btn-list" lay-submit
                                lay-filter="daochu">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>导出
                            </button> 
                        </div>
                
                    
                    </div>
                </div>
                
                
                <div class="layui-card-body">
                    <div style="position: relative;">
                        <div class="layui-tab layui-tab-brief" lay-filter="">
                            <div class="layui-tab-item layui-show">
                                <table id="LAY-app-content-list" lay-filter="LAY-app-content-list"></table>
                            </div>
                        </div>
                        
                    </div>
                    
 
                     <!-- 类型 -->
                     <script type="text/html" id="buttonType">
                        {{# if(d.Type=='0'){ }}
                            <p>原料吨袋</p>
                        {{# } else if(d.Type=='1') { }}
                            <p>原料公斤袋</p>
                        {{# } else if(d.Type=='2') { }}
                            <p>成品罐装满桶</p>
                        {{# } else if(d.Type=='3') { }}
                            <p>原料罐装桶</p>
                        {{# } else if(d.Type=='4') { }}
                            <p>成品吨袋</p>
                        {{# } else if(d.Type=='5') { }}
                            <p>耗材母托盘</p>
                        {{# } else if(d.Type=='6') { }}
                            <p>耗材子托盘塑料</p>
                        {{# } else if(d.Type=='7') { }}
                            <p>耗材子托盘木质</p>
                        {{# } else if(d.Type=='8') { }}
                            <p>包装材料</p>
                        {{# } }}
                    </script>
 
                </div>
            </div>
        </div>
 
        <script src="../../layuiadmin/layui/layui.js"></script>
        <script src="../../js/public.js"></script>
        <script src="../../js/jquery-3.5.1.min.js"></script>
        <script src="../../js/jquery.cookie.js"></script>
        <script>
            var uid = $.cookie('userId');
            layui.config({
                base: '../../layuiadmin/' //静态资源所在路径
            }).extend({
                index: 'lib/index' //主入口模块
            }).use(['index', 'table', 'laypage', 'layer','element','laydate'], function() {
                var table = layui.table,
                    form = layui.form,
                    laypage = layui.laypage,
                    layer = layui.layer;
                    element = layui.element;
                    laydate = layui.laydate;
                
                laydate.render({
                    elem: '#StartTime',
                    format: 'yyyy-MM-dd' //可任意组合
                });
                laydate.render({
                    elem: '#EndTime',
                    format: 'yyyy-MM-dd' //可任意组合
                });
                //获取当前时间
                function getNowTime() {
                    var date = new Date();
                    //年 getFullYear():四位数字返回年份
                    var year = date.getFullYear(); //getFullYear()代替getYear()
                    //月 getMonth():0 ~ 11
                    var month = date.getMonth() + 1;
                    //日 getDate():(1 ~ 31)
                    var day = date.getDate();
                    //时 getHours():(0 ~ 23)
                    var hour = date.getHours();
                    //分 getMinutes(): (0 ~ 59)
                    var minute = date.getMinutes();
                    //秒 getSeconds():(0 ~ 59)
                    var second = date.getSeconds();
                    
                    var time = year + addZero(month) + addZero(day) + addZero(hour) + addZero(minute) + addZero(second);
                    return time;
                    
                    //小于10的拼接上0字符串
                    
                };
                function addZero(s) {
                    return s < 10 ? ('0' + s) : s;
                };
 
                var $ = layui.$;
                var yemianid =0;
                refreshTable();
                //获取周期信息
                function refreshTable() {
                    var param = {
                        DataStatus: "1",
                        StartTime:$("#StartTime").val(),
                        EndTime:$("#EndTime").val(),
                    };
                    sendData(IP + "/Statistical/GetDataStockInfo", param, 'post', function(res) {
                        console.log(res)
                        if (res.code == 0) { //成功
                            var list = res.data;
                            $.extend(infoOptions, {
                                data: list
                            });
                            infoOptions.page = {
                                curr: 1
                            }
                            tableIns = table.render(infoOptions);
                        }
                        else { //不成功
                            layer.msg('获取周期信息列表失败!', {
                                icon: 2,
                                time: 2000 //2秒关闭(如果不配置,默认是3秒)
                            }, function() {});
                        }
                    });
                }
                // 表单需要的变量
                var infoOptions = {
                    elem: '#LAY-app-content-list',
                    height: 'full-92',
                    id: 'LAY-app-content-list',
                    page: true,
                    limit: pageCnt,
                    limits: pageLimits,
                    even: true,
                    // totalRow: true,
                    cellMinWidth: 80, //全局定义常规单元格的最小宽度,layui 2.2.1 新增
                    cols: 
                    [[
                        {
                            title: '序号', 
                            type: 'numbers', 
                            fixed: 'left'
                        },
                        {
                            field: 'SkuNo',
                            title: '物料编码',
                            align: 'center',
                            width: 200,
                        }, 
                        {
                            field: 'SkuName',
                            title: '物料名称',
                            align: 'center',
                            width: 300,
                            
                        },
                        {
                            field: 'Standard',
                            title: '规格',
                            align: 'center',
                            width: 200,
                        }, 
                        {
                            field: 'Type',
                            title: '类型',
                            align: 'center',
                            templet: '#buttonType',
                            width: 200,
                        },
                        // {
                        //     field: 'ExpectedQty',
                        //     title: '期初数量(天)',
                        //     align: 'center',
                        // },
                        {
                            field: 'YearExpectedQty',
                            title: '期初数量(月)',
                            align: 'center',
                            width: 200,
                        },
                        {
                            field: 'YearExpectedWeight',
                            title: '期初重量(吨)',
                            align: 'center',
                            templet: function (d) {
                                return (d.YearExpectedQty * d.Weight).toFixed(4);
                            },
                            width: 200,
                        },
                        {
                            field: 'ArrivalQty',
                            title: '入库数量(天)',
                            align: 'center',
                            width: 200,
                        },
                        {
                            field: 'ArrivalWeight',
                            title: '天入库重量(吨)',
                            align: 'center',
                            templet: function (d) {
                                return (d.ArrivalQty * d.Weight).toFixed(4);
                            },
                            width: 200,
                        },
                        {
                            field: 'YearArrivalQty',
                            title: '入库数量(月)',
                            align: 'center',
                            width: 200,
                        },
                        {
                            field: 'YearArrivalWeight',
                            title: '月入库重量(吨)',
                            align: 'center',
                            templet: function (d) {
                                return (d.YearArrivalQty * d.Weight).toFixed(4);
                            },
                            width: 200,
                        },
                        {
                            field: 'ExportQty',
                            title: '出库数量(天)',
                            align: 'center',
                            width: 200,
                        },
                        {
                            field: 'ExportWeight',
                            title: '天出库重量(吨)',
                            align: 'center',
                            templet: function (d) {
                                return (d.ExportQty * d.Weight).toFixed(4);
                            },
                            width: 200,
                        },
                        {
                            field: 'YearExportQty',
                            title: '出库数量(月)',
                            align: 'center',
                            width: 200,
                        },
                        {
                            field: 'YearExportWeight',
                            title: '月出库重量(吨)',
                            align: 'center',
                            templet: function (d) {
                                return (d.YearExportQty * d.Weight).toFixed(4);
                            },
                            width: 200,
                        },
                        // {
                        //     field: 'BalanceQty',
                        //     title: '结存数量(天)',
                        //     align: 'center',
                        // },
                        {
                            field: 'YearBalanceQty',
                            title: '结存数量',
                            align: 'center',
                            width: 200,
                        },
                        {
                            field: 'YearBalanceWeight',
                            title: '结存重量(吨)',
                            align: 'center',
                            templet: function (d) {
                                return (d.YearBalanceQty * d.Weight).toFixed(4);
                            },
                            width: 200,
                        },
                        {
                            field: 'Weight',
                            title: '理论重量(吨)',
                            align: 'center',
                            width: 200,
                            // templet: function (d) {
                            //     return (0);
                            // }
                        }
                        
                    ]]
                };
 
                //监听搜索
                form.on('submit(LAY-app-contlist-search)', function(data) {
                    var StartTime = $("#StartTime").val();
                    refreshTable(StartTime);
                });
                
                //导出
                form.on('submit(daochu)', function () {
                    layer.confirm('确定导出当前数据吗?', function(index) {
                        if(yemianid == 0){
                            var param = {
                                DataStatus: "1",
                                StartTime:$("#StartTime").val(),
                            };
                            sendData(IP + "/Statistical/GetDataStockInfo", param, 'post', function (res) {
                                if (res.code == 0) { //成功
                                    if(res.data.length > 0)
                                    {
                                        var list = res.data;
                                            console.log(list)
                                            list.forEach(item => {
                                                if (item.SkuName.split(','))
                                                {
                                                    item.SkuName = '"'+item.SkuName+'"' 
                                                }
                                                switch(item.Type)
                                                {
                                                    case '0':
                                                        item.Type = "原料吨袋"
                                                        break;
                                                    case '1':
                                                        item.Type = "原料公斤袋"
                                                        break;
                                                    case '2':
                                                        item.Type = "成品罐装满桶"
                                                        break;
                                                    case '3':
                                                        item.Type = "原料罐装桶"
                                                        break;
                                                    case '4':
                                                        item.Type = "成品吨袋"
                                                        break;
                                                    case '5':
                                                        item.Type = "耗材母托盘"
                                                        break;
                                                    case '6':
                                                        item.Type = "耗材子托盘塑料"
                                                        break;
                                                    case '7':
                                                        item.Type = "耗材子托盘木质"
                                                        break;
                                                    case '8':
                                                        item.Type = "包装材料"
                                                        break;
                                                    default:
                                                        item.Type = ""
                                                        break;
                                                }
                                                item.YearExpectedWeight = (item.YearExpectedQty * item.Weight).toFixed(4);// 期初重量
                                                item.ArrivalWeight = (item.ArrivalQty * item.Weight).toFixed(4);// 天入库重量
                                                item.YearArrivalWeight = (item.YearArrivalQty * item.Weight).toFixed(4);// 月入库重量
                                                item.ExportWeight = (item.ExportQty * item.Weight).toFixed(4);// 天出库重量
                                                item.YearExportWeight = (item.YearExportQty * item.Weight).toFixed(4);// 月出库重量
                                                item.YearBalanceWeight = (item.YearBalanceQty * item.Weight).toFixed(4);// 结存重量
                                            });
                                            console.log(list)
                                            table.exportFile(tableIns.config.id, list,'xls',"周期报表明细信息"+getNowTime(),); //data 为该实例中的任意数量的数据
                                        layer.msg('导出成功!', {
                                            icon: 1,
                                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                        }, function () {
                                            
                                        });
                                    }
                                    else
                                    {
                                        layer.msg('导出失败!', {
                                            icon: 2,
                                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                        }, function () {
                                            
                                        });
                                    }
                                    
                                } else { //不成功
                                    layer.msg('获取信息失败!', {
                                        icon: 2,
                                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                    }, function () { });
                                }
                            });
                        } 
                    });
                });
            });
        </script>
    </body>
</html>