console-main.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Sa-Admin 控制台</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <!-- 所有的 css & js 资源 -->
  8. <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
  9. <link rel="stylesheet" href="../../static/sa.css">
  10. <style type="text/css">
  11. .vue-box{margin: 0; padding: 0; height: 100%;}
  12. .el-card{border-radius: 0px; border: 1px #ddd solid ; margin-bottom: 14px;}
  13. .s-row{/* background-color: antiquewhite; */ padding: 0 14px; padding-bottom: 0px;}
  14. .s-row-1{padding-top: 14px;}
  15. .s-row-2{/* margin-top: -10px; */}
  16. .s-row-2 .el-card .el-card__body{height: 230px;}
  17. .s-row-3 .el-card{/* height: 100%; */}
  18. .echarts-div{height: 100%;}
  19. .s-row-3 .el-alert{margin-bottom: 14px;}
  20. .years {float: right;margin-top: -63px;overflow: hidden;}
  21. .ctype {float: left;margin-right: 30px;}
  22. .year {float: left;padding: 5px 10px;background-color: #f6f6f6;cursor: pointer;font-size: 14px;color: #545555;}
  23. .year.active{background-color: rgba(37, 97, 239, 1);color: white;}
  24. </style>
  25. </head>
  26. <body>
  27. <div class="vue-box" style="display: none;" :style="'display: block;'">
  28. <!-- ------------ 第一栏 - 统计数据 ------------- -->
  29. <div class="s-row s-row-1">
  30. <com-sta-data :sta="sta"></com-sta-data>
  31. </div>
  32. <!-- ------------ 第二栏 - 图表 ------------- -->
  33. <div class="s-row s-row-2">
  34. <el-card shadow="never" header="订单交易额">
  35. <div class="years">
  36. <div class="ctype">
  37. <div class="year" :class="{ active: currentType == index }" @click="currentType = index" v-for="(item, index) in types" :key="index">{{ item.name }}</div>
  38. </div>
  39. <div class="year" :class="{ active: currentYear == index }" v-for="(item, index) in year" :key="index" @click="selectYear(index)">{{ item.year}}年</div>
  40. </div>
  41. <com-chart-1 :chart-data="chartData.money" :type="types[currentType].value"></com-chart-1>
  42. </el-card>
  43. <el-card shadow="never" header="订单交易量">
  44. <com-chart-1 :chart-data="chartData.count" :type="types[currentType].value"></com-chart-1>
  45. </el-card>
  46. </div>
  47. </div>
  48. <script src="https://unpkg.com/vue@2.6.10/dist/vue.js"></script>
  49. <script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
  50. <script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
  51. <script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
  52. <script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
  53. <script src="https://unpkg.com/echarts@4.6.0/dist/echarts-en.min.js"></script>
  54. <script src="../../static/sa.js"></script>
  55. <script type="text/javascript">
  56. new Vue({
  57. components: {
  58. 'com-sta-data': httpVueLoader('com-sta-data.vue'),
  59. 'com-chart-1': httpVueLoader('com-chart-1.vue'),
  60. 'com-chart-2': httpVueLoader('com-chart-2.vue'),
  61. 'com-chart-3': httpVueLoader('com-chart-3.vue'),
  62. 'com-stack': httpVueLoader('com-stack.vue'),
  63. 'com-update-log': httpVueLoader('com-update-log.vue'),
  64. 'com-origin': httpVueLoader('com-origin.vue'),
  65. },
  66. el: '.vue-box',
  67. data: {
  68. sta: {bm: 0,purchaser: 0,orderCount: 0,totalMoney: 0,orders: 0,finishMoney: 0,},
  69. chartData: {money: [],count: []},
  70. year: [], //订单所有年份
  71. currentType: 0, //当前图表类型
  72. currentYear: 0, //当前年份
  73. types: [{name: '柱状图',value: 'bar'}, {name: '折线图',value: 'line'}],
  74. },
  75. mounted: function() {
  76. this.getYear();
  77. this.getUsers();
  78. },
  79. methods: {
  80. getOrderStatistics() {
  81. sa.ajax('/level-two-server/TbOrders/orderStatistics', {year: this.year[this.currentYear].year}, res => {
  82. this.chartData = res.data;
  83. });
  84. },
  85. getUsers() {
  86. sa.ajax('/sp-admin/AppUser/selectUsers', res => {
  87. this.sta.bm=parseInt(res.data.bmzz)+parseInt(res.data.bm);
  88. this.sta.purchaser=res.data.purchaser;
  89. });
  90. },
  91. getYear() {
  92. sa.ajax('/level-two-server/TbOrders/selectYear', res => {
  93. this.year = res.data.year;
  94. this.currentYear = this.year.length - 1;
  95. this.sta.totalMoney = res.data.count.totalMoney;
  96. this.sta.finishMoney = res.data.count.finishMoney;
  97. this.sta.orders = res.data.count.orders;
  98. this.getOrderStatistics();
  99. });
  100. },
  101. selectYear(index) {
  102. this.currentYear = index;
  103. this.getOrderStatistics();
  104. }
  105. }
  106. })
  107. // 设置监听,改变窗口大小时重绘图表
  108. window.myChartList = [];
  109. window.onresize = function() {
  110. myChartList.forEach(function(myChart) {
  111. myChart.resize();
  112. })
  113. }
  114. </script>
  115. <!-- 百度统计(下载到本地后请删除) -->
  116. <div style="height: 0px; overflow: hidden;">
  117. <script type="text/javascript" src="https://v1.cnzz.com/z_stat.php?id=1279021391&web_id=1279021391">
  118. </script>
  119. </div>
  120. </body>
  121. </html>