vendor: amis 6.13.0 base (fork root)
This commit is contained in:
@@ -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: '派发鼠标移出事件'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
108
examples/components/EventAction/cmpt-event-action/ChartEvent.jsx
Normal file
108
examples/components/EventAction/cmpt-event-action/ChartEvent.jsx
Normal 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
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
226
examples/components/EventAction/cmpt-event-action/DateEvent.jsx
Normal file
226
examples/components/EventAction/cmpt-event-action/DateEvent.jsx
Normal 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)]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
346
examples/components/EventAction/cmpt-event-action/FormEvent.jsx
Normal file
346
examples/components/EventAction/cmpt-event-action/FormEvent.jsx
Normal 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}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
427
examples/components/EventAction/cmpt-event-action/InputEvent.jsx
Normal file
427
examples/components/EventAction/cmpt-event-action/InputEvent.jsx
Normal 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'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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事件'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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事件'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
101
examples/components/EventAction/cmpt-event-action/ListEvent.jsx
Normal file
101
examples/components/EventAction/cmpt-event-action/ListEvent.jsx
Normal 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)"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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>'
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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')
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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> "
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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事件'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
470
examples/components/EventAction/cmpt-event-action/TableEvent.jsx
Normal file
470
examples/components/EventAction/cmpt-event-action/TableEvent.jsx
Normal 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'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
103
examples/components/EventAction/cmpt-event-action/TabsEvent.jsx
Normal file
103
examples/components/EventAction/cmpt-event-action/TabsEvent.jsx
Normal 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}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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')
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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'
|
||||
])
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -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多选')
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
body: {
|
||||
type: 'form',
|
||||
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/saveForm',
|
||||
title: '登录',
|
||||
body: [
|
||||
{
|
||||
type: 'alert',
|
||||
body: '阻止表单提交后的默认提示。',
|
||||
level: 'info',
|
||||
className: 'mb-1'
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'name',
|
||||
label: '姓名'
|
||||
},
|
||||
{
|
||||
type: 'input-email',
|
||||
name: 'email',
|
||||
label: '邮箱'
|
||||
}
|
||||
],
|
||||
onEvent: {
|
||||
submitFail: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'drawer',
|
||||
drawer: {
|
||||
title: '请求失败',
|
||||
body: {
|
||||
type: 'alert',
|
||||
level: 'warning',
|
||||
icon: 'fa fa-cloud',
|
||||
body: '请求失败,若给您造成不便,敬请谅解。'
|
||||
}
|
||||
},
|
||||
preventDefault: true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
body: [
|
||||
{
|
||||
type: 'alert',
|
||||
body: '刷新图表,使图表重新加载',
|
||||
level: 'info',
|
||||
className: 'mb-1'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '刷新',
|
||||
level: 'primary',
|
||||
className: 'mt-2 mb-2',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'reload',
|
||||
componentId: 'chart_reload'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'chart',
|
||||
id: 'chart_reload',
|
||||
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/chart/chartData',
|
||||
config: {
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
data: '${line}',
|
||||
type: 'line'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
43
examples/components/EventAction/reload-action/ReloadForm.jsx
Normal file
43
examples/components/EventAction/reload-action/ReloadForm.jsx
Normal file
@@ -0,0 +1,43 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
body: [
|
||||
{
|
||||
type: 'alert',
|
||||
body: '刷新表单,使表单重新加载,这样可以触发表单的远程数据重新请求',
|
||||
level: 'info',
|
||||
className: 'mb-1'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '刷新',
|
||||
className: 'mt-2 mb-2',
|
||||
level: 'primary',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'reload',
|
||||
componentId: 'form-reload'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'form',
|
||||
id: 'form-reload',
|
||||
name: 'form-reload',
|
||||
initApi:
|
||||
'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/page/initData',
|
||||
title: '表单',
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
id: 'date-input-01',
|
||||
name: 'date',
|
||||
label: '时间戳'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
body: [
|
||||
{
|
||||
type: 'alert',
|
||||
body: '刷新下拉框,使下拉框重新加载,这样可以触发下拉框的远程数据重新请求',
|
||||
level: 'info',
|
||||
className: 'mb-1'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '刷新',
|
||||
className: 'mt-2 mb-2',
|
||||
level: 'primary',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'reload',
|
||||
componentId: 'select-reload'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '下拉框',
|
||||
type: 'select',
|
||||
id: 'select-reload',
|
||||
mode: 'horizontal',
|
||||
className: 'mt-2',
|
||||
name: 'select',
|
||||
source:
|
||||
'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/getOptions?waitSeconds=1'
|
||||
}
|
||||
]
|
||||
};
|
||||
478
examples/components/EventAction/update-data/DataAutoFill.jsx
Normal file
478
examples/components/EventAction/update-data/DataAutoFill.jsx
Normal file
@@ -0,0 +1,478 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
data: {
|
||||
globalData: {
|
||||
website: 'http://www.baidu.com',
|
||||
email: 'amis!@baidu.com'
|
||||
}
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'alert',
|
||||
body: '远程请求后、表单提交后,将数据回填给另一个组件。请求返回的数据可以指定存储在`outputVar`变量里,其他动作可以通过`${[outputVar]}`直接获取该数据。',
|
||||
level: 'info',
|
||||
className: 'mb-1'
|
||||
},
|
||||
{
|
||||
type: 'alert',
|
||||
body: 'http请求后的数据回填给表单',
|
||||
level: 'info',
|
||||
className: 'mt-2 mb-1'
|
||||
},
|
||||
{
|
||||
type: 'form',
|
||||
id: 'form_data_001',
|
||||
title: '用户信息',
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
label: '名称',
|
||||
name: 'name',
|
||||
disabled: false,
|
||||
mode: 'horizontal'
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
label: '作者',
|
||||
name: 'author',
|
||||
disabled: false,
|
||||
mode: 'horizontal'
|
||||
}
|
||||
],
|
||||
actions: [
|
||||
{
|
||||
type: 'button',
|
||||
label: '去获取表单数据',
|
||||
primary: true,
|
||||
wrapWithPanel: false,
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'ajax',
|
||||
args: {
|
||||
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/initData'
|
||||
},
|
||||
outputVar: 'myResult'
|
||||
},
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'form_data_001',
|
||||
args: {
|
||||
value: '${myResult}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'alert',
|
||||
body: '弹窗提交后的数据回填给表单',
|
||||
level: 'info',
|
||||
className: 'mt-2 mb-1'
|
||||
},
|
||||
{
|
||||
type: 'form',
|
||||
id: 'form_data_002',
|
||||
title: '用户信息',
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
label: '名称',
|
||||
name: 'name',
|
||||
disabled: false,
|
||||
mode: 'horizontal'
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
label: '作者',
|
||||
name: 'author',
|
||||
disabled: false,
|
||||
mode: 'horizontal'
|
||||
}
|
||||
],
|
||||
actions: [
|
||||
{
|
||||
type: 'button',
|
||||
label: '去获取表单数据',
|
||||
primary: true,
|
||||
wrapWithPanel: false,
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '登录',
|
||||
id: 'dialog_004',
|
||||
data: {
|
||||
username: 'amis'
|
||||
},
|
||||
body: {
|
||||
type: 'form',
|
||||
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm?waitSeconds=2',
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'username',
|
||||
required: true,
|
||||
placeholder: '请输入用户名',
|
||||
label: '用户名'
|
||||
},
|
||||
{
|
||||
type: 'input-password',
|
||||
name: 'password',
|
||||
label: '密码',
|
||||
required: true,
|
||||
placeholder: '请输入密码'
|
||||
},
|
||||
{
|
||||
type: 'checkbox',
|
||||
name: 'rememberMe',
|
||||
label: '记住登录'
|
||||
}
|
||||
]
|
||||
},
|
||||
actions: [
|
||||
{
|
||||
type: 'button',
|
||||
label: '提交',
|
||||
className: 'm',
|
||||
primary: true,
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'ajax',
|
||||
args: {
|
||||
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/initData'
|
||||
},
|
||||
outputVar: 'myResult'
|
||||
},
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'form_data_002',
|
||||
args: {
|
||||
value: '${myResult}'
|
||||
}
|
||||
},
|
||||
{
|
||||
actionType: 'closeDialog'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'alert',
|
||||
body: 'Picker选择后将数据回填到form的其他组件中',
|
||||
level: 'info',
|
||||
className: 'mt-2 mb-1'
|
||||
},
|
||||
{
|
||||
type: 'form',
|
||||
api: '/api/mock2/form/saveForm',
|
||||
debug: true,
|
||||
body: [
|
||||
{
|
||||
type: 'picker',
|
||||
name: 'picker',
|
||||
id: 'picker',
|
||||
joinValues: true,
|
||||
valueField: 'id',
|
||||
labelField: 'id',
|
||||
label: '多选',
|
||||
source: '/api/mock2/sample',
|
||||
size: 'lg',
|
||||
multiple: false,
|
||||
description: '选择一项内容,自动填入Form其他组件,并触发按钮动作',
|
||||
pickerSchema: {
|
||||
mode: 'table',
|
||||
name: 'thelist',
|
||||
quickSaveApi: '/api/mock2/sample/bulkUpdate',
|
||||
quickSaveItemApi: '/api/mock2/sample/$id',
|
||||
draggable: true,
|
||||
headerToolbar: {
|
||||
wrapWithPanel: false,
|
||||
type: 'form',
|
||||
className: 'text-right',
|
||||
target: 'thelist',
|
||||
mode: 'inline',
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'keywords',
|
||||
addOn: {
|
||||
type: 'submit',
|
||||
label: '搜索',
|
||||
level: 'primary',
|
||||
icon: 'fa fa-search pull-left'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
name: 'engine',
|
||||
label: 'Rendering engine',
|
||||
sortable: true,
|
||||
searchable: true,
|
||||
type: 'text',
|
||||
toggled: true
|
||||
},
|
||||
{
|
||||
name: 'browser',
|
||||
label: 'Browser',
|
||||
sortable: true,
|
||||
type: 'text',
|
||||
toggled: true
|
||||
},
|
||||
{
|
||||
name: 'platform',
|
||||
label: 'Platform(s)',
|
||||
sortable: true,
|
||||
type: 'text',
|
||||
toggled: true
|
||||
},
|
||||
{
|
||||
name: 'version',
|
||||
label: 'Engine version',
|
||||
quickEdit: true,
|
||||
type: 'text',
|
||||
toggled: true
|
||||
},
|
||||
{
|
||||
name: 'grade',
|
||||
label: 'CSS grade',
|
||||
quickEdit: {
|
||||
mode: 'inline',
|
||||
type: 'select',
|
||||
options: ['A', 'B', 'C', 'D', 'X'],
|
||||
saveImmediately: true
|
||||
},
|
||||
type: 'text',
|
||||
toggled: true
|
||||
},
|
||||
{
|
||||
type: 'operation',
|
||||
label: '操作',
|
||||
width: 100,
|
||||
buttons: [
|
||||
{
|
||||
type: 'button',
|
||||
icon: 'fa fa-eye',
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '查看',
|
||||
body: {
|
||||
type: 'form',
|
||||
body: [
|
||||
{
|
||||
type: 'static',
|
||||
name: 'engine',
|
||||
label: 'Engine'
|
||||
},
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'browser',
|
||||
label: 'Browser'
|
||||
},
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'platform',
|
||||
label: 'Platform(s)'
|
||||
},
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'version',
|
||||
label: 'Engine version'
|
||||
},
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'grade',
|
||||
label: 'CSS grade'
|
||||
},
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
{
|
||||
type: 'html',
|
||||
html: '<p>添加其他 <span>Html 片段</span> 需要支持变量替换(todo).</p>'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
icon: 'fa fa-pencil',
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
position: 'left',
|
||||
size: 'lg',
|
||||
title: '编辑',
|
||||
body: {
|
||||
type: 'form',
|
||||
name: 'sample-edit-form',
|
||||
api: '/api/mock2/sample/$id',
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'engine',
|
||||
label: 'Engine',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'browser',
|
||||
label: 'Browser',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'platform',
|
||||
label: 'Platform(s)',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'version',
|
||||
label: 'Engine version'
|
||||
},
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
name: 'grade',
|
||||
label: 'CSS grade',
|
||||
options: ['A', 'B', 'C', 'D', 'X']
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
icon: 'fa fa-times text-danger',
|
||||
actionType: 'ajax',
|
||||
confirmText: '您确认要删除?',
|
||||
api: 'delete:/api/mock2/sample/$id'
|
||||
}
|
||||
],
|
||||
toggled: true
|
||||
}
|
||||
]
|
||||
},
|
||||
onEvent: {
|
||||
change: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'id',
|
||||
args: {
|
||||
value: '${picker}'
|
||||
}
|
||||
},
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'platform',
|
||||
args: {
|
||||
value: '${selectedItems.platform}'
|
||||
}
|
||||
},
|
||||
{
|
||||
actionType: 'click',
|
||||
componentId: 'dialog-action',
|
||||
args: {
|
||||
browser: '${selectedItems.browser}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'id',
|
||||
name: 'id',
|
||||
id: 'id',
|
||||
type: 'input-text'
|
||||
},
|
||||
{
|
||||
label: 'platform',
|
||||
name: 'platform',
|
||||
id: 'platform',
|
||||
type: 'input-text'
|
||||
},
|
||||
{
|
||||
type: 'action',
|
||||
id: 'dialog-action',
|
||||
label: '自动触发的弹窗',
|
||||
level: 'primary',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
type: 'dialog',
|
||||
title: 'browser',
|
||||
id: 'browser-dialog',
|
||||
body: [
|
||||
{
|
||||
type: 'form',
|
||||
debug: true,
|
||||
id: 'browser-form',
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
id: 'browser',
|
||||
name: 'browser',
|
||||
label: 'browser'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
184
examples/components/EventAction/update-data/SetVariable.jsx
Normal file
184
examples/components/EventAction/update-data/SetVariable.jsx
Normal file
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* @file 变量更新示例
|
||||
*/
|
||||
import update from 'lodash/update';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import {cloneObject, setVariable} from 'amis-core';
|
||||
|
||||
const variables = [
|
||||
{
|
||||
key: 'xxx',
|
||||
defaultValue: 'yyy'
|
||||
},
|
||||
|
||||
{
|
||||
key: 'ProductName',
|
||||
defaultValue: ''
|
||||
},
|
||||
|
||||
{
|
||||
key: 'count',
|
||||
defaultValue: 0,
|
||||
scope: 'page',
|
||||
storageOn: 'client'
|
||||
},
|
||||
|
||||
{
|
||||
key: 'arr',
|
||||
defaultValue: []
|
||||
},
|
||||
|
||||
{
|
||||
key: 'select',
|
||||
defaultValue: ''
|
||||
}
|
||||
];
|
||||
|
||||
export default {
|
||||
/** schema配置 */
|
||||
schema: {
|
||||
type: 'page',
|
||||
title: '更新变量数据',
|
||||
body: [
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: '变量的命名空间通过环境变量设置为了<code>global</code>, 可以通过\\${global.xxx}来取值'
|
||||
},
|
||||
{
|
||||
type: 'container',
|
||||
style: {
|
||||
padding: '8px',
|
||||
marginBottom: '8px',
|
||||
backgroundColor: '#f5f5f5',
|
||||
borderRadius: '4px'
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: '<h2>数据域global</h2>'
|
||||
},
|
||||
{
|
||||
type: 'json',
|
||||
id: 'u:44521540e64c',
|
||||
source: '${global}',
|
||||
levelExpand: 10
|
||||
},
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: '<h3>接口中的<code>ProductName (\\${ProductName})</code>: <strong>${ProductName|default:-}</strong></h3>',
|
||||
inline: false,
|
||||
id: 'u:98ed5c5534ef'
|
||||
},
|
||||
{
|
||||
type: 'tpl',
|
||||
tpl: '<h3>变量中的<code>ProductName (\\${global.ProductName})</code>: <strong>${global.ProductName|default:-}</strong></h3>',
|
||||
inline: false,
|
||||
id: 'u:98ed5c5534ef'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'form',
|
||||
title: '表单',
|
||||
debug: true,
|
||||
body: [
|
||||
{
|
||||
label: '产品名称',
|
||||
type: 'input-text',
|
||||
name: 'product',
|
||||
placeholder: '请输入内容, 观察引用变量组件的变化',
|
||||
id: 'u:d9802fd83145',
|
||||
onEvent: {
|
||||
change: {
|
||||
weight: 0,
|
||||
actions: [
|
||||
{
|
||||
args: {
|
||||
path: 'global.ProductName',
|
||||
value: '${event.data.value}'
|
||||
},
|
||||
actionType: 'setValue'
|
||||
},
|
||||
|
||||
{
|
||||
args: {
|
||||
path: 'global.arr',
|
||||
value:
|
||||
'${[{label: event.data.value, value: event.data.value}]}'
|
||||
},
|
||||
actionType: 'setValue'
|
||||
},
|
||||
|
||||
{
|
||||
args: {
|
||||
path: 'global.select',
|
||||
value: '${event.data.value}'
|
||||
},
|
||||
actionType: 'setValue'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
label: '产品名称描述',
|
||||
id: 'u:7bd4e2a4f95e',
|
||||
value: '${global.ProductName}',
|
||||
name: 'staticName'
|
||||
},
|
||||
|
||||
{
|
||||
type: 'input-number',
|
||||
label: 'Count (client)',
|
||||
description: '存储自动存入客户端,刷新页面后数据还在',
|
||||
id: 'u:7bd4e2a4f95e',
|
||||
value: '${global.count}',
|
||||
name: 'count',
|
||||
onEvent: {
|
||||
change: {
|
||||
weight: 0,
|
||||
actions: [
|
||||
{
|
||||
args: {
|
||||
path: 'global.count',
|
||||
value: '${event.data.value}'
|
||||
},
|
||||
actionType: 'setValue'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
type: 'select',
|
||||
label: 'select(${global.select})',
|
||||
name: 'select',
|
||||
value: '${global.select}',
|
||||
source: '${global.arr}'
|
||||
}
|
||||
],
|
||||
id: 'u:dc2580fa447a'
|
||||
}
|
||||
],
|
||||
initApi: '/api/mock2/page/initData2',
|
||||
onEvent: {
|
||||
inited: {
|
||||
weight: 0,
|
||||
actions: [
|
||||
{
|
||||
args: {
|
||||
path: 'global.ProductName',
|
||||
value: '${event.data.ProductName}'
|
||||
},
|
||||
actionType: 'setValue'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
props: {
|
||||
globalVars: variables
|
||||
}
|
||||
};
|
||||
216
examples/components/EventAction/update-data/SyncUpdate.jsx
Normal file
216
examples/components/EventAction/update-data/SyncUpdate.jsx
Normal file
@@ -0,0 +1,216 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
body: [
|
||||
{
|
||||
type: 'alert',
|
||||
body: '当某组件的值发生变化时,联动去更新另一个组件的数据,可以通过${responseResult}来获取事件产生的数据,例如输入框change事件可以通过${[name]}来获取输入的值,name是组件的名称。',
|
||||
level: 'info',
|
||||
className: 'mb-1'
|
||||
},
|
||||
{
|
||||
type: 'alert',
|
||||
body: '输入框同步输入框:上面输入框输入时同步更新表单内的输入框。',
|
||||
level: 'info',
|
||||
className: 'mt-2 mb-1'
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'role',
|
||||
label: '输入角色',
|
||||
mode: 'horizontal',
|
||||
onEvent: {
|
||||
change: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'form_data_2',
|
||||
args: {
|
||||
value: {
|
||||
myrole: '${role}'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
label: '输入年龄',
|
||||
name: 'age',
|
||||
mode: 'horizontal',
|
||||
onEvent: {
|
||||
change: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'form_data_2',
|
||||
args: {
|
||||
value: {
|
||||
age: '${age}'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'form',
|
||||
id: 'form_data_2',
|
||||
title: '表单',
|
||||
initApi: '/api/mock2/form/initData',
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
label: '角色',
|
||||
name: 'myrole',
|
||||
disabled: false,
|
||||
mode: 'horizontal'
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
label: '年龄',
|
||||
name: 'age',
|
||||
disabled: false,
|
||||
mode: 'horizontal'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'alert',
|
||||
body: '下拉框与输入框联动:选择消息后,将选中值同步给消息输入框。',
|
||||
level: 'info',
|
||||
className: 'mt-2 mb-1'
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
label: '选择消息',
|
||||
name: 'message',
|
||||
mode: 'horizontal',
|
||||
options: [
|
||||
{
|
||||
label: 'Hi',
|
||||
value: 'Hi!'
|
||||
},
|
||||
{
|
||||
label: 'Hello',
|
||||
value: 'Hello!'
|
||||
},
|
||||
{
|
||||
label: 'Hey',
|
||||
value: 'Hey!'
|
||||
}
|
||||
],
|
||||
onEvent: {
|
||||
change: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'input_data_msg2',
|
||||
args: {
|
||||
value: '${message}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
label: '消息',
|
||||
id: 'input_data_msg2',
|
||||
mode: 'horizontal',
|
||||
name: 'mymsg'
|
||||
},
|
||||
{
|
||||
type: 'alert',
|
||||
body: '动态更新下拉框的数据源: 选项1的选中值更新后同步更新选项2的数据源。',
|
||||
level: 'info',
|
||||
className: 'mt-2 mb-1'
|
||||
},
|
||||
{
|
||||
type: 'form',
|
||||
title: '表单',
|
||||
body: [
|
||||
{
|
||||
type: 'select',
|
||||
label: '选项1',
|
||||
name: 'select1',
|
||||
options: [
|
||||
{
|
||||
label: '选项A',
|
||||
value: 'A'
|
||||
},
|
||||
{
|
||||
label: '选项B',
|
||||
value: 'B'
|
||||
}
|
||||
],
|
||||
id: 'u:af1ad4e2f8db',
|
||||
multiple: false,
|
||||
mode: 'inline',
|
||||
onEvent: {
|
||||
change: {
|
||||
weight: 0,
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
args: {
|
||||
value: {
|
||||
opts: '${optList[select1]}'
|
||||
}
|
||||
},
|
||||
componentId: 'u:d731760b321e'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
label: '选项2',
|
||||
name: 'select2',
|
||||
id: 'u:d731760b321d',
|
||||
multiple: false,
|
||||
mode: 'inline',
|
||||
source: '${opts}'
|
||||
}
|
||||
],
|
||||
id: 'u:d731760b321e',
|
||||
data: {
|
||||
optList: {
|
||||
A: [
|
||||
{
|
||||
label: 'A',
|
||||
value: 'a'
|
||||
},
|
||||
{
|
||||
label: 'B',
|
||||
value: 'b'
|
||||
},
|
||||
{
|
||||
label: 'C',
|
||||
value: 'c'
|
||||
}
|
||||
],
|
||||
B: [
|
||||
{
|
||||
label: 'A2',
|
||||
value: 'a2'
|
||||
},
|
||||
{
|
||||
label: 'B2',
|
||||
value: 'b2'
|
||||
},
|
||||
{
|
||||
label: 'C2',
|
||||
value: 'c2'
|
||||
}
|
||||
]
|
||||
},
|
||||
opts: []
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
id: 'mypage',
|
||||
data: {
|
||||
btnData: 'c'
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'alert',
|
||||
body: '直接更新指定点选按钮的选中值。',
|
||||
level: 'info',
|
||||
className: 'mb-1'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '更新',
|
||||
level: 'primary',
|
||||
className: 'mt-2 mb-2',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'button-group-select_setvalue',
|
||||
args: {
|
||||
value: '${btnData}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'button-group-select',
|
||||
id: 'button-group-select_setvalue',
|
||||
label: '选项',
|
||||
name: 'type',
|
||||
options: [
|
||||
{
|
||||
label: 'Option A',
|
||||
value: 'a'
|
||||
},
|
||||
{
|
||||
label: 'Option B',
|
||||
value: 'b'
|
||||
},
|
||||
{
|
||||
label: 'Option C',
|
||||
value: 'c'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
55
examples/components/EventAction/update-data/UpdateChart.jsx
Normal file
55
examples/components/EventAction/update-data/UpdateChart.jsx
Normal file
@@ -0,0 +1,55 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
data: {
|
||||
lineData: {
|
||||
line: [65, 63, 10, 73, 42, 21]
|
||||
}
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'alert',
|
||||
body: '直接更新图表的数据等于更新图表所依赖数据域中的变量,例如下面的例子,`setValue`等于更新绑定的变量`${line}`。',
|
||||
level: 'info',
|
||||
className: 'mb-1'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '更新',
|
||||
level: 'primary',
|
||||
className: 'mb-2',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'chart_setvalue',
|
||||
args: {
|
||||
value: '${lineData}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'chart',
|
||||
id: 'chart_setvalue',
|
||||
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/chart/chartData',
|
||||
config: {
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
data: '${line}',
|
||||
type: 'line'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
103
examples/components/EventAction/update-data/UpdateCombo.jsx
Normal file
103
examples/components/EventAction/update-data/UpdateCombo.jsx
Normal file
@@ -0,0 +1,103 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
id: 'mypage',
|
||||
data: {
|
||||
objData: {
|
||||
name: '路飞',
|
||||
role: '海贼王'
|
||||
},
|
||||
arrayData: [
|
||||
{
|
||||
name: '苹果',
|
||||
count: 10
|
||||
},
|
||||
{
|
||||
name: '黄瓜',
|
||||
count: 5
|
||||
}
|
||||
]
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'alert',
|
||||
body: '直接更新指定输入组合的值,支持对象和数组。',
|
||||
level: 'info',
|
||||
className: 'mb-1'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '更新对象类型数据',
|
||||
level: 'primary',
|
||||
className: 'mt-2 mb-2',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'userinfo',
|
||||
args: {
|
||||
value: '${objData}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'combo',
|
||||
name: 'userinfo',
|
||||
id: 'userinfo',
|
||||
label: '用户信息',
|
||||
items: [
|
||||
{
|
||||
name: 'name',
|
||||
label: '姓名',
|
||||
type: 'input-text'
|
||||
},
|
||||
{
|
||||
name: 'role',
|
||||
label: '角色',
|
||||
type: 'input-text'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '更新数组类型数据',
|
||||
level: 'primary',
|
||||
className: 'mt-2 mb-2',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'shoppingcart',
|
||||
args: {
|
||||
value: '${arrayData}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'combo',
|
||||
name: 'shoppingcart',
|
||||
id: 'shoppingcart',
|
||||
label: '购物车',
|
||||
multiple: true,
|
||||
items: [
|
||||
{
|
||||
name: 'name',
|
||||
label: '商品名称',
|
||||
type: 'input-text'
|
||||
},
|
||||
{
|
||||
name: 'count',
|
||||
label: '购买数量',
|
||||
type: 'input-text'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
96
examples/components/EventAction/update-data/UpdateDialog.jsx
Normal file
96
examples/components/EventAction/update-data/UpdateDialog.jsx
Normal file
@@ -0,0 +1,96 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
data: {
|
||||
globalData: {
|
||||
website: 'http://www.baidu.com',
|
||||
email: 'amis!@baidu.com',
|
||||
rememberMe: true
|
||||
}
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'alert',
|
||||
body: '这种场景一般用在弹窗内某个异步操作后,数据的回填。请求返回的数据可以指定存储在`outputVar`变量里,其他动作可以通过${[outputVar]}直接获取该数据。',
|
||||
level: 'info',
|
||||
className: 'mb-1'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '打开弹窗',
|
||||
level: 'primary',
|
||||
className: 'mt-2',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '在弹框中的表单',
|
||||
id: 'dialog_003',
|
||||
data: {
|
||||
username: 'amis',
|
||||
rememberMe: '${globalData.rememberMe}'
|
||||
},
|
||||
body: {
|
||||
type: 'form',
|
||||
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm?waitSeconds=2',
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'username',
|
||||
required: true,
|
||||
placeholder: '请输入用户名',
|
||||
label: '用户名'
|
||||
},
|
||||
{
|
||||
type: 'input-password',
|
||||
name: 'password',
|
||||
label: '密码',
|
||||
required: true,
|
||||
placeholder: '请输入密码'
|
||||
},
|
||||
{
|
||||
type: 'checkbox',
|
||||
name: 'rememberMe',
|
||||
label: '记住登录'
|
||||
}
|
||||
]
|
||||
},
|
||||
actions: [
|
||||
{
|
||||
type: 'button',
|
||||
label: '确认',
|
||||
className: 'm',
|
||||
primary: true,
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'ajax',
|
||||
args: {
|
||||
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/initData'
|
||||
},
|
||||
outputVar: 'myResult'
|
||||
},
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'dialog_003',
|
||||
args: {
|
||||
value: {
|
||||
username: '${myResult.name}'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
63
examples/components/EventAction/update-data/UpdateForm.jsx
Normal file
63
examples/components/EventAction/update-data/UpdateForm.jsx
Normal file
@@ -0,0 +1,63 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
data: {
|
||||
globalData: {
|
||||
myrole: '法官',
|
||||
mymsg: '该吃饭了!'
|
||||
}
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'alert',
|
||||
body: '直接更新指定的表单组件的数据。',
|
||||
level: 'info',
|
||||
className: 'mb-1'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '更新',
|
||||
level: 'primary',
|
||||
className: 'mt-2 mb-2',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'form_data',
|
||||
args: {
|
||||
value: '${globalData}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'form',
|
||||
id: 'form_data',
|
||||
title: '表单',
|
||||
debug: true,
|
||||
data: {
|
||||
myrole: '预言家',
|
||||
age: '18'
|
||||
},
|
||||
initApi: '/api/mock2/form/initData',
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
label: '角色',
|
||||
name: 'myrole',
|
||||
disabled: false,
|
||||
mode: 'horizontal'
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
label: '年龄',
|
||||
name: 'age',
|
||||
disabled: false,
|
||||
mode: 'horizontal'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
90
examples/components/EventAction/update-data/UpdateInput.jsx
Normal file
90
examples/components/EventAction/update-data/UpdateInput.jsx
Normal file
@@ -0,0 +1,90 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
id: 'mypage',
|
||||
data: {
|
||||
globalData: {
|
||||
myrole: '法官',
|
||||
mymsg: '该吃饭了!',
|
||||
title: 'beijing time'
|
||||
}
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'alert',
|
||||
body: '直接更新指定输入框的值。',
|
||||
level: 'info',
|
||||
className: 'mb-1'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '更新输入框',
|
||||
level: 'primary',
|
||||
className: 'mt-2 mb-2',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'input_data_msg',
|
||||
args: {
|
||||
value: '我是amis!'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
label: '消息',
|
||||
id: 'input_data_msg',
|
||||
mode: 'horizontal',
|
||||
name: 'mymsg'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '更新表单内输入框',
|
||||
level: 'primary',
|
||||
className: 'mt-2 mb-2',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'input_data_role',
|
||||
args: {
|
||||
value: '预言家'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'form',
|
||||
title: '表单',
|
||||
data: {
|
||||
myrole: '杀手',
|
||||
age: '18'
|
||||
},
|
||||
initApi: '/api/mock2/form/initData',
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
id: 'input_data_role',
|
||||
label: '角色',
|
||||
name: 'myrole',
|
||||
disabled: false,
|
||||
mode: 'horizontal'
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
label: '年龄',
|
||||
name: 'age',
|
||||
disabled: false,
|
||||
mode: 'horizontal'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
123
examples/components/EventAction/update-data/UpdateSelect.jsx
Normal file
123
examples/components/EventAction/update-data/UpdateSelect.jsx
Normal file
@@ -0,0 +1,123 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
id: 'mypage',
|
||||
data: {
|
||||
singleData: 'a',
|
||||
multipleData: 'caocao,libai'
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'alert',
|
||||
body: '直接更新指定下拉框的选中值。',
|
||||
level: 'info',
|
||||
className: 'mb-1'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '更新单选数据',
|
||||
level: 'primary',
|
||||
className: 'mt-2 mb-2',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'single-select',
|
||||
args: {
|
||||
value: '${singleData}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '选项',
|
||||
type: 'select',
|
||||
name: 'single-select',
|
||||
id: 'single-select',
|
||||
options: [
|
||||
{
|
||||
label: 'A',
|
||||
value: 'a'
|
||||
},
|
||||
{
|
||||
label: 'B',
|
||||
value: 'b'
|
||||
},
|
||||
{
|
||||
label: 'C',
|
||||
value: 'c'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '更新多选数据',
|
||||
level: 'primary',
|
||||
className: 'mt-2 mb-2',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'multiple-select',
|
||||
args: {
|
||||
value: '${multipleData}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '分组',
|
||||
type: 'select',
|
||||
name: 'multiple-select',
|
||||
id: 'multiple-select',
|
||||
multiple: true,
|
||||
selectMode: 'group',
|
||||
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'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
68
examples/components/EventAction/update-data/UpdateWizard.jsx
Normal file
68
examples/components/EventAction/update-data/UpdateWizard.jsx
Normal file
@@ -0,0 +1,68 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
data: {
|
||||
globalData: {
|
||||
website: 'http://www.baidu.com',
|
||||
email: 'amis!@baidu.com'
|
||||
}
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'alert',
|
||||
body: '直接更新指定的向导组件的数据。',
|
||||
level: 'info',
|
||||
className: 'mb-1'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
label: '更新',
|
||||
level: 'primary',
|
||||
className: 'mt-2 mb-2',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'setValue',
|
||||
componentId: 'wizard_data',
|
||||
args: {
|
||||
value: '${globalData}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wizard',
|
||||
id: 'wizard_data',
|
||||
mode: 'vertical',
|
||||
data: {
|
||||
website: 'test',
|
||||
email: 'test'
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
title: '第一步',
|
||||
body: [
|
||||
{
|
||||
name: 'website',
|
||||
label: '网址',
|
||||
type: 'input-url'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Step 2',
|
||||
body: [
|
||||
{
|
||||
name: 'email',
|
||||
label: '邮箱',
|
||||
type: 'input-email',
|
||||
required: true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
Reference in New Issue
Block a user