From 43c316de7163b3ea25bd8d554b07c0b7098c9456 Mon Sep 17 00:00:00 2001
From: zhangyongtian <1181606322@qq.com>
Date: Wed, 21 Aug 2024 14:28:28 +0800
Subject: [PATCH] feat: 添加代理人逻辑

---
 gz-customerSystem/src/views/register/visit/component/applyDialog.jsx     |   16 ++++---
 gz-customerSystem/src/views/register/visit/component/agentDialog.jsx     |   31 +++++++++++----
 gz-customerSystem/src/views/register/visit/component/visitorRegister.jsx |    7 ++-
 gz-customerSystem/src/views/register/visit/component/detailDialog.jsx    |    2 
 gz-customerSystem/src/components/personCard/index.jsx                    |   19 ++++++---
 5 files changed, 50 insertions(+), 25 deletions(-)

diff --git a/gz-customerSystem/src/components/personCard/index.jsx b/gz-customerSystem/src/components/personCard/index.jsx
index fbc1e78..d9e33c6 100644
--- a/gz-customerSystem/src/components/personCard/index.jsx
+++ b/gz-customerSystem/src/components/personCard/index.jsx
@@ -20,11 +20,15 @@
  */
 const PersonCard = ({ isCheck, data, handleCheckParty, handleDeleteParty, handleAdd }) => {
     let isAgent = false
+    let isAgentFor = false
     const typeList = data.map(item => {
         return item.partyType
     })//获取有多少申请人和被申请人
-    if (typeList.indexOf(0) != -1 && typeList.indexOf(1) != -1) {
+    if (typeList.indexOf(0) != -1) {
         isAgent = true
+    }
+    if (typeList.indexOf(1) != -1) {
+        isAgentFor = true
     }
     return (
         <Row gutter={[24, 16]}>
@@ -32,7 +36,7 @@
                 <Col span={7} key={t}>
                     <div className="public-personCard" style={{ cursor: 'pointer' }}>
                         <div
-                            className={`public-personCard-card public-personCard-card-${x.partyType === 0 ? 'blue' : 'orange'}`}
+                            className={`public-personCard-card public-personCard-card-${(x.partyType === 0 || x.partyType === 2) ? 'blue' : 'orange'}`}
                             onClick={() => handleCheckParty(x)}
                         >
                             {x.trueName.substr(0, 1)}
@@ -49,12 +53,12 @@
                                 <Text style={{ maxWidth: '80%', paddingRight: '8px' }} ellipsis={{ tooltip: x.trueName }}>
                                     {x.trueName}
                                 </Text>
-                                <Text ellipsis={{ tooltip: x.perClassName }} className={`public-personCard-tag public-personCard-tag-${x.partyType === 0 ? 'blue' : 'orange'}`}>
+                                <Text ellipsis={{ tooltip: x.perClassName }} className={`public-personCard-tag public-personCard-tag-${(x.partyType === 0 || x.partyType === 2) ? 'blue' : 'orange'}`}>
                                     {x.perClassName}
                                 </Text>
                             </div>
                             {
-                                x.perClass === '09_01001-1' &&
+                                (x.perClass === '09_01001-1' || !x.perClass) &&
                                 <>
                                     <div>证件号码:{x.mobile}</div>
                                     <div>联系方式:{x.personNumber}</div>
@@ -87,9 +91,10 @@
                 <div className="dataSync-addBtn">
                     <Tooltip
                         title={(<Space direction='vertical '>
-                            <div className="dataSync-btnApply" style={{ backgroundColor: '#1A6FB8' }} onClick={() => { handleAdd(0) }}>申请方</div>
-                            <div className="dataSync-btnApply" style={{ backgroundColor: '#FA8C16' }} onClick={() => { handleAdd(1) }}>被申请方</div>
-                            {isAgent && <div className="dataSync-btnApply" style={{ backgroundColor: '#3491FA' }} onClick={() => { handleAdd(2) }}>代理人</div>}
+                            <div className="dataSync-btnApply" style={{ backgroundColor: '#1A6FB8' }} onClick={() => { handleAdd(0) }}>申请方当事人</div>
+                            {isAgent && <div className="dataSync-btnApply" style={{ backgroundColor: '#3491FA' }} onClick={() => { handleAdd(2) }}>申请方代理人</div>}
+                            <div className="dataSync-btnApply" style={{ backgroundColor: '#EF6C24' }} onClick={() => { handleAdd(1) }}>被申请方当事人</div>
+                            {isAgentFor && <div className="dataSync-btnApply" style={{ backgroundColor: '#FA8C16' }} onClick={() => { handleAdd(3) }}>被申请方代理人</div>}
                         </Space>)}
                         placement={data.length !== 0 && data.length % 3 === 0 ? 'left' : "right"}
                         color='#ffff'
diff --git a/gz-customerSystem/src/views/register/visit/component/agentDialog.jsx b/gz-customerSystem/src/views/register/visit/component/agentDialog.jsx
index 0f92863..5dfe16e 100644
--- a/gz-customerSystem/src/views/register/visit/component/agentDialog.jsx
+++ b/gz-customerSystem/src/views/register/visit/component/agentDialog.jsx
@@ -14,21 +14,36 @@
 
 export default function AgentDialog(props) {
   const formRef = useRef();
+  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])
 
   //保存信息
   const handleSave = () => {
     if (formRef.current) {
       formRef.current.validate(undefined, (errors, values) => {
-        props.handleAddParty({
-          ...values,
-          // partyType: props.dialogType,
-          // perClass: perClass,
-          // perClassName: props.dialogType === 0 ? '申请方代理人' : '被申请方当事人'
-        })
-        props.onClose()
+        if (!errors) {
+          props.handleAddParty({
+            ...values,
+            partyType: props.dialogType,
+            perClassName: props.dialogType === 2 ? '申请方代理人' : '被申请方代理人',
+          })
+          props.onClose()
+        }
       });
     }
   }
+
   return (
     <div className="applyDialog">
       <div style={{ height: '590px', overflowY: 'scroll' }}>
@@ -217,7 +232,7 @@
                   >
                     <CheckboxGroup
                       direction='vertical'
-                      options={props.fakeData.map(x => ({
+                      options={visitList.map(x => ({
                         label: <span>{x.trueName}&nbsp;&nbsp;<span style={{ color: '#86909c' }}>({x.perClassName})</span></span>,
                         value: x.id,
                       }))}
diff --git a/gz-customerSystem/src/views/register/visit/component/applyDialog.jsx b/gz-customerSystem/src/views/register/visit/component/applyDialog.jsx
index 57e321f..181b8e7 100644
--- a/gz-customerSystem/src/views/register/visit/component/applyDialog.jsx
+++ b/gz-customerSystem/src/views/register/visit/component/applyDialog.jsx
@@ -270,13 +270,15 @@
   const handleSave = () => {
     if (formRef.current) {
       formRef.current.validate(undefined, (errors, values) => {
-        props.handleAddParty({
-          ...values,
-          partyType: props.dialogType,
-          perClass: perClass,
-          perClassName: props.dialogType === 0 ? '申请方当事人' : '被申请方当事人'
-        })
-        props.onClose()
+        if (!errors) {
+          props.handleAddParty({
+            ...values,
+            partyType: props.dialogType,
+            perClass: perClass,
+            perClassName: props.dialogType === 0 ? '申请方当事人' : '被申请方当事人'
+          })
+          props.onClose()
+        }
       });
     }
   }
diff --git a/gz-customerSystem/src/views/register/visit/component/detailDialog.jsx b/gz-customerSystem/src/views/register/visit/component/detailDialog.jsx
index f58f8cc..795b2e1 100644
--- a/gz-customerSystem/src/views/register/visit/component/detailDialog.jsx
+++ b/gz-customerSystem/src/views/register/visit/component/detailDialog.jsx
@@ -268,7 +268,7 @@
   const tableList = agentList
 
   return (
-    <div>
+    <div style={{maxHeight: '590px', overflowY: 'scroll'}}>
       <table border="1" align="center" cellpadding="8" className="table" style={{marginBottom: '20px'}}>
         {
           tableList?.map((item, index) => {
diff --git a/gz-customerSystem/src/views/register/visit/component/visitorRegister.jsx b/gz-customerSystem/src/views/register/visit/component/visitorRegister.jsx
index fd3929a..9391d83 100644
--- a/gz-customerSystem/src/views/register/visit/component/visitorRegister.jsx
+++ b/gz-customerSystem/src/views/register/visit/component/visitorRegister.jsx
@@ -352,9 +352,9 @@
     return `${year}-${month}-${day} ${hours}:${minutes}`;
   }
 
-  //添加申请人: 0、被申请人: 1、代理人: 2
+  //添加申请人: 0、被申请人: 1、申请代理人: 2、被申请代理人:3
   const handleAdd = (type) => {
-    if (type === 2) {
+    if (type === 2 || type === 3) {
       setAgentVisible(true)
     } else {
       setAddVisabled(true)
@@ -727,11 +727,14 @@
         autoFocus={false}
         focusLock={true}
         footer={null}
+        unmountOnExit={true}
+        maskClosable={false}
       >
         <AgentDialog
           handleAddParty={handleAddParty}
           onClose={() => setAgentVisible(false)}
           fakeData={fakeData}
+          dialogType={dialogType}
         />
       </Modal>
       <Modal

--
Gitblit v1.8.0