ExportModal.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. obj.list.forEach(item => {
  44. if(item.ct.t == "inlineStr") {
  45. item.v = item.ct.s.map(s => s.v).join("")
  46. }
  47. })
  48. }
  49. obj.id = item.index;
  50. list.push(obj);
  51. });
  52. setCheckValue([]);
  53. setTabList(list);
  54. setActive(list[0]?.id);
  55. }
  56. }, [sheet]);
  57. const onChange = check => {
  58. setCheckValue(check);
  59. console.log(check);
  60. };
  61. const handleOk = () => {
  62. onOk(checkValue);
  63. };
  64. return (
  65. <Modal
  66. title="选择导出列"
  67. visible={visible}
  68. onCancel={onClose}
  69. onOk={handleOk}
  70. bodyStyle={{ paddingTop: 0 }}
  71. >
  72. <Checkbox.Group value={checkValue} style={{ width: '100%' }} onChange={onChange}>
  73. <Tabs activeKey={active} onChange={setActive}>
  74. {tabList.map(tab => (
  75. <TabPane tab={tab.name} key={tab.id}>
  76. <Row>
  77. {tab.list.map(item => (
  78. <Col span={8} key={item.m}>
  79. <Checkbox value={item.cid}>{item.v}</Checkbox>
  80. </Col>
  81. ))}
  82. </Row>
  83. </TabPane>
  84. ))}
  85. </Tabs>
  86. </Checkbox.Group>
  87. </Modal>
  88. );
  89. }
  90. export default CompareModal;