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
| /**
| * 主页
| */
| var myColumns=[];
| $(function(){
| getColumns();
| // var date = new Date();//获取当前时间
| // date.setDate(date.getDate()-1);//设置天数 -1 天
| // var time = date.Format("MM-dd");
| // alert(time);
| // return;
| initViewStayTime();
| getChartPieInfo();
| getChartAxisInfo();
| });
|
| /**
| * 初始化库存显示
| * @returns
| */
| function initViewStayTime(){
| $('#test-table').bootstrapTable('destroy')
| $('#test-table').bootstrapTable({
| method : 'GET',
| url: "report/viewStayTimeList.action",
| cache : false,
| striped : true,
| pagination : true, //在表格底部显示分页工具栏
| pageSize : 5, //默认每页条数
| pageNumber : 1, //默认分页
| pageList : [ 10, 20, 50, 100, 200, 500 ],//分页数
| showColumns : true, //显示隐藏列
| showRefresh : false, //显示刷新按钮
| showExport : false,
| toolbar:"#toolbar",
| singleselect : true,
| clickToSelect: true, // 单击行即可以选中
| search : false,//显示搜素表单
| silent : true, //刷新事件必须设置
| sidePagination : "server", //表示服务端请求
| columns : myColumns,
| // [{
| // field : "appe_time",
| // title : "入库时间",
| // align : "left",
| // valign : "middle",
| // sortable : "true"
| // }, {
| // field : "stay_time",
| // title : "滞留天数",
| // align : "center",
| // valign : "middle",
| // sortable : "true"
| // }, {
| // field : "loc_no",
| // title : "库位号",
| // align : "center",
| // valign : "middle",
| // sortable : "true"
| // }, {
| // field : "mat_no",
| // title : "物料编码",
| // align : "center",
| // valign : "middle",
| // sortable : "true"
| // }, {
| // field : "mat_name",
| // title : "物料名称",
| // align : "center",
| // valign : "middle",
| // sortable : "true"
| // }, {
| // field : "qty",
| // title : "数量",
| // align : "center",
| // valign : "middle",
| // sortable : "true"
| // }, {
| // field : "memo",
| // title : "备注",
| // align : "center",
| // valign : "middle",
| // sortable : "true"
| // }, {
| // field : "str1",
| // title : "单位",
| // align : "center",
| // valign : "middle",
| // sortable : "true"
| // }, {
| // field : "str2",
| // title : "规格",
| // align : "center",
| // valign : "middle",
| // sortable : "true"
| // }],
| queryParamsType: "undefined",
| queryParams: function queryParams(params) { //设置查询参数
| var param = {
| pageNumber: params.pageNumber,
| pageSize: params.pageSize,
| loc_no:$("#loc_no").val(),
| mat_no:$("#mat_no").val(),
| mat_name:$("#mat_name").val(),
| stay_time:$("#stay_time").val(),
| begin_date:$("#begin_date").val(),
| end_date:$("#end_date").val()
| // searchText: params.searchText
| };
| return param;
| },
| formatLoadingMessage : function() {
| return "请稍等,正在加载中...";
| },
|
| formatNoMatches : function() {
| return '无符合条件的记录';
| },
| //注册加载子表的事件。注意下这里的三个参数!
| onExpandRow: function (index, row, $detail) {
| oInit.InitSubTable(index, row, $detail);
| }
|
| });
| }
|
| function getColumns() {
| myColumns=[];
| // var myColumns=[];
| // 加载动态表格
| $.ajax({
| url : $("#PageContext").val() + "/matColumn.json",
| type : 'get',
| dataType : "json",
| async : false,
| success : function(returnValue) {
| // 未查询到相应的列,展示默认列
| if (returnValue.retCode == "0") {
| //没查到列的时候把之前的列再给它
| myColumns = $table.bootstrapTable('getOptions').columns[0];
| } else {
| // 异步获取要动态生成的列
| myColumns.push({
| field : "appe_time",
| title : "入库时间",
| align : "left",
| valign : "middle",
| sortable : "true"
| });
| myColumns.push({
| field : "stay_time",
| title : "滞留天数",
| align : "center",
| valign : "middle",
| sortable : "true"
| });
| myColumns.push({
| field : "loc_no",
| title : "库位号",
| class : 'col-md-1',
| align : "center",
| valign : "middle",
| sortable : "true"
| });
| var arr = returnValue.data;
| $.each(arr, function(i, item) {
| myColumns.push({
| "field" : item.ColumnCode,
| "title" : item.ColumnName,
| // "hide" : true,
| "visible" : item.visible,
| "align" : item.align,//'center',
| "valign" : item.valign//'middle'
| });
| });
| }
| }
| });
| }
|
| /**
| * 饼状图表
| * @returns
| */
| function getChartPieInfo(){
| $.ajax({
| url:'basic/getChartPieInfo.action',
| dataType:'json',
| type:'post',
| success:function(data){
| var dataPie=eval(data.rows);
| // console.log(dataPie);
|
| var chart = {
| plotBackgroundColor: null,
| plotBorderWidth: null,
| plotShadow: false
| };
| var title = {
| text: '库位使用比例',
| margin:1,
| style:{fontSize: '14px'}
| };
| var tooltip = {
| pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
| };
| var plotOptions = {
| pie: {
| allowPointSelect: true,
| cursor: 'pointer',
| dataLabels: {
| enabled: true,
| // format: '<b>{point.name}%</b>: {point.percentage:.1f} %',
| format: '<b>{point.name}</b>: {point.percentage:.1f} %',
| style: {
| color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
| }
| }
| }
| };
| var series= [{
| type: 'pie',
| name: '库位占比',
| data: dataPie
| }];
|
| var json = {};
| json.chart = chart;
| json.title = title;
| json.tooltip = tooltip;
| json.series = series;
| json.plotOptions = plotOptions;
| json.credits = {enabled: false};
| $('#chartPie').highcharts(json);
|
| },
| error:function(){
| // alert("请求失败!");
| }
| });
| }
|
| /**
| * 曲线图表
| * @returns
| */
| function getChartAxisInfo(){
| $.ajax({
| url:'basic/getChartAxisInfo.action',
| dataType:'json',
| type:'post',
| success:function(data){
| var dataPie=eval(data.rows);
| // console.log(dataPie);
| var title = {
| text: '日入出库数量',
| margin:1,
| style:{fontSize: '14px'}
| };
| var xAxis = {
| categories: [getDate(-11), getDate(-10), getDate(-9), getDate(-8), getDate(-7), getDate(-6),
| getDate(-5), getDate(-4), getDate(-3), getDate(-2), getDate(-1), getDate(-0)]
| // categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
| // 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
| };
| var yAxis = {
| title: {
| text: '入/出库数量'
| },
| plotLines: [{
| value: 0,
| width: 1,
| color: '#808080'
| }]
| };
|
| var tooltip = {
| // valueSuffix: '\xB0C'
| }
|
| var legend = {
| layout: 'vertical',
| align: 'right',
| verticalAlign: 'middle',
| borderWidth: 0
| };
|
| var series = dataPie;
| // [
| // {
| // name: 'Tokyo1',
| // data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2,
| // 26.5, 23.3, 18.3, 13.9, 9.6]
| // },
| // {
| // name: 'New York',
| // data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8,
| // 24.1, 20.1, 14.1, 8.6, 2.5]
| // },
| // {
| // name: 'London1',
| // data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0,
| // 16.6, 14.2, 10.3, 6.6, 4.8]
| // }
| // ];
|
| var json = {};
|
| json.title = title;
| json.xAxis = xAxis;
| json.yAxis = yAxis;
| json.tooltip = tooltip;
| json.legend = legend;
| json.series = series;
| json.credits = {enabled: false};
| $('#chartAxis').highcharts(json);
|
| },
| error:function(){
| // alert("请求失败!");
| }
| });
|
| // var title = {
| // text: '日入出库数量',
| // margin:1,
| // style:{fontSize: '14px'}
| // };
| // var xAxis = {
| // categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
| // 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
| // };
| // var yAxis = {
| // title: {
| // text: '入/出库数量'
| // },
| // plotLines: [{
| // value: 0,
| // width: 1,
| // color: '#808080'
| // }]
| // };
| //
| // var tooltip = {
| //// valueSuffix: '\xB0C'
| // }
| //
| // var legend = {
| // layout: 'vertical',
| // align: 'right',
| // verticalAlign: 'middle',
| // borderWidth: 0
| // };
| //
| // var series = [
| // {
| // name: 'Tokyo1',
| // data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2,
| // 26.5, 23.3, 18.3, 13.9, 9.6]
| // },
| // {
| // name: 'New York',
| // data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8,
| // 24.1, 20.1, 14.1, 8.6, 2.5]
| // },
| // {
| // name: 'London1',
| // data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0,
| // 16.6, 14.2, 10.3, 6.6, 4.8]
| // }
| // ];
| //
| // var json = {};
| //
| // json.title = title;
| // json.xAxis = xAxis;
| // json.yAxis = yAxis;
| // json.tooltip = tooltip;
| // json.legend = legend;
| // json.series = series;
| // json.credits = {enabled: false};
| // $('#chartAxis').highcharts(json);
| }
|
| function getDate(value){
| var date = new Date();// 获取当前时间
| date.setDate(date.getDate() + value);// 设置天数 -1 天
| var time = date.Format("MM-dd");
| return time;
| }
|
| /**
| * 日期格式化
| */
| Date.prototype.Format = function (fmt) {
| var o = {
| "M+": this.getMonth() + 1, //月份
| "d+": this.getDate(), //日
| "h+": this.getHours(), //小时
| "m+": this.getMinutes(), //分
| "s+": this.getSeconds(), //秒
| "q+": Math.floor((this.getMonth() + 3) / 3), //季度
| "S": this.getMilliseconds() //毫秒
| };
| if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
| for (var k in o)
| if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
| return fmt;
| }
|
|