ReportList.jsx 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import moment from 'moment'
  2. import { Card, List, Badge, Space, Carousel } from 'antd'
  3. import { useEffect, useMemo, useState } from 'react'
  4. import { history } from 'umi';
  5. const Avatar = (props) => {
  6. const style = useMemo(() => {
  7. const color = props.item.status == 'first' ? '#C5E0A9' :
  8. props.item.status == 'renewal' ? '#87C5ED' : '#E9CB99';
  9. return {
  10. background: color,
  11. color: '#fff',
  12. width: '48px',
  13. height: '48px',
  14. fontSize: '1.8em',
  15. lineHeight: '48px',
  16. textAlign: 'center',
  17. }
  18. }, [])
  19. return <div style={style}>{props.children}</div>
  20. }
  21. const Content = (props) => {
  22. const { item } = props;
  23. return (
  24. <Space size="large">
  25. <span>{moment(item.createDate).format('YYYY-MM-DD HH:mm')}</span>
  26. </Space>
  27. )
  28. }
  29. const showNum = 8;
  30. export default (props) => {
  31. const [loading, setLoading] = useState(false)
  32. const [disabled, setDisabled] = useState(false)
  33. const [list, setList] = useState([
  34. {
  35. orgName: '办证',
  36. status: 'first',
  37. userName: '俏如来',
  38. formId: 0,
  39. createDate: '2021-5-6 11:22:50'
  40. },
  41. {
  42. orgName: '续期',
  43. status: 'renewal',
  44. userName: '雪山银燕',
  45. formId: 1,
  46. createDate: '2021-5-9 11:22:50'
  47. },
  48. {
  49. orgName: '补办',
  50. status: 'reissue',
  51. userName: '史艳文',
  52. formId: 2,
  53. createDate: '2021-5-5 11:22:50'
  54. },
  55. {
  56. orgName: '办证',
  57. status: 'first',
  58. userName: '南宫恨',
  59. formId: 3,
  60. createDate: '2021-5-7 11:22:50'
  61. },
  62. {
  63. orgName: '补办',
  64. status: 'reissue',
  65. userName: '神蛊温皇',
  66. formId: 4,
  67. createDate: '2021-5-15 11:22:50'
  68. },
  69. {
  70. orgName: '办证',
  71. status: 'first',
  72. userName: '燕驼龙',
  73. formId: 5,
  74. createDate: '2021-5-6 11:22:50'
  75. },
  76. {
  77. orgName: '办证',
  78. status: 'first',
  79. userName: '忆无心',
  80. formId: 6,
  81. createDate: '2021-5-6 11:22:50'
  82. },
  83. {
  84. orgName: '补办',
  85. status: 'reissue',
  86. userName: '史艳文',
  87. formId: 7,
  88. createDate: '2021-5-6 11:22:50'
  89. },
  90. {
  91. orgName: '续期',
  92. status: 'renewal',
  93. userName: '宫本武藏',
  94. formId: 8,
  95. createDate: '2021-5-6 11:22:50'
  96. },
  97. {
  98. orgName: '办证',
  99. status: 'first',
  100. userName: '素还真',
  101. formId: 9,
  102. createDate: '2021-5-6 11:22:50'
  103. },
  104. {
  105. orgName: '续期',
  106. status: 'renewal',
  107. userName: '元邪皇',
  108. formId: 10,
  109. createDate: '2021-5-6 11:22:50'
  110. },
  111. ])
  112. const toAudit = () => {
  113. //审核详情
  114. // history.push('../../examine');
  115. }
  116. useEffect(() => {
  117. setDisabled(!list || list.length <= showNum)
  118. }, [list])
  119. return (
  120. <Card title="近期提交记录" loading={loading} bodyStyle={{ height: '600px' }}>
  121. <List style={{ height: '100%', overflow: 'hidden' }} itemLayout="horizontal">
  122. <Carousel
  123. autoplay={!disabled}
  124. infinite={!disabled}
  125. rtl
  126. slidesToShow={showNum}
  127. slidesToScroll={1}
  128. dot={false}
  129. dotPosition="right"
  130. style={{ height: '100%' }}
  131. >
  132. {
  133. list.map(item => (
  134. <div key={item.formId} style={{ display: 'flex' }}>
  135. <List.Item onClick={()=>toAudit(item)}>
  136. <List.Item.Meta
  137. avatar={<Avatar item={item}>{item.orgName.substring(0, 1)}</Avatar>}
  138. title={item.userName}
  139. description={item.orgName}
  140. />
  141. <Content item={item} />
  142. </List.Item>
  143. </div>
  144. ))
  145. }
  146. </Carousel>
  147. </List>
  148. </Card>
  149. )
  150. }