|
@@ -1,21 +1,24 @@
|
|
|
import React, {Component} from 'react';
|
|
import React, {Component} from 'react';
|
|
|
|
|
|
|
|
-import {Select, Input, Icon, Button, notification, Spin} from 'antd';
|
|
|
|
|
|
|
+import {Layout,Select, Input, Icon, Button, notification, Spin} from 'antd';
|
|
|
import {UPDATE_SCHEMA, SHOW_SCHEMA, SHOW_TABLE} from "../../gql";
|
|
import {UPDATE_SCHEMA, SHOW_SCHEMA, SHOW_TABLE} from "../../gql";
|
|
|
import gql from "graphql-tag";
|
|
import gql from "graphql-tag";
|
|
|
|
|
|
|
|
import {Mutation, Query} from "react-apollo";
|
|
import {Mutation, Query} from "react-apollo";
|
|
|
|
|
+import {getCookie} from "../../cookie";
|
|
|
|
|
|
|
|
const Option = Select.Option;
|
|
const Option = Select.Option;
|
|
|
|
|
+const {Content} = Layout;
|
|
|
|
|
|
|
|
class Column extends Component {
|
|
class Column extends Component {
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
|
super(props);
|
|
super(props);
|
|
|
|
|
+ console.log('column props',props);
|
|
|
this.state = {
|
|
this.state = {
|
|
|
- currentSchema: props.currentSchema,
|
|
|
|
|
- currentTable: props.currentTable,
|
|
|
|
|
- remark: props.remark,
|
|
|
|
|
- columns: props.columns,
|
|
|
|
|
|
|
+ currentSchema: props.currentSchema || [{}],
|
|
|
|
|
+ currentTable: props.currentTable || ' ',
|
|
|
|
|
+ remark: props.remark || '',
|
|
|
|
|
+ columns: props.columns || [],
|
|
|
newColName: '',
|
|
newColName: '',
|
|
|
newColType: 'type',
|
|
newColType: 'type',
|
|
|
types: ['ID', 'String', 'Int', 'Float', 'Boolean', 'DateTime'],
|
|
types: ['ID', 'String', 'Int', 'Float', 'Boolean', 'DateTime'],
|
|
@@ -66,7 +69,7 @@ class Column extends Component {
|
|
|
} else {
|
|
} else {
|
|
|
notification['warning']({
|
|
notification['warning']({
|
|
|
message: 'Notification',
|
|
message: 'Notification',
|
|
|
- description: 'Input a name first.',
|
|
|
|
|
|
|
+ description: 'Input a field name first.',
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
@@ -95,96 +98,127 @@ class Column extends Component {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
currentTable: next.currentTable,
|
|
currentTable: next.currentTable,
|
|
|
currentSchema: next.currentSchema,
|
|
currentSchema: next.currentSchema,
|
|
|
- columns: next.columns,
|
|
|
|
|
|
|
+ columns: next.columns || [],
|
|
|
remark: next.remark
|
|
remark: next.remark
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
- return (
|
|
|
|
|
- <div style={{margin: 20}}>
|
|
|
|
|
- <div style={{marginBottom: 20}}>
|
|
|
|
|
- <span className='table-title'> Table name</span>
|
|
|
|
|
- <Input value={this.state.currentTable} placeholder="table_name" style={{width: 120}}
|
|
|
|
|
- onChange={(e) => {
|
|
|
|
|
- this.setState({currentTable: e.target.value})
|
|
|
|
|
- }}/>
|
|
|
|
|
-
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ console.log('columns',this.state.columns);
|
|
|
|
|
+ let schemaID = this.props.location.search.substr(this.props.location.search.indexOf("=")+1);
|
|
|
|
|
+ let userID = this.props.userID || getCookie('user_id');
|
|
|
|
|
+ console.log('schemaID',schemaID,'userID',userID);
|
|
|
|
|
|
|
|
- <div style={{marginBottom: 20}}>
|
|
|
|
|
- <span className='table-title'> Table remark</span>
|
|
|
|
|
- <Input value={this.state.remark} placeholder="table_remark" style={{width: 250}} onChange={(e) => {
|
|
|
|
|
- this.setState({remark: e.target.value})
|
|
|
|
|
- }}/>
|
|
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <div className="column-menu" onClick={()=>this.props.history.goBack()}>
|
|
|
|
|
+ <Icon type="left" style={{color:'#3187FA'}} /> {this.props.match.params.name}
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <div>
|
|
|
|
|
- <span className='table-title'> Table columns</span>
|
|
|
|
|
- <span className='column-title'>name</span>
|
|
|
|
|
- <span className='column-title'>type</span>
|
|
|
|
|
- <span className='column-title'>description</span>
|
|
|
|
|
- {
|
|
|
|
|
- this.state.columns.map((col, index) =>
|
|
|
|
|
- <div key={index} style={{marginBottom: 3}}>
|
|
|
|
|
- <Input style={{width: 120, marginRight: 10}} value={col.name}
|
|
|
|
|
- onChange={this.handleNameChange(index)}/>
|
|
|
|
|
- <Select defaultValue={col.type} style={{width: 120, marginRight: 10}}
|
|
|
|
|
- onChange={this.handleTypeChange(index)}>
|
|
|
|
|
|
|
+ <Layout style={{padding: '24px', zIndex: '0'}}>
|
|
|
|
|
+ <Content style={{padding: '24px', minHeight: 280, background: '#fff', marginTop: '48px'}}>
|
|
|
|
|
+ <div className="column-content">
|
|
|
|
|
+ <span className='table-title'> Table name</span>
|
|
|
|
|
+ <Input
|
|
|
|
|
+ value={this.state.currentTable}
|
|
|
|
|
+ placeholder="please input table name"
|
|
|
|
|
+ style={{width: 200, margin:'10px 0'}}
|
|
|
|
|
+ onChange={(e) => {
|
|
|
|
|
+ this.setState({currentTable: e.target.value})
|
|
|
|
|
+ }}/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div style={{marginBottom: 20}}>
|
|
|
|
|
+ <span className='table-title'> Table remark</span>
|
|
|
|
|
+ <Input
|
|
|
|
|
+ value={this.state.remark}
|
|
|
|
|
+ placeholder="please input table remark"
|
|
|
|
|
+ style={{width: 250, margin:'10px 0'}}
|
|
|
|
|
+ onChange={(e) => {
|
|
|
|
|
+ this.setState({remark: e.target.value})
|
|
|
|
|
+ }}/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <span className='table-title'> Table fields</span>
|
|
|
|
|
+ <span className='column-title'>name</span>
|
|
|
|
|
+ <span className='column-title'>type</span>
|
|
|
|
|
+ <span className='column-title'>description</span>
|
|
|
|
|
+ {
|
|
|
|
|
+ this.state.columns.map((col, index) =>
|
|
|
|
|
+ <div key={index} style={{marginBottom: 3}}>
|
|
|
|
|
+ <Input
|
|
|
|
|
+ className="column-details"
|
|
|
|
|
+ value={col.name}
|
|
|
|
|
+ onChange={this.handleNameChange(index)}
|
|
|
|
|
+ />
|
|
|
|
|
+ <Select
|
|
|
|
|
+ className="column-details"
|
|
|
|
|
+ defaultValue={col.type}
|
|
|
|
|
+ onChange={this.handleTypeChange(index)}>
|
|
|
|
|
+ {
|
|
|
|
|
+ this.state.types.map((value) =>
|
|
|
|
|
+ <Option key={Math.random()+'types'} value={value.toLowerCase()}>{value}</Option>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ </Select>
|
|
|
|
|
+ <Select
|
|
|
|
|
+ className="column-details"
|
|
|
|
|
+ defaultValue={col.description}
|
|
|
|
|
+ onChange={this.handleDescChange(index)}>
|
|
|
|
|
+ {
|
|
|
|
|
+ this.state.descriptions.map((value) =>
|
|
|
|
|
+ <Option key={Math.random()+'descriptions'} value={value.toLowerCase()}>{value}</Option>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ </Select>
|
|
|
|
|
+ <Icon type="delete" theme="twoTone" style={{cursor: 'pointer'}} onClick={this.handleColDelete(index)}/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <Input
|
|
|
|
|
+ className="column-details"
|
|
|
|
|
+ placeholder="field name"
|
|
|
|
|
+ onChange={this.handleNameNew}
|
|
|
|
|
+ value={this.state.newColName}
|
|
|
|
|
+ />
|
|
|
|
|
+ <Select
|
|
|
|
|
+ className="column-details"
|
|
|
|
|
+ defaultValue="type"
|
|
|
|
|
+ onChange={this.handleTypeNew}
|
|
|
|
|
+ value={this.state.newColType}>
|
|
|
{
|
|
{
|
|
|
this.state.types.map((value) =>
|
|
this.state.types.map((value) =>
|
|
|
<Option key={Math.random()} value={value.toLowerCase()}>{value}</Option>
|
|
<Option key={Math.random()} value={value.toLowerCase()}>{value}</Option>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
</Select>
|
|
</Select>
|
|
|
- <Select defaultValue={col.description} style={{width: 120, marginRight: 10}}
|
|
|
|
|
- onChange={this.handleDescChange(index)}>
|
|
|
|
|
- {
|
|
|
|
|
- this.state.descriptions.map((value) =>
|
|
|
|
|
- <Option key={Math.random()} value={value.toLowerCase()}>{value}</Option>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- </Select>
|
|
|
|
|
- <Icon type="delete" theme="outlined" style={{cursor: 'pointer'}}
|
|
|
|
|
- onClick={this.handleColDelete(index)}/>
|
|
|
|
|
</div>
|
|
</div>
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- <div>
|
|
|
|
|
- <Input placeholder="column_name" style={{width: 120, marginRight: 10}}
|
|
|
|
|
- onChange={this.handleNameNew}
|
|
|
|
|
- value={this.state.newColName}/>
|
|
|
|
|
- <Select defaultValue="type" style={{width: 120, marginRight: 10}} onChange={this.handleTypeNew}
|
|
|
|
|
- value={this.state.newColType}>
|
|
|
|
|
- {
|
|
|
|
|
- this.state.types.map((value) =>
|
|
|
|
|
- <Option key={Math.random()} value={value.toLowerCase()}>{value}</Option>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- </Select>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div style={{marginTop: 20}}>
|
|
|
|
|
- <UpdateTableButton
|
|
|
|
|
- currentTable={this.state.currentTable}
|
|
|
|
|
- columns={this.state.columns}
|
|
|
|
|
- remark={this.state.remark}
|
|
|
|
|
- currentTableIndex={this.props.currentTableIndex}
|
|
|
|
|
- schemaID={this.props.schemaID}
|
|
|
|
|
- userID={this.props.userID}
|
|
|
|
|
- />
|
|
|
|
|
- {
|
|
|
|
|
- // undefined的时候 上层未传进来 currentTable === 'add',为的是输入框内不默认显示 add
|
|
|
|
|
- this.state.currentTable === '' ? '' : this.state.currentTable === undefined ? '' :
|
|
|
|
|
- <DeleteTableButton
|
|
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div style={{marginTop: 20}}>
|
|
|
|
|
+ <UpdateTableButton
|
|
|
currentTable={this.state.currentTable}
|
|
currentTable={this.state.currentTable}
|
|
|
|
|
+ columns={this.state.columns}
|
|
|
|
|
+ remark={this.state.remark}
|
|
|
currentTableIndex={this.props.currentTableIndex}
|
|
currentTableIndex={this.props.currentTableIndex}
|
|
|
- schemaID={this.props.schemaID}
|
|
|
|
|
- userID={this.props.userID}
|
|
|
|
|
|
|
+ schemaID={schemaID}
|
|
|
|
|
+ userID={userID}
|
|
|
/>
|
|
/>
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ {/*{*/}
|
|
|
|
|
+ {/*// undefined的时候 上层未传进来 currentTable === 'add',为的是输入框内不默认显示 add*/}
|
|
|
|
|
+ {/*this.state.currentTable === '' ? '' : this.state.currentTable === undefined ? '' :*/}
|
|
|
|
|
+ {/*<DeleteTableButton*/}
|
|
|
|
|
+ {/*currentTable={this.state.currentTable}*/}
|
|
|
|
|
+ {/*currentTableIndex={this.props.currentTableIndex}*/}
|
|
|
|
|
+ {/*schemaID={schemaID}*/}
|
|
|
|
|
+ {/*userID={userID}*/}
|
|
|
|
|
+ {/*/>*/}
|
|
|
|
|
+ {/*}*/}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </Content>
|
|
|
|
|
+ </Layout>
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
@@ -297,7 +331,7 @@ class UpdateTableButton extends Component {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}}>
|
|
}}>
|
|
|
- SUBMIT
|
|
|
|
|
|
|
+ save
|
|
|
</Button>
|
|
</Button>
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|