StatusRender.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { Timeline } from 'antd';
  2. import styles from './index.less';
  3. import { STATUS, SUB_STATUS } from './List';
  4. import moment from 'moment';
  5. import { useMemo } from 'react';
  6. const StatusRender = ({ statusList }) => {
  7. const list = useMemo(() => {
  8. return statusList.map(item => {
  9. let attach = [];
  10. if (item.attach) {
  11. try {
  12. attach = JSON.parse(item.attach);
  13. } catch (e) {
  14. console.error(e);
  15. }
  16. attach = attach
  17. .map(item => {
  18. if (item instanceof Object) {
  19. return (
  20. <div>
  21. <a target="_blank" download={item.name} href={item.url}>
  22. {item.name}
  23. </a>
  24. </div>
  25. );
  26. }
  27. })
  28. .filter(item => item);
  29. }
  30. return { ...item, attach };
  31. });
  32. });
  33. return (
  34. <Timeline>
  35. {list?.map((item, index) => (
  36. <Timeline.Item dot={<div className={styles.icon}>{index + 1}</div>}>
  37. <div style={{ fontSize: '16px', color: '#1890ff' }}>
  38. {STATUS.find(cur => cur.value == item.project_status)?.label}-
  39. {SUB_STATUS.find(cur => cur.value == item.status)?.label}
  40. </div>
  41. <div>
  42. 持续时间:{item.continuously}
  43. &nbsp;&nbsp;&nbsp;&nbsp; 修改人员:{item.author_name}
  44. &nbsp;&nbsp;&nbsp;&nbsp; 修改时间:{moment(item.c_time).format('YYYY-MM-DD')}
  45. </div>
  46. {item.attach.length > 0 && <div>附件: {item.attach}</div>}
  47. </Timeline.Item>
  48. ))}
  49. </Timeline>
  50. );
  51. };
  52. export default StatusRender;