优化字典 select 和 text
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { connect } from 'dva';
|
||||
import DictionarySelect from '../../components/Dictionary/DictionarySelect';
|
||||
|
||||
@connect(({ dictionarySelect, loading }) => ({
|
||||
data: dictionarySelect,
|
||||
loading: loading.models.dictionarySelect,
|
||||
}))
|
||||
class DictionaryValueSelect extends PureComponent {
|
||||
componentDidMount() {
|
||||
const { dataKey, dispatch } = this.props;
|
||||
dispatch({
|
||||
type: 'dictionarySelect/query',
|
||||
payload: {
|
||||
dataKey,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { data } = this.props;
|
||||
return <DictionarySelect {...this.props} list={data.list} />;
|
||||
}
|
||||
}
|
||||
|
||||
export default DictionaryValueSelect;
|
||||
@@ -1,19 +0,0 @@
|
||||
---
|
||||
title: DictionaryValueSelect
|
||||
subtitle: 字典 value 选择
|
||||
---
|
||||
|
||||
次组件跟使用 Antd extends Select,使用方法跟 Select 一样
|
||||
|
||||
## API
|
||||
|
||||
### DescriptionList
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
|----------|------------------------------------------|-------------|-------|
|
||||
| dataKey | 字典的key | string | [] |
|
||||
|
||||
### Demo
|
||||
```jsx harmony
|
||||
<DictionaryValueSelect dataKey="gender" defaultValue={1} />
|
||||
```
|
||||
@@ -1,26 +0,0 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { connect } from 'dva';
|
||||
|
||||
@connect(({ dictionarySelect, loading }) => ({
|
||||
data: dictionarySelect,
|
||||
loading: loading.models.dictionarySelect,
|
||||
}))
|
||||
class DictionaryValueText extends PureComponent {
|
||||
componentDidMount() {
|
||||
const { dataKey, dispatch } = this.props;
|
||||
dispatch({
|
||||
type: 'dictionarySelect/queryText',
|
||||
payload: {
|
||||
dataKey,
|
||||
value: 1,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { data } = this.props;
|
||||
return <span>{data.text}</span>;
|
||||
}
|
||||
}
|
||||
|
||||
export default DictionaryValueText;
|
||||
@@ -1,19 +0,0 @@
|
||||
---
|
||||
title: DictionaryValueText
|
||||
subtitle: 获取字典 value 显示值
|
||||
---
|
||||
|
||||
## API
|
||||
|
||||
### DescriptionList
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
|----------|------------------------------------------|-------------|-------|
|
||||
| dataKey | 字典的key | string | [] |
|
||||
| value | 显示的值 | string number | [] |
|
||||
|
||||
|
||||
### Demo
|
||||
```jsx harmony
|
||||
<DictionaryValueText dataKey="gender" value="1" />
|
||||
```
|
||||
@@ -1,33 +1,23 @@
|
||||
import React, { Component } from 'react';
|
||||
import { Button } from 'antd';
|
||||
import AuthorityControl from '../../components/AuthorityControl';
|
||||
import UrlsContext from '../../layouts/UrlsContext';
|
||||
import DictionaryValueSelect from '../Dictionary/DictionaryValueSelect';
|
||||
import DictionaryValueText from '../Dictionary/DictionaryValueText';
|
||||
import DictionarySelect from '@/components/Dictionary/DictionarySelect';
|
||||
import DictionaryText from '@/components/Dictionary/DictionaryText';
|
||||
import AuthorityControl from '@/components/AuthorityControl';
|
||||
|
||||
export default class Home extends Component {
|
||||
state = {};
|
||||
|
||||
render() {
|
||||
// 定义认证的属性 TODO
|
||||
const GlobalAuthorityProps = {
|
||||
user: 'admin',
|
||||
login: 'success',
|
||||
authList: {
|
||||
'auth.button': true,
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
<UrlsContext.Provider value={GlobalAuthorityProps}>
|
||||
<div>
|
||||
<AuthorityControl authKey="home.button">
|
||||
<Button type="primary">按钮 控制</Button>
|
||||
</AuthorityControl>
|
||||
<h1>home...</h1>
|
||||
<DictionaryValueSelect dataKey="gender" defaultValue={1} />
|
||||
|
||||
<DictionaryValueText dataKey="gender" value="1" />
|
||||
</UrlsContext.Provider>
|
||||
<DictionarySelect dicKey="gender" defaultValue="1" />
|
||||
<DictionaryText dicKey="gender" dicValue="2" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user