jt
2021-06-10 5d0d028456874576560552f5a5c4e8b801786f11
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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
@{
    ViewBag.Title = "Main";
    Layout = "~/Views/Shared/_LayoutVue.cshtml";
}
 
<script src="~/Content/js/echarts/echarts.min.js"></script>
<script src="~/Content/js/linq.js_ver2.2.0.2/linq.js"></script>
 
<style>
    .chart {
        float: left;
    }
 
    .chuku, .ruku {
        width: 25%;
        position: relative;
    }
 
        .chuku:after, .ruku:after {
            content: "";
            display: block;
            position: absolute;
            right: 0;
            top: 10%;
            width: 1px;
            height: 80%;
            background: #ccc;
            background: -webkit-gradient(linear,0% 0%,100% 100%,color-stop(0,#eee),color-stop(0.5,#bbb),color-stop(1,#eee));
        }
 
    .churuku {
        width: 50%;
    }
 
    .el-card__header {
        padding: 5px 20px;
        font-size: 15px;
        font-weight: bold;
    }
 
    ol {
        list-style: none;
        counter-reset: ordered;
    }
 
    li:before {
        counter-increment: ordered;
        /*content: counters(ordered,".")" ";*/
    }
</style>
<script type="text/javascript">
    function LoadWaitQty() {
        $.ajax({
            type: "GET",
            url: "/Home/GetWaitExecuteTask",
            dataType: "json",
            async: false,
            success: function (result) {
                $.each(result, function (i, n) {
                    $("#id" + (i + 1)).html(n.Qty);
 
                });
            },
            error: function (msg) {
                alert("error3" + msg);
            }
        });
    }
 
    function OpenIndex(index) {
        switch (index) {
            //case 1:
            //    parent.addTab('到货单审核', '/InStock/Arrival/Audit?className=ARRIVAL_MST&funcType=到货单审核', 'F747545D-7234-487F-9E60-8CC4FF866F88');
            //    break;
            //case 2:
            //    parent.addTab('到货单检验', '/Inspect/ArrivalInspect/Index?className=INSPECT_MST&funcType=标准', '4fed9013-09fd-4239-bdb6-e3f02f63454d');
            //    break;
            //case 3:
            //    parent.addTab('缺货查询', 'OutStock/Wave/OutOfStock', '1b55f051-4dc0-41c3-bd68-4ac152c481fc');
            //    break;
            //case 4:
            //    parent.addTab('入库单审核', '/InStock/InOrder/Audit?className=INCREASE_INVENTORY_MST&funcType=审核', '97ac4e4d-7d66-47c4-979d-bf7ed82e8856');
            //    break;
            //case 5:
            //    parent.addTab('发货单审核', '/OutStock/Out/Audit?className=OUT_MST&funcType=审核', '9bd9ca18-35d3-4bc6-8434-a0a4a1a4d04f');
            //    break;
            //case 6:
            //    parent.addTab('待发货', '/OutStock/OutOrder/Index?className=REDUCE_INVENTORY_MST&funcType=标准&menuid=2d099c1d-8efa-4073-8c72-2b9ca87acbe0');
            //    break;
        }
    }
 
    function getFormatDate(arg) {
        if (arg == undefined || arg == '') {
            return '';
        }
        var re = arg + '';
        if (re.length < 2) {
            re = '0' + re;
        }
        return re;
    }
</script>
 
<div id="div" v-cloak>
    <el-row>
        <el-col v-bind:span="12">
            <el-card class="box-card" shadow="hover" v-bind:style="'height:'+topHeight+'px;'">
                <div slot="header" class="clearfix">
                    <span>仓储货位情况</span>
                </div>
                <el-table v-bind:data="stockState" 
                          style="width: 100%"
                          size="mini">
                    <el-table-column prop="AreaCode" width="200px"
                                     label="库区">
                    </el-table-column>
                    <el-table-column prop="LocationCount"  
                                     label="总货位数">
                    </el-table-column>
                    <el-table-column prop="EmptyCount"
                                     label="空货位数">
                    </el-table-column>
                    <el-table-column prop="OddSpec"
                                     label="剩余比重">
                    </el-table-column>
                </el-table>
            </el-card>
        </el-col>
        <el-col v-bind:span="12">
            <el-card class="box-card" shadow="hover" v-bind:body-style="{overflow:'auto',height:(topHeight-35)+'px'}" v-bind:style="'height:'+topHeight+'px'">
                <div slot="header" class="clearfix">
                    <span>更新日志</span>
                </div>
                <div>
                    <el-table v-for="n in updateContent" v-bind:data="n.update"
                              style="width: 100%"
                              size="mini">
                        <el-table-column prop="content"
                                         v-bind:label="n.title">
                        </el-table-column>
                    </el-table>
                </div>
            </el-card>
        </el-col>
    </el-row>
    <el-card class="box-card" v-bind:style="'height:'+bottomHeight+'px;' + 'display:none;'">
        <div slot="header" class="clearfix">
            出入库业务
            <hh-select-url v-model="formData.dtRange"
                           v-bind:options="dtRangeOptions">
            </hh-select-url>
        </div>
        <el-row v-bind:gutter="24" style="">
            <el-col v-bind:span="10" style="padding:15px 12px;">
                <div id="divBussLine" class="chart churuku" style="width:100%;height:200px"></div>
            </el-col>
            <el-col v-bind:span="7" style="padding:15px 12px;">
                <div id="divOutPie" class="chart ruku" style="width:100%;height:200px"></div>
            </el-col>
            <el-col v-bind:span="7" style="padding:15px 12px;">
                <div id="divInPie" class="chart chuku" style="width:100%;height:200px"></div>
            </el-col>
        </el-row>
    </el-card>
</div>
 
@section scripts{
    <script>
        var outList = new Vue({
            mixins: [useAutoHeight],
            data: {
                stockState: [],
                updateContent: [],
                areaStoreInfo: {},
                formData: {
                    dtRange: "7"
                },
                dtRangeOptions: [{
                    value: '7',
                    label: '7天内'
                }, {
                    value: '15',
                    label: '半个月内'
                }, {
                    value: '30',
                    label: '1个月内'
                }],
                where: {},
                outCols: [
                    { f: "CN_S_ITEM_CODE", n: "物料编码", w: 180 },
                    { f: "CN_S_ITEM_NAME", n: "物料名称", w: 180 },
                    { f: "CN_S_PRODUCTION_BATCH", n: "生产批次", w: 180 },
                    { f: "CN_S_ITEM_STATE", n: "物料状态", w: 80 },
                    { f: "CN_S_OWNER", n: "货主", w: 100 },
                    { f: "CN_F_QUANTITY", n: "库存数量", w: 80 },
                    { f: "CN_F_PLANNED_QTY", n: "在单量", w: 80 },
                    { f: "CN_F_ALLOC_QTY", n: "分配量", w: 80 },
                    { f: "STOCKQTY", n: "安全库存", w: 80 },
                    {
                        f: "STOCKQTY", n: "可用库存", w: 80, format: function (row, column) {
                            return (parseInt(row.CN_F_QUANTITY) + parseInt(row.CN_F_PLANNED_QTY)) - parseInt(row.CN_F_ALLOC_QTY);
                        }
                    }
                ]
            },
            methods: {
                fixed: function (num) {
                    num = num * 100;
                    return num.toFixed(2) + "%";
                },
                Selected: function () {
                    var vue = $("#idDay option:selected").val();
                    if (vue == "7天内") {
                        InitBuss(7);
                    }
                    else if (vue == "半个月内") {
                        InitBuss(15);
                    }
                    else if (vue == "1个月内") {
                        InitBuss(30);
                    }
                },
                InitLocation: function () {
                    var $this = this;
                    ajaxManage({
                        url: '/Home/GetLocationState',
                        success: function (result) {
                            if (result.Status) {
                                $this.areaStoreInfo = result.Data;
                                //stockState
                                console.log($this.areaStoreInfo);
                                $this.areaStoreInfo.forEach(function (n) {
                                    $this.stockState.push({
                                        AreaCode: n.CN_S_AREA_CODE,
                                        LocationCount: n.不满 + n.空 + n.满,
                                        EmptyCount: n.空,
                                        OddSpec: $this.fixed(n.空 / (n.不满 + n.空 + n.满))
                                    });
                                });
                            }
                            else {
                                wms.error(result.Msg);
                            }
                        }
                    });
                },
                InitPie: function (inDataPie, outDataPie) {
                    var myChart = echarts.init(document.getElementById('divInPie'));
                    var option = {
                        title: {
                            text: '入库',
                            //subtext: '虚构数据',
                            left: 'center',
                            textStyle: {
                                fontWeight: 'bold',
                                //字体大小
                                fontSize: 12
                            }
                        },
                        color: ['#37a2da', '#e062ae', '#ff9f7f', '#67e0e3', '#9fe6b8', '#fb7293', '#e690d1', '#8378ea', '#ffdb5c', '#96bfff'],
                        tooltip: {
                            trigger: 'item',
                            formatter: "{a} <br/>{b}: {c} ({d}%)"
                        },
                        legend: {
                            orient: 'vertical',
                            x: 'left',
                            //data: ['初始化入库', '采购入库', '调拨入库', '领料入库', '其他入库']
                        },
                        series: [
                            {
                                name: '业务类型',
                                type: 'pie',
                                radius: ['40%', '70%'],
                                avoidLabelOverlap: false,
                                label: {
                                    normal: {
                                        show: false,
                                        position: 'center'
                                    },
                                    emphasis: {
                                        show: true,
                                        textStyle: {
                                            fontSize: '20',
                                            fontWeight: 'bold'
                                        }
                                    }
                                },
                                labelLine: {
                                    normal: {
                                        show: false
                                    }
                                },
                                data:
                                    inDataPie
                                //    [
                                //    { value: 335, name: '初始化入库' },
                                //    { value: 310, name: '采购入库' },
                                //    { value: 234, name: '联盟广告' },
                                //    { value: 135, name: '视频广告' },
                                //    { value: 1548, name: '搜索引擎' }
                                //]
                            }
                        ],
                        graphic: {
                            type: 'text',
                            left: 'center',
                            top: 'center',
                            style: {
                                //text: '入库',
                                textAlign: 'center',
                                fill: '#000',
                                width: 30,
                                height: 30
                            }
                        }
                    };
                    myChart.setOption(option);
 
                    var myChart2 = echarts.init(document.getElementById('divOutPie'));
                    option2 = {
                        title: {
                            text: '出库',
                            //subtext: '虚构数据',
                            left: 'center',
                            textStyle: {
                                fontWeight: 'bold',
                                //字体大小
                                fontSize: 12
                            }
                        },
                        color: ['#37a2da', '#e062ae', '#ff9f7f', '#67e0e3', '#9fe6b8', '#fb7293', '#e690d1', '#8378ea', '#ffdb5c', '#96bfff'],
                        tooltip: {
                            trigger: 'item',
                            formatter: "{a} <br/>{b}: {c} ({d}%)"
                        },
                        legend: {
                            orient: 'vertical',
                            x: 'left',
                            //data: ['简易出库', '销售出库', '其他出库', '领料出库', '调拨出库']
                        },
                        series: [
                            {
                                name: '业务类型',
                                type: 'pie',
                                radius: ['40%', '70%'],
                                avoidLabelOverlap: false,
                                label: {
                                    normal: {
                                        show: false,
                                        position: 'center'
                                    },
                                    emphasis: {
                                        show: true,
                                        textStyle: {
                                            fontSize: '20',
                                            fontWeight: 'bold'
                                        }
                                    }
                                },
                                labelLine: {
                                    normal: {
                                        show: false
                                    }
                                },
                                data:
                                    outDataPie
                            }
                        ],
                        graphic: {
                            type: 'text',
                            left: 'center',
                            top: 'center',
                            style: {
                                //text: '出库',
                                textAlign: 'center',
                                fill: '#000',
                                width: 30,
                                height: 30
                            }
                        }
                    };
                    myChart2.setOption(option2);
                },
                InitBuss: function (day) {
                    $this = this;
                    var dayTitle = new Array()
                    var inData = new Array();
                    var outData = new Array();
 
                    var inDataPie;
                    var outDataPie;
 
                    ajaxManage({
                        url: '/Home/GetBussLine?day=' + day,
                        success: function (data) {
                            result = data.Data;
                            var inQty = Enumerable.From(result).Where("x=>x.type=='IN'").GroupBy("$.CN_T_CREATE", null,
                                        function (key, g) {
                                            var result = {
                                                CN_T_CREATE: key,
                                                QTY: parseInt(g.Sum("x=>x.qty"))
                                            }
                                            return result;
                                        });
                            var outQty = Enumerable.From(result).Where("x=>x.type=='OUT'").GroupBy("x=>x.CN_T_CREATE", null,
                                        function (key, g) {
                                            var result = {
                                                CN_T_CREATE: key,
                                                QTY: parseInt(g.Sum("x=>x.qty"))
                                            }
                                            return result;
                                        });
                            var date = new Date();
                            date.setDate(date.getDate() - day)
                            for (var i = day; i > 0; i--) {
                                date.setDate(date.getDate() + 1);
                                dayTitle[day - i] = (date.getDate());
 
                                var fullDate = date.getFullYear() + "-" + getFormatDate(date.getMonth() + 1) + "-" + getFormatDate(date.getDate());
                                var inobj = inQty.Where("x=>x.CN_T_CREATE=='" + fullDate + "'").ToArray();
                                if (inobj == null || inobj.length == 0)
                                    inData[day - i] = 0;
                                else
                                    inData[day - i] = inobj[0].QTY;
 
                                var outobj = outQty.Where("x=>x.CN_T_CREATE=='" + fullDate + "'").ToArray();
                                if (outobj == null || outobj.length == 0)
                                    outData[day - i] = 0;
                                else
                                    outData[day - i] = outobj[0].QTY;
                            }
 
                            inDataPie = Enumerable.From(result).Where("x=>x.type=='IN'").GroupBy("$.CN_S_OP_TYPE", null,
                                       function (key, g) {
                                           var result = {
                                               name: key,
                                               value: parseInt(g.Sum("x=>x.qty"))
                                           }
                                           return result;
                                       }).ToArray();
                            outDataPie = Enumerable.From(result).Where("x=>x.type=='OUT'").GroupBy("$.CN_S_OP_TYPE", null,
                                       function (key, g) {
                                           var result = {
                                               name: key,
                                               value: parseInt(g.Sum("x=>x.qty"))
                                           }
                                           return result;
                                       }).ToArray();
                        }
                    });
                    var myChart = echarts.init(document.getElementById('divBussLine'));
                    var option = {
                        title: {
                        },
                        tooltip: {
                            trigger: 'axis'
                        },
                        legend: {
                            data: ['入库', '出库']
                        },
                        color: ['#37a2da', '#e062ae', '#ff9f7f', '#67e0e3', '#9fe6b8', '#fb7293', '#e690d1', '#8378ea', '#ffdb5c', '#96bfff'],
                        grid: {
                            top: '10%',
                            left: '3%',
                            right: '4%',
                            bottom: '11%',
                            containLabel: true
                        },
                        toolbox: {
                            feature: {
                                saveAsImage: {}
                            }
                        },
                        xAxis: {
                            type: 'category',
                            boundaryGap: false,
                            data: dayTitle//['周一', '周二', '周三', '周四', '周五', '周六', '周日']
                        },
                        yAxis: {
                            type: 'value'
                        },
                        series: [
                            {
                                name: '出库',
                                type: 'line',
                                data: outData
                            },
                            {
                                name: '入库',
                                type: 'line',
                                data: inData
                            }
                        ]
                    };
                    myChart.setOption(option);
                    $this.InitPie(inDataPie, outDataPie);
                },
                initVersionLog: function () {
                    var $this = this;
                    ajaxManage({
                        url: '/Home/GetVersionLog',
                        success: function (result) {
                            if (result.Success) {
                                $this.updateContent = result.Data;
                            }
                            else {
                                wms.error(result.Msg);
                            }
                        }
                    });
                }
            },
            mounted: function () {
                var $this = this;
                this.InitBuss(7);
                this.InitLocation();
                this.initVersionLog();
            },
            watch: {
                deep: true,
                "formData.dtRange": function () {
                    var $this = this;
                    $this.InitBuss($this.formData.dtRange);
                }
            },
            computed: {
                areaUrl: function () {
                    var $this = this;
                    return '/Basic/Common/AreaList?stockCode=' + $this.formData.stockCode + "&include=1";
                },
                topHeight: function () {
                    return (this.autoHeight) - 10;
                },
                bottomHeight: function () {
                    return (this.autoHeight / 2);
                }
            },
            el: '#div'
        });
    </script>
}