// 字段初始化
async fieldInit (fields) {
// 字段 (isFixed: false 非固定字段)
let newFields = fields.filter(f => !f.isFixed)
this.form.customFieldList = await Promise.all(newFields.map((item, index) => this.fieldsFormatter(item, index)))
},
fieldsFormatter (item, index) {
return new Promise(async resolve => {
if (this.drawerTitle === '新建工单') {
resolve({
fieldId: item['id'],
value: this.fieldValueInit(item),
fieldName: item['name'],
fieldType: { type: item['type'], label: this.fieldTypeFormatter(item['type']) },
required: item['required'],
optional: await this.getOptional(item['id']),
_index: index
})
} else {
resolve({
fieldId: item['fieldId'],
value: this.fieldValueInit(item),
fieldName: item['fieldName'],
fieldType: { type: item['fieldType'], label: this.fieldTypeFormatter(item['fieldType']) },
required: item['required'],
optional: item['optional'],
_index: index
})
}
})
},
promise.all(forEach).png
网友评论