|
|
@@ -25,7 +25,7 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
- widths: [ 80, 150, 150, 80, 80 ],
|
|
|
+ widths: [ 80, 300, 200, 100, 100 ],
|
|
|
visibleConfirm: false
|
|
|
}
|
|
|
}
|
|
|
@@ -37,7 +37,7 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
};
|
|
|
|
|
|
handleVisibleChange = (visible) => {
|
|
|
- const { columns } = this.props.dataSource.newOne;
|
|
|
+ const { columns } = this.props.dataSourceDetail;
|
|
|
this.setState({ visibleConfirm: visible && (columns && columns.length > 0) });
|
|
|
}
|
|
|
|
|
|
@@ -51,22 +51,22 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
|
|
|
render() {
|
|
|
|
|
|
- const { dataSource, dispatch, loading } = this.props;
|
|
|
+ const { dataSourceDetail, dispatch, fetching } = this.props;
|
|
|
const { widths } = this.state;
|
|
|
|
|
|
const columns = [{
|
|
|
title: <div><Checkbox
|
|
|
- style={{ margin: '0 8px 0 0', display: dataSource.newOne.columns ? (dataSource.newOne.columns.length > 0 ? 'inline-block' : 'none') : 'none'}}
|
|
|
- indeterminate={dataSource.newOne.columns ? (dataSource.newOne.columns.filter(c => c.using).length > 0 && dataSource.newOne.columns.filter(c => c.using).length < dataSource.newOne.columns.length) : false}
|
|
|
- checked={dataSource.newOne.columns ? (dataSource.newOne.columns.filter(c => c.using).length === dataSource.newOne.columns.length) : false}
|
|
|
+ style={{ margin: '0 8px 0 0', display: dataSourceDetail.columns ? (dataSourceDetail.columns.length > 0 ? 'inline-block' : 'none') : 'none'}}
|
|
|
+ indeterminate={dataSourceDetail.columns ? (dataSourceDetail.columns.filter(c => c.using).length > 0 && dataSourceDetail.columns.filter(c => c.using).length < dataSourceDetail.columns.length) : false}
|
|
|
+ checked={dataSourceDetail.columns ? (dataSourceDetail.columns.filter(c => c.using).length === dataSourceDetail.columns.length) : false}
|
|
|
onChange={(e) => {
|
|
|
let target = e.target;
|
|
|
- let columns = dataSource.newOne.columns ? dataSource.newOne.columns.map(c => {
|
|
|
+ let columns = dataSourceDetail.columns ? dataSourceDetail.columns.map(c => {
|
|
|
c.using = target.checked;
|
|
|
return c;
|
|
|
}) : [];
|
|
|
|
|
|
- dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
+ dispatch({ type: 'dataSourceDetail/setField', name: 'columns', value: columns });
|
|
|
}}
|
|
|
/>启用</div>,
|
|
|
dataIndex: 'using',
|
|
|
@@ -77,14 +77,14 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
onChange={(e) => {
|
|
|
let target = e.target;
|
|
|
let key = target.dataKey;
|
|
|
- let columns = dataSource.newOne.columns.map(c => {
|
|
|
+ let columns = dataSourceDetail.columns.map(c => {
|
|
|
if(c.key === key) {
|
|
|
c.using = target.checked;
|
|
|
}
|
|
|
return c;
|
|
|
});
|
|
|
|
|
|
- dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
+ dispatch({ type: 'dataSourceDetail/setField', name: 'columns', value: columns });
|
|
|
}}
|
|
|
checked={v}
|
|
|
/>
|
|
|
@@ -114,7 +114,7 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
style={{ width: '100%' }}
|
|
|
value={text}
|
|
|
onChange={(value) => {
|
|
|
- let columns = dataSource.newOne.columns.map(c => {
|
|
|
+ let columns = dataSourceDetail.columns.map(c => {
|
|
|
if(c.key === record.key) {
|
|
|
c.columnType = value;
|
|
|
c.groupable = c.columnType === 'categorical';
|
|
|
@@ -122,7 +122,7 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
}
|
|
|
return c;
|
|
|
});
|
|
|
- dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
+ dispatch({ type: 'dataSourceDetail/setField', name: 'columns', value: columns });
|
|
|
}}
|
|
|
>
|
|
|
{
|
|
|
@@ -141,17 +141,17 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
}
|
|
|
}, {
|
|
|
title: <div><Checkbox
|
|
|
- style={{ margin: '0 8px 0 0', display: dataSource.newOne.columns ? (dataSource.newOne.columns.length > 0 ? 'inline-block' : 'none') : 'none'}}
|
|
|
- indeterminate={dataSource.newOne.columns ? (dataSource.newOne.columns.filter(c => c.groupable).length > 0 && dataSource.newOne.columns.filter(c => c.groupable).length < dataSource.newOne.columns.length) : false}
|
|
|
- checked={dataSource.newOne.columns ? (dataSource.newOne.columns.filter(c => c.groupable).length === dataSource.newOne.columns.length) : false}
|
|
|
+ style={{ margin: '0 8px 0 0', display: dataSourceDetail.columns ? (dataSourceDetail.columns.length > 0 ? 'inline-block' : 'none') : 'none'}}
|
|
|
+ indeterminate={dataSourceDetail.columns ? (dataSourceDetail.columns.filter(c => c.groupable).length > 0 && dataSourceDetail.columns.filter(c => c.groupable).length < dataSourceDetail.columns.length) : false}
|
|
|
+ checked={dataSourceDetail.columns ? (dataSourceDetail.columns.filter(c => c.groupable).length === dataSourceDetail.columns.length) : false}
|
|
|
onChange={(e) => {
|
|
|
let target = e.target;
|
|
|
- let columns = dataSource.newOne.columns ? dataSource.newOne.columns.map(c => {
|
|
|
+ let columns = dataSourceDetail.columns ? dataSourceDetail.columns.map(c => {
|
|
|
c.groupable = target.checked;
|
|
|
return c;
|
|
|
}) : [];
|
|
|
|
|
|
- dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
+ dispatch({ type: 'dataSourceDetail/setField', name: 'columns', value: columns });
|
|
|
}}
|
|
|
/>允许分组</div>,
|
|
|
dataIndex: 'groupable',
|
|
|
@@ -162,30 +162,30 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
onChange={(e) => {
|
|
|
let target = e.target;
|
|
|
let key = target.dataKey;
|
|
|
- let columns = dataSource.newOne.columns.map(c => {
|
|
|
+ let columns = dataSourceDetail.columns.map(c => {
|
|
|
if(c.key === key) {
|
|
|
c.groupable = target.checked;
|
|
|
}
|
|
|
return c;
|
|
|
});
|
|
|
|
|
|
- dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
+ dispatch({ type: 'dataSourceDetail/setField', name: 'columns', value: columns });
|
|
|
}}
|
|
|
checked={v}
|
|
|
/>
|
|
|
}, {
|
|
|
title: <div><Checkbox
|
|
|
- style={{ margin: '0 8px 0 0', display: dataSource.newOne.columns ? (dataSource.newOne.columns.length > 0 ? 'inline-block' : 'none') : 'none'}}
|
|
|
- indeterminate={dataSource.newOne.columns ? (dataSource.newOne.columns.filter(c => c.filterable).length > 0 && dataSource.newOne.columns.filter(c => c.filterable).length < dataSource.newOne.columns.length) : false}
|
|
|
- checked={dataSource.newOne.columns ? (dataSource.newOne.columns.filter(c => c.filterable).length === dataSource.newOne.columns.length) : false}
|
|
|
+ style={{ margin: '0 8px 0 0', display: dataSourceDetail.columns ? (dataSourceDetail.columns.length > 0 ? 'inline-block' : 'none') : 'none'}}
|
|
|
+ indeterminate={dataSourceDetail.columns ? (dataSourceDetail.columns.filter(c => c.filterable).length > 0 && dataSourceDetail.columns.filter(c => c.filterable).length < dataSourceDetail.columns.length) : false}
|
|
|
+ checked={dataSourceDetail.columns ? (dataSourceDetail.columns.filter(c => c.filterable).length === dataSourceDetail.columns.length) : false}
|
|
|
onChange={(e) => {
|
|
|
let target = e.target;
|
|
|
- let columns = dataSource.newOne.columns ? dataSource.newOne.columns.map(c => {
|
|
|
+ let columns = dataSourceDetail.columns ? dataSourceDetail.columns.map(c => {
|
|
|
c.filterable = target.checked;
|
|
|
return c;
|
|
|
}) : [];
|
|
|
|
|
|
- dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
+ dispatch({ type: 'dataSourceDetail/setField', name: 'columns', value: columns });
|
|
|
}}
|
|
|
/>允许过滤</div>,
|
|
|
dataIndex: 'filterable',
|
|
|
@@ -196,14 +196,14 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
onChange={(e) => {
|
|
|
let target = e.target;
|
|
|
let key = target.dataKey;
|
|
|
- let columns = dataSource.newOne.columns.map(c => {
|
|
|
+ let columns = dataSourceDetail.columns.map(c => {
|
|
|
if(c.key === key) {
|
|
|
c.filterable = target.checked;
|
|
|
}
|
|
|
return c;
|
|
|
});
|
|
|
|
|
|
- dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
+ dispatch({ type: 'dataSourceDetail/setField', name: 'columns', value: columns });
|
|
|
}}
|
|
|
checked={v}
|
|
|
/>
|
|
|
@@ -214,13 +214,13 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
// width: 50,
|
|
|
// className: 'column-groupable',
|
|
|
// render: (value, record) => <Switch disabled={record.columnType!=='categorical'} checked={value} onChange={(checked) => {
|
|
|
- // let columns = dataSource.newOne.columns.map(c => {
|
|
|
+ // let columns = dataSourceDetail.columns.map(c => {
|
|
|
// if(c.key === record.key) {
|
|
|
// c.groupable = checked;
|
|
|
// }
|
|
|
// return c;
|
|
|
// });
|
|
|
- // dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
+ // dispatch({ type: 'dataSourceDetail/setField', name: 'columns', value: columns });
|
|
|
// }}/>
|
|
|
// }, {
|
|
|
// title: '允许分段',
|
|
|
@@ -233,13 +233,13 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
// checked={value}
|
|
|
// defaultChecked={true}
|
|
|
// onChange={(checked) => {
|
|
|
- // let columns = dataSource.newOne.columns.map(c => {
|
|
|
+ // let columns = dataSourceDetail.columns.map(c => {
|
|
|
// if(c.key === record.key) {
|
|
|
// c.bucketizable = checked;
|
|
|
// }
|
|
|
// return c;
|
|
|
// });
|
|
|
- // dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
+ // dispatch({ type: 'dataSourceDetail/setField', name: 'columns', value: columns });
|
|
|
// }}
|
|
|
// />
|
|
|
}, {
|
|
|
@@ -254,14 +254,14 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
placeholder={record.description ? record.description.substring(0, 10) : record.name}
|
|
|
onChange={(e) => {
|
|
|
const value = e.target.value;
|
|
|
- let columns = dataSource.newOne.columns.map(c => {
|
|
|
+ let columns = dataSourceDetail.columns.map(c => {
|
|
|
if(c.key === record.key) {
|
|
|
c['alias'] = value;
|
|
|
}
|
|
|
return c;
|
|
|
});
|
|
|
|
|
|
- dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
+ dispatch({ type: 'dataSourceDetail/setField', name: 'columns', value: columns });
|
|
|
}}
|
|
|
>
|
|
|
</Input>
|
|
|
@@ -283,24 +283,24 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
return (
|
|
|
<div>
|
|
|
{
|
|
|
- dataSource.newOne.type==='database'?(
|
|
|
+ dataSourceDetail.type==='database'?(
|
|
|
<div>
|
|
|
<Form size='small'>
|
|
|
<Divider orientation="left">数据对象</Divider>
|
|
|
<FormItem className='textarea-target'>
|
|
|
<Input.TextArea
|
|
|
- disabled={!dataSource.newOne.address}
|
|
|
- placeholder={dataSource.newOne.address ? '输入表名或查询SQL,注意不能以分号结尾' : '请返回上一步选择数据库连接'}
|
|
|
+ disabled={!dataSourceDetail.address}
|
|
|
+ placeholder={dataSourceDetail.address ? '输入表名或查询SQL,注意不能以分号结尾' : '请返回上一步选择数据库连接'}
|
|
|
autosize={{ minRows: 3 }}
|
|
|
- value={dataSource.newOne.target}
|
|
|
+ value={dataSourceDetail.target}
|
|
|
onChange={(e) => {
|
|
|
- dispatch({ type: 'dataSource/setNewModelInvalidSQL', value: false });
|
|
|
- dispatch({ type: 'dataSource/setNewModelField', name: 'target', value: e.target.value });
|
|
|
+ dispatch({ type: 'dataSource/setInvalidSQL', value: false });
|
|
|
+ dispatch({ type: 'dataSourceDetail/setField', name: 'target', value: e.target.value });
|
|
|
}}
|
|
|
/>
|
|
|
</FormItem>
|
|
|
<div className='buttons'>
|
|
|
- <div className='errormessage' style={{ cursor: dataSource.newOne.invalidSQL ? 'text' : 'default', opacity: dataSource.newOne.invalidSQL ? '1' : '0' }}>未查询到列数据,请检查SQL是否正确</div>
|
|
|
+ <div className='errormessage' style={{ cursor: dataSourceDetail.invalidSQL ? 'text' : 'default', opacity: dataSourceDetail.invalidSQL ? '1' : '0' }}>未查询到列数据,请检查SQL是否正确</div>
|
|
|
<Tooltip
|
|
|
title={
|
|
|
<div>
|
|
|
@@ -320,7 +320,7 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
this.setState({
|
|
|
visibleConfirm: false
|
|
|
});
|
|
|
- dispatch({ type: 'dataSource/importNewModelColumns', cover: true });
|
|
|
+ dispatch({ type: 'dataSourceDetail/importColumns', cover: true });
|
|
|
}}>
|
|
|
<span>全部覆盖</span>
|
|
|
</button>
|
|
|
@@ -328,7 +328,7 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
this.setState({
|
|
|
visibleConfirm: false
|
|
|
});
|
|
|
- dispatch({ type: 'dataSource/importNewModelColumns', cover: false });
|
|
|
+ dispatch({ type: 'dataSourceDetail/importColumns', cover: false });
|
|
|
}}>
|
|
|
<span>保留重复</span>
|
|
|
</button>
|
|
|
@@ -339,15 +339,13 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
onVisibleChange={this.handleVisibleChange}
|
|
|
trigger='click'
|
|
|
>
|
|
|
- <Button disabled={!dataSource.newOne.address || loading.models.dataSource} onClick={() => {
|
|
|
- if(!dataSource.newOne.columns || dataSource.newOne.columns.length === 0) {
|
|
|
- dispatch({ type: 'dataSource/importNewModelColumns', cover: true });
|
|
|
+ <Button disabled={!dataSourceDetail.address || fetching} onClick={() => {
|
|
|
+ if(!dataSourceDetail.columns || dataSourceDetail.columns.length === 0) {
|
|
|
+ dispatch({ type: 'dataSourceDetail/importColumns', cover: true });
|
|
|
}
|
|
|
}}>
|
|
|
- {
|
|
|
- loading.models.dataSource ? <Icon type="loading" /> : ''
|
|
|
- }
|
|
|
- {'获取数据列'}
|
|
|
+ {fetching && <Icon type="loading" theme="outlined" />}
|
|
|
+ 获取数据列
|
|
|
</Button>
|
|
|
</Tooltip>
|
|
|
</div>
|
|
|
@@ -360,7 +358,7 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
className='table-columnconfig'
|
|
|
bordered
|
|
|
components={this.components}
|
|
|
- dataSource={dataSource.newOne.columns}
|
|
|
+ dataSource={dataSourceDetail.columns}
|
|
|
columns={columns}
|
|
|
locale={{
|
|
|
emptyText: '未连接到数据对象'
|
|
|
@@ -371,8 +369,13 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function mapStateToProps({ present: { dataSource, dataConnect, loading } }) {
|
|
|
- return { dataSource, dataConnect, loading }
|
|
|
+function mapStateToProps({ present: { dataSourceDetail, loading } }) {
|
|
|
+ const fetching = loading.effects['dataSourceDetail/importColumns'];
|
|
|
+ console.log(loading);
|
|
|
+ return {
|
|
|
+ fetching,
|
|
|
+ dataSourceDetail
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export default connect(mapStateToProps)(DataSourceColumnConfig);
|