pengjun 2 years ago
parent
commit
78b7a03f59
  1. 54
      src/components/customerOrg/ContactPerson.vue

54
src/components/customerOrg/ContactPerson.vue

@ -108,7 +108,7 @@
</el-form-item>
</el-col>
</el-row>
<el-table :data="customerOrg.contactMethodList" border height="300" row-key="id" size="small"
<el-table :data="contactMethodListEdit" border height="300" row-key="id" size="small"
highlight-current-row ref="contactMethod" style="margin-top: 20px;">
<el-table-column prop="contactMethodType" label="类型" width="200">
<template slot-scope="scope">
@ -142,7 +142,7 @@
import moment from "moment";
import { mapState } from "vuex";
import { getapi, postapi, putapi, deletapi } from "@/api/api";
import { objCopy } from "../../utlis/proFunc";
import { objCopy, deepCopy, arrayExistObj } from "../../utlis/proFunc";
export default {
components: {},
props:["customerOrgId"],
@ -150,6 +150,7 @@ export default {
return {
personId: "",
form: {}, //
contactMethodListEdit:[], //
formTitle: "新增",
dialogContactPerson: false, //
@ -196,6 +197,7 @@ export default {
}).then((res) => {
//console.log('res.data',res.data)
this.customerOrg.contactMethodList = res.data;
this.contactMethodListEdit = deepCopy(res.data);
});
},
@ -245,29 +247,31 @@ export default {
}).then((res) => {
if(res.code != -1) {
this.personId = "";
this.getContactPersonList(this.customerOrg.customerOrgId);
this.customerOrg.contactMethodList = [];
this.$message.success("操作成功!");
}
}).catch((err) => {
console.log(`deletapi:/api/app/contact-person/${this.personId}`,err);
if (err == "cancel") {
this.$message.info("已取消删除");
}
});
},
//
deleteRow(index) {
this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", {
this.$confirm("此操作确定后将永久删除该记录, 是否继续?", "提示", {
confirmButtonText: "是",
cancelButtonText: "否",
type: "warning",
}).then(() => {
this.customerOrg.contactMethodList.splice(index, 1);
this.submit('form');
this.contactMethodListEdit.splice(index, 1);
//this.submit('form');
}).catch((err) => {
if(err == 'cancel'){
this.$message.info("已取消删除");
}else{
this.$message.error("操作失败,原因:" + err);
}
});
@ -281,11 +285,15 @@ export default {
title: "",
remark: "",
};
this.$refs[formName].validate((valid, failField) => {
if (valid) {
this.$refs[formName].validate((valid, fields) => {
if (!valid){
this.$message.warning(fields[Object.keys(fields)[0]][0].message);
return false;
}
objCopy(this.form, body);
console.log("body", body);
if (this.formTitle === "新增") {
if (this.formTitle == "新增") {
postapi("/api/app/contact-person", body)
.then((res) => {
//console.log('api/app/contact-person')
@ -296,7 +304,7 @@ export default {
.then((res) => {
//console.log(`deletapi api/app/contact-method/${this.personId}`)
let contactMethod = []; //form
this.customerOrg.contactMethodList.forEach((item, index) => {
this.contactMethodListEdit.forEach( item => {
contactMethod.push({
contactMethodValue: item.contactMethodValue,
contactMethodType: item.contactMethodType,
@ -307,7 +315,10 @@ export default {
})
.then((res) => {
//console.log('api/app/contact-method/many')
this.getContactPersonList(this.customerOrg.customerOrgId);
//this.getContactPersonList(this.customerOrgId); //
this.customerOrg.contactPersonList.push(res.data)
this.getContactMethodList(res.data.id)
this.$message.success("操作成功!");
this.dialogContactPerson = false
});
@ -320,7 +331,7 @@ export default {
.then((res) => {
console.log(`deletapi api/app/contact-method/${this.personId}`);
let contactMethod = []; //form
this.customerOrg.contactMethodList.forEach((item, index) => {
this.contactMethodListEdit.forEach((item, index) => {
contactMethod.push({
contactMethodValue: item.contactMethodValue,
contactMethodType: item.contactMethodType,
@ -331,22 +342,21 @@ export default {
})
.then((res) => {
//console.log('api/app/contact-method/many')
this.getContactPersonList(this.customerOrg.customerOrgId);
//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
});
}
} else {
//console.log('failField',failField)
this.$message.warning("未通过数据校验!");
return false;
}
})
},
//
addMethod() {
this.customerOrg.contactMethodList.push({
this.contactMethodListEdit.push({
contactMethodValue: "",
contactMethodType: "0",
contactPersonId: this.personId,
@ -356,7 +366,7 @@ export default {
rowClick(row) {
console.log("row", row);
// this.$message.success("rowClick");
this.form = row;
this.form = deepCopy(row);
this.personId = row.id;
this.getContactMethodList(row.id);
},

Loading…
Cancel
Save