diff --git a/packages/li-core-assets/src/layers/GridLayer/register-form/coordinate-schema.ts b/packages/li-core-assets/src/layers/GridLayer/register-form/coordinate-schema.ts index bfb3019b..5cf03aab 100644 --- a/packages/li-core-assets/src/layers/GridLayer/register-form/coordinate-schema.ts +++ b/packages/li-core-assets/src/layers/GridLayer/register-form/coordinate-schema.ts @@ -98,7 +98,6 @@ export default (fieldList: FieldSelectOptionType[]) => { aggregateField: { type: 'string', title: '聚合字段', - required: true, 'x-decorator': 'FormItem', 'x-component': 'FieldSelect', 'x-component-props': { @@ -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: [ @@ -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 }}', + }, + }, + }, + ], }, }, }, diff --git a/packages/li-core-assets/src/layers/HexbinLayer/register-form/coordinate-schema.ts b/packages/li-core-assets/src/layers/HexbinLayer/register-form/coordinate-schema.ts index 6819dd32..8c2f2184 100644 --- a/packages/li-core-assets/src/layers/HexbinLayer/register-form/coordinate-schema.ts +++ b/packages/li-core-assets/src/layers/HexbinLayer/register-form/coordinate-schema.ts @@ -102,7 +102,6 @@ export default (fieldList: FieldSelectOptionType[]) => { aggregateField: { type: 'string', title: '聚合字段', - required: true, 'x-decorator': 'FormItem', 'x-component': 'FieldSelect', 'x-component-props': { @@ -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: [ @@ -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 }}', + }, + }, + }, + ], }, }, },