[bug] 表单下拉带出信息清除

This commit is contained in:
zhaoxiao
2021-10-28 11:25:55 +08:00
parent f8fdade998
commit 0d03b8dd08
3 changed files with 55 additions and 33 deletions
@@ -309,7 +309,7 @@ export default {
},
principalId: {
rules: [{ required: true, message: '请选择负责人' }],
validateTrigger: 'blur'
validateTrigger: 'change'
},
contractAmount: {
rules: [{ required: true, validator: this.checkMoney }],
@@ -527,15 +527,21 @@ export default {
* @param value
*/
principalChange(value) {
let param = {
id: value
}
getAllUserList(param).then(res => {
this.model.departmentName = res.result[0].orgCodeTxt
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'departmentName'))
// value不为undefined
if (value) {
let param = {
id: value
}
getAllUserList(param).then(res => {
this.model.departmentName = res.result[0].orgCodeTxt
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'departmentName'))
})
})
})
return
}
// value为undefined时清除部门名称
this.form.setFieldsValue({departmentName: undefined})
},
/**
* 总签订金额修改
@@ -589,19 +589,25 @@ export default {
* @param value
*/
principalChange(value) {
let param = {
id: value
}
getAllUserList(param).then(res => {
if (res.success) {
this.model.departmentName = res.result[0].orgCodeTxt
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'departmentName'))
})
} else {
this.$message.warn(res.message)
// value不为undefined
if (value) {
let param = {
id: value
}
})
getAllUserList(param).then(res => {
if (res.success) {
this.model.departmentName = res.result[0].orgCodeTxt
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'departmentName'))
})
} else {
this.$message.warn(res.message)
}
})
return
}
// value为undefined时清除部门名称
this.form.setFieldsValue({departmentName: undefined})
},
/**
* 打包状态修改
@@ -283,18 +283,28 @@ export default {
*/
postContactChange(value) {
console.log(value)
getContactsById({ id: value }).then(res => {
let obj = {
postalCode: res.result.postalCode,
contactAddress: res.result.contactAddress
}
if (this.packContactId) {
this.packContact = obj
this.packContact.contactId = value
} else {
this.form.setFieldsValue(pick(obj, 'postalCode', 'contactAddress'))
}
})
// value不为undefined
if (value) {
getContactsById({ id: value }).then(res => {
let obj = {
postalCode: res.result.postalCode,
contactAddress: res.result.contactAddress
}
if (this.packContactId) {
this.packContact = obj
this.packContact.contactId = value
} else {
this.form.setFieldsValue(pick(obj, 'postalCode', 'contactAddress'))
}
})
return
}
// value为undefined,清除邮政编码和通讯地址
const obj = {
postalCode: undefined,
contactAddress: undefined
}
this.form.setFieldsValue(pick(obj, 'postalCode', 'contactAddress'))
},
/**
* 清空本次开票金额