Ver código fonte

审核列表角标

XuZinan 2 anos atrás
pai
commit
ef42382799

+ 52 - 0
src/models/authList.js

@@ -0,0 +1,52 @@
+import { queryAuthList } from '@/services/bomAuth';
+export default {
+  namespace: 'authList',
+  state: {
+    authList: [],
+    checkedList: { list: [], pagination: {} },
+  },
+  effects: {
+    *queryAuthList({ payload }, { call, put }) {
+      const responce = yield call(queryAuthList, payload);
+      if (responce) {
+        let data = responce.data;
+        let ret = [];
+        data.forEach(e => {
+          let item = ret.find(item => item.key == `${e.template_id}_${e.project_id}`);
+          if (!item) {
+            item = {
+              key: `${e.template_id}_${e.project_id}`,
+              name: e.name,
+              project_name: e.ding_schema,
+              nodes: [],
+            };
+            ret.push(item);
+          }
+          item.nodes.push({
+            template_id: e.template_id,
+            project_id: e.project_id,
+            version_name: e.version_name,
+            node_name: e.TemplateNodeInfo?.label,
+            author: e.AuthorInfo?.CName,
+            classify_id: e.classify_id,
+            version_id: e.version_id,
+            id: e.id,
+          });
+        });
+        yield put({
+          type: 'save',
+          payload: { authList: ret },
+        });
+      }
+    },
+  },
+
+  reducers: {
+    save(state, action) {
+      return {
+        ...state,
+        ...action.payload,
+      };
+    },
+  },
+};

+ 10 - 10
src/pages/Auth/Auth.js

