فهرست منبع

1. 修复项目id未选择时变成number类型的问题
2. 修改DIYTable的value逻辑

xujunjie 1 سال پیش
والد
کامیت
54872b5504
2فایلهای تغییر یافته به همراه15 افزوده شده و 24 حذف شده
  1. 7 5
      src/components/DDComponents/DIYTable/index.tsx
  2. 8 19
      src/pages/Detail/CommitAuditModal.js

+ 7 - 5
src/components/DDComponents/DIYTable/index.tsx

@@ -1,7 +1,7 @@
 import { PlusOutlined } from '@ant-design/icons';
 import { Button, Input, Table } from 'antd';
 import { ColumnsType } from 'antd/lib/table';
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, useRef } from 'react';
 import DDDateField from '@/components/DDComponents/DDDateField';
 import DDSelectField from '@/components/DDComponents/DDSelectField';
 import NumberField from '@/components/DDComponents/NumberField';
@@ -40,7 +40,8 @@ function DIYTable(props: IProps) {
     },
   ];
 
-  const [commitValue, setCommitValue] = useState<any[]>([]);
+  // const [commitValue, setCommitValue] = useState<any[]>([]);
+  const commitValueStr = useRef<string[]>([]);
 
   const handleValueChange = (value: any, id: string, label: string) => {
     let ids = id.split(';');
@@ -60,7 +61,7 @@ function DIYTable(props: IProps) {
     const rows = [];
     rows[rowIndex] = cols;
 
-    const newValues = JSON.parse(JSON.stringify(commitValue)) || [];
+    const newValues = commitValueStr.current.map(item => JSON.parse(item));
 
     if (newValues.length !== 0 && newValues[rowIndex] !== undefined) {
       newValues.forEach((row: any, rindex: number) => {
@@ -97,8 +98,9 @@ function DIYTable(props: IProps) {
     }
     console.log(newValues);
 
-    setCommitValue(newValues);
-    onChange(newValues);
+    // setCommitValue(newValues);
+    commitValueStr.current = newValues.map(item => JSON.stringify(item));
+    onChange(commitValueStr.current);
   };
 
   // 表单填写时的表格生成

+ 8 - 19
src/pages/Detail/CommitAuditModal.js

@@ -23,24 +23,12 @@ import { PlusOutlined, UploadOutlined } from '@ant-design/icons';
 import { connect } from 'dva';
 import { useForm } from 'rc-field-form';
 import AuditDetailed from './AuditDetailed';
-import AuditFlow from './AuditFlow';
-import {
-  queryDingSchema,
-  queryGetBomForm,
-  queryProcessFlows,
-  querySaveBomForm,
-} from '@/services/boom';
+import { queryGetBomForm, queryProcessFlows, querySaveBomForm } from '@/services/boom';
 import { Form as Form3x } from '@ant-design/compatible';
-import { getCurrentUser } from '@/utils/authority';
-import DDCode from '@/components/DDComponents/DDCode';
-import { uploadFile, queryUserListByRoleID } from '@/services/boom';
 import ApprovalProcess from './ApprovalProcess';
 import { uuidv4 } from '@antv/xflow';
 import AliyunOSSUpload from '@/components/OssUpload/AliyunOssUploader';
 import AttachmentTable from '@/components/AttachmentTable';
-import { getToken } from '@/utils/utils';
-import LuckyExcel from 'luckyexcel';
-import DDComponents from '@/components/DDComponents';
 import uploadExcelByUrl from '@/utils/uploadExcelByUrl';
 
 const { TextArea } = Input;
@@ -225,11 +213,12 @@ function CommitAuditModal(props) {
         ? data.find(item => item.template_node_id === approvalNode.Id).formComponentValues
         : [];
       let values = data[approvalNode.Id] || prevValues || [];
-      values.forEach(tempValue => {
-        if (tempValue.id.includes('DIYTable')) {
-          tempValue.value = tempValue.value.map(item => JSON.stringify(item));
-        }
-      });
+      // DIYTable的值不应该在此处处理,stringify逻辑挪至DIYTable内部
+      // values.forEach(tempValue => {
+      //   if (tempValue.id.includes('DIYTable')) {
+      //     tempValue.value = tempValue.value.map(item => JSON.stringify(item));
+      //   }
+      // });
 
       let audit_list = [],
         cc_list = [];
@@ -351,7 +340,7 @@ function CommitAuditModal(props) {
       prevFormData.forEach(pItem => {
         pItem.formComponentValues?.map(item => {
           if (item.id.includes('ProjectField')) {
-            item.value = [version.project_id];
+            item.value = [String(version.project_id)];
           }
         });
         formValues[pItem.template_node_id] = [...pItem.formComponentValues];