FormAndFilesNode.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { Card, Col, Row, Empty } from 'antd';
  2. import { Form } from 'antd';
  3. import { useMemo, useState } from 'react';
  4. import AttachmentTable from '@/components/AttachmentTable';
  5. const FormAndFilesNode = (props) => {
  6. const { formData, fileList } = props;
  7. const FormContent = useMemo(() => {
  8. return renderFrom(formData);
  9. }, [formData]);
  10. return (
  11. <Card title="审批信息">
  12. <Row gutter={20}>
  13. <Col span={12}>{FormContent}</Col>
  14. <Col span={12}>
  15. <AttachmentTable excelFileList={fileList} />
  16. </Col>
  17. </Row>
  18. </Card>
  19. );
  20. };
  21. const renderFrom = (data) => {
  22. if (!data) return <Empty description="没有表单信息" />;
  23. try {
  24. const formData = JSON.parse(data);
  25. if (formData.length == 0) return <Empty description="没有表单信息" />;
  26. return (
  27. <>
  28. {formData.map((item, idx) => {
  29. const value = item.value.join(',');
  30. return (
  31. <Form.Item
  32. key={`FormAndFilesNode_${idx}`}
  33. labelCol={{ span: 4 }}
  34. wrapperCol={{ span: 14 }}
  35. label={item.name}
  36. >
  37. <div
  38. style={{
  39. width: '100%',
  40. padding: '4px 12px',
  41. backgroundColor: '#ececef',
  42. border: '1px solid #bcb9b9',
  43. borderRadius: '4px',
  44. }}
  45. >
  46. {value}
  47. </div>
  48. </Form.Item>
  49. );
  50. })}
  51. </>
  52. );
  53. } catch {
  54. return <Empty description="没有表单信息" />;
  55. }
  56. };
  57. export default FormAndFilesNode;