|
@@ -26,7 +26,6 @@ class Table extends Component {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
// 下面的 handlexxxx 全是 state 内部方法,用于操作视图
|
|
// 下面的 handlexxxx 全是 state 内部方法,用于操作视图
|
|
|
// cache 仅在提交删除整体使用
|
|
// cache 仅在提交删除整体使用
|
|
|
|
|
|
|
@@ -42,7 +41,7 @@ class Table extends Component {
|
|
|
|
|
|
|
|
handleNameNew = (e) => {
|
|
handleNameNew = (e) => {
|
|
|
let r = /^[^\u4e00-\u9fa5]*$/;
|
|
let r = /^[^\u4e00-\u9fa5]*$/;
|
|
|
- if(r.test(e.target.value)){
|
|
|
|
|
|
|
+ if (r.test(e.target.value)) {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
newColName: e.target.value,
|
|
newColName: e.target.value,
|
|
|
})
|
|
})
|
|
@@ -50,7 +49,7 @@ class Table extends Component {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
characterTips: true
|
|
characterTips: true
|
|
|
});
|
|
});
|
|
|
- setTimeout(()=>{
|
|
|
|
|
|
|
+ setTimeout(() => {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
characterTips: false
|
|
characterTips: false
|
|
|
})
|
|
})
|
|
@@ -114,19 +113,14 @@ class Table extends Component {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
- // console.log('columns',this.state.columns);
|
|
|
|
|
- // console.log('this.props',this.props);
|
|
|
|
|
let schemaID = this.props.schemaID || this.props.history.location.state.schemaID;
|
|
let schemaID = this.props.schemaID || this.props.history.location.state.schemaID;
|
|
|
let schemaName = this.props.schemaName || this.props.history.location.state.schemaName;
|
|
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');
|
|
let userID = this.props.userID || getCookie('user_id');
|
|
|
- // console.log('schemaID',schemaID,'userID',userID);
|
|
|
|
|
let trialcase = this.props.trialcase;
|
|
let trialcase = this.props.trialcase;
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div>
|
|
<div>
|
|
|
<div className="column-menu" onClick={this.props.goBack}>
|
|
<div className="column-menu" onClick={this.props.goBack}>
|
|
|
- {/*()=>this.props.history.goBack()*/}
|
|
|
|
|
<Icon type="left" style={{color: '#3187FA'}}/> {schemaName}
|
|
<Icon type="left" style={{color: '#3187FA'}}/> {schemaName}
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
@@ -262,18 +256,18 @@ class UpdateTableButton extends Component {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- showConfirm = (schemaName,schemaID) => {
|
|
|
|
|
|
|
+ showConfirm = (schemaName, schemaID) => {
|
|
|
let _this = this;
|
|
let _this = this;
|
|
|
|
|
|
|
|
- if(this.props.add !== 'add') {
|
|
|
|
|
|
|
+ if (this.props.add !== 'add') {
|
|
|
this.props.history.push({
|
|
this.props.history.push({
|
|
|
pathname: `/graphql-service/my-create/${schemaName}`,
|
|
pathname: `/graphql-service/my-create/${schemaName}`,
|
|
|
- state:{
|
|
|
|
|
|
|
+ state: {
|
|
|
schemaName,
|
|
schemaName,
|
|
|
schemaID
|
|
schemaID
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
confirm({
|
|
confirm({
|
|
|
title: '添加成功',
|
|
title: '添加成功',
|
|
|
content: '继续添加数据表?',
|
|
content: '继续添加数据表?',
|
|
@@ -283,7 +277,7 @@ class UpdateTableButton extends Component {
|
|
|
onCancel() {
|
|
onCancel() {
|
|
|
_this.props.history.push({
|
|
_this.props.history.push({
|
|
|
pathname: `/graphql-service/my-create/${schemaName}`,
|
|
pathname: `/graphql-service/my-create/${schemaName}`,
|
|
|
- state:{
|
|
|
|
|
|
|
+ state: {
|
|
|
schemaName,
|
|
schemaName,
|
|
|
schemaID
|
|
schemaID
|
|
|
}
|
|
}
|
|
@@ -316,13 +310,13 @@ class UpdateTableButton extends Component {
|
|
|
|
|
|
|
|
let schemaData = data;
|
|
let schemaData = data;
|
|
|
let referenceID = '';
|
|
let referenceID = '';
|
|
|
- if(data.schema_by_id)
|
|
|
|
|
|
|
+ if (data.schema_by_id)
|
|
|
referenceID = data.schema_by_id.reference;
|
|
referenceID = data.schema_by_id.reference;
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<Mutation
|
|
<Mutation
|
|
|
mutation={gql(UPDATE_SCHEMA)}
|
|
mutation={gql(UPDATE_SCHEMA)}
|
|
|
- onCompleted={()=>this.showConfirm(schemaName,schemaID)}
|
|
|
|
|
|
|
+ onCompleted={() => this.showConfirm(schemaName, schemaID)}
|
|
|
refetchQueries={[{query: gql(SHOW_TABLE), variables: {schema_id: schemaID}}]}
|
|
refetchQueries={[{query: gql(SHOW_TABLE), variables: {schema_id: schemaID}}]}
|
|
|
>
|
|
>
|
|
|
|
|
|
|
@@ -354,7 +348,7 @@ class UpdateTableButton extends Component {
|
|
|
|
|
|
|
|
const index = this.state.originTableName === '' ? -2 : this.props.schemaData.findIndex(obj => obj.name === this.state.originTableName);
|
|
const index = this.state.originTableName === '' ? -2 : this.props.schemaData.findIndex(obj => obj.name === this.state.originTableName);
|
|
|
if (index === -2) {
|
|
if (index === -2) {
|
|
|
- if(referenceID !== '' && schemaCols.length === 0) {
|
|
|
|
|
|
|
+ if (referenceID !== '' && schemaCols.length === 0) {
|
|
|
this.props.fetchData(referenceID).then(value => {
|
|
this.props.fetchData(referenceID).then(value => {
|
|
|
schemaCols = JSON.parse(value);
|
|
schemaCols = JSON.parse(value);
|
|
|
schemaCols.push(newTable);
|
|
schemaCols.push(newTable);
|
|
@@ -384,15 +378,6 @@ class UpdateTableButton extends Component {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
this.props.showTablePagination(this.props.page, this.props.pageSize, schemaCols);
|
|
this.props.showTablePagination(this.props.page, this.props.pageSize, schemaCols);
|
|
|
- // if(this.props.add !== 'add') {
|
|
|
|
|
- // this.props.history.push({
|
|
|
|
|
- // pathname: `/graphql-service/my-create/${this.props.schemaName}`,
|
|
|
|
|
- // state:{
|
|
|
|
|
- // schemaName:this.props.schemaName,
|
|
|
|
|
- // schemaID:this.props.schemaID
|
|
|
|
|
- // }
|
|
|
|
|
- // });
|
|
|
|
|
- // }
|
|
|
|
|
}}>
|
|
}}>
|
|
|
save
|
|
save
|
|
|
</Button>
|
|
</Button>
|