diff --git a/src/components/customerOrg/ContactPerson.vue b/src/components/customerOrg/ContactPerson.vue index f2f7cac..c5bc63c 100644 --- a/src/components/customerOrg/ContactPerson.vue +++ b/src/components/customerOrg/ContactPerson.vue @@ -66,7 +66,7 @@ - + @@ -298,63 +298,104 @@ export default { postapi("/api/app/contact-person", body) .then((res) => { //console.log('api/app/contact-person') - this.personId = res.data.id; - this.formTitle = "编辑"; - return deletapi(`/api/app/contact-method/many/${this.personId}`); + if(res.code != -1){ + this.form.id = res.data.id; + this.personId = res.data.id; + this.formTitle = "编辑"; + return deletapi(`/api/app/contact-method/many/${this.personId}`); + } }) .then((res) => { //console.log(`deletapi api/app/contact-method/${this.personId}`) - let contactMethod = []; //联系方式form表单数据 - this.contactMethodListEdit.forEach( item => { - contactMethod.push({ - contactMethodValue: item.contactMethodValue, - contactMethodType: item.contactMethodType, - contactPersonId: this.personId, + if(res.code != -1){ + let contactMethod = []; //联系方式form表单数据 + this.contactMethodListEdit.forEach( item => { + contactMethod.push({ + contactMethodValue: item.contactMethodValue, + contactMethodType: item.contactMethodType, + contactPersonId: this.personId, + }); }); - }); - if(contactMethod.length > 0) return postapi("/api/app/contact-method/many", contactMethod); + if(contactMethod.length > 0){ + return postapi("/api/app/contact-method/many", contactMethod); + }else{ + this.dialogContactPerson = false + } + } }) .then((res) => { //console.log('api/app/contact-method/many') //this.getContactPersonList(this.customerOrgId); //改成局部刷新 - this.customerOrg.contactPersonList.push(res.data) - this.getContactMethodList(res.data.id) + if(res.code != -1){ - this.$message.success("操作成功!"); - this.dialogContactPerson = false + this.getContactMethodList(this.form.id) + + this.$message.success("操作成功!"); + this.dialogContactPerson = false + } }); } else { putapi(`/api/app/contact-person/${this.personId}`, body) .then((res) => { //console.log(`/api/app/contact-person/${this.personId}`) - return deletapi(`/api/app/contact-method/many/${this.personId}`); + if(res.code != -1){ + return deletapi(`/api/app/contact-method/many/${this.personId}`); + } }) .then((res) => { console.log(`deletapi api/app/contact-method/${this.personId}`); - let contactMethod = []; //联系方式form表单数据 - this.contactMethodListEdit.forEach((item, index) => { - contactMethod.push({ - contactMethodValue: item.contactMethodValue, - contactMethodType: item.contactMethodType, - contactPersonId: this.personId, + if(res.code != -1){ + let contactMethod = []; //联系方式form表单数据 + this.contactMethodListEdit.forEach((item, index) => { + contactMethod.push({ + contactMethodValue: item.contactMethodValue, + contactMethodType: item.contactMethodType, + contactPersonId: this.personId, + }); }); - }); - if(contactMethod.length > 0) return postapi("/api/app/contact-method/many", contactMethod); + if(contactMethod.length > 0){ + return postapi("/api/app/contact-method/many", contactMethod); + }else{ + this.dialogContactPerson = false + } + } + }) .then((res) => { //console.log('api/app/contact-method/many') //this.getContactPersonList(this.customerOrgId); //改成局部刷新 - let lfind = arrayExistObj(this.customerOrg.contactPersonList, 'id', this.personId) - if(lfind > - 1) objCopy(body,this.customerOrg.contactPersonList[lfind]) - this.getContactMethodList(this.personId) - - this.$message.success("操作成功!"); - this.dialogContactPerson = false + if(res.code != -1){ + + this.getContactMethodList(this.form.id) + this.$message.success("操作成功!"); + this.dialogContactPerson = false + } }); } }) }, + //新增或编辑后选中记录 + closeDialogPerson(){ + let currentRow = {} + let lfind = arrayExistObj(this.customerOrg.contactPersonList,'id',this.form.id) + if(lfind > -1){ + objCopy(this.form,this.customerOrg.contactPersonList[lfind]) + currentRow = this.customerOrg.contactPersonList[lfind] + }else if(this.form.id){ + currentRow = deepCopy(this.form) + lfind = this.customerOrg.contactPersonList.length + this.customerOrg.contactPersonList.push(currentRow) + } + + if(lfind > -1){ + setTimeout(() => { + this.$refs['customerOrg.contactPersonList'].setCurrentRow(currentRow) + }, 100) + } + + }, + //新增联系方式 addMethod() { this.contactMethodListEdit.push({ diff --git a/src/components/customerOrg/customerOrgEdit.vue b/src/components/customerOrg/customerOrgEdit.vue index 4349ac2..79769f2 100644 --- a/src/components/customerOrg/customerOrgEdit.vue +++ b/src/components/customerOrg/customerOrgEdit.vue @@ -1,6 +1,6 @@