lg_frontend/templates/dynamicForm/index.js

68 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2024-02-18 11:15:17 +00:00
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)]
)
})
)
}
}