OrgSummary.jsx 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import { useEffect, useState, useCallback } from 'react';
  2. import Echart from '@/components/echart/echart'
  3. import { Card } from 'antd'
  4. import {getApplyDaily} from '@/services/statis'
  5. import moment from 'moment';
  6. const lineOption = {
  7. tooltip: {
  8. trigger: 'axis',
  9. axisPointer: {
  10. type: 'cross'
  11. },
  12. },
  13. grid: {
  14. containLabel: true,
  15. left: 0,
  16. top: 8,
  17. right: 60,
  18. bottom: 0,
  19. },
  20. yAxis: {
  21. type: 'value',
  22. },
  23. xAxis: {
  24. type: 'category',
  25. },
  26. dataset: [
  27. {
  28. dimensions: ['date', 'value'],
  29. source: [],
  30. },
  31. ],
  32. series: [
  33. {
  34. type: 'line',
  35. name: '申请数',
  36. datasetIndex: 0,
  37. itemStyle: {
  38. normal: {
  39. color: "#08507b",
  40. lineStyle: {
  41. color: "#08507b"
  42. }
  43. }
  44. }
  45. },
  46. ]
  47. }
  48. export default (props) => {
  49. const [loading, setLoading] = useState(false)
  50. const [list, setList] = useState([])
  51. const option = {
  52. ...lineOption,
  53. dataset: {
  54. ...lineOption.dataset,
  55. source: list
  56. }
  57. }
  58. const queryList = useCallback(() => {
  59. setLoading(true)
  60. getApplyDaily({
  61. days: 10,
  62. startDate: moment().subtract(10, 'day').format('YYYY-MM-DD'),
  63. }).then((res) => {
  64. setLoading(false)
  65. setList(res)
  66. }).catch(err => {
  67. setLoading(false)
  68. })
  69. }, [])
  70. useEffect(() => {
  71. queryList()
  72. }, [])
  73. return (
  74. <Card title='近期提交趋势统计' loading={loading} bodyStyle={{ height: 616 }}>
  75. <Echart option={option} />
  76. </Card>
  77. )
  78. }