vendor: amis 6.13.0 base (fork root)

This commit is contained in:
2026-06-16 22:14:57 +08:00
commit 8c8e4247a9
3840 changed files with 2467374 additions and 0 deletions

View File

@@ -0,0 +1,319 @@
export default {
type: 'page',
title: '按钮类组件事件',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'tpl',
tpl: '1.普通按钮',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'button',
label: 'Button',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
},
mouseenter: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发鼠标移入事件'
}
}
]
},
mouseleave: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发鼠标移出事件'
}
}
]
}
}
},
{
type: 'tpl',
tpl: '2.功能按钮',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
api: '/api/mock2/form/saveForm',
body: [
{
type: 'input-text',
name: 'name',
label: '名称'
}
],
actions: [
{
type: 'submit',
label: 'Submit',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
}
},
{
type: 'reset',
label: 'Reset',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
}
}
]
},
{
type: 'tpl',
tpl: '3.按钮组&按钮工具栏',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'button-toolbar',
buttons: [
{
type: 'button',
label: '按钮1',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
}
},
{
type: 'button',
label: '按钮2',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
}
}
]
},
{
type: 'button-group',
buttons: [
{
type: 'button',
label: '按钮1',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
}
},
{
type: 'button',
label: '按钮2',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
}
}
]
},
{
type: 'tpl',
tpl: '4.下拉按钮',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'dropdown-button',
label: '下拉按钮',
buttons: [
{
type: 'button',
label: '按钮1',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
}
},
{
type: 'button',
label: '按钮2',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
}
}
]
},
{
type: 'tpl',
tpl: '5.按钮点选',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'button-group-select',
name: 'a',
options: [
{
label: '选项1',
value: 'a'
},
{
label: '选项2',
value: 'b'
}
],
onEvent: {
change: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点选事件'
}
}
]
}
}
},
{
type: 'tpl',
tpl: '6.作为容器',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'action',
body: [
{
type: 'color',
value: '#108cee'
}
],
onEvent: {
click: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
},
mouseenter: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发鼠标移入事件'
}
}
]
},
mouseleave: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发鼠标移出事件'
}
}
]
}
}
}
]
};

View File

@@ -0,0 +1,94 @@
export default {
type: 'page',
title: '轮播图组件事件',
regions: ['body', 'toolbar', 'header'],
data: {
index: 3
},
body: [
{
type: 'action',
label: '上一张',
level: 'primary',
className: 'mr-3 mb-3',
onEvent: {
click: {
actions: [
{
actionType: 'prev',
componentId: 'carousel_001'
}
]
}
}
},
{
type: 'action',
label: '下一张',
level: 'primary',
className: 'mr-3 mb-3',
onEvent: {
click: {
actions: [
{
actionType: 'next',
componentId: 'carousel_001'
}
]
}
}
},
{
type: 'action',
label: '滚动到第三张',
level: 'primary',
className: 'mr-3 mb-3',
onEvent: {
click: {
actions: [
{
actionType: 'goto-image',
componentId: 'carousel_001',
args: {
activeIndex: '${index}'
}
}
]
}
}
},
{
type: 'carousel',
id: 'carousel_001',
auto: false,
thumbMode: 'cover',
animation: 'slide',
height: 300,
options: [
{
image:
'https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png'
},
{
html: '<div style="width: 100%; height: 300px; background: #e3e3e3; text-align: center; line-height: 300px;">carousel data</div>'
},
{
thumbMode: 'contain',
image: 'https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg'
}
],
onEvent: {
change: {
actions: [
{
actionType: 'toast',
args: {
msg: '滚动至${activeIndex}'
}
}
]
}
}
}
]
};

View File

@@ -0,0 +1,108 @@
export default {
type: 'page',
title: 'chart组件事件',
body: [
{
type: 'button',
label: '显示提示框',
onEvent: {
click: {
actions: [
{
componentId: 'chart01',
actionType: 'showTip',
args: {
type: 'showTip',
seriesIndex: 0,
name: '',
dataIndex: 8
}
}
]
}
}
},
{
type: 'chart',
id: 'chart01',
onEvent: {
click: {
actions: [
{
actionType: 'dialog',
dialog: {
title: '详情',
body: [
{
type: 'tpl',
tpl: '<span>当前选中值 ${value|json}<span>'
},
{
type: 'chart',
api: '/api/mock2/chart/chart1'
}
]
}
}
]
},
legendselectchanged: {
actions: [
{
actionType: 'toast',
args: {
msg: '${event.data|json}'
}
}
]
}
},
config: {
title: {
text: '极坐标双数值轴'
},
legend: {
data: ['line']
},
polar: {
center: ['50%', '54%']
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
}
},
angleAxis: {
type: 'value',
startAngle: 0
},
radiusAxis: {
min: 0
},
series: [
{
coordinateSystem: 'polar',
name: 'line',
type: 'line',
showSymbol: false,
data: [
[0, 0],
[0.03487823687206265, 1],
[0.06958655048003272, 2],
[0.10395584540887964, 3],
[0.13781867790849958, 4],
[0.17101007166283433, 5],
[0.2033683215379001, 6],
[0.2347357813929454, 7],
[0.26495963211660245, 8],
[0.2938926261462365, 9],
[0.3213938048432697, 10]
]
}
],
animationDuration: 2000
}
}
]
};

View File

@@ -0,0 +1,226 @@
export default {
type: 'page',
title: '时间类组件事件',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'tpl',
tpl: 'inputDate日期',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: false,
body: [
{
type: 'group',
body: [
{
name: 'trigger1',
id: 'trigger1',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-inputDate-receiver',
description: '点击清空指定日期组件的具体时间'
}
]
}
}
},
{
name: 'clear-inputDate',
id: 'clear-inputDate-receiver',
type: 'input-date',
label: 'clear动作测试',
mode: 'row',
value: new Date()
}
]
},
{
type: 'group',
body: [
{
name: 'trigger2',
id: 'trigger2',
type: 'action',
label: 'reset触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'reset',
componentId: 'reset-inputDate-receiver',
description: '点击重置指定日期组件的时间'
}
]
}
}
},
{
name: 'reset-inputDate',
id: 'reset-inputDate-receiver',
type: 'input-date',
label: 'reset动作测试',
mode: 'row',
value: new Date(),
resetValue: new Date()
}
]
}
]
},
{
type: 'tpl',
tpl: 'inputDateRange日期范围',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: false,
body: [
{
type: 'group',
body: [
{
name: 'trigger3',
id: 'trigger3',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-inputDateRange-receiver',
description: '点击清空指定日期组件的具体时间'
}
]
}
}
},
{
name: 'clear-inputDate',
id: 'clear-inputDateRange-receiver',
type: 'input-date-range',
label: 'clear动作测试',
mode: 'row',
value: [new Date(2100, 1, 1), new Date(2100, 1, 2)]
}
]
},
{
type: 'group',
body: [
{
name: 'trigger4',
id: 'trigger4',
type: 'action',
label: 'reset触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'reset',
componentId: 'reset-inputDateRange-receiver',
description: '点击重置指定日期组件的时间'
}
]
}
}
},
{
name: 'reset-inputDateRange',
id: 'reset-inputDateRange-receiver',
type: 'input-date-range',
label: 'reset动作测试',
mode: 'row',
value: [new Date(2100, 1, 1), new Date(2100, 1, 2)],
resetValue: [new Date(2100, 1, 1), new Date(2100, 1, 2)]
}
]
}
]
},
{
type: 'form',
debug: false,
body: [
{
type: 'group',
body: [
{
name: 'trigger5',
id: 'trigger5',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-inputMonthRange-receiver',
description: '点击清空指定日期组件的具体时间'
}
]
}
}
},
{
name: 'clear-inputMonthRange',
id: 'clear-inputMonthRange-receiver',
type: 'input-month-range',
label: 'clear动作测试',
mode: 'row',
value: [new Date(2100, 1, 1), new Date(2100, 1, 2)]
}
]
},
{
type: 'group',
body: [
{
name: 'trigger6',
id: 'trigger6',
type: 'action',
label: 'reset触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'reset',
componentId: 'reset-inputMonthRange-receiver',
description: '点击重置指定日期组件的时间'
}
]
}
}
},
{
name: 'reset-inputMonthRange',
id: 'reset-inputMonthRange-receiver',
type: 'input-month-range',
label: 'reset动作测试',
mode: 'row',
value: [new Date(2100, 1, 1), new Date(2100, 1, 2)],
resetValue: [new Date(2100, 1, 1), new Date(2100, 1, 2)]
}
]
}
]
}
]
}

