Kaynağa Gözat

修改提交表单结构

Renxy 2 yıl önce
ebeveyn
işleme
8660475947

+ 1 - 0
src/components/AuditForm/index.js

@@ -40,6 +40,7 @@ function AuditForm(props) {
   useEffect(() => {
     if (value instanceof Array) {
       setFormList([...value]);
+      onChange?.([...value]);
     }
   }, [value]);
 

+ 1 - 1
src/components/DDComponents/DDMultiSelectField/index.js

@@ -13,7 +13,7 @@ function DDMultiSelectField(props) {
       style={{ width: '100%' }}
       disabled={disabled}
       onChange={value => {
-        onChange(JSON.stringify(value));
+        onChange(value);
       }}
     >
       {options?.map(cur => {

+ 1 - 1
src/components/DDComponents/DDSelectField/index.js

@@ -11,7 +11,7 @@ function DDSelectField(props) {
       style={{ width: '100%' }}
       disabled={disabled}
       onChange={value => {
-        onChange(value);
+        onChange(String(value));
       }}
     >
       {options?.map(cur => {

+ 2 - 2
src/components/DDComponents/InnerContactField/index.js

@@ -6,7 +6,6 @@ const { Option } = Select;
 
 function InnerContactField(props) {
   const { value, userList, onChange } = props;
-  console.log(userList);
   return (
     <Select
       showSearch
@@ -16,7 +15,8 @@ function InnerContactField(props) {
           message.error('该用户未绑定钉钉userID,请联系管理员。');
           return;
         }
-        onChange(JSON.stringify([value]));
+        onChange(String(value));
+        // onChange(JSON.stringify([value]));
       }}
       filterOption={(input, option) => option.children.toLowerCase().includes(input.toLowerCase())}
     >

+ 1 - 2
src/components/Flow/components/judgeComponent/index.tsx

@@ -100,7 +100,6 @@ const RenderJudge = (props: any) => {
         return { type: 'dep', value: cur, origin: cur };
       }
     });
-    console.log('=====================', newValues);
     handleChange(newValues, item);
   };
 
@@ -233,4 +232,4 @@ const RenderJudge = (props: any) => {
   return <>{formData.map(item => RenderComp(item))}</>;
 };
 
-export default connect(({ flow }) => ({ depUserTree: flow.depUserTree }))(RenderJudge);
+export default connect(({ user }) => ({ depUserTree: user.depUserTree }))(RenderJudge);

+ 9 - 8
src/components/Flow/components/judgeModal/index.tsx

@@ -1,6 +1,6 @@
 import { Button, Checkbox, Modal } from 'antd';
 import { PlusOutlined } from '@ant-design/icons';
-import React, { useEffect, useMemo, useState } from 'react';
+import React, { useMemo, useState } from 'react';
 import { ComponentName, FormItem } from '../../node/judgeNode/mapServe';
 
 const AddCondition = (props: any) => {
@@ -8,7 +8,12 @@ const AddCondition = (props: any) => {
   const [visible, setVisible] = useState(false);
   const [values, setValues] = useState([]);
 
-  let formData: FormItem[] = formItems ? JSON.parse(formItems) : [];
+  let formData = useMemo(() => {
+    let formDat = formItems ? JSON.parse(formItems) : [];
+    setValues(formDat.map(cur => cur.props.id));
+    return formDat;
+  }, [formItems]);
+
   const data: FormItem[] = items
     .filter((item: FormItem) => {
       return (
@@ -57,13 +62,9 @@ const AddCondition = (props: any) => {
       </div>
       <Modal title="选择条件" visible={visible} onOk={handleOk} onCancel={() => setVisible(false)}>
         <p>请选择用来区分审批流程的条件字段 ,已选{values.length}个</p>
-        <Checkbox.Group defaultValue={formData.map(item => item.props.id)} onChange={onChange}>
+        <Checkbox.Group value={values} onChange={onChange}>
           {data.map((item: FormItem) => (
-            <Checkbox
-              key={item.props.id}
-              value={item.props.id}
-              checked={formData.findIndex(cur => cur.props.id == item.props.id) !== -1}
-            >
+            <Checkbox key={item.props.id} value={item.props.id}>
               {item.props.label}
             </Checkbox>
           ))}

+ 4 - 4
src/components/Flow/node/auditNode/index.tsx

@@ -53,7 +53,7 @@ const CustomRect = props => {
         return text;
       }
     }
-  }, [audits, type, roleID]);
+  }, [audits, type, roleID, depUserTree, roleList]);
 
   // const type: TYPE = 0;
   const titleDom = () => {
@@ -111,9 +111,9 @@ const CustomRect = props => {
   );
 };
 
-export default connect(({ flow }) => ({
-  depUserTree: flow.depUserTree,
-  roleList: flow.roleList,
+export default connect(({ user }) => ({
+  depUserTree: user.depUserTree,
+  roleList: user.roleList,
 }))(CustomRect);
 
 const enum COLOR {

+ 2 - 2
src/components/Flow/node/auditNode/mapServe.tsx

@@ -219,6 +219,6 @@ function RecthServe(props: any) {
 
 export default connect(({ xflow, flow, user }) => ({
   auditList: xflow.auditList,
-  depUserTree: flow.depUserTree,
-  roleList: flow.roleList,
+  depUserTree: user.depUserTree,
+  roleList: user.roleList,
 }))(RecthServe);

+ 3 - 4
src/components/Flow/node/judgeNode/index.tsx

@@ -3,7 +3,6 @@ judgeServe;
 import judgeServe, { ComponentName, FormItem } from './mapServe';
 import { JudgeType, JudgeOptions, SiginOptions } from '../../components/judgeComponent';
 import { connect } from 'dva';
-import { flow } from 'lodash';
 export { judgeServe };
 
 const JudgeRect = props => {
@@ -69,7 +68,7 @@ const JudgeRect = props => {
       });
     }
     return text;
-  }, [formItems]);
+  }, [formItems, depUserTree]);
 
   return (
     <div
@@ -108,6 +107,6 @@ const JudgeRect = props => {
   );
 };
 
-export default connect(({ flow }) => ({
-  depUserTree: flow.depUserTree,
+export default connect(({ user }) => ({
+  depUserTree: user.depUserTree,
 }))(JudgeRect);

+ 8 - 3
src/models/user.js

@@ -159,7 +159,7 @@ export default {
       const response = yield call(queryRole, payload);
       if (response) {
         yield put({
-          type: 'save',
+          type: 'saveState',
           payload: { roleList: response.data.list },
         });
       }
@@ -167,12 +167,11 @@ export default {
     *fetchDepV2({ payload, callback }, { call, put }) {
       const response = yield call(queryDepV2, { pageSize: 999999 });
       if (response) {
-        // const depUserTree = response.data?.list;
         const depUserTree = response.data.list.map(item => {
           return getDepUserTree(item);
         });
         yield put({
-          type: 'save',
+          type: 'saveState',
           payload: { depUserTree },
         });
       }
@@ -222,6 +221,12 @@ export default {
         userList: payload,
       };
     },
+    saveState(state, action) {
+      return {
+        ...state,
+        ...action.payload,
+      };
+    },
   },
 
   subscriptions: {

+ 2 - 2
src/pages/PurchaseAdmin/PurchaseList/Detail/CommitAuditModal.js

@@ -185,13 +185,13 @@ function CommitAuditModal(props) {
                 return {
                   name: itemProps.label,
                   id: itemProps.id,
-                  ...val,
+                  value: [...val],
                 };
               } else if (allValues[itemProps.id]) {
                 return {
                   name: itemProps.label,
                   id: itemProps.id,
-                  value: allValues[itemProps.id] || undefined,
+                  value: [allValues[itemProps.id]] || undefined,
                 };
               }
             })

+ 6 - 5
src/pages/PurchaseAdmin/PurchaseList/Flow/Audit.js

@@ -18,7 +18,8 @@ function Audit(props) {
   const ref = useRef();
 
   const curItem = useMemo(() => {
-    return currentItem || localStorage.getItem('currentAudit');
+    let item = localStorage.getItem('currentAudit');
+    return JSON.stringify(currentItem) == '{}' ? JSON.parse(item) : currentItem;
   }, [currentItem, localStorage.getItem('currentAudit')]);
 
   useEffect(() => {
@@ -27,12 +28,12 @@ function Audit(props) {
       payload: { ids: Number(curItem.id) },
     });
     dispatch({
-      type: 'flow/fetchDepV2',
+      type: 'user/getRoleList',
     });
 
-    // dispatch({
-    //   type: 'user/fetchDepV2',
-    // });
+    dispatch({
+      type: 'user/fetchDepV2',
+    });
   }, []);
   const onChange = values => {
     dispatch({

+ 1 - 1
src/pages/PurchaseAdmin/PurchaseList/Flow/AuditList.js

@@ -52,7 +52,7 @@ function Audit(props) {
     });
   };
   const setCurrentNode = item => {
-    localStorage.setItem('currentAuditId', item.list);
+    if (item?.list) localStorage.setItem('currentAudit', JSON.stringify(item.list));
     dispatch({
       type: 'flow/save',
       payload: {

+ 7 - 4
src/pages/PurchaseAdmin/PurchaseList/Flow/List.js

@@ -47,12 +47,15 @@ function List(props) {
     dispatch({
       type: 'flow/queryProject',
     });
-    dispatch({
-      type: 'flow/getRoleList',
-    });
     // dispatch({
-    //   type: 'user /fetchDepV2',
+    //   type: 'flow/getRoleList',
     // });
+    dispatch({
+      type: 'user/getRoleList',
+    });
+    dispatch({
+      type: 'user/fetchDepV2',
+    });
     // dispatch({
     //   type: 'flow/queryDingTemplateList',
     // });