Преглед изворни кода

修改schema,还需修改

Csy817 пре 7 година
родитељ
комит
f44f6224f6

+ 2 - 1
src/components/app/App.jsx

@@ -21,6 +21,7 @@ import Create from "../common/schema/Create";
 import {SHOW_ALL_SCHEMA} from "../gql";
 import axios from 'axios';
 import {getCookie} from "../cookie";
+import Schema from "../common/schema/Schema";
 
 axios.defaults.withCredentials = true;
 
@@ -259,7 +260,7 @@ class App extends Component {
                                 <Route path="/graphql-service/:sidebar" component={TrialCase}/>
                                 <Route path="/wechat-service/:sidebar" component={WechatService}/>
                                 <Route path="/quant-service/" component={QuantService}/>
-                                <Route path="/table" component={Table}/>
+                                <Route path="/table" component={TrialCase}/>
                                 <Route path="/login" component={Login}/>
                                 <Redirect path="*" to="/"/>
                             </Switch>

+ 1 - 1
src/components/common/schema/Create.js

@@ -64,7 +64,7 @@ class Create extends Component {
             pathname: `/table`,
             state:{
                 schemaName:this.state.schemaName,
-                schemaId:varobj.id
+                schemaID:varobj.id
             }
         });
     };

+ 14 - 12
src/components/common/schema/Schema.jsx

@@ -12,10 +12,10 @@ class Schema extends Component {
         super(props);
         console.log('Schema props',props);
         this.state = {
-            currentTable: '',
+            currentTable: props.schemaID ?'':'add',
             // default schemaID and schemaName
-            schemaID: props.schemaID,
-            schemaName: props.schemaName
+            schemaID: props.schemaID || props.history.location.state.schemaID,
+            schemaName: props.schemaName || props.history.location.state.schemaName,
         };
     }
 
@@ -32,12 +32,14 @@ class Schema extends Component {
 
     componentWillReceiveProps(next) {
         this.setState({
-            schemaID: next.schemaID
+            schemaID: next.schemaID,
+            schemaName: next.schemaName
         });
     }
 
     render() {
         let userID = this.props.userID;
+        console.log('this.state.currentTable',this.state.currentTable);
         return (
             <Query query={gql(SHOW_TABLE)} variables={{schema_id: this.state.schemaID}}>
 
@@ -50,7 +52,7 @@ class Schema extends Component {
                             return 'error!';
                         }
 
-                        let schemaName = data.schema_by_id.schemaName;
+                        // let schemaName = data.schema_by_id.schemaName;
 
                         if (data.schema_by_id === null) data = [];
                         else data = JSON.parse(data.schema_by_id.schemaData);
@@ -58,16 +60,16 @@ class Schema extends Component {
 
                         return (
                             <div>
-                                <div onClick={() => {
-                                    this.setState({
-                                        currentTable: ''
-                                    })
-                                }}>
-                                    {schemaName || this.state.schemaName}
-                                </div>
                                 {
                                     this.state.currentTable === '' ?
                                         <div>
+                                            <div onClick={() => {
+                                                this.setState({
+                                                    currentTable: ''
+                                                })
+                                            }}>
+                                                {this.state.schemaName}
+                                            </div>
                                             <div>
                                                 <Row>
                                                     <Col span={8}><span>Name</span></Col>

+ 3 - 3
src/components/common/schema/Table.js

@@ -68,7 +68,7 @@ class Table extends Component {
         } else {
             notification['warning']({
                 message: 'Notification',
-                description: 'Input a name first.',
+                description: 'Input a field name first.',
             });
         }
     };
@@ -116,8 +116,8 @@ class Table extends Component {
                     <Icon type="left" style={{color:'#3187FA'}} /> {schemaName}
                 </div>
 
-                <Layout style={{padding: '24px', zIndex: '0'}}>
-                    <Content style={{padding: '24px', minHeight: 280, background: '#fff', marginTop: '48px'}}>
+                <Layout style={{zIndex: '0'}}>
+                    <Content style={{padding: '24px', minHeight: 280, background: '#fff'}}>
                         <div className="column-content">
                             <span className='table-title'> Table name</span>
                             <Input

+ 3 - 2
src/components/common/schema/index.css

@@ -36,13 +36,14 @@ p.show {
 }
 
 .column-menu {
-    padding: 0 24px;
-    position: fixed;
+    /*padding: 0 24px;*/
+    /*position: fixed;*/
     width: 100%;
     z-index: 1;
     line-height:50px;
     font-weight:600;
     background-color: white;
+    border-bottom: 1px solid #dcdadb;
 }
 
 .column-title {