update 字典管理

This commit is contained in:
2021-06-16 14:47:04 +08:00
parent d020f67dba
commit 8f9e1a8d4e
8 changed files with 912 additions and 18 deletions

View File

@@ -121,9 +121,11 @@ export default class ModalForm extends Component {
try {
const postData = await body.getData()
const { success } = await this.action(postData)
if (success) {
Message.success(this.props.successMessage || '保存成功')
const result = await this.action(postData)
if (!result || result.success) {
if (result && result.success) {
Message.success(this.props.successMessage || '保存成功')
}
this.close()
if (typeof this.props.onSuccess === 'function') {
this.props.onSuccess(postData)

View File

@@ -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>
)
}