|
|
@@ -43,7 +43,7 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
/>启用</div>,
|
|
|
dataIndex: 'using',
|
|
|
key: 'using',
|
|
|
- width: 100,
|
|
|
+ width: 50,
|
|
|
render: (v, r) => <Checkbox
|
|
|
dataKey={r.key}
|
|
|
onChange={(e) => {
|
|
|
@@ -64,27 +64,41 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
title: '列名',
|
|
|
dataIndex: 'name',
|
|
|
key: 'name',
|
|
|
- width: 180
|
|
|
+ width: 80
|
|
|
}, {
|
|
|
title: '别名',
|
|
|
dataIndex: 'alias',
|
|
|
key: 'alias',
|
|
|
- width: 180,
|
|
|
+ width: 100,
|
|
|
render: (text, record) => {
|
|
|
- return (<EditableCell
|
|
|
- dispatch={dispatch}
|
|
|
- dataSource={dataSource}
|
|
|
- fieldName='alias'
|
|
|
- dataKey={record.key}
|
|
|
- type='input'
|
|
|
- value={text}
|
|
|
- />)
|
|
|
+ return(
|
|
|
+ <Input
|
|
|
+ value={text}
|
|
|
+ onChange={(e) => {
|
|
|
+ const value = e.target.value;
|
|
|
+ let columns = dataSource.newOne.columns.map(c => {
|
|
|
+ if(c.key == record.key) {
|
|
|
+ c['alias'] = value;
|
|
|
+ }
|
|
|
+ return c;
|
|
|
+ });
|
|
|
+
|
|
|
+ dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ </Input>
|
|
|
+ )
|
|
|
}
|
|
|
}, {
|
|
|
- title: '类型',
|
|
|
- dataIndex: 'type',
|
|
|
- key: 'type',
|
|
|
- width: 120,
|
|
|
+ title: '数据类型',
|
|
|
+ dataIndex: 'columnType',
|
|
|
+ key: 'columnType',
|
|
|
+ width: 80
|
|
|
+ }, {
|
|
|
+ title: '分析类型',
|
|
|
+ dataIndex: 'dataType',
|
|
|
+ key: 'dataType',
|
|
|
+ width: 80,
|
|
|
render: (text, record) => {
|
|
|
return (
|
|
|
<Select
|
|
|
@@ -93,21 +107,35 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
onChange={(value) => {
|
|
|
let columns = dataSource.newOne.columns.map(c => {
|
|
|
if(c.key == record.key) {
|
|
|
- c.type = value;
|
|
|
- c.groupable = c.type == 'categorical';
|
|
|
- c.bucketizable = ['time', 'scale', 'ordinal'].indexOf(record.type) != -1;
|
|
|
+ c.dataType = value;
|
|
|
+ c.groupable = c.dataType == 'categorical';
|
|
|
+ c.bucketizable = ['time', 'scale', 'ordinal'].indexOf(record.dataType) != -1;
|
|
|
}
|
|
|
return c;
|
|
|
});
|
|
|
dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
}}
|
|
|
>
|
|
|
- <SelectOption value='index'>索引</SelectOption>
|
|
|
- <SelectOption value='time'>时间</SelectOption>
|
|
|
- <SelectOption value='categorical'>类别</SelectOption>
|
|
|
- <SelectOption value='scale'>标量</SelectOption>
|
|
|
- <SelectOption value='ordinal'>序值</SelectOption>
|
|
|
- <SelectOption value='string'>字符串</SelectOption>
|
|
|
+ {
|
|
|
+ [
|
|
|
+ <SelectOption value='index' key='index'>索引</SelectOption>,
|
|
|
+ <SelectOption value='time' key='time'>时间</SelectOption>,
|
|
|
+ <SelectOption value='categorical' key='categorical'>类别</SelectOption>,
|
|
|
+ <SelectOption value='scale' key='scale'>标量</SelectOption>,
|
|
|
+ <SelectOption value='ordinal' key='ordinal'>序值</SelectOption>,
|
|
|
+ <SelectOption value='string' key='string'>字符串</SelectOption>
|
|
|
+ ].map((s, i) => {
|
|
|
+ if(record.columnType=='VARCHAR2' && [0,2,5].indexOf(i) != -1) {
|
|
|
+ return s;
|
|
|
+ }else if(record.columnType=='DATE' && [1].indexOf(i) != -1) {
|
|
|
+ return s;
|
|
|
+ }else if(record.columnType=='NUMBER' && [0,2,3,4,5].indexOf(i) != -1) {
|
|
|
+ return s;
|
|
|
+ }else {
|
|
|
+ return null
|
|
|
+ }
|
|
|
+ }).filter((s)=>s!=null)
|
|
|
+ }
|
|
|
</Select>
|
|
|
)
|
|
|
}
|
|
|
@@ -115,8 +143,9 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
title: '允许分组',
|
|
|
dataIndex: 'groupable',
|
|
|
key: 'groupable',
|
|
|
- width: 100,
|
|
|
- render: (value, record) => <Switch disabled={record.type!='categorical'} checked={value} onChange={(checked) => {
|
|
|
+ width: 50,
|
|
|
+ className: 'column-groupable',
|
|
|
+ render: (value, record) => <Switch disabled={record.dataType!='categorical'} checked={value} onChange={(checked) => {
|
|
|
let columns = dataSource.newOne.columns.map(c => {
|
|
|
if(c.key == record.key) {
|
|
|
c.groupable = checked;
|
|
|
@@ -129,29 +158,42 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
title: '允许分段',
|
|
|
dataIndex: 'bucketizable',
|
|
|
key: 'bucketizable',
|
|
|
- width: 100,
|
|
|
- render: (value, record) => <Switch disabled={['time', 'scale', 'ordinal'].indexOf(record.type)==-1} checked={value} onChange={(checked) => {
|
|
|
- let columns = dataSource.newOne.columns.map(c => {
|
|
|
- if(c.key == record.key) {
|
|
|
- c.bucketizable = checked;
|
|
|
- }
|
|
|
- return c;
|
|
|
- });
|
|
|
- dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
- }}/>
|
|
|
+ width: 50,
|
|
|
+ className: 'column-bucketizable',
|
|
|
+ render: (value, record) => <Switch
|
|
|
+ disabled={['time', 'scale', 'ordinal'].indexOf(record.dataType)==-1}
|
|
|
+ checked={value}
|
|
|
+ defaultChecked={true}
|
|
|
+ onChange={(checked) => {
|
|
|
+ let columns = dataSource.newOne.columns.map(c => {
|
|
|
+ if(c.key == record.key) {
|
|
|
+ c.bucketizable = checked;
|
|
|
+ }
|
|
|
+ return c;
|
|
|
+ });
|
|
|
+ dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
+ }}
|
|
|
+ />
|
|
|
}, {
|
|
|
title: '备注',
|
|
|
dataIndex: 'description',
|
|
|
key: 'description',
|
|
|
+ width: 200,
|
|
|
render: (text, record) => {
|
|
|
- return (<EditableCell
|
|
|
- dispatch={dispatch}
|
|
|
- dataSource={dataSource}
|
|
|
- fieldName='description'
|
|
|
- dataKey={record.key}
|
|
|
- type='input'
|
|
|
+ return <Input
|
|
|
value={text}
|
|
|
- />)
|
|
|
+ onChange={(e) => {
|
|
|
+ let columns = dataSource.newOne.columns.map(c => {
|
|
|
+ if(c.key == record.key) {
|
|
|
+ c['description'] = e.target.value;
|
|
|
+ }
|
|
|
+ return c;
|
|
|
+ });
|
|
|
+
|
|
|
+ dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ </Input>
|
|
|
}
|
|
|
}];
|
|
|
|
|
|
@@ -174,26 +216,7 @@ class DataSourceColumnConfig extends React.Component {
|
|
|
</FormItem>
|
|
|
<div className='buttons'>
|
|
|
<Button onClick={() => {
|
|
|
- dispatch({
|
|
|
- type: 'dataSource/setNewModelField', name: 'columns', value: [
|
|
|
- { key: 30, name: 'rrrrrr', type: 'ordinal', using: false},
|
|
|
- { key: 40, name: 'rrrrrr', type: 'ordinal', using: false},
|
|
|
- { key: 50, name: 'rrrrrr', type: 'ordinal', using: false},
|
|
|
- { key: 60, name: 'rrrrrr', type: 'ordinal', using: false},
|
|
|
- { key: 70, name: 'rrrrrr', type: 'ordinal', using: false},
|
|
|
- { key: 80, name: 'rrrrrr', type: 'ordinal', using: false},
|
|
|
- { key: 120, name: 'rrrrrr', type: 'ordinal', using: false},
|
|
|
- { key: 64, name: 'rrrrrr', type: 'ordinal', using: false},
|
|
|
- { key: 12, name: 'rrrrrr', type: 'ordinal', using: false},
|
|
|
- { key: 98, name: 'rrrrrr', type: 'ordinal', using: false},
|
|
|
- { key: 630, name: 'rrrrrr', type: 'ordinal', using: false},
|
|
|
- { key: 1, name: 'ttttt', type: 'scale', using: true},
|
|
|
- { key: 2, name: 'ssssss', type: 'index', using: true },
|
|
|
- { key: 3, name: 'yyyyyy', type: 'categorical', using: true, description: 'hhhhhhhhh' },
|
|
|
- { key: 4, name: 'uuuuuuu', type: 'string', using: true },
|
|
|
- { key: 5, name: 'ggggg', type: 'time', alias: 'gg', using: true }
|
|
|
- ]
|
|
|
- });
|
|
|
+ dispatch({ type: 'dataSource/importNewModelColumns' })
|
|
|
}}>刷新</Button>
|
|
|
</div>
|
|
|
</Form>
|
|
|
@@ -218,92 +241,4 @@ function mapStateToProps({ present: { dataSource } }) {
|
|
|
return { dataSource }
|
|
|
}
|
|
|
|
|
|
-export default connect(mapStateToProps)(DataSourceColumnConfig);
|
|
|
-
|
|
|
-class EditableCell extends React.Component {
|
|
|
- state = {
|
|
|
- dispatch: this.props.dispatch,
|
|
|
- dataSource: this.props.dataSource,
|
|
|
- fieldName: this.props.fieldName,
|
|
|
- dataKey: this.props.dataKey,
|
|
|
- type: this.props.type,
|
|
|
- value: this.props.value,
|
|
|
- editable: false,
|
|
|
- }
|
|
|
-
|
|
|
- getEditor = (e) => {
|
|
|
- const { type, value } = this.state;
|
|
|
- if(type == 'input') {
|
|
|
- return (
|
|
|
- <Input
|
|
|
- value={value}
|
|
|
- onChange={this.handleChange}
|
|
|
- onPressEnter={this.check}
|
|
|
- suffix={(
|
|
|
- <Icon
|
|
|
- type="check"
|
|
|
- className="editable-cell-icon-check"
|
|
|
- onClick={this.check}
|
|
|
- />
|
|
|
- )}
|
|
|
- />
|
|
|
- )
|
|
|
- }else if(type == 'select') {
|
|
|
- return (
|
|
|
- <Select
|
|
|
- onChange={this.check}
|
|
|
- >
|
|
|
- <SelectOption value='index'>索引</SelectOption>
|
|
|
- <SelectOption value='time'>时间</SelectOption>
|
|
|
- <SelectOption value='categorical'>类别</SelectOption>
|
|
|
- <SelectOption value='scale'>标量</SelectOption>
|
|
|
- <SelectOption value='ordinal'>序值</SelectOption>
|
|
|
- <SelectOption value='string'>字符串</SelectOption>
|
|
|
- </Select>
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- handleChange = (e) => {
|
|
|
- const value = e.target.value;
|
|
|
- this.setState({ value });
|
|
|
- }
|
|
|
-
|
|
|
- check = () => {
|
|
|
- const { dispatch, dataSource, fieldName, dataKey, value } = this.state;
|
|
|
- this.setState({ editable: false });
|
|
|
-
|
|
|
- let columns = dataSource.newOne.columns.map(c => {
|
|
|
- if(c.key == dataKey) {
|
|
|
- c[fieldName] = value;
|
|
|
- }
|
|
|
- return c;
|
|
|
- });
|
|
|
-
|
|
|
- dispatch({ type: 'dataSource/setNewModelField', name: 'columns', value: columns });
|
|
|
- }
|
|
|
-
|
|
|
- edit = () => {
|
|
|
- this.setState({ editable: true });
|
|
|
- }
|
|
|
-
|
|
|
- render() {
|
|
|
- const { value, editable } = this.state;
|
|
|
- return (
|
|
|
- <div className="editable-cell">
|
|
|
- {
|
|
|
- editable ? this.getEditor() : (
|
|
|
- <div style={{ paddingRight: 24 }}>
|
|
|
- {value || ' '}
|
|
|
- <Icon
|
|
|
- type="edit"
|
|
|
- className="editable-cell-icon"
|
|
|
- onClick={this.edit}
|
|
|
- />
|
|
|
- </div>
|
|
|
- )
|
|
|
- }
|
|
|
- </div>
|
|
|
- );
|
|
|
- }
|
|
|
-}
|
|
|
+export default connect(mapStateToProps)(DataSourceColumnConfig);
|