Statistically.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <div>
  3. <div class="statistically-all">
  4. <div class="yeardate">
  5. <el-date-picker
  6. @change="yearchange"
  7. style="width:200px;"
  8. v-model="year"
  9. type="year"
  10. placeholder="选择年">
  11. </el-date-picker>
  12. </div>
  13. <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
  14. <el-tab-pane label="营业额、成本支出、毛利润" name="first">
  15. <div class="canvas-box">
  16. <div id="statisticallyone" style="width: 100%;height:400px;"></div>
  17. <div id="grossmargins" style="width: 100%;height:400px;"></div>
  18. <div id="grossmargin" style="width: 100%;height:400px;"></div>
  19. </div>
  20. </el-tab-pane>
  21. <el-tab-pane label="国交数据统计" name="second">
  22. <div class="canvas-box">
  23. <div id="grossmarginss" style="width: 50%;height:400px;"></div>
  24. </div>
  25. </el-tab-pane>
  26. <el-tab-pane label="会务数据统计" name="third">会务数据统计</el-tab-pane>
  27. <el-tab-pane label="定时任务补偿" name="fourth">定时任务补偿</el-tab-pane>
  28. </el-tabs>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. import * as echarts from 'echarts';
  34. export default {
  35. data () {
  36. return {
  37. year:new Date(),
  38. businessincome:[],
  39. Grossprofit:[],
  40. costing:[],
  41. Airticketnum:[],
  42. aaa:[
  43. ['product', '去年销售额', '今年销售额'],
  44. ['1月', 43.3, 85.8],
  45. ['2月', 83.1, 73.4],
  46. ['3月', 86.4, 65.2],
  47. ['4月', 72.4, 53.9],
  48. ['5月', 72.4, 53.9],
  49. ['6月', 72.4, 53.9],
  50. ['7月', 72.4, 53.9],
  51. ['8月', 72.4, 53.9],
  52. ['9月', 72.4, 53.9],
  53. ['10月', 72.4, 53.9],
  54. ['11月', 72.4, 53.9],
  55. ['12月', 72.4, 53.9],
  56. ],
  57. bbb:[
  58. ['product', '毛利率',],
  59. ['1月', 43.3,],
  60. ['2月', 83.1,],
  61. ['3月', 86.4,],
  62. ['4月', 72.4,],
  63. ['5月', 72.4,],
  64. ['6月', 72.4,],
  65. ['7月', 72.4,],
  66. ['8月', 72.4,],
  67. ['9月', 72.4,],
  68. ['10月', 72.4,],
  69. ['11月', 72.4,],
  70. ['12月', 72.4,],
  71. ],
  72. activeName: 'second',
  73. }
  74. },
  75. methods: {
  76. handleClick(tab, event) {
  77. console.log(this.activeName);
  78. // console.log(tab, event);
  79. },
  80. //处理时间
  81. getdate(val){
  82. var date=new Date(val);
  83. var y=date.getFullYear();
  84. return y
  85. },
  86. statisone(){
  87. console.log(this.businessincome,this.Grossprofit,this.costing);
  88. var myChart = echarts.init(document.getElementById('statisticallyone'));
  89. myChart.setOption({
  90. title:{
  91. text: '业务总营业额',
  92. },
  93. legend: {},
  94. tooltip: {},
  95. dataset: {
  96. source: this.businessincome
  97. },
  98. xAxis: { type: 'category' },
  99. yAxis: {
  100. name: '营业额',
  101. },
  102. series: [{ type: 'bar' }, { type: 'bar' },]
  103. });
  104. var grossmargins = echarts.init(document.getElementById('grossmargins'));
  105. grossmargins.setOption({
  106. title:{
  107. text: '成本',
  108. },
  109. legend: {},
  110. tooltip: {},
  111. dataset: {
  112. source: this.costing
  113. },
  114. xAxis: { type: 'category' },
  115. yAxis: {
  116. name: '成本额',
  117. },
  118. series: [{ type: 'bar' }, { type: 'bar' },]
  119. });
  120. var grossmargin = echarts.init(document.getElementById('grossmargin'));
  121. grossmargin.setOption({
  122. title:{
  123. text: '毛利润',
  124. },
  125. legend: {},
  126. tooltip: {
  127. formatter:function(params){
  128. console.log(params);
  129. // var html = params.data[0]+'毛利率'+"<br/>"+ params.data[1]+"%";
  130. // return html
  131. }
  132. },
  133. dataset: {
  134. source: this.Grossprofit
  135. },
  136. xAxis: { type: 'category' },
  137. yAxis: {
  138. name: '毛利额',
  139. },
  140. color:['#EEAD0E','#a0a7e6'],
  141. // Declare several bar series, each will be mapped
  142. // to a column of dataset.source by default.
  143. series: [{ type: 'bar' },{ type: 'bar' }]
  144. });
  145. },
  146. //年change
  147. yearchange(){
  148. this.businessincome=[];
  149. this.Grossprofit=[];
  150. this.costing=[];
  151. this.StatisticsYOY()
  152. },
  153. //获取营业额、成本支出、毛利润数据
  154. StatisticsYOY(){
  155. var url = "/api/Statistics/StatisticsYOY"
  156. var that = this
  157. this.$axios({
  158. method: 'post',
  159. url: url,
  160. headers: {
  161. Authorization: 'Bearer '
  162. },
  163. data:{
  164. year:that.getdate(that.year),
  165. }
  166. }).then(function (res) {
  167. if(res.data.code==200){
  168. //营业额
  169. that.businessincome.push(['product', '前一年该月营业额', '本年该月营业额']);
  170. for(let i=0;i<res.data.data.salesYOYData.length;i++){
  171. that.businessincome.push([res.data.data.salesYOYData[i].month+'月',res.data.data.salesYOYData[i].lastAmount,res.data.data.salesYOYData[i].thisAmount]);
  172. }
  173. //毛利润
  174. that.Grossprofit.push(['product', '前一年该月毛利润', '本年该月毛利润']);
  175. for(let j=0;j<res.data.data.grossProfitYOYData.length;j++){
  176. that.Grossprofit.push([res.data.data.grossProfitYOYData[j].month+'月',res.data.data.grossProfitYOYData[j].lastAmount,res.data.data.grossProfitYOYData[j].thisAmount]);
  177. }
  178. //成本
  179. that.costing.push(['product', '前一年该月成本', '本年该月成本']);
  180. for(let g=0;g<res.data.data.costYOYData.length;g++){
  181. that.costing.push([res.data.data.costYOYData[g].month+'月',res.data.data.costYOYData[g].lastAmount,res.data.data.costYOYData[g].thisAmount]);
  182. }
  183. that.statisone()
  184. }else{
  185. that.$message({
  186. message: res.data.msg,
  187. type: 'warning'
  188. });
  189. }
  190. })
  191. },
  192. //获取国交数据统计数据
  193. StatisticsAirTicket(){
  194. var url = "/api/Statistics/StatisticsAirTicket"
  195. var that = this
  196. this.$axios({
  197. method: 'post',
  198. url: url,
  199. headers: {
  200. Authorization: 'Bearer '
  201. },
  202. data:{
  203. year:that.getdate(that.year),
  204. }
  205. }).then(function (res) {
  206. if(res.data.code==200){
  207. var datainfo=res.data.data;
  208. //机票数
  209. that.Airticketnum.push(['product','本年机票数量']);
  210. for(let i=0;i<datainfo.airTicketNumData.length;i++){
  211. that.Airticketnum.push([datainfo.airTicketNumData[i].month+'月',datainfo.airTicketNumData[i].quantity]);
  212. }
  213. console.log(that.Airticketnum);
  214. }else{
  215. that.$message({
  216. message: res.data.msg,
  217. type: 'warning'
  218. });
  219. }
  220. })
  221. },
  222. },
  223. mounted(){
  224. this.StatisticsYOY();
  225. this.StatisticsAirTicket();
  226. }
  227. }
  228. </script>
  229. <style>
  230. .statistically-all{
  231. background-color: #fff;
  232. padding: 10px;
  233. box-shadow: 0 0 5px #0005;
  234. border-radius: 10px;
  235. height: 100%;
  236. min-height: 830px;
  237. }
  238. .canvas-box{
  239. display: flex;
  240. flex-wrap: wrap;
  241. }
  242. .yeardate{
  243. margin-bottom: 10px;
  244. }
  245. </style>