Commit 6d2ee4be authored by 毛线's avatar 毛线

代码优化

parent 81e463d9
......@@ -99,7 +99,7 @@ export default {
// 主键
id() {
const { primaryKey } = this
return this.form[primaryKey]
return this.form ? this.form[primaryKey] : ''
},
width() {
return this.props.width || '900px'
......@@ -201,7 +201,7 @@ export default {
return {
// 初始化表单数据
form: (data) => {
const { fieldList } = this
const { fieldList, primaryKey } = this
let form = {}
if (!fieldList) {
return
......@@ -235,7 +235,7 @@ export default {
break
}
}
value = value || ''
attr.placeholder = placeholder
item.attr = attr
......@@ -243,7 +243,8 @@ export default {
form[field] = value
})
form[primaryKey] = data[primaryKey]
// 如果配置参数设置了编辑时候清空某个表单字段,则将字段的值清空
Object.keys(data).forEach(key => {
const field = fieldList.filter(i => i.field == key)[0]
......@@ -261,7 +262,6 @@ export default {
}
}
this.form = form
this.$nextTick(() => {
// 清除表单验证
this.$refs['form']?.clearValidate()
......@@ -282,8 +282,7 @@ export default {
// 请求成功并返回数据
this.loading = false // 关闭表单加载状态
if (this.id) { // id存在 把数据存储到当前页面
const { form } = data
this.form = form
this.form = data
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment