Skip to content

Commit

Permalink
fix: 蜂窝和网格图层聚合属性问题 (#39)
Browse files Browse the repository at this point in the history
Co-authored-by: yxh01132861 <[email protected]>
  • Loading branch information
simplexiao and yxh01132861 authored Sep 21, 2023
1 parent b9f06e4 commit 1286f3e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export default (fieldList: FieldSelectOptionType[]) => {
aggregateField: {
type: 'string',
title: '聚合字段',
required: true,
'x-decorator': 'FormItem',
'x-component': 'FieldSelect',
'x-component-props': {
Expand All @@ -110,11 +109,10 @@ export default (fieldList: FieldSelectOptionType[]) => {
aggregateMethod: {
type: 'string',
title: '聚合方法',
required: true,
default: 'sum',
'x-decorator': 'FormItem',
'x-component': 'Select',
'x-component-props': {
allowClear: true,
placeholder: '请选择字段',
},
enum: [
Expand All @@ -123,6 +121,41 @@ export default (fieldList: FieldSelectOptionType[]) => {
{ label: 'min', value: 'min' },
{ label: 'mean', value: 'mean' },
],
'x-reactions': [
{
dependencies: ['aggregateMethod'],
fulfill: {
run: `$form.setFieldState("fillColorField", (state) => {
state.dataSource = $form.getFieldState("aggregateMethod", (state) => {
return state.value
? [
{ value: "count", label: "count" },
{ label: state.value, value: state.value },
]
: [{ value: "count", label: "count" }];
});
});
$form.setFieldState("fillColorField", (state) => {
state.value = $form
.getFieldState("aggregateMethod", (state) => {
return [state.value, "count"];
})
.includes(state.value)
? state.value
: undefined;
});`,
},
},
{
dependencies: ['aggregateField'],
fulfill: {
state: {
visible: '{{ $deps[0] !== undefined }}',
},
},
},
],
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export default (fieldList: FieldSelectOptionType[]) => {
aggregateField: {
type: 'string',
title: '聚合字段',
required: true,
'x-decorator': 'FormItem',
'x-component': 'FieldSelect',
'x-component-props': {
Expand All @@ -114,11 +113,10 @@ export default (fieldList: FieldSelectOptionType[]) => {
aggregateMethod: {
type: 'string',
title: '聚合方法',
required: true,
default: 'sum',
'x-decorator': 'FormItem',
'x-component': 'Select',
'x-component-props': {
allowClear: true,
placeholder: '请选择字段',
},
enum: [
Expand All @@ -127,6 +125,41 @@ export default (fieldList: FieldSelectOptionType[]) => {
{ label: 'min', value: 'min' },
{ label: 'mean', value: 'mean' },
],
'x-reactions': [
{
dependencies: ['aggregateMethod'],
fulfill: {
run: `$form.setFieldState("fillColorField", (state) => {
state.dataSource = $form.getFieldState("aggregateMethod", (state) => {
return state.value
? [
{ value: "count", label: "count" },
{ label: state.value, value: state.value },
]
: [{ value: "count", label: "count" }];
});
});
$form.setFieldState("fillColorField", (state) => {
state.value = $form
.getFieldState("aggregateMethod", (state) => {
return [state.value, "count"];
})
.includes(state.value)
? state.value
: undefined;
});`,
},
},
{
dependencies: ['aggregateField'],
fulfill: {
state: {
visible: '{{ $deps[0] !== undefined }}',
},
},
},
],
},
},
},
Expand Down

0 comments on commit 1286f3e

Please sign in to comment.