MergeModal.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import React, { useEffect, useState, useRef, useMemo } from 'react';
  2. import { Form } from '@ant-design/compatible';
  3. import '@ant-design/compatible/assets/index.css';
  4. import { Modal, Radio, Row, Col, message, Tabs } from 'antd';
  5. import { connect } from 'dva';
  6. const { TabPane } = Tabs;
  7. // 选择比对清单
  8. function MergeModal(props) {
  9. const { visible, versionList, onClose, onOk, dispatch, version, flowDetail } = props;
  10. const [checkValue, setCheckValue] = useState([]);
  11. const onChange = e => {
  12. setCheckValue(e.target.value);
  13. };
  14. const handleOk = () => {
  15. if (!checkValue) {
  16. message.error('请选择要合并的清单');
  17. } else {
  18. let checkSheet = versionList.find(item => item.id == checkValue);
  19. onOk(checkSheet);
  20. onClose();
  21. setCheckValue();
  22. }
  23. };
  24. const tabList = useMemo(() => {
  25. let list = {};
  26. versionList.forEach(version => {
  27. let nodeId = version.template_node_id;
  28. if (!nodeId || nodeId === '0') return;
  29. if (!list[nodeId]) {
  30. list[nodeId] = [];
  31. }
  32. list[nodeId].push(version);
  33. });
  34. return Object.keys(list).map(nodeId => ({
  35. name: flowDetail.nodes.find(node => node.Id == nodeId)?.label,
  36. id: nodeId,
  37. list: list[nodeId],
  38. }));
  39. }, [versionList, flowDetail]);
  40. return (
  41. <Modal
  42. title="选择同步文件"
  43. visible={visible}
  44. onCancel={onClose}
  45. onOk={handleOk}
  46. width={600}
  47. bodyStyle={{ paddingTop: 0 }}
  48. >
  49. <Radio.Group value={checkValue} style={{ width: '100%' }} onChange={onChange}>
  50. {/* <Row gutter={16}>
  51. {versionList.map(v => {
  52. if (v.id == version.id) return null;
  53. return (
  54. <Col span={8} key={v.id}>
  55. <Radio value={v.id}>{v.version_name}</Radio>
  56. </Col>
  57. );
  58. })}
  59. </Row> */}
  60. <Tabs>
  61. {tabList.map(tab => (
  62. <TabPane tab={tab.name} key={tab.id}>
  63. {/* <Row>
  64. {tab.list.map(version => (
  65. <Col span={8} key={version.id}>
  66. <Radio value={version.id}>{version.version_name}</Radio>
  67. </Col>
  68. ))}
  69. </Row> */}
  70. {tab.list.map(version => (
  71. <div style={{ marginBottom: 16 }} key={version.id}>
  72. <Radio value={version.id}>{version.version_name}</Radio>
  73. </div>
  74. ))}
  75. </TabPane>
  76. ))}
  77. </Tabs>
  78. </Radio.Group>
  79. </Modal>
  80. );
  81. }
  82. export default connect(({ detail, xflow }) => ({
  83. versionList: detail.versionList,
  84. flowDetail: xflow.flowDetail,
  85. }))(MergeModal);