|
|
@@ -1,5 +1,5 @@
|
|
|
import React from 'react'
|
|
|
-import { Form, Input, Button, Select, Table, Checkbox, Switch, Divider, Icon } from 'antd'
|
|
|
+import { Form, Input, Button, Select, Table, Checkbox, Switch, Divider, Icon, Popconfirm } from 'antd'
|
|
|
import { connect } from 'dva'
|
|
|
import COLUMN_TYPE from './columnType.json'
|
|
|
const FormItem = Form.Item
|
|
|
@@ -10,12 +10,13 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
-
|
|
|
+ visibleConfirm: false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- onCheckAllChange() {
|
|
|
-
|
|
|
+ handleVisibleChange = (visible) => {
|
|
|
+ const { columns } = this.props.dataSource.newOne;
|
|
|
+ this.setState({ visibleConfirm: visible && (columns && columns.length > 0) });
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
@@ -205,14 +206,35 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
</FormItem>
|
|
|
<div className='buttons'>
|
|
|
<div className='errormessage' style={{ cursor: dataSource.newOne.invalidSQL ? 'text' : 'default', opacity: dataSource.newOne.invalidSQL ? '1' : '0' }}>未查询到列数据,请检查SQL是否正确</div>
|
|
|
- <Button disabled={!dataSource.newOne.address || loading.models.dataSource} onClick={() => {
|
|
|
- dispatch({ type: 'dataSource/importNewModelColumns' })
|
|
|
- }}>
|
|
|
- {
|
|
|
- loading.models.dataSource ? <Icon type="loading" /> : ''
|
|
|
- }
|
|
|
- {'获取数据列'}
|
|
|
- </Button>
|
|
|
+ <Popconfirm
|
|
|
+ title="已存在列数据,确定要覆盖吗?"
|
|
|
+ visible={this.state.visibleConfirm}
|
|
|
+ onVisibleChange={this.handleVisibleChange}
|
|
|
+ onConfirm={() => {
|
|
|
+ this.setState({
|
|
|
+ visibleConfirm: false
|
|
|
+ });
|
|
|
+ dispatch({ type: 'dataSource/importNewModelColumns' });
|
|
|
+ }}
|
|
|
+ onCancel={() => {
|
|
|
+ this.setState({
|
|
|
+ visibleConfirm: false
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ okText="确定"
|
|
|
+ cancelText="取消"
|
|
|
+ >
|
|
|
+ <Button disabled={!dataSource.newOne.address || loading.models.dataSource} onClick={() => {
|
|
|
+ if(!dataSource.newOne.columns || dataSource.newOne.columns.length === 0) {
|
|
|
+ dispatch({ type: 'dataSource/importNewModelColumns' });
|
|
|
+ }
|
|
|
+ }}>
|
|
|
+ {
|
|
|
+ loading.models.dataSource ? <Icon type="loading" /> : ''
|
|
|
+ }
|
|
|
+ {'获取数据列'}
|
|
|
+ </Button>
|
|
|
+ </Popconfirm>
|
|
|
</div>
|
|
|
</Form>
|
|
|
<Divider orientation="left">数据列</Divider>
|