index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class="app-container">
  3. <div style="width: 60%;margin: 0 auto;display: flex;justify-content: space-around;color: #0685c0">
  4. <div><span>客户总数:</span><countTo :startVal='0' :endVal='all' :duration='2500'/></div>
  5. <div><span>活跃客户:</span><countTo :startVal='0' :endVal='active' :duration='2500'/></div>
  6. </div>
  7. <div style="width: 100%;margin-top: 30px">
  8. <div id="getData" style="width: 100%;height: 400px;"></div>
  9. </div>
  10. <div style="width: 100%;margin-top: 30px;position:relative;">
  11. <el-button
  12. type="warning"
  13. size="mini"
  14. style="position: absolute;right: 30px"
  15. @click="handleExport"
  16. :disabled="!type"
  17. >导出</el-button>
  18. <el-table
  19. ref="table"
  20. v-loading="loading"
  21. :data="dataList"
  22. stripe
  23. style="width: 50%;margin: 0 auto"
  24. >
  25. <el-table-column
  26. label="客户名称"
  27. prop="fName"
  28. align="center"
  29. :show-overflow-tooltip="true"
  30. ></el-table-column>
  31. <el-table-column
  32. label="最后收费日期"
  33. prop="fBsdate"
  34. align="center"
  35. :show-overflow-tooltip="true"
  36. ></el-table-column>
  37. </el-table>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import { corpAnalysis, inactiveCorpList, corpAnalysisExport } from "@/api/reportManagement/customerAnalysis";
  43. import countTo from 'vue-count-to';
  44. export default {
  45. name: "index",
  46. data() {
  47. return {
  48. loading:false,
  49. dataList: [],
  50. pieList: [],
  51. all: 0,
  52. active: 0,
  53. type: null,
  54. }
  55. },
  56. components: {
  57. countTo
  58. },
  59. created() {
  60. },
  61. activated() {
  62. corpAnalysis().then(res => {
  63. console.log(res)
  64. this.all = res.data.all;
  65. this.active = res.data.active;
  66. this.pieList = res.data.series[0].data;
  67. this.$nextTick(() => {
  68. this.getEcharts();
  69. })
  70. })
  71. },
  72. methods:{
  73. getEcharts() {
  74. // 基于准备好的dom,初始化echarts实例,所以只能在mounted中调用
  75. let myChart = this.$echarts.init(document.getElementById("getData"));
  76. // 绘制图表
  77. myChart.setOption({
  78. legend: {
  79. top: 'bottom',
  80. },
  81. title: {
  82. text: '未活跃分析',
  83. textStyle:{
  84. color: "#9a9494",
  85. fontSize: 15,
  86. fontWeight: 'normal'
  87. },
  88. top: "37.5%",
  89. textAlign: "center",
  90. left: "49.9%"
  91. },
  92. // toolbox: {
  93. // show: true,
  94. // feature: {
  95. // mark: { show: true },
  96. // dataView: { show: true, readOnly: false },
  97. // restore: { show: true },
  98. // saveAsImage: { show: true }
  99. // }
  100. // },
  101. tooltip: {
  102. trigger: 'item',
  103. formatter: '{b} : {c} ({d}%)'
  104. },
  105. series: [
  106. {
  107. name: '未活跃分析',
  108. type: 'pie',
  109. radius: [50, 180],
  110. center: ['50%', '40%'],
  111. roseType: 'area',
  112. itemStyle: {
  113. borderRadius: 8,
  114. },
  115. data: this.pieList
  116. }
  117. ]
  118. })
  119. myChart.on('click', this.handleClick)
  120. },
  121. handleClick(param) {
  122. this.loading = true;
  123. if (param.data.name == '1-3个月') {
  124. this.type = 1
  125. } else if (param.data.name == '3-6个月') {
  126. this.type = 2
  127. } else if (param.data.name == '6-12个月') {
  128. this.type = 3
  129. } else if (param.data.name == '12-24个月') {
  130. this.type = 4
  131. } else if (param.data.name == '24个月以上') {
  132. this.type = 5
  133. }
  134. inactiveCorpList({type: this.type}).then(res => {
  135. this.dataList = res.data
  136. }).finally(() => {
  137. this.loading = false;
  138. })
  139. },
  140. handleExport() {
  141. this.$confirm('是否确认导出', '警告', {
  142. confirmButtonText: "确定",
  143. cancelButtonText: "取消",
  144. type: "warning",
  145. }).then(() => {
  146. corpAnalysisExport({type: this.type}).then(res => {
  147. this.download(res.msg);
  148. })
  149. }).catch(() => {
  150. })
  151. },
  152. }
  153. }
  154. </script>
  155. <style scoped>
  156. </style>