[amis-saas-7504]: crud reload增加resetPage

Change-Id: I66386e5f6a22e16cdaa837df9a9e6f3fddf05126
This commit is contained in:
hsm-lv 2022-10-18 17:03:06 +08:00
parent ac1c37d91b
commit 9c96baca03
4 changed files with 154 additions and 108 deletions

View File

@ -3284,5 +3284,8 @@ extendLocale('en-US', {
'Update the data field of the target component or the data value of the target form item',
'e7af71fb102cc86ab3be6a2fb32b5e3f': 'Data settings',
'77b1081c177fa3334cc93c99f0ecee75': 'Direct assignment',
'f5c5e3d69daee06ea1606378ef466765': 'Member assignment'
'f5c5e3d69daee06ea1606378ef466765': 'Member assignment',
'697af73997072e0ce9ee65b15a7b3715': 'Reset PageNo',
'd7bf42dd6e66f2818f9a232603c4a53b':
'When "Yes" is selected, the crud component will request the first page of data'
});

View File

@ -2903,5 +2903,7 @@ extendLocale('zh-CN', {
'更新目标组件的数据域或目标表单项的数据值',
'e7af71fb102cc86ab3be6a2fb32b5e3f': '数据设置',
'77b1081c177fa3334cc93c99f0ecee75': '直接赋值',
'f5c5e3d69daee06ea1606378ef466765': '成员赋值'
'f5c5e3d69daee06ea1606378ef466765': '成员赋值',
'697af73997072e0ce9ee65b15a7b3715': '重置页码',
'd7bf42dd6e66f2818f9a232603c4a53b': '选择“是”时,将重新请求第一页数据。'
});

View File

