68 lines
1.1 KiB
JavaScript
68 lines
1.1 KiB
JavaScript
|
|
import createControlComponent from "./createControlComponent";
|
|||
|
|
import createFormComponent from "./createFormComponent";
|
|||
|
|
|
|||
|
|
export default {
|
|||
|
|
name: 'dynamicForm',
|
|||
|
|
props: {
|
|||
|
|
/**
|
|||
|
|
* 表单配置项
|
|||
|
|
*/
|
|||
|
|
formOption: {
|
|||
|
|
type: Object,
|
|||
|
|
default: () => ({})
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* 控件列表配置项
|
|||
|
|
*/
|
|||
|
|
options: {
|
|||
|
|
type: Array,
|
|||
|
|
default: () => []
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 表单全局列配置
|
|||
|
|
*/
|
|||
|
|
colOption: {
|
|||
|
|
type: Object,
|
|||
|
|
default: () => ({})
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 表单全局行配置
|
|||
|
|
*/
|
|||
|
|
rowOption: {
|
|||
|
|
type: Object,
|
|||
|
|
default: null
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 校验结果,正确触发回调
|
|||
|
|
* @param cb
|
|||
|
|
*/
|
|||
|
|
validate (cb) {},
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 重置表单内容
|
|||
|
|
*/
|
|||
|
|
reset () {}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
render (h) {
|
|||
|
|
return h(
|
|||
|
|
'a-form-model',
|
|||
|
|
this.formOption,
|
|||
|
|
this.options.map(({ type, formItemOption, elementOption }) => {
|
|||
|
|
return createFormComponent(
|
|||
|
|
h, formItemOption,
|
|||
|
|
this.rowOption,
|
|||
|
|
this.colOption,
|
|||
|
|
[createControlComponent(h, type, elementOption)]
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|