Преглед изворни кода

fix: 昵称、邮箱自动填写

outaozhen пре 4 година
родитељ
комит
9e93bd696d
1 измењених фајлова са 21 додато и 0 уклоњено
  1. 21 0
      src/pages/Customer/Client/components/AddClient/index.jsx

+ 21 - 0
src/pages/Customer/Client/components/AddClient/index.jsx

@@ -37,15 +37,36 @@ const AddClient = props => {
   }, [])
 
   const handleChange = changedValues => {
+    // const clientName = formRef.current?.getFieldValue('clientName')
     if (!changedValues) return
     if ('clientName' in changedValues) {
+      if (!changedValues.clientName) {
+        formRef.current?.setFieldsValue({ niceName: '' })
+        return
+      }
       const [lastName, ...firstName] = changedValues.clientName.split('')
       const newClientName = `${lastName}(${firstName.join('')})工`
       formRef.current?.setFieldsValue({ niceName: newClientName })
     }
     if ('qq' in changedValues) {
+      if (!changedValues.qq) {
+        formRef.current?.setFieldsValue({ email: '' })
+        return
+      }
       formRef.current?.setFieldsValue({ email: `${changedValues.qq}@qq.com` })
     }
+    // const clientName = formRef.current?.getFieldValue('clientName')
+    // if (clientName) {
+    //   const clientNameNum = clientName.split('')
+    //   const [firstName, ...lastName] = clientNameNum
+    //   const nameAfter = `(${lastName.join('')})`
+    //   const newClientName = `${firstName + nameAfter}工`
+    //   formRef.current?.setFieldsValue({ niceName: newClientName })
+    // } else if (!formRef.current?.getFieldValue('qq')) {
+    //   const emailNum = qq.value
+    //   const newEmail = `${emailNum}@qq.com`
+    //   formRef.current?.setFieldsValue({ email: newEmail })
+    // }
   }
   return (
     <ModalDragForm