View File

@@ -0,0 +1,75 @@
const changeEvent = {
actions: [
{
actionType: 'dialog',
args: {
val: '${file}'
},
dialog: {
title: `派发change事件`,
data: {
val: '${val}'
},
body: [
{
type: 'tpl',
tpl: '${val|json}'
}
]
}
}
]
};
export default {
type: 'page',
title: 'excel事件',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'tpl',
tpl: 'InputExcel',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
api: '/api/mock2/form/saveForm',
body: [
{
type: 'group',
body: [
{
name: 'trigger1',
id: 'trigger1',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-input-excel',
description: '点击清除数据'
}
]
}
}
},
{
type: 'input-excel',
id: 'clear-input-excel',
name: 'file',
multiple: true,
onEvent: {
change: changeEvent
}
}
]
}
]
}
]
};

View File

@@ -0,0 +1,346 @@
export default {
type: 'page',
title: 'form组件支持动作示例',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'action',
label: '清空表单',
level: 'primary',
className: 'mr-3 mb-3',
onEvent: {
click: {
actions: [
{
componentId: 'form-action-receiver',
actionType: 'clear'
}
]
}
}
},
{
type: 'action',
label: '重置表单',
level: 'primary',
className: 'mr-3 mb-3',
onEvent: {
click: {
actions: [
{
actionType: 'reset',
componentId: 'form-action-receiver'
}
]
}
}
},
{
type: 'action',
label: '校验表单',
level: 'primary',
className: 'mr-3 mb-3',
onEvent: {
click: {
actions: [
{
actionType: 'validate',
componentId: 'form-action-receiver'
}
]
}
}
},
{
type: 'action',
label: '重新加载表单组件',
level: 'primary',
className: 'mr-3 mb-3',
onEvent: {
click: {
actions: [
{
actionType: 'reload',
componentId: 'form-action-receiver'
}
]
}
}
},
{
type: 'action',
label: '提交表单',
level: 'primary',
className: 'mr-3 mb-3',
onEvent: {
click: {
actions: [
{
actionType: 'submit',
componentId: 'form-action-receiver'
}
]
}
}
},
{
type: 'action',
label: '将第一个表单中的姓名赋值给下面的输入框(我的名称)',
level: 'primary',
className: 'mr-3 mb-3',
onEvent: {
click: {
actions: [
{
actionType: 'setValue',
componentId: 'u:text_001',
args: {
value: '${GETRENDERERDATA("form-action-receiver", "name")}'
}
}
]
}
}
},
{
type: 'input-text',
name: 'name',
label: '我的姓名',
className: 'mt-3',
mode: 'horizontal',
id: 'u:text_001'
},
{
name: 'form-action-receiver',
id: 'form-action-receiver',
title: '表单:用于接收上面按钮的动作,派发form本身的事件',
type: 'form',
debug: true,
api: '/api/mock2/form/saveForm',
data: {
data1: '初始化数据1',
data2: '初始化数据2'
},
initApi:
'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/initData',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名',
required: true,
validateOnChange: true
},
{
type: 'input-text',
name: 'email',
label: '邮箱',
required: true,
validateOnChange: true,
validations: {
isEmail: true
}
}
],
onEvent: {
change: {
actions: [
{
actionType: 'toast',
args: {
msg: '表单值变化:${event.data|json}'
}
}
]
},
inited: {
actions: [
{
actionType: 'toast',
args: {
msg: '表单初始化完成:${event.data|json}'
}
}
]
},
formItemValidateSucc: {
actions: [
{
actionType: 'toast',
args: {
msg: '表单项校验成功:${event.data|json}'
}
}
]
},
formItemValidateError: {
actions: [
{
actionType: 'toast',
args: {
msg: '表单项校验失败:${event.data|json}'
}
}
]
},
validateSucc: {
actions: [
{
actionType: 'toast',
args: {
msg: '表单校验成功:${event.data|json}'
}
}
]
},
validateError: {
actions: [
{
actionType: 'toast',
args: {
msg: '表单校验失败:${event.data|json}'
}
}
]
},
submitSucc: {
actions: [
{
actionType: 'toast',
args: {
msg: '提交失败:${event.data|json}'
}
}
]
}
}
},
{
type: 'form',
debug: true,
api: '/api/mock2/form/saveForm',
title: '表单:派发formItem的校验事件',
data: {
data1: '初始化数据1',
data2: '初始化数据2'
},
initApi:
'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/initData',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名',
required: true,
validateOnChange: true
},
{
type: 'input-text',
name: 'email',
label: '邮箱',
required: true,
validateOnChange: true,
validations: {
isEmail: true
}
}
],
onEvent: {
formItemValidateSucc: {
actions: [
{
actionType: 'toast',
args: {
msg: '表单项校验成功:${event.data|json}'
}
}
]
},
formItemValidateError: {
actions: [
{
actionType: 'toast',
args: {
msg: '表单项校验失败:${event.data|json}'
}
}
]
}
}
},
{
type: 'form',
debug: true,
title: '表单:提交表单无target,无api,只触发提交成功事件',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名',
required: true,
validateOnChange: true
},
{
type: 'input-text',
name: 'email',
label: '邮箱',
required: true,
validateOnChange: true,
validations: {
isEmail: true
}
}
],
onEvent: {
submitSucc: {
actions: [
{
actionType: 'toast',
args: {
msg: '提交成功:${event.data|json}'
}
}
]
}
}
},
{
type: 'form',
debug: true,
api: '/api/mock2/form/saveForm',
title:
'表单:配置submit事件后,点击提交按钮或者触发表单提交动作时将不会触发表单校验、提交到api或者target等行为,所有行为需要自己配置',
body: [
{
type: 'input-text',
name: 'name',
label: '姓名',
required: true,
validateOnChange: true
},
{
type: 'input-text',
name: 'email',
label: '邮箱',
required: true,
validateOnChange: true,
validations: {
isEmail: true
}
}
],
onEvent: {
submit: {
actions: [
{
actionType: 'toast',
args: {
msg: '提交成功:${event.data|json}'
}
}
]
}
}
}
]
};

View File

