Commit 0fcdcb50ff005eceddf18eab065142701c2163ce

Authored by 刘汉宸
1 parent cddedae7

feat: 优化表单生成

examples/views/docs/component/schema-page.md
@@ -667,3 +667,16 @@ export default { @@ -667,3 +667,16 @@ export default {
667 参数|说明|类型|可选值|默认值 667 参数|说明|类型|可选值|默认值
668 -|-|-|-|- 668 -|-|-|-|-
669 schema | JSON Schema配置项列表 | Array | - | [] 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 \ No newline at end of file 683 \ No newline at end of file
packages/form-item/index.vue
@@ -4,7 +4,7 @@ export default { @@ -4,7 +4,7 @@ export default {
4 props: { 4 props: {
5 label: String, 5 label: String,
6 labelWidth: String, 6 labelWidth: String,
7 - value: [Number, String, Array, Object], 7 + value: [Number, String, Array, Boolean, Object],
8 prop: String, 8 prop: String,
9 span: { 9 span: {
10 type: [Number, String], 10 type: [Number, String],
packages/schema-form/index.vue
@@ -47,14 +47,18 @@ export default { @@ -47,14 +47,18 @@ export default {
47 } 47 }
48 } 48 }
49 let _props = item.props || {}; 49 let _props = item.props || {};
50 - if (props.value) { 50 + if ('value' in props) {
51 _props = { ..._props, value: props.value }; 51 _props = { ..._props, value: props.value };
52 } 52 }
53 let _on = item.on || {}; 53 let _on = item.on || {};
54 if (props.onInput) { 54 if (props.onInput) {
55 _on = { ..._on, input: props.onInput }; 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,7 +20,7 @@
20 <div v-if="schema.action !== false" class="z-schema-page__action"> 20 <div v-if="schema.action !== false" class="z-schema-page__action">
21 <slot name="action" v-bind="_slotScope"> 21 <slot name="action" v-bind="_slotScope">
22 <el-button :size="_size" type="primary" @click="openNew">新增</el-button> 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 <slot name="action-button" v-bind="_slotScope"></slot> 24 <slot name="action-button" v-bind="_slotScope"></slot>
25 </slot> 25 </slot>
26 </div> 26 </div>
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 <div v-if="schema.table" class="z-schema-page__table"> 28 <div v-if="schema.table" class="z-schema-page__table">
29 <z-schema-table :schema="tableSchemaDefaultProps(schema.table)" v-model="tableData" v-loading="loading" @selection-change="onTableSelectionChange"> 29 <z-schema-table :schema="tableSchemaDefaultProps(schema.table)" v-model="tableData" v-loading="loading" @selection-change="onTableSelectionChange">
30 <template #left> 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 </template> 32 </template>
33 <template v-for="item in getSlotKeys('table-')" #[item.name]="slotScope"> 33 <template v-for="item in getSlotKeys('table-')" #[item.name]="slotScope">
34 <slot :name="item.slot" v-bind="{ ..._slotScope, ...slotScope }"></slot> 34 <slot :name="item.slot" v-bind="{ ..._slotScope, ...slotScope }"></slot>