refactor: improve linkage rule enable (#1700)
This commit is contained in:
		
							parent
							
								
									76faa9e30c
								
							
						
					
					
						commit
						e8bb962389
					
				@ -74,6 +74,8 @@ export default {
 | 
				
			|||||||
  "Value":"Value",
 | 
					  "Value":"Value",
 | 
				
			||||||
  "Disabled":"Disabled",
 | 
					  "Disabled":"Disabled",
 | 
				
			||||||
  "Enabled":"Enabled",
 | 
					  "Enabled":"Enabled",
 | 
				
			||||||
 | 
					  'On':'On',
 | 
				
			||||||
 | 
					  'Off':'Off',
 | 
				
			||||||
  "Empty":"Empty",
 | 
					  "Empty":"Empty",
 | 
				
			||||||
  "Linkage rule":"Linkage rule",
 | 
					  "Linkage rule":"Linkage rule",
 | 
				
			||||||
  "Linkage rules":"Linkage rules",
 | 
					  "Linkage rules":"Linkage rules",
 | 
				
			||||||
 | 
				
			|||||||
@ -79,6 +79,8 @@ export default {
 | 
				
			|||||||
  "Value":"フィールド値",
 | 
					  "Value":"フィールド値",
 | 
				
			||||||
  "Disabled":"無効化",
 | 
					  "Disabled":"無効化",
 | 
				
			||||||
  "Enabled":"有効化",
 | 
					  "Enabled":"有効化",
 | 
				
			||||||
 | 
					  'On':'有効化',
 | 
				
			||||||
 | 
					  'Off':'無効化',
 | 
				
			||||||
  "Empty":"くうきち",
 | 
					  "Empty":"くうきち",
 | 
				
			||||||
  "Linkage rule":"連動規則",
 | 
					  "Linkage rule":"連動規則",
 | 
				
			||||||
  "Linkage rules":"連動規則",
 | 
					  "Linkage rules":"連動規則",
 | 
				
			||||||
 | 
				
			|||||||
@ -41,6 +41,8 @@ export default {
 | 
				
			|||||||
  "Setting": "设置",
 | 
					  "Setting": "设置",
 | 
				
			||||||
  "Enable": "启用",
 | 
					  "Enable": "启用",
 | 
				
			||||||
  "Disable": "禁用",
 | 
					  "Disable": "禁用",
 | 
				
			||||||
 | 
					  'On':'启用',
 | 
				
			||||||
 | 
					  'Off':'禁用',
 | 
				
			||||||
  "Logo": "Logo",
 | 
					  "Logo": "Logo",
 | 
				
			||||||
  "Add menu item": "添加菜单项",
 | 
					  "Add menu item": "添加菜单项",
 | 
				
			||||||
  "Page": "页面",
 | 
					  "Page": "页面",
 | 
				
			||||||
 | 
				
			|||||||
@ -1,13 +1,18 @@
 | 
				
			|||||||
import React from 'react';
 | 
					import React from 'react';
 | 
				
			||||||
import { Switch } from 'antd';
 | 
					import { Switch } from 'antd';
 | 
				
			||||||
import { ArrayBase } from '@formily/antd';
 | 
					import { ArrayBase } from '@formily/antd';
 | 
				
			||||||
 | 
					import { useTranslation } from 'react-i18next';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const EnableLinkage = React.forwardRef((props: any, ref) => {
 | 
					export const EnableLinkage = React.forwardRef((props: any, ref) => {
 | 
				
			||||||
  const array = ArrayBase.useArray();
 | 
					  const array = ArrayBase.useArray();
 | 
				
			||||||
  const index = ArrayBase.useIndex(props.index);
 | 
					  const index = ArrayBase.useIndex(props.index);
 | 
				
			||||||
 | 
					  const { t } = useTranslation();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <Switch
 | 
					    <Switch
 | 
				
			||||||
      {...props}
 | 
					      {...props}
 | 
				
			||||||
 | 
					      checkedChildren={t('On')}
 | 
				
			||||||
 | 
					      unCheckedChildren={t('Off')}
 | 
				
			||||||
      checked={!array?.field?.value[index].disabled}
 | 
					      checked={!array?.field?.value[index].disabled}
 | 
				
			||||||
      size={'small'}
 | 
					      size={'small'}
 | 
				
			||||||
      style={{
 | 
					      style={{
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user