Csy817 há 7 anos atrás
pai
commit
a6d5c713fc

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

@@ -341,7 +341,7 @@ class GraphqlSidebar extends Component {
                                                     pathname: "/graphql-service/trial-case",
                                                     state:{
                                                         schemaName:schema.schemaName,
-                                                        schemaId:schema.id
+                                                        schemaID:schema.id
                                                     }
                                                 }}>{schema.schemaName}</Link>
                                             </Menu.Item>)
@@ -367,7 +367,7 @@ class GraphqlSidebar extends Component {
                                                     pathname: "/graphql-service/my-create",
                                                     state:{
                                                         schemaName:schema.schemaName,
-                                                        schemaId:schema.id
+                                                        schemaID:schema.id
                                                     }
                                                 }}>{schema.schemaName}</Link>
                                             </Menu.Item>)

+ 4 - 1
src/components/common/schema/Schema.jsx

@@ -10,11 +10,12 @@ import Table from "./Table";
 class Schema extends Component {
     constructor(props) {
         super(props);
+        console.log('Schema props',props);
         this.state = {
             currentTable: '',
             // default schemaID and schemaName
             schemaID: props.schemaID,
-            schemaName: 'ecommerce'
+            schemaName: props.schemaName
         };
     }
 
@@ -100,6 +101,7 @@ class Schema extends Component {
                                                 columns={[]}
                                                 remark=''
                                                 schemaID={this.state.schemaID}
+                                                schemaName={this.state.schemaName}
                                                 userID={userID}
                                             /> :
                                             <Table
@@ -108,6 +110,7 @@ class Schema extends Component {
                                                 columns={this.findColumns(data)}
                                                 remark={this.findRemark(data)}
                                                 schemaID={this.state.schemaID}
+                                                schemaName={this.state.schemaName}
                                                 userID={userID}
                                             />
                                 }

+ 19 - 16
src/components/common/schema/Table.js

@@ -13,10 +13,11 @@ const {Content} = Layout;
 class Table extends Component {
     constructor(props) {
         super(props);
+        console.log('Table props',props);
         this.state = {
-            currentTable: props.currentTable,
-            remark: props.remark,
-            columns: props.columns,
+            currentTable: props.currentTable || ' ',
+            remark: props.remark || '',
+            columns: props.columns || [],
             newColName: '',
             newColType: 'type',
             types: ['ID', 'String', 'Int', 'Float', 'Boolean', 'DateTime'],
@@ -95,14 +96,17 @@ class Table extends Component {
     componentWillReceiveProps(next) {
         this.setState({
             currentTable: next.currentTable,
-            columns: next.columns,
+            columns: next.columns || [],
             remark: next.remark
         });
     };
 
     render() {
         // console.log('columns',this.state.columns);
-        let {schemaId:schemaID,schemaName} = this.props.history.location.state;
+        console.log('this.props',this.props);
+        let schemaID = this.props.schemaID || this.props.history.location.state.schemaID;
+        let schemaName = this.props.schemaName || this.props.history.location.state.schemaName;
+        console.log('schemaID',schemaID,'schemaName',schemaName);
         let userID = this.props.userID || getCookie('user_id');
         // console.log('schemaID',schemaID,'userID',userID);
 
@@ -114,7 +118,6 @@ class Table extends Component {
 
                 <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
@@ -204,16 +207,16 @@ class Table extends Component {
                                 schemaID={schemaID}
                                 userID={userID}
                             />
-                            {
-                                // undefined的时候 上层未传进来 currentTable === 'add',为的是输入框内不默认显示 add
-                                this.state.currentTable === '' ? '' : this.state.currentTable === undefined ? '' :
-                                    <DeleteTableButton
-                                        currentTable={this.state.currentTable}
-                                        currentTableIndex={this.props.currentTableIndex}
-                                        schemaID={schemaID}
-                                        userID={userID}
-                                    />
-                            }
+                            {/*{*/}
+                            {/*// 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>

+ 5 - 4
src/components/trialCase/TrialCase.jsx

@@ -48,8 +48,9 @@ class TrialCase extends Component {
 
 
     render() {
-        let schemaID = this.props.history.location.state ? this.props.history.location.state.schemaId : "schema_1542243424669_92094965";
-        console.log('schemaID',schemaID);
+        let schemaID = this.props.history.location.state ? this.props.history.location.state.schemaID : "schema_1542243424669_92094965";
+        let schemaName = this.props.history.location.state ? this.props.history.location.state.schemaName : "ecommerce";
+        console.log('schemaID0',schemaID,'schemaName0',schemaName);
         return (
             <div>
                 <Menu
@@ -73,9 +74,9 @@ class TrialCase extends Component {
                             (() => {
                                 switch (this.state.menuLevel2) {
                                     case 'schema':
-                                        return <Schema userID={this.state.userID} schemaID={schemaID}/>;
+                                        return <Schema userID={this.state.userID} schemaName={schemaName} schemaID={schemaID} />;
                                     case 'deploy':
-                                        return <Deploy userID={this.state.userID} schemaID={schemaID}/>;
+                                        return <Deploy userID={this.state.userID} schemaID={schemaID} schemaName={schemaName}/>;
                                     case 'graphql':
                                         return <GenerateJs/>;
                                     case 'graphiql':