mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-21 15:04:26 +00:00
add:ui-components
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import React, {PropTypes} from 'react'
|
||||
import {Dropdown, Button, Icon, Menu} from 'antd'
|
||||
|
||||
const DropOption = ({onMenuClick, menuOptions = [], buttonStyle, dropdownProps}) => {
|
||||
const menu = menuOptions.map(item => <Menu.Item key={item.key}>{item.name}</Menu.Item>)
|
||||
return <Dropdown overlay={<Menu onClick={onMenuClick} {...dropdownProps}>
|
||||
{menu}
|
||||
</Menu>}>
|
||||
<Button style={{ border: 'none', ...buttonStyle}}>
|
||||
<Icon style={{ marginRight: 2 }} type='bars' />
|
||||
<Icon type='down' />
|
||||
</Button>
|
||||
</Dropdown>
|
||||
}
|
||||
|
||||
DropOption.propTypes = {
|
||||
onMenuClick: PropTypes.func,
|
||||
menuOptions: PropTypes.array.isRequired,
|
||||
buttonStyle: PropTypes.object,
|
||||
dropdownProps: PropTypes.object
|
||||
}
|
||||
|
||||
export default DropOption
|
||||
@@ -1,4 +1,5 @@
|
||||
import Ico from './ico.js'
|
||||
import Search from './search.js'
|
||||
import DropOption from './dropOption.js'
|
||||
|
||||
export { Ico, Search }
|
||||
export { Ico, Search, DropOption }
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import React, {PropTypes} from 'react'
|
||||
import {Table, Dropdown, Button, Menu, Icon, Modal} from 'antd'
|
||||
import {Table, Modal} from 'antd'
|
||||
import styles from './list.less'
|
||||
import classnames from 'classnames'
|
||||
import TableBodyWrapper from '../common/TableBodyWrapper'
|
||||
import {DropOption} from '../ui/index'
|
||||
|
||||
const confirm = Modal.confirm
|
||||
|
||||
@@ -69,15 +70,7 @@ function list ({ loading, dataSource, pagination, onPageChange, onDeleteItem, on
|
||||
key: 'operation',
|
||||
width: 100,
|
||||
render: (text, record) => {
|
||||
return (<Dropdown overlay={<Menu onClick={(e) => handleMenuClick(record, e)}>
|
||||
<Menu.Item key='1'>编辑</Menu.Item>
|
||||
<Menu.Item key='2'>删除</Menu.Item>
|
||||
</Menu>}>
|
||||
<Button style={{ border: 'none' }}>
|
||||
<Icon style={{ marginRight: 2 }} type='bars' />
|
||||
<Icon type='down' />
|
||||
</Button>
|
||||
</Dropdown>)
|
||||
return <DropOption onMenuClick={e => handleMenuClick(record, e)} menuOptions={[{key: '1', name: '编辑'}, {key: '2', name: '删除'}]} />
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -56,6 +56,14 @@ export default function ({history, app}) {
|
||||
cb(null, require('./routes/ui/search'))
|
||||
}, 'ui-search')
|
||||
}
|
||||
}, {
|
||||
path: 'ui/dropOption',
|
||||
name: 'ui/dropOption',
|
||||
getComponent (nextState, cb) {
|
||||
require.ensure([], require => {
|
||||
cb(null, require('./routes/ui/dropOption'))
|
||||
}, 'ui-dropOption')
|
||||
}
|
||||
}, {
|
||||
path: '*',
|
||||
name: 'error',
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
import React from 'react'
|
||||
import { DropOption } from '../../components/ui'
|
||||
import { Table, Row, Col, Card, message } from 'antd'
|
||||
|
||||
const DropOptionPage = () => <div className='content-inner'>
|
||||
<Row gutter={32}>
|
||||
<Col lg={8} md={12}>
|
||||
<Card title='默认'>
|
||||
<DropOption menuOptions={[{key: '1', name: '编辑'}, {key: '2', name: '删除'}]} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col lg={8} md={12}>
|
||||
<Card title='样式'>
|
||||
<DropOption menuOptions={[{key: '1', name: '编辑'}, {key: '2', name: '删除'}]} buttonStyle={{border: 'solid 1px #eee', width: 60}} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col lg={8} md={12}>
|
||||
<Card title='事件'>
|
||||
<DropOption
|
||||
menuOptions={[{key: '1', name: '编辑'}, {key: '2', name: '删除'}]}
|
||||
buttonStyle={{border: 'solid 1px #eee', width: 60}}
|
||||
onMenuClick={({key}) => {
|
||||
switch (key) {
|
||||
case '1':
|
||||
message.success('点击了编辑')
|
||||
break
|
||||
case '2':
|
||||
message.success('点击了删除')
|
||||
break
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
<h2 style={{margin: '16px 0'}}>Props</h2>
|
||||
<Row>
|
||||
<Col lg={18} md={24}>
|
||||
<Table rowKey={(record, key) => key}
|
||||
pagination={false}
|
||||
bordered
|
||||
scroll={{ x: 800 }}
|
||||
columns={[
|
||||
{
|
||||
title: '参数',
|
||||
dataIndex: 'props'
|
||||
},
|
||||
{
|
||||
title: '说明',
|
||||
dataIndex: 'desciption'
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'type'
|
||||
},
|
||||
{
|
||||
title: '默认值',
|
||||
dataIndex: 'default'
|
||||
}
|
||||
]}
|
||||
dataSource={[
|
||||
{
|
||||
props: 'menuOptions',
|
||||
desciption: '下拉操作的选项,格式为[{name:string,key:string}]',
|
||||
type: 'Array',
|
||||
default: '必选'
|
||||
},
|
||||
{
|
||||
props: 'onMenuClick',
|
||||
desciption: '点击 menuitem 调用此函数,参数为 {item, key, keyPath}',
|
||||
type: 'Function',
|
||||
default: '-'
|
||||
},
|
||||
{
|
||||
props: 'buttonStyle',
|
||||
desciption: '按钮的样式',
|
||||
type: 'Object',
|
||||
default: '-'
|
||||
},
|
||||
{
|
||||
props: 'dropdownProps',
|
||||
desciption: '下拉菜单的参数,可参考antd的【Dropdown】组件',
|
||||
type: 'Object',
|
||||
default: '-'
|
||||
}
|
||||
]} />
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
|
||||
export default DropOptionPage
|
||||
@@ -22,6 +22,10 @@ module.exports = [
|
||||
{
|
||||
key: 'search',
|
||||
name: 'Search 搜索'
|
||||
},
|
||||
{
|
||||
key: 'dropOption',
|
||||
name: 'DropOption 下拉操作'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user