zhao
2021-07-02 23ee356c6f260ecc1a48bbb8bd60932b979e4698
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
@{
    ViewBag.Title = "LocationHistory";
    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>
    .el-table .warning-row {
        background:#ffc5c5;
    }
 
    .el-table .success-row {
        background:#c4ffc1;
    }
</style>
<div id="list" v-cloak>
    <el-card class="box-card">
        <el-form label-width="90px" v-bind:model="formData" class="demo-ruleForm" v-bind:inline="true">
            <el-form-item label="@L("cshtml_allquery_inventory_locationhistoryqzhk_stockcode"):">
                <hh-select-url v-model="formData.stockCode"
                               url="/Basic/Common/StockList"
                               valuefield="CN_S_STOCK_CODE"
                               textfield="CN_S_STOCK_NAME"
                               datafield="Data">
                </hh-select-url>
            </el-form-item>
            @*<el-form-item label="上/下架:">
                <hh-select-url v-model="formData.type"
                               valuefield="CN_S_STOCK_CODE"
                               textfield="CN_S_STOCK_NAME"
                               datafield="Data">
                </hh-select-url>
            </el-form-item>*@
            @*<el-form-item label="业务类型:">
                <hh-select-url v-model="formData.opType"
                               url="/Basic/Common/GetOperationTypeList?opType=入库单,出库单"
                               valuefield="CN_S_OPERATION_NAME"
                               textfield="CN_S_OPERATION_NAME"
                               datafield="Data"></hh-select-url>
            </el-form-item>*@
 
            <el-form-item label="@L("cshtml_allquery_inventory_locationhistoryqzhk_location"):">
                <el-input v-model="formData.location" size="mini"></el-input>
            </el-form-item>
            <el-form-item label="@L("cshtml_allquery_inventory_locationhistoryqzhk_businessnumber"):">
                <el-input v-model="formData.opNo" size="mini"></el-input>
            </el-form-item>
            <el-form-item label="@L("cshtml_allquery_inventory_locationhistoryqzhk_itemcode"):">
                <el-input v-model="formData.itemCode" size="mini"></el-input>
            </el-form-item>
            <el-form-item label="@L("cshtml_allquery_inventory_locationhistoryqzhk_itemname"):">
                <el-input v-model="formData.itemName" size="mini"></el-input>
            </el-form-item>
            <el-form-item label="@L("cshtml_allquery_inventory_locationhistoryqzhk_itemmodel"):">
                <el-input v-model="formData.model" size="mini"></el-input>
            </el-form-item>
            <el-form-item label="@L("cshtml_allquery_inventory_locationhistoryqzhk_creationtime"):" style="width:400px">
                <el-date-picker v-model="formData.date"
                                type="daterange"
                                align="right"
                                unlink-panels
                                range-separator="@L("cshtml_public_constant_to")"
                                start-placeholder="@L("cshtml_public_constant_start_date")"
                                end-placeholder="@L("cshtml_public_constant_end_date")"
                                value-format="yyyy-MM-dd"
                                v-on:change="selectTime" size="mini" style="width:300px">
                </el-date-picker>
            </el-form-item>
            <el-form-item>
                <el-button style="margin-top:2px;" size="mini" type="primary" v-on:click="search">@L("cshtml_public_button_search")</el-button>
            </el-form-item>
 
        </el-form>
        <el-row style="padding-left: 10px; margin-top: 7px;">
            @*<el-button size="mini" type="primary" v-on:click="add">导 出</el-button>*@
        </el-row>
    </el-card>
    <hh-table v-bind:coloptions="outCols"
              v-bind:paging="true"
              v-bind:check="false"
              v-bind:where="where"
              v-bind:rowno="true"
              v-bind:rowstyle="tableRowClassName"
              dh="120"
              url="@Url.Action("GetLocationHistory")"
              ref="busslist"></hh-table>
    @*<el-card class="box-card" >
        <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-row>
    </el-card>*@
</div>
@section scripts{
    <script>
        var outList = new Vue({
            data: {
                formData: {
                    stockCode: "",
                    opType: "",
                    opNo: "",
                    itemCode: "",
                    itemName: "",
                    model: "",
                    location:"",
                    date: "",
                    valueDate: ""
                },
                where: {},
                outCols: [
                    { f: "type", n: "+/-", w: 30 },
                    { f: "CN_S_STOCK_CODE", n: "@L("cshtml_allquery_inventory_locationhistoryqzhk_stockcode")", w: 80 },
                    { f: "CN_S_STOCK_AREA", n: "@L("cshtml_allquery_inventory_locationhistoryqzhk_areacode")", w: 80 },
                    { f: "CN_S_LOCATION_CODE", n: "@L("cshtml_allquery_inventory_locationhistoryqzhk_location")", w: 120 },
                    { f: "CN_S_TRAY_CODE", n: "@L("cshtml_allquery_inventory_locationhistoryqzhk_tray")", w: 100 },           
                    { f: "CN_S_ITEM_CODE", n: "@L("cshtml_allquery_inventory_locationhistoryqzhk_itemcode")", w: 150 },
                    { f: "CN_S_ITEM_NAME", n: "@L("cshtml_allquery_inventory_locationhistoryqzhk_itemname")", w: 150 },
                    { f: "CN_S_MODEL", n: "@L("cshtml_allquery_inventory_locationhistoryqzhk_itemmodel")", w: 150 },
                    { f: "CN_S_PRODUCTION_BATCH", n: "@L("cshtml_allquery_inventory_locationhistoryqzhk_productbatch")", w: 150 },
                    {
                        f: "CN_F_QUANTITY", n: "@L("cshtml_allquery_inventory_locationhistoryqzhk_qty")", w: 60, format: function (row, column) {
                            if (row.type == "+") {
                                value = row.CN_F_QUANTITY;
                            } else if (row.type == "-") {
                                value = "-" + row.CN_F_QUANTITY;
                            } else {
                                value = row.CN_F_QUANTITY;
                            }
                            return value;
                        }
                    },
                    { f: "CN_S_MEASURE_UNIT", n: "@L("cshtml_allquery_inventory_locationhistoryqzhk_unit")", w: 60 },
                    { f: "CN_T_CREATE", n: "@L("cshtml_allquery_inventory_locationhistoryqzhk_worktime")", w: 120 },
                { f: "CN_S_OP_FROM", n: "@L("cshtml_allquery_inventory_locationhistoryqzhk_frombusiness")", w: 80 }
                ]
            },
            mounted: function () {
                $this = this;
                //data();
                //$this.InitBuss(7);
            },
            methods: {
                search: function () {
                    this.$refs.busslist.loadData(this.formData);
                },
                selectTime: function (val) {
                    $this = this;
                    if (val != null)
                        $this.formData.valueDate = JSON.stringify(val);
                    else
                        $this.formData.valueDate = "";
                },
                InitBuss: function (day) {
                    $this = this;
                    var dayTitle = new Array()
                    var inData = new Array();
                    var outData = new Array();
 
                    ajaxManage({
                        url: '@Url.Action("HistoryLine")',
                        data: $this.formData,
                        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 inQty = 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.INTIME=='" + 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;
                            //}
                        }
                    });
                    var myChart = echarts.init(document.getElementById('divBussLine'));
                    var option = {
                        title: {
                        },
                        tooltip: {
                            trigger: 'axis'
                        },
                        legend: {
                            data: ['@L("cshtml_allquery_inventory_locationhistoryqzhk_instock")', '@L("cshtml_allquery_inventory_locationhistoryqzhk_outstock")']
                        },
                        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: '@L("cshtml_allquery_inventory_locationhistoryqzhk_instock")',
                                type: 'line',
                                data: inData
                            }
                        ]
                    };
                    myChart.setOption(option);
                },
                tableRowClassName: function (data, rowIndex) {
                    if (data.row.type === '-') {
                        return 'warning-row';
                    } else if (data.row.type === '+') {
                        return 'success-row';
                    }
                    return '';
                }
            },
            el: '#list'
        });
 
        function getFormatDate(arg) {
            if (arg == undefined || arg == '') {
                return '';
            }
            var re = arg + '';
            if (re.length < 2) {
                re = '0' + re;
            }
            return re;
        }
    </script>
}