amis/examples/components/Form/Definitions.jsx

277 lines
6.4 KiB
React
Raw Normal View History

export default {
2019-11-07 10:41:14 +08:00
$schema: 'https://houtai.baidu.com/v2/schemas/page.json#',
definitions: {
options: {
type: 'combo',
multiple: true,
multiLine: true,
controls: [
{
type: 'group',
controls: [
{
label: '名称',
name: 'label',
type: 'text',
required: true
},
{
label: '值',
name: 'value',
type: 'text',
required: true
}
]
},
{
$ref: 'options',
label: '子选项',
name: 'children',
addButtonText: '新增子选项'
}
]
},
queryItem: {
type: 'combo',
multiple: true,
multiLine: true,
typeSwitchable: false,
conditions: [
{
label: '条件',
test: "!data.hasOwnProperty('connect')",
scaffold: {},
controls: [
{
type: 'group',
className: 'm-b-none',
controls: [
2019-06-25 16:03:58 +08:00
{
2019-11-07 10:41:14 +08:00
name: 'key',
type: 'text',
placeholder: '字段名',
required: true
2019-06-25 16:03:58 +08:00
},
{
2019-11-07 10:41:14 +08:00
name: 'type',
type: 'select',
value: 0,
options: [
{
label: 'int64',
value: 0
},
{
label: 'double64',
value: 1
},
{
label: 'string',
value: 2
},
{
label: 'version',
value: 3
}
]
},
2019-06-25 16:03:58 +08:00
{
2019-11-07 10:41:14 +08:00
type: 'formula',
name: 'opt',
formula: '""',
condition: '${type}'
},
2019-06-25 16:03:58 +08:00
{
2019-11-07 10:41:14 +08:00
name: 'opt',
type: 'select',
placeholder: '请选择',
required: true,
options: [
{
label: '>',
value: '>',
visibleOn: '~[0,1,3].indexOf(this.type)'
},
{
label: '<',
value: '<',
visibleOn: '~[0,1,3].indexOf(this.type)'
},
{
label: '==',
value: '=='
},
{
label: '>=',
value: '>=',
visibleOn: '~[0,1,3].indexOf(this.type)'
2019-06-26 17:57:23 +08:00
},
2019-11-07 10:41:14 +08:00
{
label: '<=',
value: '<=',
visibleOn: '~[0,1,3].indexOf(this.type)'
},
{
label: 'in',
value: 'in'
},
{
label: 'not in',
value: 'not in'
},
{
label: '!=',
value: '!='
}
]
},
{
name: 'val',
type: 'text',
placeholder: '值',
required: true,
visibleOn:
'~[">", "<", ">=", "<=", "==", "!="].indexOf(this.opt)'
},
{
name: 'val',
type: 'array',
required: true,
minLength: 1,
items: {
type: 'text',
placeholder: '值',
required: true
},
visibleOn: '~["in", "not in"].indexOf(this.opt)'
2019-06-25 16:03:58 +08:00
}
2019-11-07 10:41:14 +08:00
]
}
]
2019-06-25 16:03:58 +08:00
},
2019-11-07 10:41:14 +08:00
{
label: '组合',
test: "data.hasOwnProperty('connect')",
scaffold: {
connect: '&',
exprs: [{}]
},
controls: [
{
type: 'button-group',
name: 'connect',
value: '&',
clearable: false,
size: 'xs',
options: [
2019-06-25 16:03:58 +08:00
{
2019-11-07 10:41:14 +08:00
label: 'AND',
value: '&'
2019-06-25 16:03:58 +08:00
},
2019-11-07 10:41:14 +08:00
2019-06-25 16:03:58 +08:00
{
2019-11-07 10:41:14 +08:00
label: 'OR',
value: '|'
}
2019-11-07 10:41:14 +08:00
]
},
{
$ref: 'queryItem',
name: 'exprs',
minLength: 1,
value: [{}]
}
]
}
2019-11-07 10:41:14 +08:00
]
},
2019-11-07 10:41:14 +08:00
queryGroup: {
type: 'combo',
multiple: false,
multiLine: true,
controls: [
{
2019-11-07 10:41:14 +08:00
type: 'button-group',
name: 'connect',
value: '&',
// label: "连接方式",
// mode: 'inline',
clearable: false,
size: 'sm',
options: [
{
label: 'AND',
value: '&'
},
{
label: 'OR',
value: '|'
}
]
},
{
2019-11-07 10:41:14 +08:00
$ref: 'queryItem',
name: 'exprs',
minLength: 1,
value: [{}]
}
]
}
},
type: 'page',
title: '引用',
body: [
'<p>引用可以用来减少重复的结构定义,<code>最主要的是可以用来实现结构的递归定义</code>。</p>',
{
type: 'form',
api: '/api/mock/saveForm',
mode: 'horizontal',
controls: [
{
$ref: 'options',
name: 'options',
value: [
{
label: '选项1',
value: '1'
}
],
minLength: 1,
label: '选项配置'
}
]
},
{
type: 'form',
api: '/api/mock/saveForm',
controls: [
{
$ref: 'queryGroup',
name: 'q',
value: {},
label: 'Query'
2019-06-25 16:03:58 +08:00
},
2019-11-07 10:41:14 +08:00
{
type: 'static',
name: 'q',
label: '当前值',
tpl: '<pre>${q|json}</pre>'
}
]
}
]
};