Flow.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import Flow, { FLOW_TYPE } from '@/components/Flow';
  2. import { connect } from 'dva';
  3. import React, { useEffect } from 'react';
  4. import { UnityAction } from '@/utils/utils';
  5. import { Button } from 'antd';
  6. import router from 'umi/router';
  7. @connect(({ xflow }) => ({ flowDetail: xflow.flowDetail }))
  8. class FlowPage extends React.PureComponent {
  9. onUpdate(node) {
  10. const { dispatch, flowDetail } = this.props;
  11. let params = {
  12. ...node,
  13. id: node.Id,
  14. node_type: node.name == 'custom-circle' ? 1 : 0,
  15. data: JSON.stringify(node.data),
  16. project_id: flowDetail.ProjectId,
  17. template_id: flowDetail.Id,
  18. template_name: flowDetail.Name,
  19. };
  20. delete params.node_id;
  21. dispatch({
  22. type: 'flow/updateNode',
  23. payload: {
  24. templateId: flowDetail.Id,
  25. nodeId: node.Id,
  26. body: params,
  27. },
  28. });
  29. }
  30. componentDidMount() {
  31. const {
  32. dispatch,
  33. match: {
  34. params: { flowId },
  35. },
  36. } = this.props;
  37. dispatch({
  38. type: 'xflow/queryOSSData',
  39. });
  40. dispatch({
  41. type: 'xflow/queryBoomFlowDetail',
  42. payload: {
  43. id: flowId,
  44. },
  45. });
  46. dispatch({
  47. type: 'xflow/queryAuditList',
  48. });
  49. UnityAction.on('NODE_SAVE', nodeConfig => {
  50. this.onUpdate(nodeConfig);
  51. });
  52. }
  53. componentWillUnmount() {
  54. UnityAction.off('NODE_SAVE');
  55. }
  56. render() {
  57. const { flowDetail } = this.props;
  58. return (
  59. <div>
  60. {/* <Form></Form> */}
  61. <Button style={{ marginBottom: 20 }} onClick={() => router.go(-1)}>
  62. 返回
  63. </Button>
  64. <Flow
  65. meta={{ type: 'edit', flowId: 1 }}
  66. flowDetail={flowDetail}
  67. // onUpdate={node => this.onUpdate(node)}
  68. />
  69. </div>
  70. );
  71. }
  72. }
  73. export default FlowPage;