mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:48:55 +08:00
65ac422ed6
* 补充容错 * fix: form 中 name 关联顶层数据初始化失效 * 更新 examples * 文档调整 * 删除多余的文档, 调整 schema * schema 调整 * schema 调整 * control 类型容器 control 改成 body * 修复一个选项加载的bug * form 注册直接用 type
127 lines
2.4 KiB
JavaScript
127 lines
2.4 KiB
JavaScript
export default {
|
|
title: '公式示例',
|
|
body: [
|
|
'<p>通过公式,可以动态的设置目标值。</p>',
|
|
{
|
|
type: 'form',
|
|
title: '自动应用',
|
|
api: '/api/mock2/form/saveForm',
|
|
body: [
|
|
{
|
|
type: 'input-number',
|
|
name: 'a',
|
|
label: 'A'
|
|
},
|
|
|
|
{
|
|
type: 'input-number',
|
|
name: 'b',
|
|
label: 'B'
|
|
},
|
|
|
|
{
|
|
type: 'input-number',
|
|
name: 'sum',
|
|
label: '和',
|
|
disabled: true,
|
|
description: '自动计算 A + B'
|
|
},
|
|
|
|
{
|
|
type: 'formula',
|
|
name: 'sum',
|
|
value: 0,
|
|
formula: 'a + b'
|
|
}
|
|
]
|
|
},
|
|
|
|
{
|
|
type: 'form',
|
|
title: '手动应用',
|
|
api: '/api/mock2/form/saveForm',
|
|
body: [
|
|
{
|
|
type: 'input-number',
|
|
name: 'a',
|
|
label: 'A'
|
|
},
|
|
|
|
{
|
|
type: 'input-number',
|
|
name: 'b',
|
|
label: 'B'
|
|
},
|
|
|
|
{
|
|
type: 'group',
|
|
body: [
|
|
{
|
|
type: 'input-number',
|
|
name: 'sum',
|
|
label: '和',
|
|
disabled: true,
|
|
columnClassName: 'col-sm-11'
|
|
},
|
|
|
|
{
|
|
type: 'button',
|
|
label: '计算',
|
|
columnClassName: 'col-sm-1 v-bottom',
|
|
target: 'theFormula'
|
|
}
|
|
]
|
|
},
|
|
|
|
{
|
|
type: 'formula',
|
|
name: 'sum',
|
|
id: 'theFormula',
|
|
value: 0,
|
|
formula: 'a + b',
|
|
initSet: false,
|
|
autoSet: false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
type: 'form',
|
|
title: '条件应用',
|
|
api: '/api/mock2/form/saveForm',
|
|
body: [
|
|
{
|
|
type: 'radios',
|
|
name: 'radios',
|
|
inline: true,
|
|
label: 'radios',
|
|
options: [
|
|
{
|
|
label: 'a',
|
|
value: 'a'
|
|
},
|
|
{
|
|
label: 'b',
|
|
value: 'b'
|
|
}
|
|
],
|
|
description: 'radios 变化会自动清空 B'
|
|
},
|
|
{
|
|
type: 'input-text',
|
|
name: 'b',
|
|
label: 'B'
|
|
},
|
|
|
|
{
|
|
type: 'formula',
|
|
name: 'b',
|
|
value: 'some string',
|
|
formula: "''",
|
|
condition: '${radios}',
|
|
initSet: false
|
|
}
|
|
]
|
|
}
|
|
]
|
|
};
|