update 字典管理
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Form, Button, Table } from 'antd'
|
||||
import { Form, Button, Table, Tooltip } from 'antd'
|
||||
import { AntIcon } from 'components'
|
||||
|
||||
const clearChildren = (data) => {
|
||||
@@ -182,6 +182,18 @@ export default class QueryTable extends Component {
|
||||
this.onLoadData()
|
||||
}
|
||||
|
||||
onAddRow(record = {}) {
|
||||
let { dataSource } = this.state
|
||||
if (!dataSource.find(item => !item.id)) {
|
||||
dataSource = [...dataSource, record]
|
||||
this.setState({
|
||||
dataSource
|
||||
})
|
||||
return dataSource.length - 1
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染查询栏
|
||||
* @returns
|
||||
@@ -201,8 +213,10 @@ export default class QueryTable extends Component {
|
||||
{query}
|
||||
<Form.Item>
|
||||
<Button.Group className="mr-xs">
|
||||
<Button htmlType="submit" type="primary">查询</Button>
|
||||
<Button onClick={() => this.onResetQuery()}>重置</Button>
|
||||
<Button htmlType="submit" type="primary" icon={<AntIcon type="search" />}>查询</Button>
|
||||
<Tooltip placement="bottom" title="重置查询">
|
||||
<Button onClick={() => this.onResetQuery()} icon={<AntIcon type="undo" />} />
|
||||
</Tooltip>
|
||||
</Button.Group>
|
||||
{
|
||||
moreQuery && <Button>更多查询条件</Button>
|
||||
@@ -213,6 +227,10 @@ export default class QueryTable extends Component {
|
||||
)
|
||||
}
|
||||
|
||||
renderTable(props, on) {
|
||||
return <Table className="yo-table" {...props} {...on} />
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
const { loading, dataSource } = this.state
|
||||
@@ -227,6 +245,7 @@ export default class QueryTable extends Component {
|
||||
bordered: true,
|
||||
size: 'middle',
|
||||
rowKey: record => record.id || Math.random().toString(16).slice(2),
|
||||
sticky: true,
|
||||
...this.props
|
||||
}
|
||||
|
||||
@@ -243,11 +262,20 @@ export default class QueryTable extends Component {
|
||||
</div>
|
||||
<div className="yo-action-bar--actions">
|
||||
<Button.Group>
|
||||
<Button>刷新</Button>
|
||||
<Tooltip placement="bottom" title="刷新">
|
||||
<Button onClick={() => this.onReloadData()} type="text" icon={<AntIcon type="reload" />} />
|
||||
</Tooltip>
|
||||
</Button.Group>
|
||||
</div>
|
||||
</div>
|
||||
<Table className="yo-table" {...props} {...on} sticky />
|
||||
{
|
||||
this.props.editable ?
|
||||
<Form ref={this.props.form}>
|
||||
{this.renderTable(props, on)}
|
||||
</Form>
|
||||
:
|
||||
this.renderTable(props, on)
|
||||
}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user