Commit 0fcdcb50ff005eceddf18eab065142701c2163ce
1 parent
cddedae7
Exists in
master
and in
2 other branches
feat: 优化表单生成
Showing
4 changed files
with
22 additions
and
5 deletions
Show diff stats
examples/views/docs/component/schema-page.md
| ... | ... | @@ -667,3 +667,16 @@ export default { |
| 667 | 667 | 参数|说明|类型|可选值|默认值 |
| 668 | 668 | -|-|-|-|- |
| 669 | 669 | schema | JSON Schema配置项列表 | Array | - | [] |
| 670 | + | |
| 671 | +## Schema 参数 | |
| 672 | + | |
| 673 | +参数|说明|类型|可选值|默认值 | |
| 674 | +-|-|-|-|- | |
| 675 | +filter | 搜索表单,false表示不显示,Object表示Schema | Object, Boolean | - | false | |
| 676 | +action | 操作栏显示状态 | Boolean | - | true | |
| 677 | +table | 表格,false表示不显示,Object表示Schema | Object, Boolean | - | false | |
| 678 | +operation | 操作列,false表示不显示,Object表示操作栏配置 | Object, Boolean | - | {} | |
| 679 | +pagination | 分页器,false表示不显示,Object表示分页器配置 | Object, Boolean | - | {} | |
| 680 | +form | 表单,false表示不显示,Object表示Schema | Object, Boolean | - | false | |
| 681 | +action | 表单 | Boolean | - | true | |
| 682 | +selection | 可选择 | Boolean | - | true | |
| 670 | 683 | \ No newline at end of file | ... | ... |
packages/form-item/index.vue
packages/schema-form/index.vue
| ... | ... | @@ -47,14 +47,18 @@ export default { |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | let _props = item.props || {}; |
| 50 | - if (props.value) { | |
| 50 | + if ('value' in props) { | |
| 51 | 51 | _props = { ..._props, value: props.value }; |
| 52 | 52 | } |
| 53 | 53 | let _on = item.on || {}; |
| 54 | 54 | if (props.onInput) { |
| 55 | 55 | _on = { ..._on, input: props.onInput }; |
| 56 | 56 | } |
| 57 | - return h(item.is, { attrs: item.attrs, props: _props, on: _on }, content); | |
| 57 | + const otherAttrs = ['class', 'attrs', 'style', 'domProps', 'slot', 'key', 'ref'].reduce((result, current) => { | |
| 58 | + result[current] = item[current]; | |
| 59 | + return result; | |
| 60 | + }, {}); | |
| 61 | + return h(item.is, { props: _props, on: _on, ...otherAttrs }, content); | |
| 58 | 62 | }, |
| 59 | 63 | }, |
| 60 | 64 | }, | ... | ... |
packages/schema-page/index.vue
| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | <div v-if="schema.action !== false" class="z-schema-page__action"> |
| 21 | 21 | <slot name="action" v-bind="_slotScope"> |
| 22 | 22 | <el-button :size="_size" type="primary" @click="openNew">新增</el-button> |
| 23 | - <el-button :size="_size" plain :disabled="selection.length === 0" @click="onDeleteMultiple(selection)">删除</el-button> | |
| 23 | + <el-button v-if="schema.selection !== false" :size="_size" plain :disabled="selection.length === 0" @click="onDeleteMultiple(selection)">删除</el-button> | |
| 24 | 24 | <slot name="action-button" v-bind="_slotScope"></slot> |
| 25 | 25 | </slot> |
| 26 | 26 | </div> |
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | <div v-if="schema.table" class="z-schema-page__table"> |
| 29 | 29 | <z-schema-table :schema="tableSchemaDefaultProps(schema.table)" v-model="tableData" v-loading="loading" @selection-change="onTableSelectionChange"> |
| 30 | 30 | <template #left> |
| 31 | - <el-table-column v-if="schema.selectable !== false" type="selection" width="40" align="center"></el-table-column> | |
| 31 | + <el-table-column v-if="schema.selection !== false" type="selection" width="40" align="center"></el-table-column> | |
| 32 | 32 | </template> |
| 33 | 33 | <template v-for="item in getSlotKeys('table-')" #[item.name]="slotScope"> |
| 34 | 34 | <slot :name="item.slot" v-bind="{ ..._slotScope, ...slotScope }"></slot> | ... | ... |