@@ -0,0 +1,427 @@
export default {
type: 'page',
title: '输入类组件事件',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'tpl',
tpl: '事件',
inline: false,
wrapperComponent: 'h1'
},
{
type: 'form',
name: 'input-event-form',
debug: true,
api: '/api/mock2/form/saveForm',
body: ['click', 'focus', 'blur', 'enter', 'change'].map(event => ({
name: `${event}-dispatch`,
id: `${event}-dispatch`,
type: 'input-text',
clearable: true,
label: `${event}事件测试`,
mode: 'horizontal',
horizontal: {
justify: true,
left: 4
},
multiple: true,
options: [
{
label: 'aa',
value: 'aa'
},
{
label: 'bb',
value: 'bb'
}
],
onEvent: {
[event]: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: `触发<b>${event}</b>事件`
}
}
]
}
}
}))
},
{
type: 'divider'
},
{
type: 'tpl',
tpl: '动作',
inline: false,
wrapperComponent: 'h1'
},
{
type: 'tpl',
tpl: 'InputText输入框',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
name: 'text-form',
debug: true,
api: '/api/mock2/form/saveForm',
body: [
{
type: 'group',
body: [
{
name: 'trigger1',
id: 'trigger1',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-receiver',
description: '点击清空指定输入框的内容'
},
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发clear事件'
}
}
]
}
}
},
{
name: 'clear-receiver',
id: 'clear-receiver',
type: 'input-text',
clearable: true,
label: 'clear动作测试',
mode: 'row',
value: 'chunk of text ready to be cleared.'
}
]
},
{
type: 'group',
body: [
{
name: 'trigger2',
id: 'trigger2',
type: 'action',
label: 'focus触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'focus',
componentId: 'focus-receiver',
description: '点击使指定输入框聚焦'
},
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
}
}
},
{
name: 'focus-receiver',
id: 'focus-receiver',
type: 'input-text',
label: 'focus动作测试',
mode: 'row'
}
]
}
]
},
{
type: 'divider'
},
{
type: 'tpl',
tpl: 'Textarea 多行文本输入框',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
name: 'textarea-form',
debug: true,
api: '/api/mock2/form/saveForm',
body: [
{
type: 'group',
body: [
{
name: 'textarea-trigger1',
id: 'textarea-trigger1',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'textarea-clear-receiver',
description: '点击清空指定输入框的内容'
},
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发clear事件'
}
}
]
}
}
},
{
name: 'textarea-clear-receiver',
id: 'textarea-clear-receiver',
type: 'textarea',
clearable: true,
label: 'clear动作测试',
mode: 'row',
value: 'chunk of text ready to be cleared.'
}
]
},
{
type: 'group',
body: [
{
name: 'textarea-trigger2',
id: 'textarea-trigger2',
type: 'action',
label: 'focus触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'focus',
componentId: 'textarea-focus-receiver',
description: '点击使指定输入框聚焦'
},
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
}
}
},
{
name: 'textarea-focus-receiver',
id: 'textarea-focus-receiver',
type: 'textarea',
label: 'focus动作测试',
mode: 'row'
}
]
}
]
},
{
type: 'divider'
},
{
type: 'tpl',
tpl: 'InputNumber数字输入框',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
type: 'group',
body: [
{
name: 'trigger1',
id: 'trigger1',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-input-number-receiver',
description: '点击清空指定输入框的内容'
}
]
}
}
},
{
name: 'clear-input-number-receiver',
id: 'clear-input-number-receiver',
type: 'input-number',
label: 'clear动作测试',
value: 1,
onEvent: {
blur: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发blur事件'
}
}
]
},
focus: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
},
change: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发change事件'
}
}
]
}
}
}
]
}
]
},
{
type: 'divider'
},
{
type: 'tpl',
tpl: 'Editor 编辑器',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
name: 'editor-form',
debug: true,
api: '/api/mock2/form/saveForm',
body: [
{
type: 'group',
mode: 'inline',
body: [
{
name: 'editor-trigger2',
id: 'editor-trigger2',
type: 'action',
label: '编辑器focus触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'focus',
componentId: 'editor-focus-receiver',
description: '点击使指定输入框聚焦'
},
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
}
}
},
{
name: 'editor-focus-receiver',
id: 'editor-focus-receiver',
type: 'editor',
language: 'javascript',
label: '编辑器focus动作测试',
value:
"function HelloWorld() {\n console.log('Hello World');\n}",
mode: 'row'
}
]
},
{
type: 'group',
mode: 'inline',
body: [
{
name: 'diffeditor-trigger2',
id: 'diffeditor-trigger2',
type: 'action',
label: '对比编辑器focus触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'focus',
componentId: 'diffeditor-focus-receiver',
description: '点击使指定输入框聚焦'
},
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
}
}
},
{
name: 'diffeditor-focus-receiver',
id: 'diffeditor-focus-receiver',
type: 'diff-editor',
label: '对比编辑器focus动作测试',
diffValue:
"function HelloWorld() {\n console.log('Hello World');\n}",
value:
"function HelloWorld() {\n console.log('Hello World!');\n}",
mode: 'row'
}
]
}
]
}
]
};

View File

@@ -0,0 +1,84 @@
export default {
type: 'page',
title: '数字输入组件事件',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'tpl',
tpl: 'InputNumber数字输入框',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
type: 'group',
body: [
{
name: 'trigger1',
id: 'trigger1',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-input-number-receiver',
description: '点击清空指定输入框的内容'
}
]
}
}
},
{
name: 'clear-input-number-receiver',
id: 'clear-input-number-receiver',
type: 'input-number',
label: 'clear动作测试',
value: 1,
onEvent: {
blur: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发blur事件'
}
}
]
},
focus: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
},
change: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发change事件'
}
}
]
}
}
}
]
}
]
}
]
};

View File

@@ -0,0 +1,92 @@
export default {
type: 'page',
title: '评分组件事件',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'tpl',
tpl: 'InputRating组件',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
name: 'input-rating-clear',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-input-rating-clear-receiver',
description: '点击清空内容'
}
]
}
}
},
{
name: 'rate-clear',
id: 'clear-input-rating-clear-receiver',
type: 'input-rating',
value: 3,
onEvent: {
change: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发change事件'
}
}
]
}
}
},
{
name: 'input-rating-reset',
type: 'action',
label: 'reset触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-input-rating-reset-receiver',
description: '点击清空内容'
}
]
}
}
},
{
name: 'rate-reset',
id: 'clear-input-rating-reset-receiver',
type: 'input-rating',
value: 3,
resetValue: 3,
onEvent: {
change: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发change事件'
}
}
]
}
}
}
]
}
]
};

View File

@@ -0,0 +1,348 @@
export default {
"type": "page",
"title": "InputTable事件动作",
"regions": [
"body"
],
"body": [
{
"type": "button",
"label": "setValue 未指定index",
"onEvent": {
"click": {
"actions": [
{
"componentId": "u:39c47c713ae6",
"args": {
"value": [
{
"name": "zzl",
"color": "#ff0000"
},
{
"name": "zzl测试下setValue动作",
"color": "#00ff00"
}
]
},
"actionType": "setValue"
}
]
}
},
"id": "u:691a43978f4e"
},
{
"type": "button",
"label": "setValue 指定index",
"onEvent": {
"click": {
"actions": [
{
"componentId": "u:39c47c713ae6",
"args": {
"index": 2,
"value": {
"name": "setValue 指定index",
"color": "#00ff00"
}
},
"actionType": "setValue"
}
]
}
},
"id": "u:691a43978f4e"
},
{
"type": "button",
"label": "addItem 未指定index",
"onEvent": {
"click": {
"actions": [
{
"componentId": "u:39c47c713ae6",
"args": {
"item": [
{
"name": "${name}",
"color": "#ffffff"
},
{
"name": "插入2",
"color": "#2468f2"
}
]
},
"actionType": "addItem"
}
]
}
},
"id": "u:691a43978f4e"
},
{
"type": "button",
"label": "addItem 指定index",
"onEvent": {
"click": {
"actions": [
{
"componentId": "u:39c47c713ae6",
"args": {
"index": 1,
"item": [
{
"name": "index 1",
"color": "#ffffff"
},
{
"name": "index 2",
"color": "#ffffff"
}
]
},
"actionType": "addItem"
}
]
}
},
"id": "u:691a43978f4e"
},
{
"type": "button",
"label": "deleteItem",
"onEvent": {
"click": {
"actions": [
{
"componentId": "u:39c47c713ae6",
"args": {
"condition": "${CONTAINS(name, 'index')}"
},
"actionType": "deleteItem"
}
]
}
},
"id": "u:691a43978f4e"
},
{
"type": "button",
"label": "clear",
"onEvent": {
"click": {
"actions": [
{
"componentId": "u:39c47c713ae6",
"actionType": "clear"
}
]
}
},
"id": "u:691a43978f4e"
},
{
"type": "button",
"label": "reset",
"onEvent": {
"click": {
"actions": [
{
"componentId": "u:39c47c713ae6",
"actionType": "reset"
}
]
}
},
"id": "u:691a43978f4e"
},
{
"type": "button",
"label": "老add",
"actionType": "add",
"target": "table",
"payload": {
"name": "black",
"color": "#000000"
}
},
{
"type": "button",
"label": "老delete",
"target": "table",
"actionType": "delete",
"payload": {
"name": "black",
}
},
{
"type": "input-text",
"label": "测试获取父级数据",
"name": "name",
"id": "u:5aea6935a4f2",
"value": "23455656"
},
{
"type": "input-table",
"name": "table",
"label": "表格表单",
// "needConfirm": false,
"value": [
{
"name": "zzl",
"color": "#ff0000"
},
{
"name": "zzl测试下setValue动作",
"color": "#00ff00"
}
],
// "valueField": "name",
"resetValue": [
{
name: 'resetValue',
color: '#ffffff'
}
],
"columns": [
{
"label": "color",
"name": "color",
"quickEdit": {
"type": "input-color",
"id": "u:1d828c468cbd"
},
"type": "text",
"id": "u:d2dc063d4a3e"
},
{
"label": "说明文字",
"name": "name",
"quickEdit": {
"type": "input-text",
"mode": "inline",
"id": "u:c9db91691264"
},
"type": "text",
"id": "u:6b9d980a101d"
}
],
"strictMode": false,
"id": "u:39c47c713ae6",
"addable": true,
"copyable": true,
"editable": true,
"removable": true,
"draggable": false,
"valueField": "name",
"onEvent": {
"add": {
"actions": [
{
"args": {
"msg": "add ${event.data | json}"
},
"actionType": "toast"
}
],
},
"addConfirm": {
"actions": [
{
"args": {
"msg": "addConfirm ${event.data | json}"
},
"actionType": "toast"
}
]
},
"addSuccess": {
"actions": [
{
"args": {
"msg": "addSuccess ${event.data | json}"
},
"actionType": "toast"
}
]
},
"edit": {
"actions": [
{
"args": {
"msg": "edit ${event.data | json}"
},
"actionType": "toast"
}
],
},
"editConfirm": {
"actions": [
{
"args": {
"msg": "editConfirm ${event.data | json}"
},
"actionType": "toast"
}
]
},
"editSuccess": {
"actions": [
{
"args": {
"msg": "editSuccess ${event.data | json}"
},
"actionType": "toast"
}
]
},
"editFail": {
"actions": [
{
"args": {
"msg": "editFail ${event.data | json}"
},
"actionType": "toast"
}
]
},
"delete": {
"actions": [
{
"args": {
"msg": "delete ${event.data | json}"
},
"actionType": "toast"
}
]
},
"deleteSuccess": {
"actions": [
{
"args": {
"msg": "deleteSuccess ${event.data | json}"
},
"actionType": "toast"
}
]
},
"deleteFail": {
"actions": [
{
"args": {
"msg": "deleteFail ${event.data | json}"
},
"actionType": "toast"
}
]
}
}
},
{
"type": "tpl",
"tpl": "${table | json}"
}
],
"id": "u:6bbc05138917"
}

