Merge pull request #4942 from nwind/feat-property-autovar

feat: Property 的 title 等属性支持自动变量解析 Closes #4900
This commit is contained in:
RUNZE LU 2022-07-22 11:09:13 +08:00 committed by GitHub
commit da2469c1ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 9 deletions

View File

@ -165,6 +165,7 @@ order: 60
{ {
"type": "page", "type": "page",
"data": { "data": {
"title": "title1",
"items": [ "items": [
{ {
"label": "cpu", "label": "cpu",
@ -196,6 +197,7 @@ order: 60
}, },
"body": { "body": {
"type": "property", "type": "property",
"title": "${title}",
"source": "${items}" "source": "${items}"
} }
} }
@ -372,6 +374,8 @@ items 里的属性还支持 `visibleOn` 和 `hiddenOn` 表达式,能隐藏部
| column | `number` | 3 | 每行几列 | | column | `number` | 3 | 每行几列 |
| mode | `string` | 'table' | 显示模式,目前只有 'table' 和 'simple' | | mode | `string` | 'table' | 显示模式,目前只有 'table' 和 'simple' |
| separator | `string` | ',' | 'simple' 模式下属性名和值之间的分隔符 | | separator | `string` | ',' | 'simple' 模式下属性名和值之间的分隔符 |
| title | `string` | | 标题 |
| source | `string` | | 数据源 |
| items[].label | `SchemaTpl` | | 属性名 | | items[].label | `SchemaTpl` | | 属性名 |
| items[].content | `SchemaTpl` | | 属性值 | | items[].content | `SchemaTpl` | | 属性值 |
| items[].span | `SchemaTpl` | | 属性值跨几列 | | items[].span | `SchemaTpl` | | 属性值跨几列 |

View File

@ -119,14 +119,7 @@ export default class Property extends React.Component<PropertyProps, object> {
*/ */
prepareRows() { prepareRows() {
const {column = 3, items, source, data} = this.props; const {column = 3, items, source, data} = this.props;
const propertyItems = const propertyItems = items ? items : source || [];
(items
? items
: (resolveVariableAndFilter(
source,
data,
'| raw'
) as Array<PropertyItem>)) || [];
const rows: PropertyContent[][] = []; const rows: PropertyContent[][] = [];
@ -246,6 +239,7 @@ export default class Property extends React.Component<PropertyProps, object> {
} }
@Renderer({ @Renderer({
type: 'property' type: 'property',
autoVar: true
}) })
export class PropertyRenderer extends Property {} export class PropertyRenderer extends Property {}