@@ -20,12 +20,12 @@ function Auth(props) {
   useEffect(() => {
     if (!currentUser.ID) return;
     dispatch({
-      type: 'auth/queryAuthList',
+      type: 'authList/queryAuthList',
       payload: { user_id: currentUser.ID },
     });
     dispatch({
       type: 'auth/queryCheckedList',
-      payload: { user_id: currentUser.ID, params: {} },
+      payload: { user_id: currentUser.ID, params: { page_size: 99999 } },
     });
   }, [currentUser]);
 
@@ -51,17 +51,15 @@ function Auth(props) {
   ];
 
   const loadNode = item => {
-    // localStorage.excelItem = JSON.stringify({ version_id: item.version_id });
     //调用接口获取version信息
     dispatch({
       type: 'auth/queryVersionByNode',
       callback: versionList => {
-        let version = versionList.find(v => v.id == item.version_id) || {};
+        let version = versionList.find(v => v.id == item.id) || {};
         localStorage.excelItem = JSON.stringify(version);
+        router.push(`/home/detail/${item.project_id}/${item.template_id}`);
       },
     });
-
-    router.push(`/home/detail/${item.project_id}/${item.template_id}`);
   };
 
   const renderUnauth = data => (
@@ -69,7 +67,7 @@ function Auth(props) {
   );
 
   const renderAuth = data => (
-    <Table columns={flowColumns} dataSource={data} pagination={checkedPagination} rowKey="id" />
+    <Table columns={flowColumns} dataSource={data} pagination={false} rowKey="id" />
   );
 
   return (
@@ -81,6 +79,7 @@ function Auth(props) {
           expandable={{ expandedRowRender: record => renderUnauth(record.nodes) }}
           pagination={false}
           rowKey="key"
+          loading={loading.models.authList}
         />
       </Panel>
       <Panel header="已审批" key="1">
@@ -90,17 +89,18 @@ function Auth(props) {
           expandable={{ expandedRowRender: record => renderAuth(record.nodes) }}
           pagination={false}
           rowKey="key"
+          loading={loading.models.auth}
         />
       </Panel>
     </Collapse>
   );
 }
 
-export default connect(({ auth, loading, user }) => ({
-  authList: auth.authList,
+export default connect(({ auth, authList, loading, user }) => ({
+  authList: authList.authList,
   checkedList: auth.checkedList.list,
   checkedPagination: auth.checkedList.pagination,
   typeOptions: auth.typeOptions,
-  loading: loading.models.auth,
   currentUser: user.currentUser,
+  loading,
 }))(Auth);

+ 1 - 37
src/pages/Auth/models/auth.js

@@ -1,46 +1,11 @@
-import { queryAuthList, queryCheckedList, queryVersionByNode } from '@/services/bomAuth';
+import { queryCheckedList, queryVersionByNode } from '@/services/bomAuth';
 import { queryClassify } from '@/services/boom';
 export default {
   namespace: 'auth',
   state: {
-    authList: [],
     checkedList: { list: [], pagination: {} },
   },
   effects: {
-    *queryAuthList({ payload }, { call, put }) {
-      const responce = yield call(queryAuthList, payload);
-      if (responce) {
-        let data = responce.data;
-        let ret = [];
-        data.forEach(e => {
-          let item = ret.find(item => item.key == `${e.template_id}_${e.project_id}`);
-          if (!item) {
-            item = {
-              key: `${e.template_id}_${e.project_id}`,
-              name: e.name,
-              project_name: e.ding_schema,
-              nodes: [],
-            };
-            ret.push(item);
-          }
-          item.nodes.push({
-            template_id: e.template_id,
-            project_id: e.project_id,
-            version_name: e.version_name,
-            node_name: e.TemplateNodeInfo?.label,
-            author: e.AuthorInfo?.CName,
-            classify_id: e.classify_id,
-            version_id: e.version_id,
-            id: e.id,
-          });
-        });
-        yield put({
-          type: 'save',
-          payload: { authList: ret },
-        });
-      }
-    },
-
     *queryCheckedList({ payload }, { call, put }) {
       const responce = yield call(queryCheckedList, payload);
       if (responce) {
@@ -64,7 +29,6 @@ export default {
             node_name: e.TemplateNodeInfo?.label,
             author: e.AuthorInfo?.CName,
             classify_id: e.classify_id,
-            version_id: e.version_id,
             id: e.id,
           });
         });

+ 5 - 0
src/pages/Detail/Index.js

@@ -268,6 +268,11 @@ function Detail(props) {
             id: templateId,
           },
         });
+        //更新未审批列表
+        dispatch({
+          type: 'authList/queryAuthList',
+          payloda: { user_id: currentUser.ID },
+        });
         localStorage.excelId = newVersion.id;
         setVersion({
           ...version,

+ 14 - 1
src/pages/Detail/TimeNode.js

@@ -4,6 +4,7 @@ import '@ant-design/compatible/assets/index.css';
 import { connect } from 'dva';
 import { Steps, Button, Modal } from 'antd';
 import styles from './Index.less';
+import { getCurrentUser } from '@/utils/authority';
 
 const { Step } = Steps;
 // 时间节点
@@ -19,6 +20,8 @@ function TimeNode(props) {
     setAuditVisible,
     projectId,
     dispatch,
+
+    currentUser,
   } = props;
   const { current, list, active } = flow;
 
@@ -101,6 +104,13 @@ function TimeNode(props) {
                 audit_series: version.audit_series,
               },
             });
+
+            //更新未审核列表
+            dispatch({
+              type: 'authList/queryAuthList',
+              payload: { user_id: currentUser.ID },
+            });
+
             if (flow.current == flow.list.FlowNodes.length - 1) {
               // 最后一个审核节点通过后  需要更新version id 不更不更,留在原地
               // localStorage.excelId = newVersion.id;
@@ -154,4 +164,7 @@ function TimeNode(props) {
   return null;
 }
 
-export default connect(({ detail }) => ({ versionList: detail.versionList }))(TimeNode);
+export default connect(({ user, detail }) => ({
+  currentUser: user.currentUser,
+  versionList: detail.versionList,
+}))(TimeNode);

+ 27 - 4
src/pages/Index.js

@@ -1,15 +1,17 @@
 import React, { useEffect } from 'react';
-import { Layout, Menu } from 'antd';
+import { Badge, Layout, Menu } from 'antd';
 import { connect } from 'dva';
 import RightContent from './RightContent';
 import Link from 'umi/link';
+import styles from './Index.less';
 
 const { Header, Content, Footer } = Layout;
 const { SubMenu } = Menu;
+let timer;
 
 // 布局
 function LayoutDetail(props) {
-  const { currentUser, permission } = props;
+  const { currentUser, permission, dispatch, authList } = props;
   const isAdmin = currentUser.UserName == 'admin';
   var logoStyle = {
     color: 'white',
@@ -25,7 +27,20 @@ function LayoutDetail(props) {
       type: 'user/fetchCurrent',
     });
   }, []);
- 
+
+  useEffect(() => {
+    if (!currentUser.ID) return;
+    clearInterval(timer);
+    timer = setInterval(() => {
+      dispatch({
+        type: 'authList/queryAuthList',
+        payload: { user_id: currentUser.ID },
+      });
+    }, 10000);
+
+    return () => clearInterval(timer);
+  }, [currentUser.ID]);
+
   return (
     <Layout>
       <Header>
@@ -44,6 +59,13 @@ function LayoutDetail(props) {
               <Menu.Item key="/home/flow-list">
                 <Link to="/home/flow-list">流程管理</Link>
               </Menu.Item>
+              <Menu.Item key="/home/auth">
+                <Link to="/home/auth">
+                  <Badge count={authList.length} className={styles.badge}>
+                    审核列表
+                  </Badge>
+                </Link>
+              </Menu.Item>
             </Menu>
           </div>
           <RightContent />
@@ -56,7 +78,8 @@ function LayoutDetail(props) {
     </Layout>
   );
 }
-export default connect(({ user }) => ({
+export default connect(({ user, authList }) => ({
   currentUser: user.currentUser,
   permission: user.currentUser.Permission,
+  authList: authList.authList,
 }))(LayoutDetail);

+ 3 - 0
src/pages/Index.less

@@ -0,0 +1,3 @@
+.badge {
+  color: inherit;
+}