|
|
@@ -1,14 +1,11 @@
|
|
|
import React from 'react'
|
|
|
import { connect } from 'dva'
|
|
|
-import { Layout, Steps, Button, Tabs, Popconfirm, Icon } from 'antd'
|
|
|
-import DataConnectConfig from './dataConnectConfig'
|
|
|
+import { Layout, Tabs } from 'antd'
|
|
|
import BaseConfig from './baseConfig'
|
|
|
import ColumnConfig from './columnConfig'
|
|
|
import AccessConfig from './accessConfig'
|
|
|
-import OtherConfig from './otherConfig'
|
|
|
import './content.less'
|
|
|
const { Content } = Layout
|
|
|
-const Step = Steps.Step
|
|
|
const TabPane = Tabs.TabPane
|
|
|
|
|
|
class DataSourceDetailContent extends React.Component {
|
|
|
@@ -19,54 +16,17 @@ class DataSourceDetailContent extends React.Component {
|
|
|
mode: props.params.code && props.params.code==='create'?'create':'modify',
|
|
|
type: props.params.type,
|
|
|
code: props.params.code,
|
|
|
- tab: props.params.tab,
|
|
|
- // current: ['base', 'column', 'access', 'other'].indexOf(props.match.params.tab)
|
|
|
- current: ['base', 'column', 'other'].indexOf(props.params.tab),
|
|
|
- visibleConfirm: false,
|
|
|
+ tab: props.params.tab
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- next() {
|
|
|
- const { type, current } = this.state;
|
|
|
- this.setState({ current: current + 1 });
|
|
|
- // let step = ['base', 'column', 'access', 'other'][current + 1];
|
|
|
- let step = ['base', 'column', 'other'][current + 1];
|
|
|
- this.props.dispatch({ type: 'main/redirect', path: '/workshop/datasource/' + type + '/create/' + step })
|
|
|
- }
|
|
|
-
|
|
|
- prev() {
|
|
|
- const { type, current } = this.state;
|
|
|
- this.setState({ current: current - 1 });
|
|
|
- // let step = ['base', 'column', 'access', 'other'][current - 1];
|
|
|
- let step = ['base', 'column', 'other'][current - 1];
|
|
|
- this.props.dispatch({ type: 'main/redirect', path: '/workshop/datasource/' + type + '/create/' + step })
|
|
|
- }
|
|
|
-
|
|
|
- handleVisibleChange = (visible) => {
|
|
|
- this.setState({ visibleConfirm: visible });
|
|
|
- }
|
|
|
-
|
|
|
render() {
|
|
|
- const { dispatch, dataSourceDetail, dataConnect } = this.props;
|
|
|
- const { type, code, tab, mode, current } = this.state;
|
|
|
-
|
|
|
- const steps = [{
|
|
|
- tabName: 'base',
|
|
|
- title: type === 'database' ? '数据链接配置' : '文件选择',
|
|
|
- content: <DataConnectConfig mode={mode} />,
|
|
|
- }, {
|
|
|
- tabName: 'column',
|
|
|
- title: '数据列配置',
|
|
|
- content: <ColumnConfig mode={mode} />,
|
|
|
- }, {
|
|
|
- tabName: 'other',
|
|
|
- title: '完成',
|
|
|
- content: <OtherConfig mode={mode} />,
|
|
|
- }];
|
|
|
+ const { dispatch } = this.props;
|
|
|
+ const { type, code, tab, mode } = this.state;
|
|
|
|
|
|
const tabs = [{
|
|
|
tabName: 'base',
|
|
|
- title: '属性配置',
|
|
|
+ title: '基本信息',
|
|
|
content: <BaseConfig mode={mode} />,
|
|
|
}, {
|
|
|
tabName: 'column',
|
|
|
@@ -80,85 +40,20 @@ class DataSourceDetailContent extends React.Component {
|
|
|
return (
|
|
|
<Layout className='content-datasourcedetail'>
|
|
|
<Content className='content'>
|
|
|
- {mode === 'create' ? (<div className='datasource-steps-container'>
|
|
|
- <div className="steps-action">
|
|
|
- <Popconfirm
|
|
|
- placement="bottomLeft"
|
|
|
- title="确定不保存直接退出吗?"
|
|
|
- visible={this.state.visibleConfirm}
|
|
|
- onVisibleChange={this.handleVisibleChange}
|
|
|
- onConfirm={() => {
|
|
|
- dispatch({ type: 'main/redirect', path: '/workshop/datasource' });
|
|
|
- this.setState({
|
|
|
- visibleConfirm: false
|
|
|
- });
|
|
|
- }}
|
|
|
- onCancel={() => {
|
|
|
- this.setState({
|
|
|
- visibleConfirm: false
|
|
|
- });
|
|
|
- }}
|
|
|
- okText="确定"
|
|
|
- cancelText="取消"
|
|
|
- >
|
|
|
- <Button onClick={(e) => {
|
|
|
- if(!dataSourceDetail.dirty) {
|
|
|
- dispatch({ type: 'main/redirect', path: '/workshop/datasource' });
|
|
|
- }
|
|
|
- }}>
|
|
|
- <Icon type='left' />返回
|
|
|
- </Button>
|
|
|
- </Popconfirm>
|
|
|
- <div className='steps-buttons'>
|
|
|
- {
|
|
|
- current > 0 && (
|
|
|
- <Button onClick={() => this.prev()}>
|
|
|
- 上一步
|
|
|
- </Button>)
|
|
|
- }
|
|
|
- {
|
|
|
- current < steps.length - 1
|
|
|
- && <Button disabled={
|
|
|
- // 第一步:没有选择数据连接或没有上传文件或上传文件有误
|
|
|
- ( current === 0 && ( ( type === 'database' && !dataSourceDetail.connectCode ) || ( type === 'file' && +1 === 2) ) ) ||
|
|
|
- // 第二步:数据列为空或者数据对象有变更
|
|
|
- (current === 1 && (!dataSourceDetail.columns || dataSourceDetail.columns.length === 0 || dataSourceDetail.targetDirty))
|
|
|
- } type="primary" onClick={() => this.next()}>下一步</Button>
|
|
|
- }
|
|
|
- {
|
|
|
- current === steps.length - 1
|
|
|
- && <Button disabled={
|
|
|
- !dataSourceDetail.name ||
|
|
|
- !dataConnect.selected ||
|
|
|
- (!dataSourceDetail.columns || dataSourceDetail.columns.length === 0)
|
|
|
- } type="primary" onClick={() => {
|
|
|
- dispatch({ type: 'dataSource/remoteAdd' })
|
|
|
- }}>完成</Button>
|
|
|
- }
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <Steps className='steps-body' current={current}>
|
|
|
- {steps.map((item,index) => <Step key={'step-' + index} title={item.title} />)}
|
|
|
- </Steps>
|
|
|
- <div className="steps-content">
|
|
|
- {steps[current].content}
|
|
|
- </div>
|
|
|
- </div>) : (
|
|
|
- <Tabs activeKey={tab} type="card"
|
|
|
- onChange={(key) => {
|
|
|
- dispatch({ type: 'main/redirect', path: '/workshop/datasource/' + type + '/' + code + '/' + key })
|
|
|
- this.setState({
|
|
|
- tab: key,
|
|
|
- })
|
|
|
- }}
|
|
|
- >
|
|
|
- {tabs.map((item, index) => {
|
|
|
- return <TabPane className='tab-datasource' key={item.tabName} tab={item.title}>
|
|
|
- {item.content}
|
|
|
- </TabPane>
|
|
|
- })}
|
|
|
- </Tabs>
|
|
|
- )}
|
|
|
+ <Tabs activeKey={tab} type="card"
|
|
|
+ onChange={(key) => {
|
|
|
+ dispatch({ type: 'main/redirect', path: '/workshop/datasource/' + type + '/' + code + '/' + key })
|
|
|
+ this.setState({
|
|
|
+ tab: key,
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {tabs.map((item, index) => {
|
|
|
+ return <TabPane className='tab-datasource' key={item.tabName} tab={item.title}>
|
|
|
+ {item.content}
|
|
|
+ </TabPane>
|
|
|
+ })}
|
|
|
+ </Tabs>
|
|
|
</Content>
|
|
|
</Layout>
|
|
|
)
|