|
|
@@ -18,6 +18,7 @@ import {request} from 'graphql-request'
|
|
|
import {getCookie} from "../../../../cookie";
|
|
|
import {idGen} from "../../../../func";
|
|
|
import {graphqlUrl} from "../../../../config";
|
|
|
+import {manageUsers} from "../../../../config";
|
|
|
|
|
|
const confirm = Modal.confirm;
|
|
|
const Search = Input.Search;
|
|
|
@@ -40,7 +41,7 @@ class Schema extends Component {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- shouldComponentUpdate(nextProps,nextState) {
|
|
|
+ shouldComponentUpdate(nextProps, nextState) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -111,11 +112,10 @@ class Schema extends Component {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request(graphqlUrl, SEARCH_SCHEMA, {id: referenceID}).then(
|
|
|
data => {
|
|
|
- console.log(data);
|
|
|
if (data.schema_by_id !== null) {
|
|
|
- localStorage.setItem('ecommerce', data.caseSchema.find(obj=>obj.schemaName==='ecommerce').schemaData);
|
|
|
- localStorage.setItem('subscribe', data.caseSchema.find(obj=>obj.schemaName==='subscribe').schemaData);
|
|
|
- localStorage.setItem('bills', data.caseSchema.find(obj=>obj.schemaName==='bills').schemaData);
|
|
|
+ localStorage.setItem('ecommerce', data.caseSchema.find(obj => obj.schemaName === 'ecommerce').schemaData);
|
|
|
+ localStorage.setItem('subscribe', data.caseSchema.find(obj => obj.schemaName === 'subscribe').schemaData);
|
|
|
+ localStorage.setItem('bills', data.caseSchema.find(obj => obj.schemaName === 'bills').schemaData);
|
|
|
resolve(data.schema_by_id.schemaData);
|
|
|
}
|
|
|
}
|
|
|
@@ -126,9 +126,9 @@ class Schema extends Component {
|
|
|
};
|
|
|
|
|
|
receiveDataFromTable = (data) => {
|
|
|
- this.setState({
|
|
|
- data
|
|
|
- })
|
|
|
+ this.setState({
|
|
|
+ data
|
|
|
+ })
|
|
|
};
|
|
|
|
|
|
componentWillReceiveProps(next) {
|
|
|
@@ -156,14 +156,12 @@ class Schema extends Component {
|
|
|
return 'error!';
|
|
|
}
|
|
|
|
|
|
- // let schemaName = data.schema_by_id.schemaName;
|
|
|
-
|
|
|
let copy;
|
|
|
- if(this.props.location.state)
|
|
|
+ if (this.props.location.state)
|
|
|
copy = this.props.location.state.copy;
|
|
|
|
|
|
// 找到 copy 一定几率不显示的 问题原因,异步导致的未存先取
|
|
|
- if (data.schema_by_id === null && copy!==true) data = [];
|
|
|
+ if (data.schema_by_id === null && copy !== true) data = [];
|
|
|
else {
|
|
|
let reference = data.schema_by_id ? data.schema_by_id.reference : this.props.location.state.reference;
|
|
|
data = data.schema_by_id ? JSON.parse(data.schema_by_id.schemaData) : [];
|
|
|
@@ -200,9 +198,7 @@ class Schema extends Component {
|
|
|
<div className={'schema'}>
|
|
|
<span className={'schema-name'}>{this.state.schemaName}</span>
|
|
|
{
|
|
|
- trialcase ?
|
|
|
- ''
|
|
|
- :
|
|
|
+ userID.indexOf(manageUsers) > -1 ?
|
|
|
<Icon style={{marginLeft: 15}}
|
|
|
type="edit"
|
|
|
theme="twoTone"
|
|
|
@@ -212,6 +208,19 @@ class Schema extends Component {
|
|
|
}
|
|
|
}
|
|
|
/>
|
|
|
+ :
|
|
|
+ trialcase ?
|
|
|
+ ''
|
|
|
+ :
|
|
|
+ <Icon style={{marginLeft: 15}}
|
|
|
+ type="edit"
|
|
|
+ theme="twoTone"
|
|
|
+ onClick={
|
|
|
+ () => {
|
|
|
+ this.setState({editSchemaName: this.state.schemaName})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ />
|
|
|
}
|
|
|
</div>
|
|
|
}
|
|
|
@@ -224,9 +233,7 @@ class Schema extends Component {
|
|
|
className={'schema-table-title'}>Remark</span></Col>
|
|
|
<Col span={2} offset={2}>
|
|
|
{
|
|
|
- trialcase ?
|
|
|
- ''
|
|
|
- :
|
|
|
+ userID.indexOf(manageUsers) > -1 ?
|
|
|
<span
|
|
|
className={'schema-table-title'}
|
|
|
onClick={() => {
|
|
|
@@ -236,6 +243,19 @@ class Schema extends Component {
|
|
|
}}>
|
|
|
<Icon type="plus"/>
|
|
|
</span>
|
|
|
+ :
|
|
|
+ trialcase ?
|
|
|
+ ''
|
|
|
+ :
|
|
|
+ <span
|
|
|
+ className={'schema-table-title'}
|
|
|
+ onClick={() => {
|
|
|
+ this.setState({
|
|
|
+ currentTable: 'add'
|
|
|
+ })
|
|
|
+ }}>
|
|
|
+ <Icon type="plus"/>
|
|
|
+ </span>
|
|
|
}
|
|
|
|
|
|
</Col>
|
|
|
@@ -263,9 +283,7 @@ class Schema extends Component {
|
|
|
|
|
|
<span className={'schema-table-content'}>
|
|
|
{
|
|
|
- trialcase ?
|
|
|
- ''
|
|
|
- :
|
|
|
+ userID.indexOf(manageUsers) > -1 ?
|
|
|
<DeleteTableButton
|
|
|
currentTable={table.name}
|
|
|
schemaData={data}
|
|
|
@@ -277,8 +295,22 @@ class Schema extends Component {
|
|
|
fetchData={this.fetchData}
|
|
|
location={this.props.location}
|
|
|
/>
|
|
|
+ :
|
|
|
+ trialcase ?
|
|
|
+ ''
|
|
|
+ :
|
|
|
+ <DeleteTableButton
|
|
|
+ currentTable={table.name}
|
|
|
+ schemaData={data}
|
|
|
+ schemaID={this.state.schemaID}
|
|
|
+ userID={userID}
|
|
|
+ showTablePagination={this.showTablePagination}
|
|
|
+ page={this.state.page}
|
|
|
+ pageSize={this.state.pageSize}
|
|
|
+ fetchData={this.fetchData}
|
|
|
+ location={this.props.location}
|
|
|
+ />
|
|
|
}
|
|
|
-
|
|
|
</span>
|
|
|
</Col>
|
|
|
</Row>
|
|
|
@@ -303,9 +335,7 @@ class Schema extends Component {
|
|
|
<Col span={2} offset={2}>
|
|
|
<span className={'schema-table-content'}>
|
|
|
{
|
|
|
- trialcase ?
|
|
|
- ''
|
|
|
- :
|
|
|
+ userID.indexOf(manageUsers) > -1 ?
|
|
|
<DeleteTableButton
|
|
|
currentTable={table.name}
|
|
|
schemaData={data}
|
|
|
@@ -317,6 +347,21 @@ class Schema extends Component {
|
|
|
fetchData={this.fetchData}
|
|
|
location={this.props.location}
|
|
|
/>
|
|
|
+ :
|
|
|
+ trialcase ?
|
|
|
+ ''
|
|
|
+ :
|
|
|
+ <DeleteTableButton
|
|
|
+ currentTable={table.name}
|
|
|
+ schemaData={data}
|
|
|
+ schemaID={this.state.schemaID}
|
|
|
+ showTablePagination={this.showTablePagination}
|
|
|
+ page={this.state.page}
|
|
|
+ pageSize={this.state.pageSize}
|
|
|
+ userID={userID}
|
|
|
+ fetchData={this.fetchData}
|
|
|
+ location={this.props.location}
|
|
|
+ />
|
|
|
}
|
|
|
</span>
|
|
|
</Col>
|
|
|
@@ -330,22 +375,51 @@ class Schema extends Component {
|
|
|
<Row>
|
|
|
<Col span={4}>
|
|
|
{
|
|
|
- trialcase ?
|
|
|
- <div className={'delete-schema'}>
|
|
|
- <CopySchemaButton
|
|
|
- userID={userID}
|
|
|
- history={this.props.history}
|
|
|
- schemaName={this.state.schemaName}
|
|
|
- />
|
|
|
- </div>
|
|
|
+ userID.indexOf(manageUsers) > -1 ?
|
|
|
+ trialcase ?
|
|
|
+ <div>
|
|
|
+ <div style={{display: 'inline-block'}}
|
|
|
+ className={'delete-schema'}>
|
|
|
+ <CopySchemaButton
|
|
|
+ userID={userID}
|
|
|
+ history={this.props.history}
|
|
|
+ schemaName={this.state.schemaName}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div style={{display: 'inline-block'}}
|
|
|
+ className={'delete-schema'}>
|
|
|
+ <DeleteSchemaButton
|
|
|
+ userID={userID}
|
|
|
+ schemaName={this.state.schemaName}
|
|
|
+ history={this.props.history}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ :
|
|
|
+ <div className={'delete-schema'}>
|
|
|
+ <DeleteSchemaButton
|
|
|
+ userID={userID}
|
|
|
+ schemaName={this.state.schemaName}
|
|
|
+ history={this.props.history}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
:
|
|
|
- <div className={'delete-schema'}>
|
|
|
- <DeleteSchemaButton
|
|
|
- userID={userID}
|
|
|
- schemaName={this.state.schemaName}
|
|
|
- history={this.props.history}
|
|
|
- />
|
|
|
- </div>
|
|
|
+ trialcase ?
|
|
|
+ <div className={'delete-schema'}>
|
|
|
+ <CopySchemaButton
|
|
|
+ userID={userID}
|
|
|
+ history={this.props.history}
|
|
|
+ schemaName={this.state.schemaName}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ :
|
|
|
+ <div className={'delete-schema'}>
|
|
|
+ <DeleteSchemaButton
|
|
|
+ userID={userID}
|
|
|
+ schemaName={this.state.schemaName}
|
|
|
+ history={this.props.history}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
}
|
|
|
</Col>
|
|
|
<Col span={4} offset={16}>
|
|
|
@@ -387,8 +461,8 @@ class Schema extends Component {
|
|
|
<Table
|
|
|
currentTable={this.state.currentTable}
|
|
|
schemaData={data}
|
|
|
- columns={this.findColumns(data.length !== 0? data : this.state.data)}
|
|
|
- remark={this.findRemark(data.length !== 0? data : this.state.data)}
|
|
|
+ columns={this.findColumns(data.length !== 0 ? data : this.state.data)}
|
|
|
+ remark={this.findRemark(data.length !== 0 ? data : this.state.data)}
|
|
|
schemaID={this.state.schemaID}
|
|
|
schemaName={this.state.schemaName}
|
|
|
userID={userID}
|