View File

@@ -0,0 +1,213 @@
export default {
type: 'page',
title: '树形选择框',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'form',
debug: true,
body: [
{
name: 'input-tree-clear',
type: 'action',
label: 'clear触发器',
level: 'primary',
className: 'mr-3',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'input-tree-action',
description: '点击清空内容'
}
]
}
}
},
{
name: 'input-tree-reset',
type: 'action',
label: 'reset触发器',
level: 'primary',
className: 'mr-3',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'input-tree-action',
description: '点击清空内容'
}
]
}
}
},
{
name: 'input-tree-expand',
type: 'action',
label: 'expand触发器(openLevel: 2)',
level: 'primary',
className: 'mr-3',
onEvent: {
click: {
actions: [
{
actionType: 'expand',
componentId: 'input-tree-action',
description: '点击展开',
args: {
openLevel: 2
}
}
]
}
}
},
{
name: 'input-tree-collapse',
type: 'action',
label: 'collapse触发器',
level: 'primary',
className: 'mr-3',
onEvent: {
click: {
actions: [
{
actionType: 'collapse',
componentId: 'input-tree-action',
description: '点击收起'
}
]
}
}
},
{
type: 'input-tree',
id: 'input-tree-action',
name: 'tree',
label: 'Tree',
creatable: true,
removable: true,
editable: true,
initiallyOpen: false,
unfoldedLevel: 1,
deferApi: '/api/mock2/form/deferOptions?label=${label}&waitSeconds=2',
options: [
{
label: 'Folder A',
value: 1,
children: [
{
label: 'file A(懒加载)',
defer: true,
value: 2
},
{
label: 'Folder B',
value: 3,
children: [
{
label: 'file b1',
value: 3.1
},
{
label: 'file b2',
value: 3.2
}
]
}
]
},
{
label: 'file C',
value: 4
},
{
label: 'file D',
value: 5
}
],
onEvent: {
change: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发change事件${tree}'
}
}
]
},
add: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发add事件${tree|json}'
}
},
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发add事件${items|json}'
}
}
]
},
edit: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发edit事件${tree|json}'
}
},
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发edit事件${items|json}'
}
}
]
},
delete: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发delete事件${tree|json}'
}
},
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发delete事件${items|json}'
}
}
]
},
loadFinished: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发loadFinished事件${tree|json}'
}
}
]
}
}
}
]
}
]
};

View File

@@ -0,0 +1,101 @@
export default {
type: 'page',
title: '列表类组件事件',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'flex',
direction: 'row',
justify: 'flex-start',
items: [
{
type: 'html',
html: '<h2>List组件单行点击事件 - itemClick</h2>',
className: 'mr-4'
},
{
type: 'tag',
label: '2.4.0',
closable: false
}
]
},
{
type: 'service',
api: '/api/mock2/sample?perPage=5',
body: [
{
type: 'panel',
title: '',
body: {
type: 'list',
source: '$rows',
listItem: {
body: [
{
type: 'hbox',
columns: [
{
label: 'Engine',
name: 'engine'
},
{
name: 'version',
label: 'Version'
}
]
}
],
actions: [
{
type: 'button',
level: 'link',
label: '查看详情',
actionType: 'dialog',
dialog: {
title: '查看详情',
body: {
type: 'form',
body: [
{
label: 'Engine',
name: 'engine',
type: 'static'
},
{
name: 'version',
label: 'Version',
type: 'static'
}
]
}
}
}
]
},
onEvent: {
itemClick: {
actions: [
{
actionType: 'dialog',
dialog: {
title: 'Event触发的Dialog',
closeOnEsc: true,
body: '当前行的数据engine: ${item.data.engine}, version: ${item.data.version}'
}
},
{
actionType: 'custom',
script:
"console.log('点击行的索引值', event.data.item.index)"
}
]
}
}
}
}
]
}
]
};

View File

@@ -0,0 +1,97 @@
export default {
type: 'page',
initApi: '/api/mock2/page/initData?keywords=${keywords}',
body: [
{
type: 'form',
debug: true,
body: [
{
type: 'search-box',
name: 'keywords',
id: 'searchbox01',
onEvent: {
search: {
actions: [
{
actionType: 'toast',
args: {
msg: '${keywords}'
}
}
]
},
change: {
actions: [
{
actionType: 'toast',
args: {
msg: '${keywords}'
}
}
]
},
focus: {
actions: [
{
actionType: 'toast',
args: {
msg: '${keywords}'
}
}
]
},
blur: {
actions: [
{
actionType: 'toast',
args: {
msg: '${keywords}'
}
}
]
}
}
}
]
},
{
type: 'button',
label: '清空',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'searchbox01'
}
]
}
}
},
{
type: 'button',
label: '更新值',
onEvent: {
click: {
actions: [
{
actionType: 'setValue',
componentId: 'searchbox01',
args: {
value: 'Jerry'
}
}
]
}
}
},
{
type: 'tpl',
tpl: '<p>关键字:${keywords}</p><p>返回结果:${&|json}</p>'
}
]
};

View File

