123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import React from 'react';
  2. import Taro from '@tarojs/taro';
  3. import { View } from '@tarojs/components';
  4. import { CellGroup, Cell, Popup } from '@antmjs/vantui';
  5. import Card from '@/components/Card';
  6. import Chart, { getLinearGradient } from '@/subpkg1/components/chart';
  7. // import OrgPicker from '@/components/OrgPicker';
  8. import OrgTree from '@/components/OrgTree';
  9. import { getIssueOrg } from '@/services/stat';
  10. export default (props) => {
  11. const [show, setShow] = React.useState(false);
  12. const [org, setOrg] = React.useState();
  13. const [option, setOption] = React.useState({});
  14. const valStr = React.useMemo(() => {
  15. if (!org) {
  16. return '请选择单位'
  17. }
  18. return org.name;
  19. }, [org]);
  20. const onCancel = () => {
  21. setShow(false);
  22. }
  23. const onOrgChange = (orgId, orgInfo) => {
  24. setShow(false);
  25. setOrg(orgInfo);
  26. }
  27. React.useEffect(() => {
  28. if (!org) return;
  29. getIssueOrg({orgId: org.orgId}).then((res) => {
  30. setOption({
  31. grid: {
  32. top: 6,
  33. bottom: 40,
  34. },
  35. xAxis: [
  36. {
  37. type: 'category',
  38. data: res.map(x => x.name),
  39. }
  40. ],
  41. yAxis: [
  42. {
  43. type: 'value',
  44. minInterval: 1,
  45. name: '交办次数'
  46. }
  47. ],
  48. series: [
  49. {
  50. type: 'bar',
  51. barWidth: '15%',
  52. itemStyle: {
  53. color: getLinearGradient(0, 0, 0, 1, [
  54. { offset: 0, color: '#F772D1' },
  55. { offset: 0.5, color: '#C872F2' },
  56. { offset: 1, color: '#E5BEF8' }
  57. ])
  58. },
  59. data: res.map(x => x.value)
  60. }
  61. ]
  62. });
  63. });
  64. }, [org]);
  65. return (
  66. <Card>
  67. <Cell title="交办统计" isLink value={valStr} onClick={() => setShow(true)} />
  68. <Chart option={option} style={{ height: '30vh'}} />
  69. <OrgTree show={show} onChange={onOrgChange} onClose={onCancel} />
  70. </Card>
  71. )
  72. }