61 lines
986 B
TypeScript
61 lines
986 B
TypeScript
interface Config {
|
|
ref: string,
|
|
model: string,
|
|
rules: string,
|
|
size: string,
|
|
labelPosition: string,
|
|
labelWidth: number,
|
|
disabled: boolean,
|
|
isMobile: boolean,
|
|
counter: 0
|
|
}
|
|
|
|
export default class FormBuild {
|
|
// 表单配置
|
|
config: Config
|
|
// 字段信息
|
|
fields: Array<any>
|
|
// 激活字段
|
|
activeField: Object
|
|
|
|
constructor() {
|
|
this.config = {
|
|
ref: 'formRef',
|
|
model: 'form',
|
|
rules: 'rules',
|
|
size: 'default',
|
|
labelPosition: 'right',
|
|
labelWidth: 100,
|
|
disabled: false,
|
|
isMobile: false,
|
|
counter: 0
|
|
}
|
|
this.fields = []
|
|
this.activeField = null
|
|
}
|
|
|
|
restData() {
|
|
this.config = {
|
|
ref: 'formRef',
|
|
model: 'form',
|
|
rules: 'rules',
|
|
size: 'default',
|
|
labelPosition: 'right',
|
|
labelWidth: 100,
|
|
disabled: false,
|
|
isMobile: false,
|
|
counter: 0
|
|
}
|
|
this.fields = []
|
|
}
|
|
|
|
initData(config: Config, fields: Array<any>) {
|
|
this.config = config
|
|
this.fields = fields
|
|
}
|
|
|
|
setActiveField(field: Object) {
|
|
this.activeField = field
|
|
}
|
|
}
|