@@ -0,0 +1,635 @@
const change = name => ({
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: `派发change事件\${${name}|json\}`
}
}
]
});
const add = {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: 'clear-select: ${clear-select|json},items: ${items|json}'
}
}
]
};
const edit = {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: 'clear-select: ${clear-select|json},items: ${items|json}'
}
}
]
};
const del = {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: 'clear-select: ${clear-select|json},items: ${items|json}'
}
}
]
};
const blur = {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发blur事件'
}
}
]
};
const focus = {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
};
const options = [
{
label: '选项A',
value: 'A'
},
{
label: '选项B',
value: 'B'
},
{
label: '选项C',
value: 'C'
}
];
export default {
type: 'page',
title: '下拉框组件事件',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'tpl',
tpl: 'Select下拉框',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
type: 'group',
body: [
{
name: 'trigger1',
id: 'trigger1',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-select',
description: '点击清空指定下拉框选中值'
}
]
}
}
},
{
name: 'clear-select',
id: 'clear-select',
type: 'select',
label: 'clear动作测试',
mode: 'row',
value: 'A,B,C',
multiple: true,
checkAll: true,
creatable: true,
editable: true,
removable: true,
options,
onEvent: {
change: change('clear-select'),
blur,
focus,
add,
edit,
delete: del
}
}
]
}
]
},
{
type: 'tpl',
tpl: 'inputTag标签选择器',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
type: 'group',
body: [
{
name: 'trigger2',
id: 'trigger2',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-input-tag',
description: '点击清空指定下拉框选中值'
}
]
}
}
},
{
name: 'clear-input-tag',
id: 'clear-input-tag',
type: 'input-tag',
label: 'clear动作测试',
mode: 'row',
value: 'A,B',
multiple: true,
options,
onEvent: {
change: change('clear-input-tag'),
blur,
focus
}
}
]
}
]
},
{
type: 'tpl',
tpl: 'matrix-checkboxes矩阵勾选',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
type: 'group',
body: [
{
name: 'trigger3',
id: 'trigger3',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-matrix-checkboxes',
description: '点击清空指定下拉框选中值'
}
]
}
}
},
{
name: 'clear-matrix-checkboxes',
id: 'clear-matrix-checkboxes',
type: 'matrix-checkboxes',
rowLabel: '行标题说明',
columns: [
{
label: '列1'
},
{
label: '列2'
}
],
rows: [
{
label: '行1'
},
{
label: '行2'
}
],
onEvent: {
change: change('clear-matrix-checkboxes')
}
}
]
}
]
},
{
type: 'tpl',
tpl: 'radios单选框',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
type: 'group',
body: [
{
name: 'trigger4',
id: 'trigger4',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-radios',
description: '点击清空指定下拉框选中值'
}
]
}
}
},
{
name: 'clear-radios',
id: 'clear-radios',
type: 'radios',
options,
onEvent: {
change: change('clear-radios')
}
}
]
}
]
},
{
type: 'tpl',
tpl: 'nested-select嵌套下拉框',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
type: 'group',
body: [
{
name: 'trigger6',
id: 'trigger6',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-nested-select',
description: '点击清空指定嵌套下拉框选中值'
}
]
}
}
},
{
name: 'clear-nested-select',
id: 'clear-nested-select',
type: 'nested-select',
label: 'clear动作测试',
mode: 'row',
options: [
{
label: '选项A',
value: 'A',
children: []
},
{
label: '选项B',
value: 'B',
children: [
{
label: '选项C',
value: 'C'
},
{
label: '选项D',
value: 'D'
}
]
}
],
multiple: false,
hideNodePathLabel: false,
onlyChildren: false,
joinValues: true,
delimiter: '。',
onEvent: {
change: change('clear-nested-select'),
blur,
focus
}
}
]
}
]
},
{
type: 'tpl',
tpl: 'chained-select级联下拉框',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
type: 'group',
body: [
{
name: 'trigger11',
id: 'trigger11',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-chained-select',
description: '点击清空指定级联下拉框选中值'
}
]
}
}
},
{
name: 'clear-chained-select',
id: 'clear-chained-select',
label: 'clear动作测试',
mode: 'row',
type: 'chained-select',
source:
'/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4',
value: 'a,b',
onEvent: {
change: change('clear-chained-select'),
blur,
focus
}
}
]
}
]
},
{
type: 'tpl',
tpl: 'input-city城市选择器',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
type: 'group',
body: [
{
name: 'trigger10',
id: 'trigger10',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-input-city',
description: '点击清空城市选择器选中值'
}
]
}
}
},
{
name: 'clear-input-city',
id: 'clear-input-city',
type: 'input-city',
label: 'clear动作测试',
mode: 'row',
onEvent: {
change: change('clear-input-city')
}
}
]
}
]
},
{
type: 'tpl',
tpl: '单选框/复选框',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
type: 'group',
body: [
{
name: 'trigger8',
id: 'trigger8',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-checkbox',
description: '点击清空指定单选框选中值'
}
]
}
}
},
{
name: 'clear-checkbox',
id: 'clear-checkbox',
type: 'checkbox',
label: 'clear动作测试',
mode: 'row',
option: '勾选框',
onEvent: {
change: change('clear-checkbox')
}
}
]
},
{
type: 'group',
body: [
{
name: 'trigger9',
id: 'trigger9',
type: 'action',
mode: 'row',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-checkboxes',
description: '点击清空指定浮选框选中值'
}
]
}
}
},
{
name: 'clear-checkboxes',
id: 'clear-checkboxes',
type: 'checkboxes',
mode: 'row',
label: 'clear动作测试',
options,
onEvent: {
change: change('clear-checkboxes')
}
}
]
}
]
},
{
type: 'tpl',
tpl: 'options类',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
type: 'group',
body: [
{
type: 'group',
body: [
{
name: 'trigger5',
id: 'trigger5',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-options_001',
description: '点击清空指定下拉框选中值'
}
]
}
}
},
{
name: 'clear-options_001',
id: 'clear-options_001',
type: 'button-group-select',
options,
onEvent: {
change: change('clear-options_001')
}
}
]
}
]
},
{
type: 'group',
body: [
{
name: 'trigger5',
id: 'trigger5',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-options_002',
description: '点击清空指定下拉框选中值'
}
]
}
}
},
{
name: 'clear-options_002',
id: 'clear-options_002',
type: 'list-select',
options,
onEvent: {
change: change('clear-options_002')
}
}
]
}
]
}
]
};

View File

@@ -0,0 +1,295 @@
export default {
type: 'page',
title: 'Service功能型容器',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'tpl',
tpl: '事件',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'tpl',
tpl: '<code>fetchInited</code> 事件',
inline: false,
wrapperComponent: 'h3'
},
{
type: 'action',
level: 'success',
label: 'fetchInited',
actionType: 'dialog',
dialog: {
title: 'fetchInited',
body: [
{
type: 'service',
name: 'service-api',
api: '/api/mock2/page/initData',
body: {
type: 'panel',
title: '$title',
body: '现在是:${date}'
},
onEvent: {
fetchInited: {
actions: [
{
actionType: 'toast',
expression: '${!__response.error}',
args: {
msgType: 'success',
msg: 'API inited: <b>${date}</b>'
}
}
]
}
}
}
]
}
},
{
type: 'divider'
},
{
type: 'tpl',
tpl: '对于amis的接口标准来说, status不为0, 则视为请求失败. 该事件额外提供了<code>__response</code>参数用于区分接口状态码实际是200成功, 但接口中的status字段不为0的情况(接口状态码如果为非200, 则不会触发该事件)',
inline: false
},
{
type: 'action',
level: 'danger',
label: 'fetchInited(failed)',
actionType: 'dialog',
dialog: {
title: 'fetchInited(failed)',
body: [
{
type: 'service',
name: 'service-api',
id: 'service-failed',
api: '/api/mock2/service/fail',
body: {
type: 'panel',
title: '$title',
body: [
{
type: 'tpl',
tpl: '<strong>toast消息提示设置了触发条件, 当接口失败时不显示toast, 所以结果只会有1个全局默认的toast, 如果不设置条件则会弹出2个toast.</strong>',
inline: false
},
{
type: 'tpl',
tpl: '错误信息是: ${__response.msg}',
inline: false
}
]
},
onEvent: {
fetchInited: {
actions: [
{
actionType: 'setValue',
args: {
value: '${event.data}'
}
},
{
actionType: 'toast',
expression: '${!__response.error}',
args: {
msgType: 'success',
msg: 'API inited: <b>${date}</b>'
}
}
]
}
}
}
]
}
},
{
type: 'divider'
},
{
type: 'tpl',
tpl: '<code>fetchSchemaInited</code> 事件',
inline: false,
wrapperComponent: 'h3'
},
{
type: 'action',
level: 'info',
label: 'fetchSchemaInited',
actionType: 'dialog',
dialog: {
title: 'fetchSchemaInited',
body: [
{
type: 'service',
name: 'service-schema-api',
schemaApi: '/api/mock2/service/schema?type=form',
onEvent: {
fetchSchemaInited: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: 'SchemaAPI inited: <b>title: ${title}</b>'
}
}
]
}
}
}
]
}
},
{
type: 'divider'
},
{
type: 'tpl',
tpl: '动作',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'tpl',
tpl: '<code>reload</code> 动作',
inline: false,
wrapperComponent: 'h3'
},
{
type: 'action',
label: 'reload触发器',
level: 'primary',
className: 'mb-3',
onEvent: {
click: {
actions: [
{
actionType: 'reload',
componentId: 'service-reload'
}
]
}
}
},
{
type: 'service',
id: 'service-reload',
name: 'service-reload',
api: '/api/mock2/number/random',
body: {
type: 'panel',
title: 'reload动作',
body: '现在是:${random}'
}
},
{
type: 'divider'
},
{
type: 'tpl',
tpl: '<code>rebuild</code> 动作',
inline: false,
wrapperComponent: 'h3'
},
{
type: 'alert',
body: '请选择一种构建方式生成组件',
level: 'info',
showIcon: true,
className: 'mb-3',
visibleOn: 'this.schemaType == null'
},
{
type: 'button-group',
tiled: true,
className: 'mb-3',
buttons: ['form', 'tabs', 'crud'].map(schema => ({
type: 'action',
label: `构建${schema}`,
icon: 'fa fa-hammer',
onEvent: {
click: {
actions: [
{
actionType: 'rebuild',
componentId: 'service-rebuild',
args: {
schemaType: `${schema}`
}
}
]
}
}
}))
},
{
type: 'service',
id: 'service-rebuild',
name: 'service-rebuild',
schemaApi: {
url: '/api/mock2/service/schema?type=${schemaType}',
method: 'post',
sendOn: 'this.schemaType != null'
}
},
{
type: 'divider'
},
{
type: 'tpl',
tpl: '<code>setValue</code> 动作',
inline: false,
wrapperComponent: 'h3'
},
{
type: 'action',
label: 'setValue触发器',
level: 'primary',
className: 'mb-3',
onEvent: {
click: {
actions: [
{
actionType: 'setValue',
componentId: 'service-setvalue',
args: {
value: {language: ['🇨🇳 中国']}
}
}
]
}
}
},
{
type: 'service',
id: 'service-setvalue',
name: 'service-setvalue',
data: {
language: ['🇺🇸 美国']
},
body: {
type: 'panel',
title: 'setValue动作',
body: [
{
type: 'each',
name: 'language',
items: {
type: 'tpl',
tpl: "<span class='label label-default m-l-sm'><%= data.item %></span> "
}
}
]
}
}
]
};

