|
|
@@ -34,7 +34,7 @@ class CusFilterBox extends React.Component {
|
|
|
header={<Form.Item className='filtercolumn-name' label='名称' labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
|
|
|
<Input size='small' value={r.name}
|
|
|
onChange={(e) => {
|
|
|
- dispatch({ type: 'dashboardDesigner/setRelationColumn', code: r.code, relationColumn: { ...r, name: e.target.value, cusName: true } });
|
|
|
+ dispatch({ type: 'dashboardDesigner/setRelationColumn', code: r.code, relationColumn: { ...r, name: e.target.value } });
|
|
|
}} onFocus={() => {
|
|
|
this.setState({
|
|
|
editing: true,
|
|
|
@@ -129,6 +129,7 @@ class CusFilterBox extends React.Component {
|
|
|
const { dashboardDesigner, dispatch } = this.props;
|
|
|
const { selectedDataSource } = this.state;
|
|
|
const { relationColumns } = dashboardDesigner;
|
|
|
+ let setFlag, cusName;
|
|
|
|
|
|
this.setState({
|
|
|
selectedColumn: {
|
|
|
@@ -140,6 +141,8 @@ class CusFilterBox extends React.Component {
|
|
|
const { relations } = r;
|
|
|
let idx = relations.findIndex(r => r.dataSource.code === selectedDataSource.code);
|
|
|
if(idx === -1){
|
|
|
+ setFlag = relations.length === 0; // 当添加第一个数据源列时
|
|
|
+ cusName = c.label;
|
|
|
relations.push({
|
|
|
dataSource: {
|
|
|
code: selectedDataSource.code,
|
|
|
@@ -151,6 +154,26 @@ class CusFilterBox extends React.Component {
|
|
|
type: c.type
|
|
|
}
|
|
|
});
|
|
|
+ }else if(idx === 0) { // 如果是第一个则需要重新设置关联
|
|
|
+ let cr = relations[idx];
|
|
|
+ setFlag = true;
|
|
|
+ cusName = c.label;
|
|
|
+
|
|
|
+ if(cr.column.name === selectedColumn.name) {
|
|
|
+ relations.splice(0, relations.length); // 第一个取消勾选后全部清空
|
|
|
+ }else {
|
|
|
+ relations[idx] = {
|
|
|
+ dataSource: {
|
|
|
+ code: selectedDataSource.code,
|
|
|
+ name: selectedDataSource.name
|
|
|
+ },
|
|
|
+ column: {
|
|
|
+ name: c.name,
|
|
|
+ label: c.label,
|
|
|
+ type: c.type
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
}else {
|
|
|
let cr = relations[idx];
|
|
|
if(cr.column.name === selectedColumn.name) {
|
|
|
@@ -170,7 +193,11 @@ class CusFilterBox extends React.Component {
|
|
|
}
|
|
|
}
|
|
|
let index = relationColumns.findIndex(rc => rc.code === r.code);
|
|
|
- relationColumns[index] = { ...r, name: relationColumns[index].cusName ? relationColumns[index].name : c.label, cusName: true, relations };
|
|
|
+ if(setFlag) {
|
|
|
+ relationColumns[index] = { ...r, name: cusName, relations };
|
|
|
+ }else {
|
|
|
+ relationColumns[index] = { ...r, relations };
|
|
|
+ }
|
|
|
dispatch({ type: 'dashboardDesigner/setField', name: 'relationColumns', value: relationColumns });
|
|
|
});
|
|
|
}
|