rightBottomView.jsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * @Author: dayan_hjm 累计销量客户
  3. * @Date: 2023-10-23 09:32:12
  4. * @Last Modified by: dayan_hjm
  5. * @Last Modified time: 2023-11-16 17:05:05
  6. */
  7. import React, { useState, useEffect, Component } from "react";
  8. import styles from "../style.less";
  9. import { useHistory, useLocation, withRouter } from "react-router-dom";
  10. import mod from '../mod';
  11. import Slider from "react-slick";
  12. import "slick-carousel/slick/slick.css";
  13. import "slick-carousel/slick/slick-theme.css";
  14. import { Progress } from 'antd';
  15. import { getArrMax,sortby } from "@utils/util";
  16. import {
  17. rollService,
  18. } from "../api";
  19. import { get, } from "lodash";
  20. @withRouter
  21. class RightBottomView extends Component {
  22. // 构造函数,组件的实例创建时,最先执行
  23. constructor(props, context) {
  24. super(props, context);
  25. this.store = mod;
  26. this.state = {
  27. data_item: [],
  28. };
  29. }
  30. componentDidMount() {
  31. this.getUrl()
  32. }
  33. async getUrl() {
  34. await rollService().then(({ data=[], resultCode }) => {
  35. if (+resultCode === 0) {
  36. let data_item = [];
  37. const max1 = data.sort(sortby('salesQty',false));
  38. const max2 = max1?.[0]?.salesQty / 0.95 || 0;
  39. data.map((x,i)=>{
  40. data_item.push({
  41. name: x.customerName,
  42. num: x.salesQty,
  43. percent:Number(x.salesQty / max2).toFixed(2) * 100
  44. })
  45. });
  46. this.setState({data_item});
  47. }
  48. });
  49. }
  50. render() {
  51. const { data_item } = this.state;
  52. const settings = {
  53. dots: false,
  54. arrows:false,
  55. infinite: true,
  56. autoplay: true,
  57. autoplaySpeed: 2500,//自动播放的时间
  58. // fade: true,//是否采用淡入淡出的效果 竖着的滚动方式不能添加此动效
  59. slidesToShow: data_item.length >= 8 ? 8 : data_item.length,
  60. slidesToScroll: 1,
  61. vertical: true,
  62. verticalSwiping: true,
  63. beforeChange: function (currentSlide, nextSlide) {
  64. console.log("before change", currentSlide, nextSlide);
  65. },
  66. afterChange: function (currentSlide) {
  67. console.log("after change", currentSlide);
  68. }
  69. };
  70. return (
  71. <div className={["eacharView cbRightBottomView slider_item_box"]} style={{height: data_item.length > 8 ? 'auto' : "100%"}}>
  72. <p className="title_">累计销量客户/吨</p>
  73. <Slider {...settings}>
  74. {
  75. data_item.map((x, i) => {
  76. return (
  77. <div className="slider_box">
  78. <div className="slider_top">
  79. <p>{i + 1}.<span>{x.name}</span></p>
  80. <p className="p2">{x.num}</p>
  81. </div>
  82. <Progress
  83. strokeColor={{
  84. from: '#a98911cf',
  85. to: 'rgb(248,204,41,0.9)',
  86. }}
  87. percent={x.percent}
  88. status="active"
  89. />
  90. </div>
  91. )
  92. })
  93. }
  94. </Slider>
  95. </div>
  96. )
  97. }
  98. }
  99. export default RightBottomView;