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/visitorRegister.jsx |   49 +++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/gz-customerSystem/src/views/register/visit/component/visitorRegister.jsx b/gz-customerSystem/src/views/register/visit/component/visitorRegister.jsx
index 7735b89..3dce4c6 100644
--- a/gz-customerSystem/src/views/register/visit/component/visitorRegister.jsx
+++ b/gz-customerSystem/src/views/register/visit/component/visitorRegister.jsx
@@ -46,9 +46,10 @@
   const [fileTip, setFileTip] = useState('0');
   const [detailVisabled, setDetailVisabled] = useState(false);//查看信息弹窗控制
   const [mapView, setMapView] = useState(false);
-  const [flagId, setFlagId] = useState(0);//赋予当事人唯一id,用于删除
+  const [flagId, setFlagId] = useState(1);//赋予当事人唯一id,用于删除
   const [visible, setVisible] = useState(false);
   const [apply, setApply] = useState(false);
+  const [editData, setEditData] = useState(null);
 
   const addressOptions = [
     { label: '地址1', value: 'address1' },
@@ -369,12 +370,24 @@
 
   //添加当事人
   const handleAddParty = (value) => {
-    console.log(value);
-    setFakeData([...fakeData, {
-      ...value,
-      id: flagId
-    }])
-    setFlagId(flagId + 1)
+    if (value.id) {
+      //编辑
+      const newList = fakeData.map(item => {
+        if (item.id === value.id) {
+          return value
+        } else {
+          return item
+        }
+      })
+      setFakeData(newList)
+      setEditData(null)
+    } else {
+      setFakeData([...fakeData, {
+        ...value,
+        id: flagId
+      }])
+      setFlagId(flagId + 1)
+    }
   }
 
   //删除当事人
@@ -382,6 +395,19 @@
     event.stopPropagation();
     const filterData = fakeData.filter(item => item.id !== value.id)
     setFakeData(filterData)
+  }
+
+  //编辑
+  const handleEdit = (value) => {
+    console.log(value);
+    if (value.partyType === 0 || value.partyType === 1) {
+      //当事人
+      setAddVisabled(true)
+    } else {
+      //代理人
+      setAgentVisible(true)
+    }
+    setEditData(value)
   }
 
 
@@ -401,6 +427,7 @@
           handleCheckParty={handleCheckParty}
           handleAdd={handleAdd}
           handleDeleteParty={handleDeleteParty}
+          handleEdit={handleEdit}
         />
       </div>
       <Col span={24} style={{ display: 'flex', alignItems: 'center', marginBottom: '8px' }}>
@@ -726,6 +753,7 @@
           dialogType={dialogType}
           onClose={() => setAddVisabled(false)}
           handleAddParty={handleAddParty}
+          editData={editData}
         />
       </Modal>
       <Modal
@@ -744,6 +772,7 @@
           onClose={() => setAgentVisible(false)}
           fakeData={fakeData}
           dialogType={dialogType}
+          editData={editData}
         />
       </Modal>
       <Modal
@@ -795,7 +824,7 @@
       >
         <div style={{ marginTop: '-8px' }}>
           <div>
-            <div style={{ color: '#1A6FB8', fontSize: '15px',lineHeight:'23px',marginBottom:'8px' }}>一类重点事件</div>
+            <div style={{ color: '#1A6FB8', fontSize: '15px', lineHeight: '23px', marginBottom: '8px' }}>一类重点事件</div>
             1、5人(含5人)以上到非接待场所聚集、滞留、静坐、游行或准备上访;<br />
             2、拉横幅、穿着“状衣”、呼喊口号、呼喊标语、堵塞交通非法占据公其场所、扰乱公共秩序、向他人散发传单等上访材料;<br />
             3、拖欠工资、劳资纠纷涉及人数5人以上;<br />
@@ -805,7 +834,7 @@
             7、群体性民事纠纷(5人及5人以上的邻里矛盾纠纷、经济债务纠纷、家庭纠纷等可能导致“民转刑”的民事纠纷);8、存在重大安全隐患、重大不稳定因索的矛盾;9、涉及政治类,非宗教类的非访宣传(在出租屋内从事涉邪教迷信印刷、存放资料的;在公共场所粘贴类似邪教的符号、图案、标志等)10、县(市、区)职能部门、各镇(街道)分管领导根据应急情况认为有必要启动红色预警机制的其他矛盾纠纷。
           </div>
           <div>
-            <div style={{ color: '#1A6FB8', fontSize: '15px',lineHeight:'23px',marginBottom:'8px',marginTop:'20px' }}>二类重点事件</div>
+            <div style={{ color: '#1A6FB8', fontSize: '15px', lineHeight: '23px', marginBottom: '8px', marginTop: '20px' }}>二类重点事件</div>
             1、5人(含5人)以上到非接待场所聚集、滞留、静坐、游行或准备上访;<br />
             2、拉横幅、穿着“状衣”、呼喊口号、呼喊标语、堵塞交通非法占据公其场所、扰乱公共秩序、向他人散发传单等上访材料;<br />
             3、拖欠工资、劳资纠纷涉及人数5人以上;<br />
@@ -815,7 +844,7 @@
             7、群体性民事纠纷(5人及5人以上的邻里矛盾纠纷、经济债务纠纷、家庭纠纷等可能导致“民转刑”的民事纠纷);8、存在重大安全隐患、重大不稳定因索的矛盾;9、涉及政治类,非宗教类的非访宣传(在出租屋内从事涉邪教迷信印刷、存放资料的;在公共场所粘贴类似邪教的符号、图案、标志等)10、县(市、区)职能部门、各镇(街道)分管领导根据应急情况认为有必要启动红色预警机制的其他矛盾纠纷。
           </div>
           <div>
-            <div style={{ color: '#1A6FB8', fontSize: '15px',lineHeight:'23px',marginBottom:'8px',marginTop:'20px' }}>三类普通事件</div>
+            <div style={{ color: '#1A6FB8', fontSize: '15px', lineHeight: '23px', marginBottom: '8px', marginTop: '20px' }}>三类普通事件</div>
             1、5人(含5人)以上到非接待场所聚集、滞留、静坐、游行或准备上访;<br />
             2、拉横幅、穿着“状衣”、呼喊口号、呼喊标语、堵塞交通非法占据公其场所、扰乱公共秩序、向他人散发传单等上访材料;<br />
             3、拖欠工资、劳资纠纷涉及人数5人以上;<br />

--
Gitblit v1.8.0