vendor: amis 6.13.0 base (fork root)
This commit is contained in:
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