amis-saas-8338 优化多个loading配置

Change-Id: Ibf187b85fb3aa74c21875b4b0a6ffb9ac6d692a4
This commit is contained in:
meerkat-morecats 2022-11-30 10:31:04 +08:00
parent abf0861e62
commit 1b36da34ce
24 changed files with 238 additions and 23 deletions

View File

@ -1,6 +1,6 @@
{
"name": "amis-editor",
"version": "5.2.1-beta.32",
"version": "5.2.2-alpha.5",
"description": "amis 可视化编辑器",
"main": "lib/index.js",
"module": "esm/index.js",

View File

@ -899,6 +899,12 @@ export class CRUDPlugin extends BasePlugin {
type: 'divider'
},
getSchemaTpl('loadingConfig', {}, {context}),
{
type: 'divider'
},
{
label: '默认消息提示',
type: 'combo',

View File

@ -106,6 +106,7 @@ export class CardsPlugin extends BasePlugin {
type: 'input-text',
label: '打开外部链接'
},
isCRUDBody
? null
: {
@ -116,6 +117,7 @@ export class CardsPlugin extends BasePlugin {
description: '绑定当前环境变量',
test: !isCRUDBody
},
{
name: 'placeholder',
value: '暂无数据',

View File

@ -124,7 +124,16 @@ export class ButtonGroupControlPlugin extends BasePlugin {
},
{
title: '按钮管理',
body: [getSchemaTpl('optionControlV2')]
body: [
getSchemaTpl('optionControlV2'),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source || !this.options'
},
{context}
)
]
},
getSchemaTpl('status', {
isFormItem: true

View File

@ -158,6 +158,14 @@ export class ChainedSelectControlPlugin extends BasePlugin {
)
}),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source || !this.options'
},
{context}
),
{
type: 'input-text',
name: 'labelField',

View File

@ -195,7 +195,14 @@ export class CheckboxesControlPlugin extends BasePlugin {
form: {
body: [getSchemaTpl('deleteApi')]
}
})
}),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source || !this.options'
},
{context}
)
]
},
getSchemaTpl('status', {isFormItem: true}),

View File

@ -724,6 +724,18 @@ export class FormPlugin extends BasePlugin {
type: 'divider'
},
getSchemaTpl(
'loadingConfig',
{
label: '加载设置'
},
{context}
),
{
type: 'divider'
},
isCRUDFilter
? {
name: 'messages',

View File

@ -120,7 +120,9 @@ export class CityControlPlugin extends BasePlugin {
name: 'searchable',
label: '是否出搜索框',
pipeIn: defaultValue(false)
})
}),
getSchemaTpl('loadingConfig', {}, {context})
]
},
getSchemaTpl('status', {isFormItem: true}),

View File

@ -349,6 +349,13 @@ export class TreeControlPlugin extends BasePlugin {
label: '数据',
showIconField: true
}),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source || !this.options'
},
{context}
),
getSchemaTpl('switch', {
label: '只可选择叶子节点',
name: 'onlyLeaf'

View File

@ -122,7 +122,14 @@ export class ListControlPlugin extends BasePlugin {
body: [
getSchemaTpl('optionControlV2', {
description: '设置选项后,输入时会下拉这些选项供用户参考。'
})
}),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source'
},
{context}
)
]
},
status: {}

View File

@ -202,7 +202,8 @@ export class MatrixControlPlugin extends BasePlugin {
label: tipedLabel('接口', '获取矩阵数据接口'),
name: 'source',
mode: 'normal'
})
}),
getSchemaTpl('loadingConfig', {}, {context})
// getSchemaTpl('value')
]
},

View File

@ -305,7 +305,16 @@ export class NestedSelectControlPlugin extends BasePlugin {
},
{
title: '选项',
body: [getSchemaTpl('treeOptionControl')]
body: [
getSchemaTpl('treeOptionControl'),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source || !this.options'
},
{context}
)
]
},
getSchemaTpl('status', {isFormItem: true}),
getSchemaTpl('validation', {

View File

@ -140,7 +140,14 @@ export class RadiosControlPlugin extends BasePlugin {
name: 'selectFirst',
horizontal: {justify: true, left: 5},
visibleOn: '!this.options'
})
}),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source || !this.options'
},
{context}
)
]
},
getSchemaTpl('status', {isFormItem: true}),

View File

@ -251,6 +251,13 @@ export class SelectControlPlugin extends BasePlugin {
title: '选项',
body: [
getSchemaTpl('optionControlV2'),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source || !this.options'
},
{context}
),
// 模板
getSchemaTpl('optionsMenuTpl', {
manager: this.manager,

View File

@ -324,6 +324,13 @@ export class TabsTransferPlugin extends BasePlugin {
name: 'options'
},
getSchemaTpl('source'),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source || !this.options'
},
{context}
),
getSchemaTpl('joinValues'),
getSchemaTpl('delimiter'),
getSchemaTpl('extractValue'),

View File

