Jelajahi Sumber

Merge branch 'dev' of http://192.168.1.41:3000/outaozhen/cldV2react into dev

outaozhen 4 tahun lalu
induk
melakukan
f9223a9db0

+ 12 - 6
src/pages/Customer/Client/components/AddClient/index.jsx

@@ -10,6 +10,7 @@ import { validateEnum } from '@/pages/Customer/Company/components/AddCompany/Com
 
 const AddClient = props => {
   const {
+    visible,
     onCancel,
     reload,
     onConfirm,
@@ -29,12 +30,12 @@ const AddClient = props => {
   const [validStatusFtl, setValidStatusFtl] = useState('')
   const dispatch = useDispatch()
   useEffect(() => {
-    if (!sourceList?.length) {
+    if (visible && !sourceList?.length) {
       dispatch({
         type: 'client/fetchSourceList'
       })
     }
-  }, [])
+  }, [visible])
 
   const handleChange = changedValues => {
     if (!changedValues) return
@@ -82,6 +83,7 @@ const AddClient = props => {
   return (
     <Modal
       {...resetModalProps}
+      visible={visible}
       onCancel={onCancel}
       width="43vw"
       title="添加客户"
@@ -105,12 +107,14 @@ const AddClient = props => {
                 }
                 formRef?.setFieldsValue(values)
                 handleOnOk()
-              }}>
+              }}
+            >
               添加并关联
             </Button>
           ) : null}
         </div>
-      }>
+      }
+    >
       <Form {...layout} form={formRef} onValuesChange={handleChange} initialValues={defaultValues}>
         {showDataItem ? <ProFormText name={`${dataType}Id`} hidden /> : null}
         <ProFormText
@@ -122,7 +126,8 @@ const AddClient = props => {
         <Form.Item
           label="客户地区"
           name="districtIds"
-          rules={[{ required: true, message: '请选择地区' }]}>
+          rules={[{ required: true, message: '请选择地区' }]}
+        >
           <LazyCascader showFooter={true} />
         </Form.Item>
         <Row>
@@ -144,7 +149,8 @@ const AddClient = props => {
               name="telephone"
               validateStatus={validStatusFtl}
               hasFeedback
-              rules={[{ required: true, message: '请输入手机号码' }]}>
+              rules={[{ required: true, message: '请输入手机号码' }]}
+            >
               <TelephoneFormItem validateFn={status => setValidStatusFtl(status)} />
             </Form.Item>
             <ProFormText

+ 16 - 12
src/pages/Customer/Company/components/AddCompany/index.jsx

@@ -8,6 +8,7 @@ import { isNullOrUnDef } from '@/utils/is'
 import CompanyFormItem from './CompanyFormItem'
 import { validateEnum } from './CompanyFormItem'
 const AddCompanyModal = ({
+  visible,
   onCancel,
   reload,
   dataId,
@@ -27,22 +28,24 @@ const AddCompanyModal = ({
   }
   const [validStatusFcn, setValidStatusFcn] = useState('')
   useEffect(() => {
-    if (defaultValue) {
-      if (defaultValue.districtIds && defaultValue.districtIds?.length > 1) {
+    if (visible) {
+      if (defaultValue) {
+        if (defaultValue.districtIds && defaultValue.districtIds?.length > 1) {
+          dispatch({
+            type: 'district/fetchWithValues',
+            payload: defaultValue.districtIds
+          })
+        }
+        formRef?.setFieldsValue(defaultValue)
+      }
+      const getNatures = () => {
         dispatch({
-          type: 'district/fetchWithValues',
-          payload: defaultValue.districtIds
+          type: 'company/fetchNatures'
         })
       }
-      formRef?.setFieldsValue(defaultValue)
-    }
-    const getNatures = () => {
-      dispatch({
-        type: 'company/fetchNatures'
-      })
+      !natures.length && getNatures()
     }
-    !natures.length && getNatures()
-  }, [])
+  }, [visible])
 
   const handleOnOk = () => {
     formRef
@@ -69,6 +72,7 @@ const AddCompanyModal = ({
   return (
     <Modal
       {...resetModalProps}
+      visible={visible}
       onCancel={onCancel}
       title="添加新单位"
       width="43vw"

+ 0 - 1
src/pages/Product/Lock/LockStore/components/ChangeClient/index.jsx

@@ -40,7 +40,6 @@ const ChangeClient = ({
   const normalValueRender = (
     <Card size="small">
       <div className="flex justify-between">
-        {/* <div className={styles.nameContent} onClick={handleCompanyClick}> */}
         <div
           className={styles.nameContent}
           onClick={() => dispatchModal('D_CLIENT_DETAIL', { dataId: clientId })}