vendor: amis 6.13.0 base (fork root)
This commit is contained in:
175
examples/components/Linkage/CRUD.jsx
Normal file
175
examples/components/Linkage/CRUD.jsx
Normal file
@@ -0,0 +1,175 @@
|
||||
export default {
|
||||
title: '表单与列表之间的联动',
|
||||
body: [
|
||||
{
|
||||
title: '',
|
||||
type: 'form',
|
||||
mode: 'inline',
|
||||
target: 'list',
|
||||
wrapWithPanel: false,
|
||||
className: 'm-b',
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'keywords',
|
||||
placeholder: '通过关键字搜索',
|
||||
clearable: true,
|
||||
addOn: {
|
||||
type: 'submit',
|
||||
icon: 'fa fa-search',
|
||||
level: 'primary'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'crud',
|
||||
name: 'list',
|
||||
api: '/api/sample',
|
||||
mode: 'list',
|
||||
listItem: {
|
||||
actions: [
|
||||
{
|
||||
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: 'button',
|
||||
icon: 'fa fa-pencil',
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '编辑',
|
||||
body: {
|
||||
type: 'form',
|
||||
name: 'sample-edit-form',
|
||||
api: '/api/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: 'input-text',
|
||||
name: 'grade',
|
||||
label: 'CSS grade'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
icon: 'fa fa-times text-danger',
|
||||
actionType: 'ajax',
|
||||
confirmText: '您确认要删除?',
|
||||
api: 'delete:/api/sample/$id'
|
||||
}
|
||||
],
|
||||
body: [
|
||||
{
|
||||
name: 'engine',
|
||||
label: 'Rendering engine',
|
||||
labelClassName: 'w-sm'
|
||||
},
|
||||
{
|
||||
type: 'hbox',
|
||||
columns: [
|
||||
{
|
||||
name: 'browser',
|
||||
label: 'Browser',
|
||||
labelClassName: 'w-sm'
|
||||
},
|
||||
{
|
||||
name: 'platform',
|
||||
label: 'Platform(s)',
|
||||
labelClassName: 'w-sm'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'version',
|
||||
label: 'Engine version',
|
||||
labelClassName: 'w-sm'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
67
examples/components/Linkage/Form.jsx
Normal file
67
examples/components/Linkage/Form.jsx
Normal file
@@ -0,0 +1,67 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
title: '表单与表单之间的联动',
|
||||
aside: {
|
||||
type: 'form',
|
||||
target: 'detailForm',
|
||||
className: 'wrapper-sm', // 来点间隔
|
||||
wrapWithPanel: false, // 不要用 panel 包裹了。
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
placeholder: '关键字',
|
||||
name: 'keywords',
|
||||
addOn: {
|
||||
type: 'submit',
|
||||
label: '搜索',
|
||||
primary: true
|
||||
}
|
||||
},
|
||||
|
||||
'<span class="text-danger">请在此输入内容后点击搜索</sapn>'
|
||||
]
|
||||
},
|
||||
body: {
|
||||
name: 'detailForm',
|
||||
type: 'form',
|
||||
mode: 'horizontal',
|
||||
title: '',
|
||||
initApi: '/api/mock2/form/initData?keywords=${keywords}',
|
||||
actions: [],
|
||||
body: [
|
||||
'Form 模型除了用来提交数据外,还比较适合用来做详情数据的展示',
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
|
||||
{
|
||||
label: '名称',
|
||||
type: 'static',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'name'
|
||||
},
|
||||
|
||||
{
|
||||
label: '作者',
|
||||
type: 'static',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'author'
|
||||
},
|
||||
|
||||
{
|
||||
label: '输入信息',
|
||||
type: 'static',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'info'
|
||||
},
|
||||
|
||||
{
|
||||
label: '请求时间',
|
||||
type: 'static-datetime',
|
||||
labelClassName: 'text-muted',
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
name: 'date'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
301
examples/components/Linkage/Form2.jsx
Normal file
301
examples/components/Linkage/Form2.jsx
Normal file
@@ -0,0 +1,301 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
title: '表单初始数据自动重新拉取',
|
||||
body: [
|
||||
{
|
||||
type: 'form',
|
||||
mode: 'horizontal',
|
||||
title: '监听表单内部的修改',
|
||||
initApi: '/api/mock2/form/initData?tpl=${tpl}',
|
||||
actions: [],
|
||||
body: [
|
||||
'<span class="text-danger">当 <code>initApi</code> 中有变量,且变量的值发生了变化了,则该表单就会重新初始数据。</span>',
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
|
||||
{
|
||||
label: '数据模板',
|
||||
type: 'select',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'tpl',
|
||||
value: 'tpl1',
|
||||
inline: true,
|
||||
options: [
|
||||
{
|
||||
label: '模板1',
|
||||
value: 'tpl1'
|
||||
},
|
||||
|
||||
{
|
||||
label: '模板2',
|
||||
value: 'tpl2'
|
||||
},
|
||||
|
||||
{
|
||||
label: '模板3',
|
||||
value: 'tpl3'
|
||||
}
|
||||
],
|
||||
description: '<span class="text-danger">请修改这里看效果</span>'
|
||||
},
|
||||
|
||||
{
|
||||
label: '名称',
|
||||
type: 'static',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'name'
|
||||
},
|
||||
|
||||
{
|
||||
label: '作者',
|
||||
type: 'static',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'author'
|
||||
},
|
||||
|
||||
{
|
||||
label: '请求时间',
|
||||
type: 'static-datetime',
|
||||
labelClassName: 'text-muted',
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
name: 'date'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
type: 'grid',
|
||||
columns: [
|
||||
{
|
||||
type: 'form',
|
||||
mode: 'horizontal',
|
||||
title: '自动填充',
|
||||
actions: [],
|
||||
body: [
|
||||
{
|
||||
label: '数据模板',
|
||||
type: 'select',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'tpl',
|
||||
value: 'tpl1',
|
||||
inline: true,
|
||||
options: [
|
||||
{
|
||||
label: '模板1',
|
||||
value: 'tpl1'
|
||||
},
|
||||
|
||||
{
|
||||
label: '模板2',
|
||||
value: 'tpl2'
|
||||
},
|
||||
|
||||
{
|
||||
label: '模板3',
|
||||
value: 'tpl3'
|
||||
}
|
||||
],
|
||||
description: '<span class="text-danger">请修改这里看效果</span>'
|
||||
},
|
||||
|
||||
'<div class="text-danger m-b">如果 <code>initApi</code> 已经暂用,用 <code>service</code>一样可以拉取值填充,同样以下 api 值发生变化时会自动填充。</div>',
|
||||
|
||||
{
|
||||
type: 'service',
|
||||
api: '/api/mock2/form/initData?tpl=${tpl}',
|
||||
body: [
|
||||
{
|
||||
label: '名称',
|
||||
type: 'input-text',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'name'
|
||||
},
|
||||
|
||||
{
|
||||
label: '作者',
|
||||
type: 'input-text',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'author'
|
||||
},
|
||||
|
||||
{
|
||||
label: '请求时间',
|
||||
type: 'input-datetime',
|
||||
labelClassName: 'text-muted',
|
||||
inputFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
name: 'date'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
type: 'form',
|
||||
mode: 'horizontal',
|
||||
title: '手动填充',
|
||||
actions: [],
|
||||
body: [
|
||||
{
|
||||
type: 'group',
|
||||
label: '数据模板',
|
||||
labelClassName: 'text-muted',
|
||||
body: [
|
||||
{
|
||||
type: 'select',
|
||||
name: 'tpl',
|
||||
value: 'tpl1',
|
||||
mode: 'inline',
|
||||
options: [
|
||||
{
|
||||
label: '模板1',
|
||||
value: 'tpl1'
|
||||
},
|
||||
|
||||
{
|
||||
label: '模板2',
|
||||
value: 'tpl2'
|
||||
},
|
||||
|
||||
{
|
||||
label: '模板3',
|
||||
value: 'tpl3'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
mode: 'inline',
|
||||
type: 'button',
|
||||
label: '获取',
|
||||
level: 'dark',
|
||||
actionType: 'reload',
|
||||
target: 'theService'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
'<div class="text-danger m-b">如果不想自动填充,自动填充,则把参数放在 data 里面,就不会监控变化自动拉取了,同时把 <code>servcie</code> 的初始拉取关掉,然后来个刷新目标组件的按钮。</div>',
|
||||
|
||||
{
|
||||
type: 'service',
|
||||
name: 'theService',
|
||||
api: {
|
||||
method: 'get',
|
||||
url: '/api/mock2/form/initData',
|
||||
data: {
|
||||
tpl: '${tpl}'
|
||||
}
|
||||
},
|
||||
body: [
|
||||
{
|
||||
label: '名称',
|
||||
type: 'input-text',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'name'
|
||||
},
|
||||
|
||||
{
|
||||
label: '作者',
|
||||
type: 'input-text',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'author'
|
||||
},
|
||||
|
||||
{
|
||||
label: '请求时间',
|
||||
type: 'input-datetime',
|
||||
labelClassName: 'text-muted',
|
||||
inputFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
name: 'date'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
|
||||
{
|
||||
type: 'form',
|
||||
title: '条件表单',
|
||||
target: 'detailForm',
|
||||
submitOnInit: true,
|
||||
mode: 'inline',
|
||||
body: [
|
||||
{
|
||||
label: '数据模板',
|
||||
type: 'select',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'tpl',
|
||||
value: 'tpl1',
|
||||
options: [
|
||||
{
|
||||
label: '模板1',
|
||||
value: 'tpl1'
|
||||
},
|
||||
|
||||
{
|
||||
label: '模板2',
|
||||
value: 'tpl2'
|
||||
},
|
||||
|
||||
{
|
||||
label: '模板3',
|
||||
value: 'tpl3'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
type: 'submit',
|
||||
label: '提交',
|
||||
primary: true
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
name: 'detailForm',
|
||||
type: 'form',
|
||||
mode: 'horizontal',
|
||||
title: '响应表单',
|
||||
initApi: '/api/mock2/form/initData?tpl=${tpl}',
|
||||
initFetchOn: 'data.tpl',
|
||||
actions: [],
|
||||
body: [
|
||||
'<span class="text-danger">当 <code>initApi</code> 中有变量,且变量的值发生了变化了,则该表单就会重新初始数据。</span>',
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
|
||||
{
|
||||
label: '名称',
|
||||
type: 'static',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'name'
|
||||
},
|
||||
|
||||
{
|
||||
label: '作者',
|
||||
type: 'static',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'author'
|
||||
},
|
||||
|
||||
{
|
||||
label: '请求时间',
|
||||
type: 'static-datetime',
|
||||
labelClassName: 'text-muted',
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
name: 'date'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
34
examples/components/Linkage/FormSubmit.jsx
Normal file
34
examples/components/Linkage/FormSubmit.jsx
Normal file
@@ -0,0 +1,34 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
title: '表单提交后显示结果',
|
||||
body: {
|
||||
type: 'form',
|
||||
api: '/api/mock2/form/saveForm',
|
||||
title: '查询用户 ID',
|
||||
body: [
|
||||
{
|
||||
type: 'input-group',
|
||||
name: 'input-group',
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'name',
|
||||
label: '姓名'
|
||||
},
|
||||
{
|
||||
type: 'submit',
|
||||
label: '查询',
|
||||
level: 'primary'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'static',
|
||||
name: 'id',
|
||||
visibleOn: "typeof data.id !== 'undefined'",
|
||||
label: '返回 ID'
|
||||
}
|
||||
],
|
||||
actions: []
|
||||
}
|
||||
};
|
||||
60
examples/components/Linkage/Options.jsx
Normal file
60
examples/components/Linkage/Options.jsx
Normal file
@@ -0,0 +1,60 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
title: '表单选线之间的远程联动',
|
||||
body: {
|
||||
type: 'form',
|
||||
mode: 'horizontal',
|
||||
title: '',
|
||||
actions: [],
|
||||
body: [
|
||||
'<p class="text-danger">表单选项可以设置 source 通过 API 远程拉取,同时如果 source 中有变量的话,变量值发生变化就会重新拉取,达到联动效果。</p>',
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
|
||||
{
|
||||
label: '选项1',
|
||||
type: 'select',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'a',
|
||||
inline: true,
|
||||
options: [
|
||||
{
|
||||
label: '选项1',
|
||||
value: 1
|
||||
},
|
||||
|
||||
{
|
||||
label: '选项2',
|
||||
value: 2
|
||||
},
|
||||
|
||||
{
|
||||
label: '选项3',
|
||||
value: 3
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
label: '选项2',
|
||||
type: 'select',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'b',
|
||||
inline: true,
|
||||
source: '/api/mock2/options/level2?a=${a}',
|
||||
initFetchOn: 'data.a'
|
||||
},
|
||||
|
||||
{
|
||||
label: '选项3',
|
||||
type: 'select',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'c',
|
||||
inline: true,
|
||||
visibleOn: 'data.b',
|
||||
source: '/api/mock2/options/level3?b=${b}'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
106
examples/components/Linkage/OptionsLocal.jsx
Normal file
106
examples/components/Linkage/OptionsLocal.jsx
Normal file
@@ -0,0 +1,106 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
title: '表单选项的联动',
|
||||
body: {
|
||||
type: 'form',
|
||||
mode: 'horizontal',
|
||||
title: '',
|
||||
actions: [],
|
||||
debug: true,
|
||||
body: [
|
||||
'<p class="text-danger">表单选项内也能联动,通过配置 visibleOn、hiddenOn或者disabledOn</p>',
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
|
||||
{
|
||||
label: '选项1',
|
||||
type: 'list-select',
|
||||
multiple: false,
|
||||
labelClassName: 'text-muted',
|
||||
name: 'a',
|
||||
inline: true,
|
||||
options: [
|
||||
{
|
||||
label: '选项1',
|
||||
value: 1
|
||||
},
|
||||
|
||||
{
|
||||
label: '选项2',
|
||||
value: 2
|
||||
},
|
||||
|
||||
{
|
||||
label: '选项3',
|
||||
value: 3
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
label: '选项级别联动',
|
||||
type: 'radios',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'b',
|
||||
inline: true,
|
||||
selectFirst: true,
|
||||
options: [
|
||||
{
|
||||
label: '选项1',
|
||||
value: 1,
|
||||
disabledOn: 'data.a == 1'
|
||||
},
|
||||
|
||||
{
|
||||
label: '选项2',
|
||||
value: 2,
|
||||
hiddenOn: 'data.a == 2'
|
||||
},
|
||||
|
||||
{
|
||||
label: '选项3',
|
||||
value: 3,
|
||||
visibleOn: 'data.a == 3'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
label: '组件级别联动',
|
||||
type: 'radios',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'b',
|
||||
inline: true,
|
||||
selectFirst: true,
|
||||
visibleOn: 'data.a == 1',
|
||||
options: [
|
||||
{
|
||||
label: '选项1',
|
||||
value: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
label: '选项级别联动',
|
||||
type: 'radios',
|
||||
labelClassName: 'text-muted',
|
||||
name: 'b',
|
||||
inline: true,
|
||||
selectFirst: true,
|
||||
visibleOn: 'data.a == 2',
|
||||
options: [
|
||||
{
|
||||
label: '选项1',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
label: '选项2',
|
||||
value: 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
48
examples/components/Linkage/Page.jsx
Normal file
48
examples/components/Linkage/Page.jsx
Normal file
@@ -0,0 +1,48 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
title: '地址栏变化自动更新',
|
||||
initApi: '/api/mock2/form/initData?id=${id}',
|
||||
aside: {
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
className: '',
|
||||
body: {
|
||||
type: 'nav',
|
||||
stacked: true,
|
||||
links: [
|
||||
{
|
||||
label: '页面1',
|
||||
to: '?id=1'
|
||||
},
|
||||
|
||||
{
|
||||
label: '页面2',
|
||||
children: [
|
||||
{
|
||||
label: '页面2-1',
|
||||
to: '?id=2-1'
|
||||
},
|
||||
{
|
||||
label: '页面2-2',
|
||||
to: '?id=2-2'
|
||||
},
|
||||
{
|
||||
label: '页面2-3(disabled)',
|
||||
disabled: true,
|
||||
to: '?id=2-3'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
label: '页面3',
|
||||
to: '?id=3'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
body: [
|
||||
'<p><span class="text-danger">注意 page 渲染器的 `initApi` 中有变量跟地址栏中变量关联,只要值发生了变化,就会重新拉取一次 initApi。</sapn></p>',
|
||||
'<p>这些数据是通过 initApi 拉取到的数据。 `\\$infoId`: <span class="text-danger">${infoId|default:空}</span></p>'
|
||||
]
|
||||
};
|
||||
Reference in New Issue
Block a user