From 33440bb15f8d7f07b68e34760129d3300cab5e88 Mon Sep 17 00:00:00 2001
From: zhangyongtian <1181606322@qq.com>
Date: Tue, 27 Aug 2024 10:57:21 +0800
Subject: [PATCH] feat:编辑当事人逻辑

---
 gz-customerSystem/src/views/register/visit/component/agentDialog.jsx |   56 +++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/gz-customerSystem/src/views/register/visit/component/agentDialog.jsx b/gz-customerSystem/src/views/register/visit/component/agentDialog.jsx
index 5dfe16e..bea0658 100644
--- a/gz-customerSystem/src/views/register/visit/component/agentDialog.jsx
+++ b/gz-customerSystem/src/views/register/visit/component/agentDialog.jsx
@@ -17,27 +17,48 @@
   const [visitList, setVisitList] = useState([])
 
   useEffect(() => {
-    //过滤代理人
-    setVisitList(props.fakeData.filter(item => {
-      console.log(item,props.dialogType);
-      if (props.dialogType === 2) {
-        return item.partyType === 0
-      } else {
-        return item.partyType === 1
-      }
-    }))
-  }, [props.fakeData])
+    if (props.editData) {
+      //编辑
+      formRef.current.setFieldsValue({
+        ...props.editData
+      })
+      //过滤代理人
+      setVisitList(props.fakeData.filter(item => {
+        if (props.editData.dialogType === 2) {
+          return item.partyType === 0
+        } else {
+          return item.partyType === 1
+        }
+      }))
+    } else {
+      //过滤代理人
+      setVisitList(props.fakeData.filter(item => {
+        if (props.dialogType === 2) {
+          return item.partyType === 0
+        } else {
+          return item.partyType === 1
+        }
+      }))
+    }
+  }, [])
 
   //保存信息
   const handleSave = () => {
     if (formRef.current) {
       formRef.current.validate(undefined, (errors, values) => {
         if (!errors) {
-          props.handleAddParty({
-            ...values,
-            partyType: props.dialogType,
-            perClassName: props.dialogType === 2 ? '申请方代理人' : '被申请方代理人',
-          })
+          if (props.editData) {
+            props.handleAddParty({
+              ...props.editData,
+              ...values,
+            })
+          } else {
+            props.handleAddParty({
+              ...values,
+              partyType: props.dialogType,
+              perClassName: props.dialogType === 2 ? '申请方代理人' : '被申请方代理人',
+            })
+          }
           props.onClose()
         }
       });
@@ -55,6 +76,7 @@
               requiredSymbol={false}
               initialValues={{
               }}//默认值
+              scrollToFirstError
             >
               <Row gutter={[32, 0]} style={{ margin: '0 -10px' }}>
                 <Col span={24}>
@@ -227,7 +249,7 @@
                 <Col span={12}>
                   <FormItem
                     label={(<div style={{ display: 'flex' }}>代理对象<div className="must">必填</div></div>)}
-                    rules={[{ required: true }]}
+                    rules={[{ required: true, message: '请选择代理对象' }]}
                     field='dailimap'
                   >
                     <CheckboxGroup
@@ -256,7 +278,7 @@
           className="dialogPrimary"
           onClick={handleSave}
         >
-          保存信息
+          保存
         </Button>
         <Button className="dialogBack">
           重置

--
Gitblit v1.8.0