import React from 'react' import { connect } from 'dva' import { Layout, Steps, Button, Tabs } from 'antd' import DataConnectConfig from './dataConnectConfig' 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 { constructor(props) { super(props); this.state = { 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) } } 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 }) } render() { const { dispatch, dataSourceDetail, dataConnect } = this.props; const { type, code, tab, mode, current } = this.state; const steps = [{ tabName: 'base', title: type === 'database' ? '数据链接配置' : '文件选择', content: , }, { tabName: 'column', title: '数据列配置', content: , }, { tabName: 'other', title: '完成', content: , }]; const tabs = [{ tabName: 'base', title: '属性配置', content: , }, { tabName: 'column', title: '数据列配置', content: , }, { tabName: 'access', title: '数据开放策略', content: , }]; return ( {mode === 'create' ? ( {steps.map((item,index) => )} {steps[current].content} { current > 0 && ( this.prev()}> 上一步 ) } { current < steps.length - 1 && this.next()}>下一步 } { current === steps.length - 1 && { dispatch({ type: 'dataSource/remoteAdd' }) }}>完成 } ) : ( { dispatch({ type: 'main/redirect', path: '/workshop/datasource/' + type + '/' + code + '/' + key }) this.setState({ tab: key, }) }} > {tabs.map((item, index) => { return {item.content} })} )} ) } } export default connect(({ present: { dataSourceDetail, dataConnect } }) => ({ dataSourceDetail, dataConnect }))(DataSourceDetailContent);