瀏覽代碼

删除工时过滤

XuZinan 2 年之前
父節點
當前提交
8a7e13f04b

+ 6 - 4
src/pages/PurchaseAdmin/PurchaseList/WorkingHours/WorkList.js

@@ -101,10 +101,12 @@ function WorkList(props) {
   };
 
   const onHandleSave = (item, data) => {
-    let currentWorkload = list.reduce((total, temp) => {
-      if (temp.id == item.id) return total;
-      return total + temp.workload;
-    }, 0);
+    let currentWorkload = list
+      .filter(item => item.status == 0)
+      .reduce((total, temp) => {
+        if (temp.id == item.id) return total;
+        return total + temp.workload;
+      }, 0);
     if (data + currentWorkload > 8) return message.error('每日工时不能超过8小时!');
     onSave(item, data);
   };

+ 20 - 10
src/pages/PurchaseAdmin/PurchaseList/WorkingHours/index.js

@@ -6,7 +6,17 @@ import { connect } from 'dva';
 import moment from 'moment';
 
 function List(props) {
-  const { typeList, dispatch, loading, dataList, projectList, currentUser, allType, depUserTree, depUserMap } = props;
+  const {
+    typeList,
+    dispatch,
+    loading,
+    dataList,
+    projectList,
+    currentUser,
+    allType,
+    depUserTree,
+    depUserMap,
+  } = props;
   const [visible, setVisible] = useState(false);
   const [current, setCurrent] = useState({
     date: moment(),
@@ -33,7 +43,7 @@ function List(props) {
                 project_id: item.project_id,
                 workload: workload,
                 day: item.time,
-                pay_dep_id: item.pay_dep_id
+                pay_dep_id: item.pay_dep_id,
               },
             ],
           },
@@ -61,7 +71,7 @@ function List(props) {
       cancelText: '取消',
       onOk() {
         let params = [];
-        debugger
+        debugger;
         for (let i = 0; i < dataList.length; i++) {
           const element = dataList[i];
           if (element.audit_state != 0) continue;
@@ -74,7 +84,7 @@ function List(props) {
               project_id: element.project_id,
               workload: element.workload,
               day: element.time,
-              pay_dep_id: element.pay_dep_id
+              pay_dep_id: element.pay_dep_id,
             });
           } else {
             let data = [];
@@ -83,7 +93,7 @@ function List(props) {
               project_id: element.project_id,
               workload: element.workload,
               day: element.time,
-              pay_dep_id: element.pay_dep_id
+              pay_dep_id: element.pay_dep_id,
             });
             params.push({
               type_id: Number(element.type_id),
@@ -123,7 +133,7 @@ function List(props) {
               project_id: element.project_id,
               workload: element.workload,
               day: element.time,
-              pay_dep_id: element.pay_dep_id
+              pay_dep_id: element.pay_dep_id,
             });
           } else {
             let data = [];
@@ -132,7 +142,7 @@ function List(props) {
               project_id: element.project_id,
               workload: element.workload,
               day: element.time,
-              pay_dep_id: element.pay_dep_id
+              pay_dep_id: element.pay_dep_id,
             });
             params.push({
               type_id: Number(element.type_id),
@@ -164,7 +174,7 @@ function List(props) {
             project_id: Number(item.project_id),
             workload: workload,
             day: item.time,
-            pay_dep_id: item.pay_dep_id
+            pay_dep_id: item.pay_dep_id,
           },
         ],
       },
@@ -222,7 +232,7 @@ function List(props) {
 
   const dateCellRender = value => {
     let current = value.format('YYYY-MM-DD');
-    let list = dataList.filter(item => item.time == current);
+    let list = dataList.filter(item => item.time == current && item.status == 0);
     // let total = list.reduce((total, item) => total + item.workload, 0);
     let waitTotal = 0,
       successTotal = 0;
@@ -412,5 +422,5 @@ export default connect(({ workload, user, loading }) => ({
   currentUser: user.currentUser,
   loading: loading.models.workload,
   depUserTree: workload.depUserTree,
-  depUserMap: workload.depUserMap
+  depUserMap: workload.depUserMap,
 }))(List);