@ -234,6 +234,14 @@ export class TransferPlugin extends BasePlugin {
multiple: true
}),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source || !this.options'
},
{context}
),
{
type: 'ae-transferTableControl',
label: '数据',

View File

@ -345,6 +345,13 @@ export class TreeSelectControlPlugin extends BasePlugin {
label: '数据',
showIconField: true
}),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source || !this.options'
},
{context}
),
getSchemaTpl('switch', {
label: '只可选择叶子节点',
name: 'onlyLeaf'

View File

@ -1,4 +1,4 @@
import {registerEditorPlugin} from 'amis-editor-core';
import {BaseEventContext, registerEditorPlugin} from 'amis-editor-core';
import {BasePlugin} from 'amis-editor-core';
import {getSchemaTpl} from 'amis-editor-core';
@ -140,8 +140,8 @@ export class NavPlugin extends BasePlugin {
]
}
};
panelBody = [
getSchemaTpl('tabs', [
panelBodyCreator = (context: BaseEventContext) => {
return getSchemaTpl('tabs', [
{
title: '常规',
body: [
@ -156,7 +156,8 @@ export class NavPlugin extends BasePlugin {
name: 'source',
label: '获取菜单接口',
description: '如果菜单地址希望可以动态设置,请在此填入接口地址'
})
}),
getSchemaTpl('loadingConfig', {}, {context})
]
},
{
@ -174,8 +175,8 @@ export class NavPlugin extends BasePlugin {
title: '显隐',
body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
}
])
];
]);
};
}
registerEditorPlugin(NavPlugin);

View File

@ -97,6 +97,9 @@ export class ServicePlugin extends BasePlugin {
panelTitle = '服务';
panelBodyCreator = (context: BaseEventContext) => {
console.log(context);
console.log(context.node.parent);
console.log(context.node.parent.getComponent());
return getSchemaTpl('tabs', [
{
title: '属性',
@ -186,6 +189,7 @@ export class ServicePlugin extends BasePlugin {
{
title: '全局配置',
body: [
getSchemaTpl('loadingConfig', {}, {context}),
getSchemaTpl('data'),
{
type: 'js-editor',

View File

@ -364,6 +364,12 @@ export class TablePlugin extends BasePlugin {
placeholder: '设置列数',
description:
'设置从左到右多少列内启用自动合并单元格,根据字段值是否相同来决定是否合并。'
},
isCRUDBody
? null
: {
type: 'divider'
}
// {

View File

@ -741,7 +741,13 @@ export class Table2Plugin extends BasePlugin {
})
]
}
])
]),
isCRUDBody
? null
: {
type: 'divider'
}
]
},
{

View File

@ -1,4 +1,4 @@
import {registerEditorPlugin} from 'amis-editor-core';
import {BaseEventContext, registerEditorPlugin} from 'amis-editor-core';
import {BasePlugin} from 'amis-editor-core';
import {defaultValue, getSchemaTpl} from 'amis-editor-core';
@ -43,8 +43,8 @@ export class TasksPlugin extends BasePlugin {
};
panelTitle = '异步任务';
panelBody = [
getSchemaTpl('tabs', [
panelBodyCreator = (context: BaseEventContext) => {
return getSchemaTpl('tabs', [
{
title: '常规',
body: [
@ -111,6 +111,12 @@ export class TasksPlugin extends BasePlugin {
label: '重试接口'
}),
getSchemaTpl('loadingConfig', {}, {context}),
{
type: 'divider'
},
{
name: 'taskNameLabel',
type: 'input-text',
@ -268,8 +274,8 @@ export class TasksPlugin extends BasePlugin {
title: '显隐',
body: [getSchemaTpl('visible')]
}
])
];
]);
};
}
registerEditorPlugin(TasksPlugin);

View File

@ -544,7 +544,13 @@ export class WizardPlugin extends BasePlugin {
visibleOn: 'data.asyncApi != null',
description:
'设置此属性后,表单提交发送保存接口后,还会继续轮训请求该接口,直到返回 finished 属性为 true 才 结束'
})
}),
{
type: 'divider'
},
getSchemaTpl('loadingConfig', {}, {context})
]
},

View File

@ -1,4 +1,9 @@
import {setSchemaTpl, getSchemaTpl, tipedLabel} from 'amis-editor-core';
import {
setSchemaTpl,
getSchemaTpl,
tipedLabel,
BaseEventContext
} from 'amis-editor-core';
import React from 'react';
import {buildApi, Html} from 'amis';
import {get} from 'lodash';
@ -535,3 +540,78 @@ setSchemaTpl('actionApiControl', (patch: any = {}) => {
...rest
};
});
const enum LoadingOption {
HIDDEN,
MERGE,
GLOBAL
}
setSchemaTpl(
'loadingConfig',
(patch: any, {context}: {context: BaseEventContext}) => {
let globalSelector = '';
let parent = context.node.parent;
while (parent && !globalSelector) {
const parentNodeType = parent.type;
if (parentNodeType === 'dialog' || parentNodeType === 'drawer') {
globalSelector = '[role=dialog-body]';
} else if (parentNodeType === 'page') {
globalSelector = '[role=page-body]';
}
parent = parent.parent;
}
return {
name: 'loadingConfig',
type: 'select',
label: '加载设置',
options: [
{
label: '合并到上层loading',
value: LoadingOption.MERGE
},
{
label: '不展示loading',
value: LoadingOption.HIDDEN
},
{
label: '使用页面全局loading',
value: LoadingOption.GLOBAL
}
],
...patch,
pipeOut: (value: LoadingOption) => {
switch (value) {
case LoadingOption.HIDDEN:
return {
show: false
};
case LoadingOption.GLOBAL:
return {
show: true,
root: globalSelector
};
case LoadingOption.MERGE:
return {
show: true
};
default:
return {};
}
},
pipeIn: (value: any = {}) => {
if (value.root) {
return LoadingOption.GLOBAL;
}
if (value.show === false) {
return LoadingOption.HIDDEN;
}
return LoadingOption.MERGE;
}
};
}
);