top-right.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div id="top-right">
  3. <div id="chart" class="" style="height:450px;margin:40px 0 0 0"></div>
  4. </div>
  5. </template>
  6. <script>
  7. import echarts from 'echarts/lib/echarts';
  8. import 'echarts/lib/chart/bar';
  9. import 'echarts/lib/chart/pie';
  10. import 'echarts/lib/chart/line';
  11. import 'echarts/lib/component/title';
  12. import 'echarts/lib/component/legend';
  13. import 'echarts/lib/component/toolbox';
  14. import 'echarts/lib/component/markPoint';
  15. import 'echarts/lib/component/tooltip';
  16. import { mapState, createNamespacedHelpers } from 'vuex';
  17. const { mapActions } = createNamespacedHelpers('transaction');
  18. const { mapActions: personalRoom } = createNamespacedHelpers('personalroom');
  19. export default {
  20. name: 'top-right',
  21. props: {},
  22. components: {},
  23. data: () => {
  24. return {
  25. myChart: null,
  26. };
  27. },
  28. created() {
  29. this.init();
  30. },
  31. methods: {
  32. ...mapActions(['query']),
  33. ...personalRoom(['countRoom']),
  34. async init() {
  35. let res = await this.query();
  36. let rooms = await this.countRoom();
  37. if (this.$checkRes(res)) {
  38. let arr = res.data.filter(f => f.status != '3');
  39. let s1 = res.data.filter(f => f.status == '1'); //达成意向
  40. let s2 = res.data.filter(f => f.status == '2'); //对接完成
  41. let s3 = res.data.filter(f => f.status == '0'); //正在洽谈
  42. this.myChart = echarts.init(document.getElementById('chart'));
  43. const option = {
  44. title: { text: '交易情况', left: 'center' },
  45. tooltip: { trigger: 'axis' },
  46. legend: {
  47. data: ['正在洽谈', '达成意向', '对接完成'],
  48. },
  49. xAxis: {
  50. type: 'category',
  51. data: ['正在洽谈', '达成意向', '对接完成'],
  52. },
  53. yAxis: {},
  54. series: [
  55. {
  56. name: '交易情况',
  57. label: {
  58. show: true,
  59. position: 'top',
  60. },
  61. type: 'bar',
  62. data: [
  63. { name: '正在洽谈', value: s3.length, itemStyle: { color: '#7cb5ec' } },
  64. { name: '达成意向', value: s1.length, itemStyle: { color: '#ffa94b' } },
  65. { name: '对接完成', value: s2.length, itemStyle: { color: '#346da4' } },
  66. ],
  67. animationType: 'scale',
  68. },
  69. ],
  70. };
  71. this.myChart.setOption(option);
  72. }
  73. },
  74. },
  75. computed: {
  76. ...mapState(['top-right']),
  77. pageTitle() {
  78. return `${this.$route.meta.title}`;
  79. },
  80. },
  81. metaInfo() {
  82. return { title: this.$route.meta.title };
  83. },
  84. };
  85. </script>
  86. <style lang="less" scoped></style>