Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
Bug:导入代码,json 错误处理及 formAttr Bug修复
Browse files Browse the repository at this point in the history
导入代码,json 错误处理及 formAttr Bug修复
  • Loading branch information
Wisenl committed Feb 5, 2020
1 parent 1acd55e commit fb3727b
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/components/app-main/components/main-header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export default {
// 处理数据
jsonInput(json) {
this.jsonData = _.cloneDeep(json)
this.jsonFormDesc = _.cloneDeep(json).formDesc
this.jsonFormDesc = this.jsonData.formDesc
},
processData(obj, defaultObj = {}, assistProperty = [], formatterObj = {}) {
obj = _.cloneDeep(obj)
Expand Down Expand Up @@ -229,8 +229,18 @@ export default {
},
// 处理粘贴的json
handleJson() {
this.jsonTempFormAttr = Object.assign(formAttrDefault, this.jsonData) // 临时预览的 formAttr
this.innerDialogShow = true
if (typeof this.jsonData !== 'object') {
this.$message.error('请输入正确的 JSON 格式!')
return false
}
if (this.jsonData && this.jsonData.formDesc) {
let keys = Object.keys(formAttrDefault)
this.jsonTempFormAttr = Object.assign(formAttrDefault, _.pick(this.jsonData, keys)) // 临时预览的 formAttr
this.innerDialogShow = true
} else {
this.$message.error('数据必须有 "formDesc" 属性!')
return false
}
},
// 确认生成表单
confirmGen() {
Expand All @@ -243,8 +253,7 @@ export default {
// 清空原有list (待优化)
this.clearForm()
// 1.分离 formAttr (表单配置数据)
let formAttr = Object.assign(formAttrDefault, this.jsonData) // 覆盖原有数据
this.updateFormAttr(formAttr)
this.updateFormAttr(this.jsonTempFormAttr)
// 2.更新 formDesc(组件通用配置数据)
let list = Object.entries(this.jsonFormDesc).map(([key, val]) => {
// 3.处理 formDesc.attr(组件属性配置数据)
Expand Down

0 comments on commit fb3727b

Please sign in to comment.