Kaynağa Gözat

fix: 修复首次提交时报错问题

ZhaoJun 1 yıl önce
ebeveyn
işleme
b576b645a4

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
public/Luckysheet/luckysheet.umd.js


Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
public/Luckysheet/luckysheet.umd.js.map


+ 9 - 3
src/components/FileViewer/index.js

@@ -1,8 +1,9 @@
 import FileViewer from 'react-file-viewer';
 import { Modal, Spin } from 'antd';
-import { memo, useMemo } from 'react';
+import { memo, useEffect, useMemo, useState } from 'react';
 
 const FileViewerModal = ({ data, visible, onCancel, downloadFile }) => {
+  const [active, setActive] = useState(false);
   const type = useMemo(() => {
     if (!data || !data.url) return '';
     let url = data.url || '';
@@ -11,6 +12,12 @@ const FileViewerModal = ({ data, visible, onCancel, downloadFile }) => {
     return arr[arr.length - 1];
   }, [data?.url]);
 
+  useEffect(() => {
+    setTimeout(() => {
+      setActive(visible);
+    }, 300);
+  }, [visible]);
+
   const renderContent = () => {
     if (type == 'xlsx') {
       return (
@@ -48,9 +55,8 @@ const FileViewerModal = ({ data, visible, onCancel, downloadFile }) => {
       width={1000}
       footer={null}
       onCancel={onCancel}
-      bodyStyle={{ height: '680px', overflowY: 'hidden' }}
     >
-      {renderContent()}
+      <div style={{ height: '680px', overflowY: 'hidden' }}>{active && renderContent()}</div>
     </Modal>
   );
 };

+ 12 - 13
src/pages/Detail/CommitAuditModal.js

@@ -106,8 +106,9 @@ function CommitAuditModal(props) {
       // 设置延迟,等待组件渲染
       setTimeout(async () => {
         form.setFieldsValue(defaultValues);
-        const {approvalProcess} = await initFormList();
-        Object.values(defaultValues).forEach(value => onChange(value, approvalProcess || {}));
+        const initForm = await initFormList()
+        const approvalProcess = initForm?.approvalProcess ? initForm.approvalProcess : {};
+        Object.values(defaultValues).forEach(value => onChange(value, approvalProcess));
       }, 200);
     }
     setData(data);
@@ -256,11 +257,12 @@ function CommitAuditModal(props) {
 
   const onChange = async (value, approvalProcess) => {
     // 加载之前提交的form数据
-    const {formList: resData} = await initFormList();
-    const prevFormData = resData && resData.length ? JSON.parse(resData[0]) : [];
+    const resFormData = await initFormList();
+    const resData = resFormData?.formList;
+    const prevFormData = resData && resData.length ? JSON.parse(resData[0]) : null;
     if (value) {
       changeAudit(value[value.length - 1]);
-      if (prevFormData.formComponentValues.length && value[0] === prevFormData.template_node_id) {
+      if (prevFormData !== null && prevFormData?.formComponentValues?.length && value[0] === prevFormData?.template_node_id) {
         setAuditListFun(approvalProcess, prevFormData.formComponentValues);
       } else {
         setAuditListFun(approvalProcess);
@@ -270,7 +272,6 @@ function CommitAuditModal(props) {
       setAuditList([]);
       setApprovalProcess({});
     }
-
     form.setFieldValue('next_template_node_id', '');
   };
 
@@ -322,7 +323,7 @@ function CommitAuditModal(props) {
   };
 
   //处理tabs页
-  const setAuditListFun = async (approvalProcess = {}, prevFromData = []) => {
+  const setAuditListFun = async (approvalProcess = {},prevFormData = []) => {
     var fieldsValue = await form.validateFields();
     let addAuditList = [];
     let result = Object.values(fieldsValue)
@@ -353,9 +354,9 @@ function CommitAuditModal(props) {
     }
     addAuditList.forEach((item, index) => {
       // 回填历史数据
-      if (prevFromData.length) {
+      if (prevFormData.length) {
         item.items.forEach(DDComponent => {
-          const prevValue = prevFromData.find(pItem => pItem.id === DDComponent.props.id)
+          const prevValue = prevFormData.find(pItem => pItem.id === DDComponent.props.id)
           DDComponent.props.defaultValue = prevValue.value
         })
       }
@@ -390,12 +391,11 @@ function CommitAuditModal(props) {
       item.FormComponents = <Components items={item.items}/>;
     });
     setAuditList(addAuditList);
-    if (Object.keys(approvalProcess).length == 0) advanceSubmit();
+    advanceSubmit();
   };
 
   const getFromData = idList => {
     const data = formComponentValues;
-    console.log(data)
     const result = [];
     //获取流转节点的层级关系
     let len = 0;
@@ -430,7 +430,6 @@ function CommitAuditModal(props) {
       };
       result.push(JSON.stringify(formItem));
     });
-    console.log(result)
     return result;
   };
 
@@ -566,7 +565,7 @@ function CommitAuditModal(props) {
       await querySaveBomForm({
         project_id: version.project_id,
         node_id: version.template_node_id,
-        json: JSON.stringify({approvalProcess, formList}),
+        json: JSON.stringify({approvalProcess}),
       });
       params.audit_series = uuidv4();
       params.files = uploadList.current.join(',');

+ 9 - 9
src/pages/Flow/FlowDetail.json

@@ -68,7 +68,7 @@
       "parentKey": "1",
       "x": -578,
       "y": 6,
-      "flow_id": 1,
+      "flow_id": 9,
       "node_type_psr": 1,
       "count": 0,
       "role_list": ""
@@ -260,7 +260,7 @@
       "parentKey": "1",
       "x": 325,
       "y": -170,
-      "flow_id": 1,
+      "flow_id": 5,
       "node_type_psr": 1,
       "count": 0,
       "role_list": ""
@@ -284,7 +284,7 @@
       "parentKey": "1",
       "x": 111,
       "y": 6,
-      "flow_id": 1,
+      "flow_id": 8,
       "node_type_psr": 1,
       "count": 0,
       "role_list": ""
@@ -357,7 +357,7 @@
       "x": -537,
       "y": -240,
       "zIndex": 10,
-      "flow_id": 0,
+      "flow_id": 3,
       "node_type_psr": 1,
       "count": 0
     },
@@ -381,7 +381,7 @@
       "x": -537,
       "y": -117,
       "zIndex": 10,
-      "flow_id": 0,
+      "flow_id": 4,
       "node_type_psr": 1,
       "count": 0
     },
@@ -404,7 +404,7 @@
       "parentKey": "1",
       "x": 168,
       "y": -117,
-      "flow_id": 1,
+      "flow_id": 4,
       "node_type_psr": 1,
       "count": 0,
       "role_list": ""
@@ -428,7 +428,7 @@
       "parentKey": "1",
       "x": 168,
       "y": -240,
-      "flow_id": 1,
+      "flow_id": 3,
       "node_type_psr": 1,
       "count": 0,
       "role_list": ""
@@ -453,7 +453,7 @@
       "x": -264,
       "y": -170,
       "zIndex": 10,
-      "flow_id": 0,
+      "flow_id": 5,
       "node_type_psr": 1,
       "count": 0
     },
@@ -477,7 +477,7 @@
       "x": 471,
       "y": -170,
       "zIndex": 10,
-      "flow_id": 0,
+      "flow_id": 7,
       "node_type_psr": 1,
       "count": 0
     },

+ 2 - 1
src/utils/request.js

@@ -2,7 +2,7 @@ import fetch from 'dva/fetch';
 import { message, notification } from 'antd';
 import router from 'umi/router';
 import hash from 'hash.js';
-import { isAntdPro, getToken, GetTokenFromUrl } from './utils';
+import { isAntdPro, getToken, GetTokenFromUrl, storeToken } from './utils';
 
 // var apiUrl = "http://oraysmart.com:8888"
 // var apiUrl = "http://120.55.44.4:8900"
@@ -90,6 +90,7 @@ export default function request(url, option, jwt) {
   let token = getToken();
   if (!token) {
     token = GetTokenFromUrl();
+    storeToken(token);
   }
 
   const options = {

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor