Sfoglia il codice sorgente

缺陷 1638 流程保存增加loading

XuZinan 2 anni fa
parent
commit
01ff8f0504
2 ha cambiato i file con 25 aggiunte e 13 eliminazioni
  1. 23 12
      src/pages/Flow/Flow.js
  2. 2 1
      src/pages/Flow/models/flow.js

+ 23 - 12
src/pages/Flow/Flow.js

@@ -2,7 +2,7 @@ import Flow, { FLOW_TYPE } from '@/components/Flow';
 import { connect } from 'dva';
 import React, { useEffect } from 'react';
 import { UnityAction } from '@/utils/utils';
-import { Button } from 'antd';
+import { Button, Spin } from 'antd';
 import router from 'umi/router';
 
 @connect(({ xflow, user }) => ({
@@ -11,6 +11,11 @@ import router from 'umi/router';
   permission: user.currentUser.Permission,
 }))
 class FlowPage extends React.PureComponent {
+  constructor(props) {
+    super(props);
+    this.state = { spinning: false };
+  }
+
   onUpdate(node) {
     const { dispatch, flowDetail } = this.props;
     let params = {
@@ -31,6 +36,9 @@ class FlowPage extends React.PureComponent {
         nodeId: node.Id,
         body: params,
       },
+      callback: () => {
+        this.setState({ spinning: false });
+      },
     });
   }
 
@@ -59,6 +67,7 @@ class FlowPage extends React.PureComponent {
 
     UnityAction.on('NODE_SAVE', nodeConfig => {
       this.onUpdate(nodeConfig);
+      this.setState({ spinning: true });
     });
   }
   componentWillUnmount() {
@@ -67,7 +76,7 @@ class FlowPage extends React.PureComponent {
   getEditMode() {
     const { flowDetail, permission } = this.props;
 
-    return 2
+    return 2;
   }
   render() {
     const { flowDetail, permission, currentUser } = this.props;
@@ -77,23 +86,25 @@ class FlowPage extends React.PureComponent {
       // 判断是否有权限
       permission['func-01-point-bom-flow'] ||
       // 判断是否为创建者
-      flowDetail.Creator == currentUser.ID) {
-      editMode = 1
+      flowDetail.Creator == currentUser.ID
+    ) {
+      editMode = 1;
     }
 
     return (
-      <div>
+      <Spin spinning={this.state.spinning}>
         {/* <Form></Form> */}
         <Button style={{ marginBottom: 20 }} onClick={() => router.go(-1)}>
           返回
         </Button>
-        {currentUser.ID && <Flow
-          meta={{ type: 'edit', editMode, flowId: 1 }}
-          flowDetail={flowDetail}
-        // onUpdate={node => this.onUpdate(node)}
-        />}
-
-      </div>
+        {currentUser.ID && (
+          <Flow
+            meta={{ type: 'edit', editMode, flowId: 1 }}
+            flowDetail={flowDetail}
+            // onUpdate={node => this.onUpdate(node)}
+          />
+        )}
+      </Spin>
     );
   }
 }

+ 2 - 1
src/pages/Flow/models/flow.js

@@ -195,10 +195,11 @@ export default {
         payload: { flowList: res.data },
       });
     },
-    *updateNode({ payload }, { call, put }) {
+    *updateNode({ payload, callback }, { call, put }) {
       const data = yield call(updateNode, payload);
       console.log(data);
       message.success('修改成功');
+      callback && callback();
     },
     *queryAuditList({ payload }, { call, put }) {
       const response = yield call(queryAuditList, payload);