Flow.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. dispatch({
  50. type: 'xflow/fetchDepV2',
  51. });
  52. UnityAction.on('NODE_SAVE', nodeConfig => {
  53. this.onUpdate(nodeConfig);
  54. });
  55. }
  56. componentWillUnmount() {
  57. UnityAction.off('NODE_SAVE');
  58. }
  59. render() {
  60. const { flowDetail } = this.props;
  61. return (
  62. <div>
  63. {/* <Form></Form> */}
  64. <Button style={{ marginBottom: 20 }} onClick={() => router.go(-1)}>
  65. 返回
  66. </Button>
  67. <Flow
  68. meta={{ type: 'edit', flowId: 1 }}
  69. flowDetail={flowDetail}
  70. // onUpdate={node => this.onUpdate(node)}
  71. />
  72. </div>
  73. );
  74. }
  75. }
  76. export default FlowPage;