| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- import React from 'react'
- import { connect } from 'dva'
- import { Layout, Steps, Button, message, Tabs } from 'antd'
- const { Header, Content } = Layout
- const Step = Steps.Step
- const TabPane = Tabs.TabPane
- import { Link } from 'react-router-dom'
- import BaseConfig from './baseConfig'
- import ConnectConfig from './connectConfig'
- import ColumnConfig from './columnConfig'
- import AccessConfig from './accessConfig'
- import './dataSourceDetail.less'
- class DataSourceDetail extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- mode: props.match.params.code&&props.match.params.code=='create'?'create':'modify',
- type: props.match.params.type,
- code: props.match.params.code,
- tab: props.match.params.tab,
- current: ['base', 'column', 'access'].indexOf(props.match.params.tab)
- }
- }
- componentDidMount() {
- this.props.dispatch({ type: 'dataSource/setNewModelFields', fields: [
- { name: 'type', value: this.props.match.params.type },
- { name: 'code', value: this.props.match.params.code }
- ] });
- }
- next() {
- const { type, current } = this.state;
- this.setState({ current: current + 1 });
- let step = ['base', 'column', 'access'][current + 1];
- this.props.dispatch({ type: 'main/redirect', path: '/datasource/' + type + '/create/' + step })
- }
- prev() {
- const { type, current } = this.state;
- this.setState({ current: current - 1 });
- let step = ['base', 'column', 'access'][current - 1];
- this.props.dispatch({ type: 'main/redirect', path: '/datasource/' + type + '/create/' + step })
- }
- render() {
- const { dispatch } = this.props;
- const { type, mode, code, tab, current } = this.state;
- const steps = [{
- tabName: 'base',
- title: '属性配置',
- content: <BaseConfig/>
- }, {
- tabName: 'column',
- title: '数据列配置',
- content: <ColumnConfig />
- }, {
- tabName: 'access',
- title: '权限配置',
- content: <AccessConfig />
- }];
- return (
- <Layout className='layout-datasource-detail'>
- <Content className='content'>
- {mode == 'create' ? (<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 className="steps-action">
- {
- current > 0 && (
- <Button onClick={() => this.prev()}>
- 上一步
- </Button>)
- }
- {
- current < steps.length - 1
- && <Button type="primary" onClick={() => this.next()}>下一步</Button>
- }
- {
- current === steps.length - 1
- && <Button type="primary" onClick={() => {
- dispatch({ type: 'dataSource/remoteAdd' })
- dispatch({ type: 'main/redirect', path: { pathname: '/datasource' } });
- }}>完成</Button>
- }
- </div>
- </div>) : (
- <Tabs activeKey={tab} type="card"
- onChange={(key) => {
- dispatch({ type: 'main/redirect', path: '/datasource/' + type + '/' + code + '/' + key })
- this.setState({
- tab: key
- })
- }}
- tabBarExtraContent={<Button onClick={() => {
- dispatch({ type: 'dataSource/remoteModify', code: this.props.match.params.code });
- }}>保存修改</Button>}
- >
- {steps.map((item, index) => {
- return <TabPane className='tab-datasource' key={item.tabName} tab={item.title}>
- {item.content}
- </TabPane>
- })}
- </Tabs>
- )}
- </Content>
- </Layout>
- )
- }
- }
- export default connect()(DataSourceDetail);
|