Browse Source

修改提交审批表单报错

Renxy 2 năm trước cách đây
mục cha
commit
7053d97b96

+ 1 - 1
src/pages/Flow/OaAuditDetail.js

@@ -75,7 +75,7 @@ function OaAuditDetail(props) {
     <PageContent extra={btns} loading={loading}>
       <Steps
         style={{ marginBottom: 20 }}
-        current={audit_status == 3 ? OaAuditList.length : current_seq - 1}
+        current={audit_status == 3 ? OaAuditList?.length : current_seq - 1}
         status={audit_status == 2 ? 'error' : 'process'}
         items={OaAuditList?.map((item) => ({
           title: item.seq_name,

+ 22 - 19
src/pages/Flow/components/ApprovalProcess.tsx

@@ -27,25 +27,28 @@ const ApprovalProcess = (props: any) => {
   const { userList, run } = useModel('userList');
 
   const list = useMemo(() => {
-    approvalProcess?.forEach((item: any) => {
-      if (item.length > 1 && item[0].type == TYPE.USER) {
-        item.forEach((curUser: any) => {
-          curUser.name =
-            userList.find((user: any) => user.ID == curUser.value)?.CName ||
+    approvalProcess
+      ?.filter((item: any) => item)
+      .forEach((item: any) => {
+        if (item.length > 1 && item[0].type == TYPE.USER) {
+          item.forEach((curUser: any) => {
+            curUser.name =
+              userList?.find((user: any) => user.ID == curUser.value)?.CName ||
+              '-';
+          });
+        } else if (item.length == 1 && item[0].type == TYPE.USER) {
+          item[0].name =
+            userList?.find((user: any) => user.ID == item[0].value)?.CName ||
             '-';
-        });
-      } else if (item.length == 1 && item[0].type == TYPE.USER) {
-        item[0].name =
-          userList.find((user: any) => user.ID == item[0].value)?.CName || '-';
-      } else if (item.length == 1 && item[0].nowType == TYPE.USER) {
-        item[0].name =
-          userList.find((user: any) => user.ID == item[0].nowValue)?.CName ||
-          '-';
-      } else {
-        item[0].name = null;
-      }
-    });
-    return approvalProcess;
+        } else if (item.length == 1 && item[0].nowType == TYPE.USER) {
+          item[0].name =
+            userList?.find((user: any) => user.ID == item[0].nowValue)?.CName ||
+            '-';
+        } else {
+          item[0].name = null;
+        }
+      });
+    return approvalProcess?.filter((item: any) => item);
   }, [approvalProcess]);
 
   const onStepsChange = async (current: any, list: any) => {
@@ -60,7 +63,7 @@ const ApprovalProcess = (props: any) => {
 
   const selectedUserId = ({ target: { value } }: RadioChangeEvent) => {
     //userId
-    const name = userList.find((user: any) => user.ID == value)?.CName || '-';
+    const name = userList?.find((user: any) => user.ID == value)?.CName || '-';
     const data = { nowType: TYPE.USER, nowValue: Number(value), name }; //type: TYPE.USER, value: Number(value)
     list[curNodeIdx][0] = { ...list[curNodeIdx][0], ...data };
     console.log([...list]);