FormAndFilesNode.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 } = 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
  16. version={version}
  17. canDelete={version.last_version == 0}
  18. /> */}
  19. </Col>
  20. </Row>
  21. </Card>
  22. );
  23. };
  24. const renderFrom = (data) => {
  25. if (!data) return <Empty description="没有表单信息" />;
  26. try {
  27. const formData = JSON.parse(data);
  28. if (formData.length == 0) return <Empty description="没有表单信息" />;
  29. return (
  30. <>
  31. {formData.map((item, idx) => {
  32. const value = item.value.join(',');
  33. return (
  34. <Form.Item
  35. key={`FormAndFilesNode_${idx}`}
  36. labelCol={{ span: 4 }}
  37. wrapperCol={{ span: 14 }}
  38. label={item.name}
  39. >
  40. <div
  41. style={{
  42. width: '100%',
  43. padding: '4px 12px',
  44. backgroundColor: '#ececef',
  45. border: '1px solid #bcb9b9',
  46. borderRadius: '4px',
  47. }}
  48. >
  49. {value}
  50. </div>
  51. </Form.Item>
  52. );
  53. })}
  54. </>
  55. );
  56. } catch {
  57. return <Empty description="没有表单信息" />;
  58. }
  59. };
  60. export default FormAndFilesNode;