View File

@@ -0,0 +1,37 @@
export default {
type: 'page',
title: '开关组件事件',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'tpl',
tpl: 'Switch组件',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
name: 'switch',
type: 'switch',
option: '开关事件',
onEvent: {
change: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发change事件'
}
}
]
}
}
}
]
}
]
};

View File

@@ -0,0 +1,470 @@
export default {
type: 'page',
title: '表格组件事件',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'tpl',
tpl: '事件',
inline: false,
wrapperComponent: 'h1'
},
{
type: 'tpl',
tpl: '选择表格项事件',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'service',
api: '/api/mock2/sample?perPage=10',
body: [
{
type: 'table',
source: '$rows',
selectable: true,
multiple: true,
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'browser',
label: 'Browser'
},
{
name: 'version',
label: 'Version'
}
],
onEvent: {
selectedChange: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '选中${selectedItems.length}项数据;未选中${unSelectedItems.length}项数据'
}
}
]
}
}
}
]
},
{
type: 'tpl',
tpl: '列排序、列搜索、列筛选事件',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'service',
api: '/api/mock2/sample?perPage=10',
body: [
{
type: 'table',
source: '$rows',
columns: [
{
name: 'id',
label: 'ID',
searchable: true
},
{
name: 'browser',
label: 'Browser',
filterable: {
options: ['Internet Explorer 4.0', 'Internet Explorer 5.0']
}
},
{
name: 'version',
label: 'Version',
sortable: true
}
],
onEvent: {
columnSort: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: 'orderBy:${orderBy},orderDir:${orderDir}'
}
}
]
},
columnFilter: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: 'filterName:${filterName},filterValue:${filterValue}'
}
}
]
},
columnSearch: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: 'searchName:${searchName},searchValue:${searchValue|json}'
}
}
]
}
}
}
]
},
{
type: 'tpl',
tpl: '行排序事件',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'service',
api: '/api/mock2/sample?perPage=10',
body: [
{
type: 'table',
source: '$rows',
draggable: true,
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'browser',
label: 'Browser'
},
{
name: 'version',
label: 'Version'
}
],
onEvent: {
orderChange: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '${movedItems.length}行发生移动'
}
}
]
}
}
}
]
},
{
type: 'tpl',
tpl: '列显示变化事件',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'service',
api: '/api/mock2/sample?perPage=10',
body: [
{
type: 'table',
source: '$rows',
columnsTogglable: true,
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'browser',
label: 'Browser'
},
{
name: 'version',
label: 'Version'
}
],
onEvent: {
columnToggled: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '当前显示${columns.length}列'
}
}
]
}
}
}
]
},
{
type: 'tpl',
tpl: '行单击事件',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'service',
api: '/api/mock2/sample?perPage=10',
body: [
{
type: 'table',
source: '$rows',
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'browser',
label: 'Browser'
},
{
name: 'version',
label: 'Version'
}
],
onEvent: {
rowClick: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '行单击数据:${item|json};行索引:${index}'
}
}
]
}
}
}
]
},
{
type: 'tpl',
tpl: '数据元素点击、鼠标移入、鼠标移出事件(元素可监听事件与元素的组件类型相关)',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'service',
api: '/api/mock2/sample?perPage=10',
body: [
{
type: 'table',
source: '$rows',
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'browser',
label: 'Browser',
type: 'tpl',
onEvent: {
mouseenter: {
weight: 0,
actions: [
{
args: {
msgType: 'info',
position: 'top-right',
closeButton: true,
showIcon: true,
msg: '${nativeEvent.clientX}'
},
actionType: 'toast'
}
]
},
mouseleave: {
weight: 0,
actions: [
{
args: {
msgType: 'info',
position: 'top-right',
closeButton: true,
showIcon: true,
msg: '${nativeEvent.type}'
},
actionType: 'toast'
}
]
}
}
},
{
name: 'version',
label: 'Version',
onEvent: {
click: {
weight: 0,
actions: [
{
args: {
msgType: 'info',
position: 'top-right',
closeButton: true,
showIcon: true,
msg: '${id},${browser},${version}'
},
actionType: 'toast'
}
]
}
}
}
]
}
]
},
{
type: 'divider'
},
{
type: 'tpl',
tpl: '动作',
inline: false,
wrapperComponent: 'h1'
},
{
type: 'button-toolbar',
className: 'm-b',
buttons: [
{
name: 'trigger1',
id: 'trigger1',
type: 'action',
label: '设置表格第一项选中',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'select',
componentId: 'table-select',
description: '点击设置指定表格第一项内容选中',
args: {
selected: 'data.rowIndex === 0'
}
}
]
}
}
},
{
name: 'trigger2',
id: 'trigger2',
type: 'action',
label: '设置表格全部项选中',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'selectAll',
componentId: 'table-select',
description: '点击设置指定表格全部内容选中'
}
]
}
}
},
{
name: 'trigger3',
id: 'trigger3',
type: 'action',
label: '清空表格全部选中项',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clearAll',
componentId: 'table-select',
description: '点击设置指定表格全部选中项清空'
}
]
}
}
},
{
name: 'trigger4',
id: 'trigger4',
type: 'action',
label: '开启表格行排序',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'initDrag',
componentId: 'table-select',
description: '点击开启表格行排序功能'
}
]
}
}
}
]
},
{
type: 'service',
api: '/api/mock2/sample?perPage=10',
body: [
{
id: 'table-select',
type: 'table',
source: '$rows',
selectable: true,
multiple: true,
columns: [
{
name: 'id',
label: 'ID'
},
{
name: 'browser',
label: 'Browser'
},
{
name: 'version',
label: 'Version'
}
]
}
]
}
]
};

View File

