Forráskód Böngészése

可以选择 schema 进行操作

xy 7 éve
szülő
commit
b490248199

+ 7 - 6
src/components/common/schema/Schema.jsx

@@ -19,7 +19,7 @@ class Schema extends Component {
         this.state = {
             currentSchema: '',
             currentTable: '',
-            schemaID: 'schema_1542175090046_77378701',
+            schemaID: '',
             userID: 'xy_1'
         };
     }
@@ -28,9 +28,10 @@ class Schema extends Component {
 
     findRemark = data => this.state.currentTable === '' ? '' : data.find(table => table.name === this.state.currentTable) ? data.find(table => table.name === this.state.currentTable).remark : '';
 
-    switchSchema = (schema) => {
+    switchSchema = (name, id) => {
         this.setState({
-            currentSchema: schema
+            currentSchema: name,
+            schemaID: id
         });
     };
 
@@ -52,7 +53,8 @@ class Schema extends Component {
                         <ShowSchemaList
                             userID={this.state.userID}
                             switchTable={this.switchTable}
-                            switchSchema={this.switchSchema}/>
+                            switchSchema={this.switchSchema}
+                        />
                     </Col>
 
                     <Col span={17} offset={1}>
@@ -188,8 +190,7 @@ class ShowSchemaList extends Component {
                                         data.schema_by_props.map((schema) => {
                                             return <div key={schema.schemaName} className='title'
                                                         onClick={() => {
-                                                            this.props.switchSchema(schema.schemaName)
-
+                                                            this.props.switchSchema(schema.schemaName, schema.id);
                                                         }}>
                                                 <Row>
                                                     <Col span={20}>{schema.schemaName}</Col>

+ 2 - 1
src/components/common/schema/gql.js

@@ -4,7 +4,7 @@ const SHOW_SCHEMA = gql`
                 schema_by_props(user_id: $user_id) {
                     schemaData
                     schemaName
-                    
+                    id
                 }
             }
         `;
@@ -22,6 +22,7 @@ const ADD_SCHEMA = gql`
                 ) {
                     schemaName,
                     schemaData
+                    id
                 }
             }
         `;