Statistically.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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: 100%;height:400px;"></div>
  24. <div id="Airticketcitybox" style="width: 100%;height:400px;"></div>
  25. </div>
  26. </el-tab-pane>
  27. <el-tab-pane label="会务数据统计" name="third">会务数据统计</el-tab-pane>
  28. <el-tab-pane label="定时任务补偿" name="fourth">定时任务补偿</el-tab-pane>
  29. </el-tabs>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import * as echarts from 'echarts';
  35. export default {
  36. data () {
  37. return {
  38. year:new Date(),
  39. businessincome:[],
  40. Grossprofit:[],
  41. costing:[],
  42. Airticketnum:[],
  43. Airticketcity:[],
  44. aaa:[
  45. ['product', '去年销售额', '今年销售额'],
  46. ['1月', 43.3, 85.8],
  47. ['2月', 83.1, 73.4],
  48. ['3月', 86.4, 65.2],
  49. ['4月', 72.4, 53.9],
  50. ['5月', 72.4, 53.9],
  51. ['6月', 72.4, 53.9],
  52. ['7月', 72.4, 53.9],
  53. ['8月', 72.4, 53.9],
  54. ['9月', 72.4, 53.9],
  55. ['10月', 72.4, 53.9],
  56. ['11月', 72.4, 53.9],
  57. ['12月', 72.4, 53.9],
  58. ],
  59. bbb:[
  60. ['product', '毛利率',],
  61. ['1月', 43.3,],
  62. ['2月', 83.1,],
  63. ['3月', 86.4,],
  64. ['4月', 72.4,],
  65. ['5月', 72.4,],
  66. ['6月', 72.4,],
  67. ['7月', 72.4,],
  68. ['8月', 72.4,],
  69. ['9月', 72.4,],
  70. ['10月', 72.4,],
  71. ['11月', 72.4,],
  72. ['12月', 72.4,],
  73. ],
  74. activeName: 'second',
  75. }
  76. },
  77. methods: {
  78. handleClick(tab, event) {
  79. console.log(this.activeName);
  80. if(this.activeName=='first'){
  81. this.StatisticsYOY()
  82. }
  83. if(this.activeName=='second'){
  84. this.StatisticsAirTicket()
  85. }
  86. // console.log(tab, event);
  87. },
  88. //处理时间
  89. getdate(val){
  90. var date=new Date(val);
  91. var y=date.getFullYear();
  92. return y
  93. },
  94. groupstatisone(){
  95. var grossmarginss = echarts.init(document.getElementById('grossmarginss'));
  96. grossmarginss.setOption({
  97. title:{
  98. text: '预订机票数量',
  99. },
  100. legend: {},
  101. tooltip: {
  102. formatter:function(params){
  103. var html="该月总次数:"+params.data[1]+"次<br/>";
  104. for(let i=0;i<params.data[2].length;i++){
  105. html += '团组:'+params.data[2][i].groupName+'&nbsp;&nbsp;&nbsp;'+'预订机票次数:' +params.data[2][i].quantity+"<br/>";
  106. }
  107. return html
  108. }
  109. },
  110. dataset: {
  111. source: this.Airticketnum
  112. },
  113. xAxis: { type: 'category' },
  114. yAxis: {
  115. name: '机票数量',
  116. },
  117. color:['#2e83d4'],
  118. // Declare several bar series, each will be mapped
  119. // to a column of dataset.source by default.
  120. series: [{ type: 'bar' }]
  121. });
  122. var Airticketcitybox = echarts.init(document.getElementById('Airticketcitybox'));
  123. Airticketcitybox.setOption({
  124. title:{
  125. text: '机票到达地数量',
  126. },
  127. legend: {},
  128. tooltip: {
  129. formatter:function(params){
  130. console.log(params.data);
  131. var html="该月总次数:"+params.data[1]+"次<br/>";
  132. for(let i=0;i<params.data[2].length;i++){
  133. html += '城市:'+params.data[2][i].city+'&nbsp;&nbsp;&nbsp;'+'到到此城市次数:' +params.data[2][i].quantity+"<br/>";
  134. }
  135. return html
  136. }
  137. },
  138. dataset: {
  139. source: this.Airticketcity
  140. },
  141. xAxis: { type: 'category' },
  142. yAxis: {
  143. name: '到达次数',
  144. },
  145. color:['#2e83d4'],
  146. // Declare several bar series, each will be mapped
  147. // to a column of dataset.source by default.
  148. series: [{ type: 'bar' }]
  149. });
  150. },
  151. statisone(){
  152. var myChart = echarts.init(document.getElementById('statisticallyone'));
  153. myChart.setOption({
  154. title:{
  155. text: '业务总营业额',
  156. },
  157. legend: {},
  158. tooltip: {},
  159. dataset: {
  160. source: this.businessincome
  161. },
  162. xAxis: { type: 'category' },
  163. yAxis: {
  164. name: '营业额',
  165. },
  166. series: [{ type: 'bar' }, { type: 'bar' },]
  167. });
  168. var grossmargins = echarts.init(document.getElementById('grossmargins'));
  169. grossmargins.setOption({
  170. title:{
  171. text: '成本',
  172. },
  173. legend: {},
  174. tooltip: {},
  175. dataset: {
  176. source: this.costing
  177. },
  178. xAxis: { type: 'category' },
  179. yAxis: {
  180. name: '成本额',
  181. },
  182. series: [{ type: 'bar' }, { type: 'bar' },]
  183. });
  184. var grossmargin = echarts.init(document.getElementById('grossmargin'));
  185. grossmargin.setOption({
  186. title:{
  187. text: '毛利润',
  188. },
  189. legend: {},
  190. tooltip: {
  191. // formatter:function(params){
  192. // console.log(params);
  193. // var html = params.data[0]+'毛利率'+"<br/>"+ params.data[1]+"%";
  194. // return html
  195. // }
  196. },
  197. dataset: {
  198. source: this.Grossprofit
  199. },
  200. xAxis: { type: 'category' },
  201. yAxis: {
  202. name: '毛利额',
  203. },
  204. color:['#EEAD0E','#a0a7e6'],
  205. // Declare several bar series, each will be mapped
  206. // to a column of dataset.source by default.
  207. series: [{ type: 'bar' },{ type: 'bar' }]
  208. });
  209. },
  210. //年change
  211. yearchange(){
  212. // this.businessincome=[];
  213. // this.Grossprofit=[];
  214. // this.costing=[];
  215. this.StatisticsYOY()
  216. },
  217. //获取营业额、成本支出、毛利润数据
  218. StatisticsYOY(){
  219. var url = "/api/Statistics/StatisticsYOY"
  220. var that = this
  221. this.$axios({
  222. method: 'post',
  223. url: url,
  224. headers: {
  225. Authorization: 'Bearer '
  226. },
  227. data:{
  228. year:that.getdate(that.year),
  229. }
  230. }).then(function (res) {
  231. if(res.data.code==200){
  232. that.businessincome=[];
  233. that.Grossprofit=[];
  234. that.costing=[];
  235. //营业额
  236. that.businessincome.push(['product', '前一年该月营业额', '本年该月营业额']);
  237. for(let i=0;i<res.data.data.salesYOYData.length;i++){
  238. that.businessincome.push([res.data.data.salesYOYData[i].month+'月',res.data.data.salesYOYData[i].lastAmount,res.data.data.salesYOYData[i].thisAmount]);
  239. }
  240. //毛利润
  241. that.Grossprofit.push(['product', '前一年该月毛利润', '本年该月毛利润']);
  242. for(let j=0;j<res.data.data.grossProfitYOYData.length;j++){
  243. that.Grossprofit.push([res.data.data.grossProfitYOYData[j].month+'月',res.data.data.grossProfitYOYData[j].lastAmount,res.data.data.grossProfitYOYData[j].thisAmount]);
  244. }
  245. //成本
  246. that.costing.push(['product', '前一年该月成本', '本年该月成本']);
  247. for(let g=0;g<res.data.data.costYOYData.length;g++){
  248. that.costing.push([res.data.data.costYOYData[g].month+'月',res.data.data.costYOYData[g].lastAmount,res.data.data.costYOYData[g].thisAmount]);
  249. }
  250. that.statisone()
  251. }else{
  252. that.$message({
  253. message: res.data.msg,
  254. type: 'warning'
  255. });
  256. }
  257. })
  258. },
  259. //获取国交数据统计数据
  260. StatisticsAirTicket(){
  261. var url = "/api/Statistics/StatisticsAirTicket"
  262. var that = this
  263. this.$axios({
  264. method: 'post',
  265. url: url,
  266. headers: {
  267. Authorization: 'Bearer '
  268. },
  269. data:{
  270. year:that.getdate(that.year),
  271. }
  272. }).then(function (res) {
  273. if(res.data.code==200){
  274. that.Airticketnum=[];
  275. that.Airticketcity=[];
  276. var datainfo=res.data.data;
  277. //机票数
  278. that.Airticketnum.push(['product','本年机票数量']);
  279. for(let i=0;i<datainfo.airTicketNumData.length;i++){
  280. that.Airticketnum.push([datainfo.airTicketNumData[i].month+'月',datainfo.airTicketNumData[i].quantity,datainfo.airTicketNumData[i].aitTicketInfos]);
  281. }
  282. //机票到达地
  283. that.Airticketcity.push(['product','本年机票到达地']);
  284. for(let i=0;i<datainfo.airTicketAreaData.length;i++){
  285. that.Airticketcity.push([datainfo.airTicketAreaData[i].month+'月',datainfo.airTicketAreaData[i].quantity,datainfo.airTicketAreaData[i].cityData]);
  286. }
  287. that.groupstatisone()
  288. }else{
  289. that.$message({
  290. message: res.data.msg,
  291. type: 'warning'
  292. });
  293. }
  294. })
  295. },
  296. },
  297. mounted(){
  298. // this.StatisticsYOY();
  299. this.StatisticsAirTicket();
  300. }
  301. }
  302. </script>
  303. <style>
  304. .statistically-all{
  305. background-color: #fff;
  306. padding: 10px;
  307. box-shadow: 0 0 5px #0005;
  308. border-radius: 10px;
  309. height: 100%;
  310. min-height: 830px;
  311. }
  312. .canvas-box{
  313. display: flex;
  314. flex-wrap: wrap;
  315. }
  316. .yeardate{
  317. margin-bottom: 10px;
  318. }
  319. </style>