@@ -0,0 +1,103 @@
export default {
type: 'page',
title: '标签页组件事件',
regions: ['body', 'toolbar', 'header'],
body: [
{
name: 'trigger1',
id: 'trigger1',
type: 'action',
label: '选项卡1',
level: 'primary',
className: 'mr-3 mb-3',
onEvent: {
click: {
actions: [
{
actionType: 'changeActiveKey',
componentId: 'tabs-change-receiver',
args: {
activeKey: 1
}
}
]
}
}
},
{
name: 'trigger2',
id: 'trigger2',
type: 'action',
label: '选项卡2',
level: 'primary',
className: 'mr-3 mb-3',
onEvent: {
click: {
actions: [
{
actionType: 'changeActiveKey',
componentId: 'tabs-change-receiver',
args: {
activeKey: 2
}
}
]
}
}
},
{
name: 'trigger3',
id: 'trigger3',
type: 'action',
label: '选项卡3',
level: 'primary',
className: 'mr-3 mb-3',
onEvent: {
click: {
actions: [
{
actionType: 'changeActiveKey',
componentId: 'tabs-change-receiver',
args: {
activeKey: 3
}
}
]
}
}
},
{
name: 'tabs-change-receiver',
id: 'tabs-change-receiver',
type: 'tabs',
mode: 'line',
tabs: [
{
title: '选项卡1',
body: '选项卡内容1'
},
{
title: '选项卡2',
body: '选项卡内容2'
},
{
title: '选项卡3',
body: '选项卡内容3'
}
],
onEvent: {
change: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '切换至选项卡${tabs-change-receiver}'
}
}
]
}
}
}
]
};

View File

@@ -0,0 +1,39 @@
export default {
type: 'service',
api: '/api/mock2/sample',
id: 'service-reload',
body: [
{
type: 'each',
name: 'rows',
items: {
type: 'tag',
label: '${id}',
closable: true,
onEvent: {
close: {
actions: [
{
actionType: 'ajax',
args: {
api: {
url: '/api/mock2/sample/${event.data.label}',
method: 'DELETE'
},
messages: {
success: '${label} 删除成功',
failed: '删除失败'
}
}
},
{
actionType: 'reload',
componentId: 'service-reload'
}
]
}
}
}
}
]
};

View File

@@ -0,0 +1,631 @@
export default {
type: 'page',
title: '穿梭框类事件',
regions: ['body', 'toolbar', 'header'],
body: [
// transfer
{
type: 'tpl',
tpl: 'transfer',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
name: 'transferEvent1',
id: 'transferEvent1',
type: 'action',
label: '全选功能',
level: 'primary',
className: 'mr-3 mb-3',
debugger: true,
onEvent: {
click: {
actions: [
{
actionType: 'selectAll',
componentId: 'transfer-receiver'
}
]
}
}
},
{
name: 'transferEvent2',
id: 'transferEvent2',
type: 'action',
label: '清空功能',
level: 'primary',
className: 'mr-3 mb-3',
debugger: true,
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'transfer-receiver'
}
]
}
}
},
{
name: 'transferEvent2',
id: 'transferEvent2',
type: 'action',
label: '清空搜索',
level: 'primary',
className: 'mr-3 mb-3',
debugger: true,
onEvent: {
click: {
actions: [
{
actionType: 'clearSearch',
componentId: 'transfer-receiver',
args: {
left: true,
right: true
}
}
]
}
}
},
{
name: 'transferEvent2',
id: 'transferEvent2',
type: 'action',
label: '重置功能',
level: 'primary',
className: 'mr-3 mb-3',
debugger: true,
onEvent: {
click: {
actions: [
{
actionType: 'reset',
componentId: 'transfer-receiver'
}
]
}
}
},
{
type: 'action',
actionType: 'reload',
label: '刷新 reload',
level: 'primary',
className: 'mr-3 mb-3',
target: 'transfer'
},
{
label: '穿梭器',
id: 'transfer-receiver',
type: 'transfer',
name: 'transfer',
searchable: true,
resultSearchable: true,
debugger: true,
resetValue: 'c',
source: '/api/mock2/form/getTreeOptions',
onEvent: {
change: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '${transfer|json}'
}
}
]
}
}
}
]
},
// tabstransfer
{
type: 'tpl',
tpl: 'tabstransfer',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
name: 'transferEvent4',
id: 'transferEvent4',
type: 'action',
label: '设置changeTabKey为1',
level: 'primary',
className: 'mr-3 mb-3',
debugger: true,
onEvent: {
click: {
actions: [
{
actionType: 'changeTabKey',
componentId: 'tab-transfer-receiver',
args: {
activeKey: 1
}
}
]
}
}
},
{
name: 'transferEvent5',
id: 'transferEvent5',
type: 'action',
label: '清空功能',
level: 'primary',
className: 'mr-3 mb-3',
debugger: true,
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'tab-transfer-receiver'
}
]
}
}
},
{
name: 'transferEvent6',
id: 'transferEvent6',
type: 'action',
label: '重置功能',
level: 'primary',
className: 'mr-3 mb-3',
debugger: true,
onEvent: {
click: {
actions: [
{
actionType: 'reset',
componentId: 'tab-transfer-receiver'
}
]
}
}
},
{
label: '组合穿梭器',
type: 'tabs-transfer',
name: 'transferEvent7',
sortable: true,
selectMode: 'tree',
debug: true,
id: 'tab-transfer-receiver',
resetValue: 'zhugeliang',
options: [
{
label: '成员',
selectMode: 'tree',
searchable: true,
children: [
{
label: '法师',
children: [
{
label: '诸葛亮',
value: 'zhugeliang'
}
]
},
{
label: '战士',
children: [
{
label: '曹操',
value: 'caocao'
},
{
label: '钟无艳',
value: 'zhongwuyan'
}
]
},
{
label: '打野',
children: [
{
label: '李白',
value: 'libai'
},
{
label: '韩信',
value: 'hanxin'
},
{
label: '云中君',
value: 'yunzhongjun'
}
]
}
]
},
{
label: '用户',
selectMode: 'chained',
children: [
{
label: '法师',
children: [
{
label: '诸葛亮',
value: 'zhugeliang2'
}
]
},
{
label: '战士',
children: [
{
label: '曹操',
value: 'caocao2'
},
{
label: '钟无艳',
value: 'zhongwuyan2'
}
]
},
{
label: '打野',
children: [
{
label: '李白',
value: 'libai2'
},
{
label: '韩信',
value: 'hanxin2'
},
{
label: '云中君',
value: 'yunzhongjun2'
}
]
}
]
}
],
onEvent: {
change: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '${transferEvent7|json}'
}
}
]
}
}
}
]
},
// transferpicker
{
type: 'tpl',
tpl: 'transferpicker',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
name: 'transferEvent8',
id: 'transferEvent8',
type: 'action',
label: '清空功能',
level: 'primary',
className: 'mr-3 mb-3',
debugger: true,
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'transfer-picker-receiver'
}
]
}
}
},
{
name: 'transferEvent9',
id: 'transferEvent9',
type: 'action',
label: '重置功能',
level: 'primary',
className: 'mr-3 mb-3',
debugger: true,
onEvent: {
click: {
actions: [
{
actionType: 'reset',
componentId: 'transfer-picker-receiver'
}
]
}
}
},
{
label: '组合穿梭器',
type: 'transfer-picker',
name: 'transferEvent10',
debug: true,
id: 'transfer-picker-receiver',
resetValue: 'zhugeliang',
sortable: true,
selectMode: 'tree',
searchable: true,
options: [
{
label: '法师',
children: [
{
label: '诸葛亮',
value: 'zhugeliang'
}
]
},
{
label: '战士',
children: [
{
label: '曹操',
value: 'caocao'
},
{
label: '钟无艳',
value: 'zhongwuyan'
}
]
},
{
label: '打野',
children: [
{
label: '李白',
value: 'libai'
},
{
label: '韩信',
value: 'hanxin'
},
{
label: '云中君',
value: 'yunzhongjun'
}
]
}
],
onEvent: {
change: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '${transferEvent10|json}'
}
}
]
}
}
}
]
},
// tabsTransferPicker
{
type: 'tpl',
tpl: 'tabsTransferPicker',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
body: [
{
name: 'transferEvent11',
id: 'transferEvent11',
type: 'action',
label: '清空功能',
level: 'primary',
className: 'mr-3 mb-3',
debugger: true,
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'tabs-transfer-picker-receiver'
}
]
}
}
},
{
name: 'transferEvent12',
id: 'transferEvent12',
type: 'action',
label: '重置功能',
level: 'primary',
className: 'mr-3 mb-3',
debugger: true,
onEvent: {
click: {
actions: [
{
actionType: 'reset',
componentId: 'tabs-transfer-picker-receiver'
}
]
}
}
},
{
label: '组合穿梭器',
type: 'tabs-transfer-picker',
name: 'transferEvent13',
debug: true,
id: 'tabs-transfer-picker-receiver',
resetValue: 'zhugeliang',
sortable: true,
selectMode: 'tree',
pickerSize: 'md',
menuTpl:
"<div class='flex justify-between'><span>${label}</span>${email ? `<div class='text-muted m-r-xs text-sm text-right'>${email}<br />${phone}</div>`: ''}</div>",
valueTpl: '${label}(${value})',
options: [
{
label: '成员',
selectMode: 'tree',
searchable: true,
children: [
{
label: '法师',
children: [
{
label: '诸葛亮',
value: 'zhugeliang',
email: 'zhugeliang@timi.com',
phone: 13111111111
}
]
},
{
label: '战士',
children: [
{
label: '曹操',
value: 'caocao',
email: 'caocao@timi.com',
phone: 13111111111
},
{
label: '钟无艳',
value: 'zhongwuyan',
email: 'zhongwuyan@timi.com',
phone: 13111111111
}
]
},
{
label: '打野',
children: [
{
label: '李白',
value: 'libai',
email: 'libai@timi.com',
phone: 13111111111
},
{
label: '韩信',
value: 'hanxin',
email: 'hanxin@timi.com',
phone: 13111111111
},
{
label: '云中君',
value: 'yunzhongjun',
email: 'yunzhongjun@timi.com',
phone: 13111111111
}
]
}
]
},
{
label: '角色',
selectMode: 'list',
children: [
{
label: '角色 1',
value: 'role1'
},
{
label: '角色 2',
value: 'role2'
},
{
label: '角色 3',
value: 'role3'
},
{
label: '角色 4',
value: 'role4'
}
]
},
{
label: '部门',
selectMode: 'tree',
children: [
{
label: '总部',
value: 'dep0',
children: [
{
label: '部门 1',
value: 'dep1',
children: [
{
label: '部门 4',
value: 'dep4'
},
{
label: '部门 5',
value: 'dep5'
}
]
},
{
label: '部门 2',
value: 'dep2'
},
{
label: '部门 3',
value: 'dep3'
}
]
}
]
}
],
onEvent: {
change: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '${transferEvent13|json}'
}
}
]
}
}
}
]
}
]
};