@ -692,110 +692,128 @@ 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('__addParamType', 'default');
form.setValueByName('__reloadParam', []);
}
)
// {
// type: 'switch',
// name: '__addParam',
// label: '追加数据',
// labelRemark: {
// className: 'm-l-xs',
// icon: 'fa fa-question-circle',
// rootClose: true,
// content: `选择“是”时,会将源组件所在数据域变量同步到目标组件的数据域。<br/>如果目标组件是增删改查组件且增删改查组件的数据拉取接口是get请求则源组件所在数据域变量将追加到目标组件的初始化请求query中。`,
// placement: 'top'
// },
// onText: '是',
// offText: '否',
// mode: 'horizontal',
// pipeIn: defaultValue(true),
// visibleOn: `data.actionType === "reload" && ${IS_DATA_CONTAINER}`
// },
// {
// type: 'radios',
// name: 'dataMergeMode',
// mode: 'horizontal',
// label: '追加方式',
// labelRemark: {
// className: 'm-l-xs',
// icon: 'fa fa-question-circle',
// rootClose: true,
// content: `选择“合并”时,会将数据合并到目标组件的数据域。<br/>选择“覆盖”时,数据会直接覆盖目标组件的数据域。`,
// placement: 'top'
// },
// pipeIn: defaultValue('merge'),
// visibleOn: `data.__addParam && data.actionType === "reload" && ${IS_DATA_CONTAINER}`,
// options: [
// {
// label: '合并',
// value: 'merge'
// },
// {
// label: '覆盖',
// value: 'override'
// }
// ]
// },
// {
// type: 'radios',
// name: '__addParamType',
// mode: 'horizontal',
// label: '数据配置',
// labelRemark: {
// className: 'm-l-xs',
// icon: 'fa fa-question-circle',
// rootClose: true,
// content: `数据默认为源组件所在数据域,可以选择“自定义”来定制所需数据`,
// placement: 'top'
// },
// pipeIn: defaultValue('default'),
// visibleOn: `data.__addParam && data.actionType === "reload" && ${IS_DATA_CONTAINER}`,
// options: [
// {
// label: '源组件所在数据域',
// value: 'default'
// },
// {
// label: '自定义',
// value: 'custom'
// }
// ]
// },
// {
// type: 'combo',
// name: '__reloadParams',
// label: '',
// multiple: true,
// removable: true,
// addable: true,
// strictMode: false,
// canAccessSuperData: true,
// size: 'lg',
// mode: 'horizontal',
// items: [
// {
// name: 'key',
// type: 'input-text',
// placeholder: '参数名',
// labelField: 'label',
// valueField: 'value',
// required: true
// },
// {
// name: 'val',
// type: 'input-formula',
// placeholder: '参数值',
// variables: '${variables}',
// evalMode: false,
// variableMode: 'tabs',
// inputMode: 'input-group'
// }
// ],
// visibleOn: `data.__addParam && data.__addParamType === "custom" && data.actionType === "reload" && ${IS_DATA_CONTAINER}`
// }
),
{
type: 'switch',
name: '__resetPage',
label: '重置页码',
labelRemark: {
className: 'm-l-xs',
icon: 'fa fa-question-circle',
rootClose: true,
content: `选择“是”时,将重新请求第一页数据。`,
placement: 'top'
},
onText: '是',
offText: '否',
mode: 'horizontal',
pipeIn: defaultValue(true),
visibleOn: `data.actionType === "reload" && data.__rendererName === "crud"`
},
{
type: 'switch',
name: '__addParam',
label: '追加数据',
labelRemark: {
className: 'm-l-xs',
icon: 'fa fa-question-circle',
rootClose: true,
content: `选择“是”时,会将源组件所在数据域变量同步到目标组件的数据域。<br/>如果目标组件是增删改查组件且增删改查组件的数据拉取接口是get请求则源组件所在数据域变量将追加到目标组件的初始化请求query中。`,
placement: 'top'
},
onText: '是',
offText: '否',
mode: 'horizontal',
pipeIn: defaultValue(true),
visibleOn: `data.actionType === "reload" && ${IS_DATA_CONTAINER}`
},
{
type: 'radios',
name: 'dataMergeMode',
mode: 'horizontal',
label: '追加方式',
labelRemark: {
className: 'm-l-xs',
icon: 'fa fa-question-circle',
rootClose: true,
content: `选择“合并”时,会将数据合并到目标组件的数据域。<br/>选择“覆盖”时,数据会直接覆盖目标组件的数据域。`,
placement: 'top'
},
pipeIn: defaultValue('merge'),
visibleOn: `data.__addParam && data.actionType === "reload" && ${IS_DATA_CONTAINER}`,
options: [
{
label: '合并',
value: 'merge'
},
{
label: '覆盖',
value: 'override'
}
]
},
{
type: 'radios',
name: '__addParamType',
mode: 'horizontal',
label: '数据配置',
labelRemark: {
className: 'm-l-xs',
icon: 'fa fa-question-circle',
rootClose: true,
content: `数据默认为源组件所在数据域,可以选择“自定义”来定制所需数据`,
placement: 'top'
},
pipeIn: defaultValue('default'),
visibleOn: `data.__addParam && data.actionType === "reload" && ${IS_DATA_CONTAINER}`,
options: [
{
label: '源组件所在数据域',
value: 'default'
},
{
label: '自定义',
value: 'custom'
}
]
},
{
type: 'combo',
name: '__reloadParams',
label: '',
multiple: true,
removable: true,
addable: true,
strictMode: false,
canAccessSuperData: true,
size: 'lg',
mode: 'horizontal',
items: [
{
name: 'key',
type: 'input-text',
placeholder: '参数名',
labelField: 'label',
valueField: 'value',
required: true
},
{
name: 'val',
type: 'input-formula',
placeholder: '参数值',
variables: '${variables}',
evalMode: false,
variableMode: 'tabs',
inputMode: 'input-group'
}
],
visibleOn: `data.__addParam && data.__addParamType === "custom" && data.actionType === "reload" && ${IS_DATA_CONTAINER}`
}
]
},
{

View File

@ -1151,21 +1151,35 @@ export const getEventControlConfig = (
// 处理刷新组件动作的追加参数
if (config.actionType === 'reload') {
config.__addParam = config.args === undefined || !!config.args;
config.__resetPage = config.args?.resetPage;
config.__addParam = config.data === undefined || !!config.data;
if (config.args && typeof config.args === 'object') {
if (
(config.data && typeof config.data === 'object') ||
(config.args &&
!Object.keys(config.args).length &&
config.data === undefined)
) {
config.__addParamType = 'custom';
}
if (
config.__addParam &&
config.__addParamType === 'custom' &&
config.args
config.data
) {
config.__reloadParams = objectToComboArray(config.data);
} else if (
config.args &&
!Object.keys(config.args).length &&
config.data === undefined
) {
config.__reloadParams = objectToComboArray(config.args);
}
}
delete config.data;
// 还原args为可视化配置结构(args + addOnArgs)
if (config.args) {
if (innerArgs) {
@ -1260,13 +1274,22 @@ export const getEventControlConfig = (
// 刷新组件时,处理是否追加事件变量
if (config.actionType === 'reload') {
action.args = null;
action.data = null;
action.dataMergeMode = undefined;
action.args =
action.__rendererName === 'crud'
? {
...action.args,
resetPage: config.__resetPage ?? true
}
: undefined;
if (config.__addParam) {
action.dataMergeMode = config.dataMergeMode || 'merge';
action.args = undefined;
action.data = undefined;
if (config.__addParamType === 'custom') {
action.args = comboArrayToObject(config.__reloadParams || []);
action.data = comboArrayToObject(config.__reloadParams || []);
}
}
}