ExportModal.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import React, { useEffect, useState, useRef } from 'react';
  2. import { Form } from '@ant-design/compatible';
  3. import '@ant-design/compatible/assets/index.css';
  4. import {
  5. Steps,
  6. Button,
  7. Drawer,
  8. Comment,
  9. Tooltip,
  10. Avatar,
  11. List,
  12. Card,
  13. Modal,
  14. Checkbox,
  15. Row,
  16. Col,
  17. message,
  18. Input,
  19. Table,
  20. Alert,
  21. Spin,
  22. Tabs,
  23. } from 'antd';
  24. import list from '../List/models/list';
  25. const { Step } = Steps;
  26. const { TextArea } = Input;
  27. const { TabPane } = Tabs;
  28. // 选择比对清单
  29. function CompareModal(props) {
  30. const { visible, onClose, onOk, sheet } = props;
  31. const [checkValue, setCheckValue] = useState([]);
  32. const [tabList, setTabList] = useState([]);
  33. const [active, setActive] = useState();
  34. useEffect(() => {
  35. const list = [];
  36. if (sheet && sheet.length > 0) {
  37. const sheetData = JSON.parse(JSON.stringify(sheet));
  38. sheetData.forEach(item => {
  39. let obj = {};
  40. obj.name = item.name;
  41. if (item.data && item.data[0]) {
  42. obj.list = item.data[0]?.filter(cur => cur);
  43. }
  44. obj.id = item.index;
  45. list.push(obj);
  46. });
  47. setCheckValue([]);
  48. setTabList(list);
  49. setActive(list[0]?.id);
  50. }
  51. }, [sheet]);
  52. const onChange = check => {
  53. setCheckValue(check);
  54. console.log(check);
  55. };
  56. const handleOk = () => {
  57. onOk(checkValue);
  58. };
  59. return (
  60. <Modal
  61. title="选择导出列"
  62. visible={visible}
  63. onCancel={onClose}
  64. onOk={handleOk}
  65. bodyStyle={{ paddingTop: 0 }}
  66. >
  67. <Checkbox.Group value={checkValue} style={{ width: '100%' }} onChange={onChange}>
  68. <Tabs activeKey={active} onChange={setActive}>
  69. {tabList.map(tab => (
  70. <TabPane tab={tab.name} key={tab.id}>
  71. <Row>
  72. {tab.list.map(item => (
  73. <Col span={8} key={item.m}>
  74. <Checkbox value={item.v}>{item.v}</Checkbox>
  75. </Col>
  76. ))}
  77. </Row>
  78. </TabPane>
  79. ))}
  80. </Tabs>
  81. </Checkbox.Group>
  82. </Modal>
  83. );
  84. }
  85. export default CompareModal;