feat:「动作配置」刷新动作配置面板优化 (#7476)

* amis-saas-13021 [Feature] 「动作配置」刷新动作配置面板优化

* amis-saas-13021 [Feature] 「动作配置」刷新动作配置面板优化

* amis-saas-13021 [Feature] 「动作配置」刷新动作配置面板优化

* amis-saas-13021 默认关闭发送数据按钮,关闭时data应被清除,不是设置为null
This commit is contained in:
miaoxinyu01 2023-07-17 09:35:15 +08:00 committed by GitHub
parent 512c86c7ed
commit c893fdd667
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 39 deletions

View File

@ -2462,8 +2462,9 @@ extendLocale('zh-CN', {
'5e75800641ec5c1198092bcf9d34f180': '控制所选的组件的启用/禁用',
'7854b52a889b3ef0590d9f542efeb4c8': '启用',
'd86d5919f595226b7a1e8264635ca23d': '启用/禁用',
'c5a9b6e8c522de8a14ad7fab51c1a1e3': '刷新组件',
'be4b778e7f5aa6aa5a811d7db4e1a8b3': '请求并重新加载所选组件的数据',
'c5a9b6e8c522de8a14ad7fab51c1a1e3': '重新请求数据',
'be4b778e7f5aa6aa5a811d7db4e1a8b3':
'如果开启发送数据,会先发送配置数据到目标组件,然后重新请求数据。',
'694fc5efa9e1d1c2c5eb6525e1c7fb29': '刷新',
'ea4d3723b350b2cb8f4c1a615e1b7df1': '设置组件数据',
'cb7add16ba6f0cd65d5ddcad71359813': '设置数据容器或表单项的数据',

View File

@ -1121,9 +1121,10 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => {
]
},
{
actionLabel: '刷新组件',
actionLabel: '重新请求数据',
actionType: 'reload',
description: '请求并重新加载所选组件的数据',
description:
'如果开启发送数据,会先发送配置数据到目标组件,然后重新请求数据。',
descDetail: (info: any) => {
return (
<div>
@ -1142,8 +1143,7 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => {
true,
(value: string, oldVal: any, data: any, form: any) => {
form.setValueByName('args.resetPage', true);
form.setValueByName('__addParam', true);
form.setValueByName('__customData', false);
form.setValueByName('__addParam', false);
form.setValueByName('__containerType', 'all');
form.setValueByName('__reloadParam', []);
}
@ -1165,27 +1165,14 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => {
type: 'switch',
name: '__addParam',
label: tipedLabel(
'追加数据',
'当选择“是”且目标组件是增删改查组件时数据接口请求时将带上这些数据其他类型的目标组件只有在数据接口是post请求时才会带上这些数据。'
'发送数据',
'开启“发送数据”后,所配置的数据将发送给目标组件,这些数据将与目标组件数据域进行合并或覆盖'
),
onText: '是',
offText: '否',
mode: 'horizontal',
pipeIn: defaultValue(true),
visibleOn: `data.actionType === "reload" && data.__isScopeContainer`
},
{
type: 'switch',
name: '__customData',
label: tipedLabel(
'自定义数据',
'数据默认为源组件所在数据域,开启“自定义”可以定制所需数据'
),
onText: '是',
offText: '否',
mode: 'horizontal',
pipeIn: defaultValue(true),
visibleOn: `data.__addParam && data.actionType === "reload" && data.__isScopeContainer`,
pipeIn: defaultValue(false),
visibleOn: `data.actionType === "reload" && data.__isScopeContainer`,
onChange: (value: string, oldVal: any, data: any, form: any) => {
form.setValueByName('__containerType', 'all');
}
@ -1196,7 +1183,7 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => {
mode: 'horizontal',
label: '',
pipeIn: defaultValue('all'),
visibleOn: `data.__addParam && data.__customData && data.actionType === "reload" && data.__isScopeContainer`,
visibleOn: `data.__addParam && data.actionType === "reload" && data.__isScopeContainer`,
options: [
{
label: '直接赋值',
@ -1219,7 +1206,7 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => {
size: 'lg',
mode: 'horizontal',
required: true,
visibleOn: `data.__addParam && data.__customData && data.__containerType === "all" && data.actionType === "reload" && data.__isScopeContainer`
visibleOn: `data.__addParam && data.__containerType === "all" && data.actionType === "reload" && data.__isScopeContainer`
}),
{
type: 'combo',
@ -1247,14 +1234,14 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => {
placeholder: '参数值'
})
],
visibleOn: `data.__addParam && data.__customData && data.__containerType === "appoint" && data.actionType === "reload" && data.__isScopeContainer`
visibleOn: `data.__addParam && data.__containerType === "appoint" && data.actionType === "reload" && data.__isScopeContainer`
},
{
type: 'radios',
name: 'dataMergeMode',
mode: 'horizontal',
label: tipedLabel(
'追加方式',
'数据处理方式',
'选择“合并”时,会将数据合并到目标组件的数据域。<br/>选择“覆盖”时,数据会直接覆盖目标组件的数据域。'
),
pipeIn: defaultValue('merge'),
@ -2797,8 +2784,7 @@ export const getEventControlConfig = (
// 处理刷新组件动作的追加参数
if (config.actionType === 'reload') {
config.__resetPage = config.args?.resetPage;
config.__addParam = config.data === undefined || !!config.data;
config.__customData = !!config.data;
config.__addParam = !!config.data;
if (
(config.data && typeof config.data === 'object') ||
@ -2806,12 +2792,12 @@ export const getEventControlConfig = (
!Object.keys(config.args).length &&
config.data === undefined)
) {
config.__customData = true;
config.__addParam = true;
config.__containerType = 'appoint';
config.dataMergeMode = 'override';
}
if (config.__addParam && config.__customData && config.data) {
if (config.__addParam && config.data) {
if (typeof config.data === 'string') {
config.__containerType = 'all';
config.__valueInput = config.data;
@ -2916,7 +2902,7 @@ export const getEventControlConfig = (
// 刷新组件时,处理是否追加事件变量
if (config.actionType === 'reload') {
action.data = null;
action.data = undefined;
action.dataMergeMode = undefined;
action.args =
@ -2927,15 +2913,13 @@ export const getEventControlConfig = (
}
: undefined;
action.data = undefined;
if (config.__addParam) {
action.dataMergeMode = config.dataMergeMode || 'merge';
action.data = undefined;
if (config.__customData) {
action.data =
config.__containerType === 'all'
? config.__valueInput
: comboArrayToObject(config.__reloadParams || []);
}
action.data =
config.__containerType === 'all'
? config.__valueInput
: comboArrayToObject(config.__reloadParams || []);
}
}