diff --git a/packages/amis-editor/src/renderer/event-control/action-config-panel.tsx b/packages/amis-editor/src/renderer/event-control/action-config-panel.tsx index e3e2644e26d7..11d1fdbae498 100644 --- a/packages/amis-editor/src/renderer/event-control/action-config-panel.tsx +++ b/packages/amis-editor/src/renderer/event-control/action-config-panel.tsx @@ -3,11 +3,10 @@ */ import {RendererProps, Schema} from 'amis-core'; -import {defaultValue, RendererPluginAction} from 'amis-editor-core'; +import {RendererPluginAction} from 'amis-editor-core'; import React from 'react'; import cx from 'classnames'; import {COMMON_ACTION_SCHEMA_MAP, renderCmptActionSelect} from './helper'; -import {Button} from 'amis'; export default class ActionConfigPanel extends React.Component { render() { diff --git a/packages/amis-editor/src/renderer/event-control/helper.tsx b/packages/amis-editor/src/renderer/event-control/helper.tsx index cea67048a031..2df093ac480e 100644 --- a/packages/amis-editor/src/renderer/event-control/helper.tsx +++ b/packages/amis-editor/src/renderer/event-control/helper.tsx @@ -1075,7 +1075,6 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => { { type: 'wrapper', size: 'sm', - visibleOn: 'data.componentId === "customCmptId"', body: [ ...renderCmptSelect( '目标组件', @@ -1090,23 +1089,6 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => { ) ] }, - { - type: 'wrapper', - size: 'sm', - visibleOn: 'data.componentId !== "customCmptId"', - body: [ - ...renderCmptSelect( - '目标组件', - true, - (value: string, oldVal: any, data: any, form: any) => { - form.setValueByName('args.resetPage', true); - form.setValueByName('__addParam', false); - form.setValueByName('__containerType', 'all'); - form.setValueByName('__reloadParam', []); - } - ) - ] - }, renderCmptIdInput( (value: string, oldVal: any, data: any, form: any) => { // 找到组件并设置相关的属性 @@ -1371,173 +1353,167 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => { } } ), - getArgsWrapper({ - type: 'wrapper', - className: 'p-none', - body: [ + { + type: 'radios', + name: '__containerType', + mode: 'horizontal', + label: '数据设置', + pipeIn: defaultValue('all'), + visibleOn: 'data.__isScopeContainer', + options: [ { - type: 'radios', - name: '__containerType', - mode: 'horizontal', - label: '数据设置', - pipeIn: defaultValue('all'), - visibleOn: 'data.__isScopeContainer', - options: [ - { - label: '直接赋值', - value: 'all' - }, - { - label: '成员赋值', - value: 'appoint' - } - ], - onChange: ( - value: string, - oldVal: any, - data: any, - form: any - ) => { - form.setValueByName('value', []); - form.setValueByName('__valueInput', undefined); - } + label: '直接赋值', + value: 'all' }, { - type: 'radios', - name: '__comboType', - inputClassName: 'event-action-radio', - mode: 'horizontal', - label: '数据设置', - pipeIn: defaultValue('all'), - visibleOn: `data.__rendererName === 'combo' || data.__rendererName === 'input-table'`, - options: [ - { - label: '全量', - value: 'all' - }, - { - label: '指定序号', - value: 'appoint' - } - ], - onChange: ( - value: string, - oldVal: any, - data: any, - form: any - ) => { - form.setValueByName('index', undefined); - form.setValueByName('value', []); - form.setValueByName('__valueInput', undefined); - } + label: '成员赋值', + value: 'appoint' + } + ], + onChange: ( + value: string, + oldVal: any, + data: any, + form: any + ) => { + form.setValueByName('value', []); + form.setValueByName('__valueInput', undefined); + } + }, + { + type: 'radios', + name: '__comboType', + inputClassName: 'event-action-radio', + mode: 'horizontal', + label: '数据设置', + pipeIn: defaultValue('all'), + visibleOn: `data.__rendererName === 'combo' || data.__rendererName === 'input-table'`, + options: [ + { + label: '全量', + value: 'all' }, { - type: 'input-number', - required: true, - name: 'index', - mode: 'horizontal', - label: '输入序号', - size: 'lg', - placeholder: '请输入待更新序号', - visibleOn: `(data.__rendererName === 'input-table' || data.__rendererName === 'combo') - && data.__comboType === 'appoint'` + label: '指定序号', + value: 'appoint' + } + ], + onChange: ( + value: string, + oldVal: any, + data: any, + form: any + ) => { + form.setValueByName('index', undefined); + form.setValueByName('value', []); + form.setValueByName('__valueInput', undefined); + } + }, + { + type: 'input-number', + required: true, + name: 'index', + mode: 'horizontal', + label: '输入序号', + size: 'lg', + placeholder: '请输入待更新序号', + visibleOn: `(data.__rendererName === 'input-table' || data.__rendererName === 'combo') + && data.__comboType === 'appoint'` + }, + { + type: 'combo', + name: 'value', + label: '', + multiple: true, + removable: true, + required: true, + addable: true, + strictMode: false, + canAccessSuperData: true, + size: 'lg', + mode: 'horizontal', + items: [ + { + name: 'key', + type: 'input-text', + placeholder: '变量名', + source: '${__setValueDs}', + labelField: 'label', + valueField: 'value', + required: true }, + getSchemaTpl('formulaControl', { + name: 'val', + variables: '${variables}', + placeholder: '字段值' + }) + ], + visibleOn: `data.__isScopeContainer && data.__containerType === 'appoint' || data.__comboType === 'appoint'` + }, + { + type: 'combo', + name: 'value', + label: '', + multiple: true, + removable: true, + required: true, + addable: true, + strictMode: false, + canAccessSuperData: true, + mode: 'horizontal', + size: 'lg', + items: [ { type: 'combo', - name: 'value', - label: '', + name: 'item', + label: false, + renderLabel: false, multiple: true, removable: true, required: true, addable: true, strictMode: false, canAccessSuperData: true, + className: 'm-l', size: 'lg', mode: 'horizontal', items: [ { name: 'key', type: 'input-text', - placeholder: '变量名', source: '${__setValueDs}', labelField: 'label', valueField: 'value', - required: true + required: true, + visibleOn: `data.__rendererName` }, getSchemaTpl('formulaControl', { name: 'val', - variables: '${variables}', - placeholder: '字段值' + variables: '${variables}' }) - ], - visibleOn: `data.__isScopeContainer && data.__containerType === 'appoint' || data.__comboType === 'appoint'` - }, - { - type: 'combo', - name: 'value', - label: '', - multiple: true, - removable: true, - required: true, - addable: true, - strictMode: false, - canAccessSuperData: true, - mode: 'horizontal', - size: 'lg', - items: [ - { - type: 'combo', - name: 'item', - label: false, - renderLabel: false, - multiple: true, - removable: true, - required: true, - addable: true, - strictMode: false, - canAccessSuperData: true, - className: 'm-l', - size: 'lg', - mode: 'horizontal', - items: [ - { - name: 'key', - type: 'input-text', - source: '${__setValueDs}', - labelField: 'label', - valueField: 'value', - required: true, - visibleOn: `data.__rendererName` - }, - getSchemaTpl('formulaControl', { - name: 'val', - variables: '${variables}' - }) - ] - } - ], - visibleOn: `(data.__rendererName === 'combo' || data.__rendererName === 'input-table') - && data.__comboType === 'all'` - }, - getSchemaTpl('formulaControl', { - name: '__valueInput', - label: '', - variables: '${variables}', - size: 'lg', - mode: 'horizontal', - visibleOn: `(data.__isScopeContainer || ${SHOW_SELECT_PROP}) && data.__containerType === 'all'`, - required: true - }), - getSchemaTpl('formulaControl', { - name: '__valueInput', - label: '数据设置', - variables: '${variables}', - size: 'lg', - mode: 'horizontal', - visibleOn: `data.__rendererName && !data.__isScopeContainer && data.__rendererName !== 'combo' && data.__rendererName !== 'input-table'`, - required: true - }) - ] + ] + } + ], + visibleOn: `(data.__rendererName === 'combo' || data.__rendererName === 'input-table') + && data.__comboType === 'all'` + }, + getSchemaTpl('formulaControl', { + name: '__valueInput', + label: '', + variables: '${variables}', + size: 'lg', + mode: 'horizontal', + visibleOn: `(data.__isScopeContainer || ${SHOW_SELECT_PROP}) && data.__containerType === 'all'`, + required: true + }), + getSchemaTpl('formulaControl', { + name: '__valueInput', + label: '数据设置', + variables: '${variables}', + size: 'lg', + mode: 'horizontal', + visibleOn: `data.__rendererName && !data.__isScopeContainer && data.__rendererName !== 'combo' && data.__rendererName !== 'input-table'`, + required: true }) ] }, @@ -1952,52 +1928,34 @@ export const renderCmptSelect = ( required: boolean, onChange?: (value: string, oldVal: any, data: any, form: any) => void, hideAutoFill?: boolean -) => { - if (hideAutoFill) { - return [ - { - type: 'tree-select', - name: 'componentId', - label: componentLabel || '选择组件', - showIcon: false, - searchable: true, - required, - selfDisabledAffectChildren: false, - size: 'lg', - source: '${__cmptTreeSource}', - mode: 'horizontal', - onChange: async (value: string, oldVal: any, data: any, form: any) => { - onChange?.(value, oldVal, data, form); - } - } - ]; - } else { - return [ - { - type: 'tree-select', - name: 'componentId', - label: componentLabel || '选择组件', - showIcon: false, - searchable: true, - required, - selfDisabledAffectChildren: false, - size: 'lg', - source: '${__cmptTreeSource}', - mode: 'horizontal', - autoFill: { - __rendererLabel: '${label}', - __rendererName: '${type}', - __nodeId: '${id}', - __nodeSchema: '${schema}', - __isScopeContainer: '${isScopeContainer}' - }, - onChange: async (value: string, oldVal: any, data: any, form: any) => { - onChange?.(value, oldVal, data, form); - } - } - ]; +) => [ + { + type: 'tree-select', + name: 'componentId', + label: componentLabel || '选择组件', + showIcon: false, + searchable: true, + required, + selfDisabledAffectChildren: false, + size: 'lg', + source: '${__cmptTreeSource}', + mode: 'horizontal', + autoFill: { + __isScopeContainer: '${isScopeContainer}', + ...(hideAutoFill + ? {} + : { + __rendererLabel: '${label}', + __rendererName: '${type}', + __nodeId: '${id}', + __nodeSchema: '${schema}' + }) + }, + onChange: async (value: string, oldVal: any, data: any, form: any) => { + onChange?.(value, oldVal, data, form); + } } -}; +]; // 渲染组件特性动作配置项 export const renderCmptActionSelect = ( @@ -2122,167 +2080,163 @@ export const COMMON_ACTION_SCHEMA_MAP: { ); }, - schema: getArgsWrapper({ - type: 'wrapper', - className: 'p-none', - body: [ - { - type: 'radios', - name: '__containerType', - mode: 'horizontal', - label: '数据设置', - pipeIn: defaultValue('all'), - visibleOn: 'data.__isScopeContainer', - options: [ - { - label: '直接赋值', - value: 'all' - }, - { - label: '成员赋值', - value: 'appoint' - } - ], - onChange: (value: string, oldVal: any, data: any, form: any) => { - form.setValueByName('value', []); - form.setValueByName('__valueInput', undefined); + schema: [ + { + type: 'radios', + name: '__containerType', + mode: 'horizontal', + label: '数据设置', + pipeIn: defaultValue('all'), + visibleOn: 'data.__isScopeContainer', + options: [ + { + label: '直接赋值', + value: 'all' + }, + { + label: '成员赋值', + value: 'appoint' } - }, - { - type: 'radios', - name: '__comboType', - inputClassName: 'event-action-radio', - mode: 'horizontal', - label: '数据设置', - pipeIn: defaultValue('all'), - visibleOn: `data.__rendererName === 'combo' || data.__rendererName === 'input-table'`, - options: [ - { - label: '全量', - value: 'all' - }, - { - label: '指定序号', - value: 'appoint' - } - ], - onChange: (value: string, oldVal: any, data: any, form: any) => { - form.setValueByName('index', undefined); - form.setValueByName('value', []); - form.setValueByName('__valueInput', undefined); + ], + onChange: (value: string, oldVal: any, data: any, form: any) => { + form.setValueByName('value', []); + form.setValueByName('__valueInput', undefined); + } + }, + { + type: 'radios', + name: '__comboType', + inputClassName: 'event-action-radio', + mode: 'horizontal', + label: '数据设置', + pipeIn: defaultValue('all'), + visibleOn: `data.__rendererName === 'combo' || data.__rendererName === 'input-table'`, + options: [ + { + label: '全量', + value: 'all' + }, + { + label: '指定序号', + value: 'appoint' } - }, - { - type: 'input-number', - required: true, - name: 'index', - mode: 'horizontal', - label: '输入序号', - size: 'lg', - placeholder: '请输入待更新序号', - visibleOn: `(data.__rendererName === 'input-table' || data.__rendererName === 'combo') - && data.__comboType === 'appoint'` - }, - { - type: 'combo', - name: 'value', - label: '', - multiple: true, - removable: true, - required: true, - addable: true, - strictMode: false, - canAccessSuperData: true, - size: 'lg', - mode: 'horizontal', - items: [ - { - name: 'key', - type: 'input-text', - placeholder: '变量名', - source: '${__setValueDs}', - labelField: 'label', - valueField: 'value', - required: true - }, - getSchemaTpl('formulaControl', { - name: 'val', - variables: '${variables}', - placeholder: '字段值' - }) - ], - visibleOn: `data.__isScopeContainer && data.__containerType === 'appoint' || data.__comboType === 'appoint'` - }, - { - type: 'combo', - name: 'value', - label: '', - multiple: true, - removable: true, - required: true, - addable: true, - strictMode: false, - canAccessSuperData: true, - mode: 'horizontal', - size: 'lg', - items: [ - { - type: 'combo', - name: 'item', - label: false, - renderLabel: false, - multiple: true, - removable: true, - required: true, - addable: true, - strictMode: false, - canAccessSuperData: true, - className: 'm-l', - size: 'lg', - mode: 'horizontal', - items: [ - { - name: 'key', - type: 'input-text', - source: '${__setValueDs}', - labelField: 'label', - valueField: 'value', - required: true, - visibleOn: `data.__rendererName` - }, - getSchemaTpl('formulaControl', { - name: 'val', - variables: '${variables}' - }) - ] - } - ], - visibleOn: `(data.__rendererName === 'combo' || data.__rendererName === 'input-table') - && data.__comboType === 'all'` - }, - getSchemaTpl('formulaControl', { - name: '__valueInput', - label: '', - variables: '${variables}', - size: 'lg', - mode: 'horizontal', - visibleOn: `(data.__isScopeContainer || ${SHOW_SELECT_PROP}) && data.__containerType === 'all'`, - required: true - }), - getSchemaTpl('formulaControl', { - name: '__valueInput', - label: '数据设置', - variables: '${variables}', - size: 'lg', - mode: 'horizontal', - visibleOn: `data.__rendererName && !data.__isScopeContainer && data.__rendererName !== 'combo' && data.__rendererName !== 'input-table'`, - required: true, - horizontal: { - leftFixed: true + ], + onChange: (value: string, oldVal: any, data: any, form: any) => { + form.setValueByName('index', undefined); + form.setValueByName('value', []); + form.setValueByName('__valueInput', undefined); + } + }, + { + type: 'input-number', + required: true, + name: 'index', + mode: 'horizontal', + label: '输入序号', + size: 'lg', + placeholder: '请输入待更新序号', + visibleOn: `(data.__rendererName === 'input-table' || data.__rendererName === 'combo') + && data.__comboType === 'appoint'` + }, + { + type: 'combo', + name: 'value', + label: '', + multiple: true, + removable: true, + required: true, + addable: true, + strictMode: false, + canAccessSuperData: true, + size: 'lg', + mode: 'horizontal', + items: [ + { + name: 'key', + type: 'input-text', + placeholder: '变量名', + source: '${__setValueDs}', + labelField: 'label', + valueField: 'value', + required: true + }, + getSchemaTpl('formulaControl', { + name: 'val', + variables: '${variables}', + placeholder: '字段值' + }) + ], + visibleOn: `data.__isScopeContainer && data.__containerType === 'appoint' || data.__comboType === 'appoint'` + }, + { + type: 'combo', + name: 'value', + label: '', + multiple: true, + removable: true, + required: true, + addable: true, + strictMode: false, + canAccessSuperData: true, + mode: 'horizontal', + size: 'lg', + items: [ + { + type: 'combo', + name: 'item', + label: false, + renderLabel: false, + multiple: true, + removable: true, + required: true, + addable: true, + strictMode: false, + canAccessSuperData: true, + className: 'm-l', + size: 'lg', + mode: 'horizontal', + items: [ + { + name: 'key', + type: 'input-text', + source: '${__setValueDs}', + labelField: 'label', + valueField: 'value', + required: true, + visibleOn: `data.__rendererName` + }, + getSchemaTpl('formulaControl', { + name: 'val', + variables: '${variables}' + }) + ] } - }) - ] - }) + ], + visibleOn: `(data.__rendererName === 'combo' || data.__rendererName === 'input-table') + && data.__comboType === 'all'` + }, + getSchemaTpl('formulaControl', { + name: '__valueInput', + label: '', + variables: '${variables}', + size: 'lg', + mode: 'horizontal', + visibleOn: `(data.__isScopeContainer || ${SHOW_SELECT_PROP}) && data.__containerType === 'all'`, + required: true + }), + getSchemaTpl('formulaControl', { + name: '__valueInput', + label: '数据设置', + variables: '${variables}', + size: 'lg', + mode: 'horizontal', + visibleOn: `data.__rendererName && !data.__isScopeContainer && data.__rendererName !== 'combo' && data.__rendererName !== 'input-table'`, + required: true, + horizontal: { + leftFixed: true + } + }) + ] }, reload: { descDetail: (info: any) => {