View File

@@ -0,0 +1,124 @@
const getEventDesc = eventName => {
return {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: `派发${eventName}事件` + '${file|json}'
}
}
]
};
};
const change = {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发change事件${file|json}'
}
}
]
};
export default {
type: 'page',
title: '上传类组件事件',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'tpl',
tpl: 'InputFile上传类',
inline: false,
wrapperComponent: 'h2'
},
{
type: 'form',
debug: true,
api: '/api/mock2/form/saveForm',
body: [
{
type: 'group',
body: [
{
name: 'trigger1',
id: 'trigger1',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-input-file',
description: '点击清除数据'
}
]
}
}
},
{
type: 'input-file',
id: 'clear-input-file',
name: 'file',
multiple: true,
receiver: 'ddd',
onEvent: {
change,
remove: getEventDesc('remove'),
success: getEventDesc('success'),
fail: getEventDesc('fail')
}
}
]
}
]
},
{
type: 'form',
debug: true,
api: '/api/mock2/form/saveForm',
body: [
{
type: 'group',
body: [
{
name: 'trigger2',
id: 'trigger2',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'clear-input-image',
description: '点击清除数据'
}
]
}
}
},
{
type: 'input-image',
id: 'clear-input-image',
name: 'file',
multiple: true,
onEvent: {
change,
remove: getEventDesc('remove'),
success: getEventDesc('success'),
fail: getEventDesc('fail')
}
}
]
}
]
}
]
};

View File

@@ -0,0 +1,136 @@
const wizardSchema = {
type: 'wizard',
initApi: '/api/mock2/form/initData',
steps: [
{
title: '第一步',
body: [
{
name: 'website',
label: '网址',
type: 'input-url',
required: true
},
{
name: 'email',
label: '邮箱',
type: 'input-email',
required: true
}
],
api: '/api/mock2/form/saveForm?waitSeconds=2'
},
{
title: '第二步',
body: [
{
name: 'defaultEmail',
type: 'input-email',
label: 'Email',
value: 'test@test.com'
},
{
type: 'input-text',
name: 'name'
}
],
initApi: '/api/mock2/form/initData',
api: '/api/mock2/form/saveForm?waitSeconds=2'
},
{
title: '确定',
body: ['最后一步了,确认要提交吗?'],
api: '/api/mock2/form/saveForm?waitSeconds=2'
}
]
};
function generateEventAcions(events) {
const onEvent = {};
events.forEach(event => {
onEvent[event] = {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: `派发 ${event} 事件,数据:` + '${event.data|json}'
}
}
]
};
});
return onEvent;
}
function generateActions(actions) {
return actions.map(action => ({
name: `wizard-${action.actionName}`,
type: 'button',
label: action.label,
level: actions.level || 'primary',
className: 'mr-3 mb-3',
onEvent: {
click: {
actions: [
{
actionType: action.actionName,
componentId: 'wizard-receiver',
description: action.label,
args: action.actionValue
}
]
}
}
}));
}
export default {
type: 'page',
title: '向导组件事件',
regions: ['body', 'toolbar', 'header'],
body: [
...generateActions([
{
actionName: 'prev',
label: '跳转上一步'
},
{
actionName: 'next',
label: '跳转下一步'
},
{
actionName: 'goto-step',
label: '跳转第三步',
actionValue: {
step: 3
}
},
{
actionName: 'step-submit',
label: '本步骤提交'
},
{
actionName: 'submit',
label: '全部提交'
}
]),
{
name: 'wizard',
id: 'wizard-receiver',
...wizardSchema,
onEvent: generateEventAcions([
'inited',
'change',
'stepChange',
'finished',
'submitSucc',
'submitFail',
'stepSubmitSucc',
'stepSubmitFail'
])
}
]
};

View File

@@ -0,0 +1,211 @@
const options = [
{
label: 'Folder A',
value: 1,
children: [
{
label: 'file A(懒加载)',
defer: true,
value: 2
},
{
label: 'Folder B',
value: 3,
children: [
{
label: 'file b1',
value: 3.1
},
{
label: 'file b2',
value: 3.2
}
]
}
]
},
{
label: 'file C',
value: 4
},
{
label: 'file D',
value: 5
}
];
const onEvent = name => ({
blur: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发blur事件${' + name + '|json}'
}
}
]
},
focus: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发focus事件${' + name + '|json}'
}
}
]
},
change: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发change事件${' + name + '|json}'
}
}
]
},
add: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发add事件${' + name + '|json}'
}
},
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发add事件${items|json}'
}
}
]
},
edit: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发edit事件${' + name + '|json}'
}
},
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发edit事件${items|json}'
}
}
]
},
delete: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发delete事件${' + name + '|json}'
}
},
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发delete事件${items|json}'
}
}
]
},
loadFinished: {
actions: [
{
actionType: 'toast',
args: {
msgType: 'info',
msg: '派发loadFinished事件${' + name + '|json}'
}
}
]
}
});
export default {
type: 'page',
title: '树形选择器',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'form',
debug: true,
body: [
{
name: 'tree-select-clear',
type: 'action',
label: 'clear触发器',
level: 'primary',
className: 'mr-3',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'tree-select-action',
description: '点击清空内容'
}
]
}
}
},
{
name: 'tree-select-reset',
type: 'action',
label: 'reset触发器',
level: 'primary',
className: 'mr-3',
onEvent: {
click: {
actions: [
{
actionType: 'clear',
componentId: 'tree-select-action',
description: '点击清空内容'
}
]
}
}
},
{
type: 'tree-select',
id: 'tree-select-action',
name: 'tree',
label: 'Tree',
creatable: true,
removable: true,
editable: true,
deferApi: '/api/mock2/form/deferOptions?label=${label}&waitSeconds=2',
options,
onEvent: onEvent('tree')
},
{
type: 'tree-select',
id: 'tree-select-action2',
name: 'tree多选',
label: 'tree多选',
multiple: true,
creatable: true,
removable: true,
editable: true,
deferApi: '/api/mock2/form/deferOptions?label=${label}&waitSeconds=2',
options,
onEvent: onEvent('tree多选')
}
]
}
]
};