goods.tpl 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>欢迎页面-X-admin2.0</title>
  6. <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
  7. <script src="http://code.highcharts.com/highcharts.js"></script>
  8. </head>
  9. <body>
  10. 指定服务器:
  11. <input id="server_id" type="text" name="服务器ID" value={{.Server_id}}>
  12. <br>
  13. <br>
  14. 过往天数:
  15. <input id="days" type="text" name="天数" value={{.Days}}>
  16. <br>
  17. <br>
  18. <input class="layui-btn" type="button" onclick="submitUpdate()" value=刷新>
  19. <input class="layui-btn" type="button" onclick="submitDownload()" value=下载>
  20. <br><br>
  21. <br><br>
  22. <div id="container" style="width: 1600px; height: 800px; margin: 0 auto"></div>
  23. <script language="JavaScript">
  24. $(document).ready(function() {
  25. var chart = {
  26. type: 'column'
  27. };
  28. var title = {
  29. text: '商品统计'
  30. };
  31. var subtitle = {
  32. text: 'Source: '
  33. };
  34. var xAxis = {
  35. title: {
  36. text: '商品id'
  37. },
  38. tickPixelInterval: 1,
  39. categories: {{.Categories}}
  40. };
  41. var yAxis = {
  42. title: {
  43. text: '数量(件)'
  44. },
  45. plotLines: [{
  46. value: 0,
  47. width: 1,
  48. color: '#808080'
  49. }]
  50. };
  51. var tooltip = {
  52. valueSuffix: '件'
  53. }
  54. var legend = {
  55. layout: 'vertical',
  56. align: 'right',
  57. verticalAlign: 'middle',
  58. borderWidth: 0
  59. };
  60. var series = [
  61. ];
  62. var list = {{.Series}}
  63. for ( var i= 0; i < list.length; i++){
  64. series.push({"name":list[i].Name, "data":eval(list[i].Data)})
  65. }
  66. var json = {};
  67. json.title = title;
  68. json.subtitle = subtitle;
  69. json.xAxis = xAxis;
  70. json.yAxis = yAxis;
  71. json.tooltip = tooltip;
  72. json.legend = legend;
  73. json.series = series;
  74. json.chart = chart;
  75. $('#container').highcharts(json);
  76. });
  77. function submitUpdate () {
  78. var sid = document.getElementById("server_id").value;
  79. var days = document.getElementById("days").value;
  80. var text = "server_id=" + encodeURI(sid) + "&days=" + encodeURI(days) ;
  81. $.ajax({
  82. type:"get",
  83. url:"/goods?" + text,
  84. success:function (data) {
  85. // alert(data.status);
  86. if (data.status){
  87. window.location.href="/goods?"+text;
  88. }else{
  89. if (data.info){
  90. alert(data.info);
  91. }else{
  92. window.location.href="/goods?"+text;
  93. }
  94. }
  95. }
  96. });
  97. }
  98. function submitDownload () {
  99. var sid = document.getElementById("server_id").value;
  100. var days = document.getElementById("days").value;
  101. var text = "server_id=" + encodeURI(sid) + "&days=" + encodeURI(days) + "&querydata=goods";
  102. $.ajax({
  103. type:"get",
  104. url:"/goods?" + text,
  105. success:function (data) {
  106. // alert(data.status);
  107. if (data.status){
  108. window.location.href="/goods?"+text;
  109. }else{
  110. if (data.info){
  111. alert(data.info);
  112. }else{
  113. window.location.href="/goods?"+text;
  114. }
  115. }
  116. }
  117. });
  118. }
  119. </script>
  120. </body>
  121. </html>