Browse Source

feat: ProFormSwitch与之关联的ProFormCheckbox功能逻辑优化

lanjianrong 4 years ago
parent
commit
45289a9af6
3 changed files with 22 additions and 1 deletions
  1. 1 1
      src/global.tsx
  2. 14 0
      src/pages/Role/Customer/index.tsx
  3. 7 0
      src/pages/Role/System/index.tsx

+ 1 - 1
src/global.tsx

@@ -3,10 +3,10 @@ import { useIntl } from 'umi'
 import defaultSettings from '../config/defaultSettings'
 
 import 'windi.css'
+import '@icon-park/react/styles/index.less'
 
 const { pwa } = defaultSettings
 const isHttps = document.location.protocol === 'https:'
-
 // if pwa is true
 if (pwa) {
   // Notify user if offline now

+ 14 - 0
src/pages/Role/Customer/index.tsx

@@ -140,6 +140,13 @@ const Customer = () => {
                       message.success('设置成功')
                     }}>
                     <ProFormSwitch
+                      fieldProps={{
+                        onChange(checked) {
+                          if (!checked) {
+                            formRef.current?.setFieldsValue({ client: [] })
+                          }
+                        }
+                      }}
                       name="showClient"
                       label={
                         <span className="flex items-center">
@@ -162,6 +169,13 @@ const Customer = () => {
                       )}
                     </ProFormDependency>
                     <ProFormSwitch
+                      fieldProps={{
+                        onChange(checked) {
+                          if (!checked) {
+                            formRef.current?.setFieldsValue({ company: [] })
+                          }
+                        }
+                      }}
                       name="showCompany"
                       label={
                         <span className="flex items-center">

+ 7 - 0
src/pages/Role/System/index.tsx

@@ -181,6 +181,13 @@ const System = () => {
 
                     <ProFormSwitch
                       name="showSystem"
+                      fieldProps={{
+                        onChange(checked) {
+                          if (!checked) {
+                            formRef.current?.setFieldsValue({ system: [] })
+                          }
+                        }
+                      }}
                       label={
                         <span className="flex items-center">
                           <EveryUser className="mr-1" className="flex items-baseline mr-1" />