Quellcode durchsuchen

审批工时列表刷新 工时上报判断不为0

XuZinan vor 2 Jahren
Ursprung
Commit
571e5424ae

+ 13 - 2
src/pages/PurchaseAdmin/PurchaseList/WorkingHours/Auth.js

@@ -18,7 +18,6 @@ import AuthWorkList from './AuthWorkList';
 import { connect } from 'dva';
 import styles from './index.less';
 import moment from 'moment';
-import { getList } from '@/services/devOpsScoreRule';
 
 function List(props) {
   const { dispatch, loading, list, project, currentUser, allType, user } = props;
@@ -43,9 +42,16 @@ function List(props) {
           status: 2,
           desc: '',
         }));
+        let time = current.date.format('YYYY-MM-DD');
         dispatch({
           type: 'workload/authWorkload',
           payload: params,
+          callback: list => {
+            setCurrent({
+              ...current,
+              list: list.filter(item => item.time == time),
+            });
+          },
         });
       },
     });
@@ -60,11 +66,16 @@ function List(props) {
       status: 3,
       desc: data.desc || '',
     }));
+    let time = current.date.format('YYYY-MM-DD');
     dispatch({
       type: 'workload/authWorkload',
       payload: params,
-      callback: () => {
+      callback: list => {
         setVisible(false);
+        setCurrent({
+          ...current,
+          list: list.filter(item => item.time == time),
+        });
       },
     });
   };

+ 2 - 2
src/pages/PurchaseAdmin/PurchaseList/WorkingHours/index.js

@@ -1,5 +1,5 @@
 import React, { useState, useEffect, useRef } from 'react';
-import { Modal, Button, Calendar, Popover, Spin, Row, Col } from 'antd';
+import { Modal, Button, Calendar, Popover, Spin, Row, Col, message } from 'antd';
 import AddModal from './AddModal';
 import WorkList from './WorkList';
 import { connect } from 'dva';
@@ -14,7 +14,7 @@ function List(props) {
   });
 
   const onAuth = (item, workload) => {
-    console.log(workload);
+    if (workload == 0) return message.error('请上报有效工时');
     Modal.confirm({
       title: '提示',
       content: '是否上报审批?',

+ 1 - 1
src/pages/PurchaseAdmin/PurchaseList/WorkingHours/models/workingHours.js

@@ -167,10 +167,10 @@ export default {
       const res = yield call(authWorkload, payload);
       if (res) {
         message.success('操作成功');
-        callback && callback();
         yield put({
           type: 'queryAuthWorkHours',
           payload: {},
+          callback,
         });
       }
     },