Skip to content

Commit

Permalink
feat(schema-generator): 优化导出代码
Browse files Browse the repository at this point in the history
  • Loading branch information
lljj-x committed Nov 23, 2020
1 parent f13a159 commit 20d429c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ function genBaseObj() {
return {
type: 'object',
required: [],
properties: {}
properties: {},
'ui:order': []
};
}

Expand Down Expand Up @@ -215,6 +216,9 @@ export function componentList2JsonSchema(componentList) {
// 连接数据
(parentObj.properties || parentObj.items.properties)[item.componentValue.property] = curSchema;

// 设置 ui:order
(parentObj['ui:order'] || parentObj.items['ui:order']).push(item.componentValue.property);

// 设置 required
if (required) {
(parentObj.required || parentObj.items.required).push(item.componentValue.property);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const viewSchema = {
items: {
type: 'object',
required: [],
properties: {}
properties: {},
'ui:order': []
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const viewSchema = {
title: 'Object',
type: 'object',
required: [],
properties: {}
properties: {},
'ui:order': []
};

export default {
Expand Down
11 changes: 6 additions & 5 deletions packages/lib/src/JsonSchemaForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ export default {
rootSchema: this.schema,
rootFormData: this.formData, // 根节点的数据
curNodePath: '', // 当前节点路径
formProps
formProps: {
labelPosition: 'top',
labelSuffix: ':',
...formProps,
}
};

return h(
Expand All @@ -137,10 +141,7 @@ export default {
ref: 'genEditForm',
props: {
model: self.formData,
labelPosition: 'top',
labelSuffix: ':',
...formProps
// size: 'small'
...props.formProps
}
},
[
Expand Down

0 comments on commit 20d429c

Please sign in to comment.