rank-list.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <el-drawer size='480px' :visible.sync="show" direction="rtl" destroy-on-close>
  3. <view id="chart-bar" ref="chartBar" v-loading="loading" :style="{height:height}" class=""></view>
  4. <view slot="title">
  5. <text class="ui-mr20">排行榜<!-- {{yearMonth}} --></text>
  6. <el-date-picker v-model="yearMonth" value-format="yyyyMM" type="month" placeholder="选择月" @change="change"></el-date-picker>
  7. </view>
  8. </el-drawer>
  9. </template>
  10. <script>
  11. import { Loading } from 'element-ui';
  12. import * as echarts from "echarts";
  13. import {
  14. chartBar
  15. } from './chart.js'
  16. export default {
  17. data() {
  18. return {
  19. show: false,
  20. loading : false,
  21. height : 0,
  22. yearMonth : '',
  23. }
  24. },
  25. props: {
  26. chooseClassId: {
  27. type: Number | String,
  28. default: ""
  29. },
  30. cartoonHeadImg : {
  31. default : true,
  32. },
  33. },
  34. computed: {},
  35. methods: {
  36. change(){
  37. this.getData();
  38. },
  39. open() {
  40. this.show = true;
  41. this.$nextTick(() => {
  42. this.getData();
  43. })
  44. },
  45. getData(){
  46. this.loading = true;
  47. // this.loadingInstance = Loading.service({
  48. // target : this.$refs.chartBar.$el
  49. // });
  50. this.$api.sendRequest({
  51. url: '/mobile/studentTab/getStudentMonthRank',
  52. method: "post",
  53. data: {
  54. class_id: this.chooseClassId,
  55. year_month : this.yearMonth
  56. },
  57. success: res => {
  58. // this.loadingInstance.close();
  59. this.loading = false;
  60. this.height = `${res.data.length * 60}px`
  61. this.$nextTick(() => {
  62. // console.log(this.$refs.chartBar.$el);
  63. const dom = this.$refs.chartBar.$el;
  64. this.chart = echarts.init(dom);
  65. this.chart.clear();
  66. this.chart.setOption(chartBar(res.data, this.cartoonHeadImg));
  67. })
  68. }
  69. })
  70. }
  71. }
  72. }
  73. </script>
  74. <style>
  75. </style>