Browse Source

contactPerson

master
pengjun 2 years ago
parent
commit
f9338adee5
  1. 113
      src/components/customerOrg/ContactPerson.vue
  2. 8
      src/utlis/proFunc.js

113
src/components/customerOrg/ContactPerson.vue

@ -81,22 +81,22 @@
<el-row>
<el-col :span="5">
<el-form-item label="创建者">
<el-input v-model="customerOrg.customerOrgRd.creatorName" disabled></el-input>
<el-input v-model="form.creatorName" disabled></el-input>
</el-form-item>
</el-col>
<el-col :span="7">
<el-form-item label="创建时间" style="margin-left: -5%">
<el-input :value="customerOrg.customerOrgRd.creationTime | dateFormat" disabled style="width: 90%"></el-input>
<el-input :value="form.creationTime | dateFormat" disabled style="width: 90%"></el-input>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="修改者" style="margin-left: -25%">
<el-input v-model="customerOrg.customerOrgRd.creatorName" disabled></el-input>
<el-input v-model="form.creatorName" disabled></el-input>
</el-form-item>
</el-col>
<el-col :span="7">
<el-form-item label="修改时间" style="margin-left: -5%">
<el-input :value="customerOrg.customerOrgRd.lastModificationTime | dateFormat" disabled style="width: 90%"></el-input>
<el-input :value="form.lastModificationTime | dateFormat" disabled style="width: 90%"></el-input>
</el-form-item>
</el-col>
</el-row>
@ -141,7 +141,7 @@
import { mapState } from 'vuex'
import { getapi, postapi, putapi, deletapi } from "@/api/api";
import { objCopy } from '../../utlis/proFunc'
export default {
components: {
@ -149,13 +149,7 @@ export default {
data() {
return {
personId:'',
form: {
customerOrgId:'',
displayName: "",
title: "",
remark: "",
},
form: {}, //
formTitle:'新增',
dialogContactPerson: false, //
@ -163,9 +157,8 @@ export default {
//{ value: '',label: '' },
{ value: '0',label: '电话' },
{ value: '1',label: '邮箱' },
],
],
contactMethod: [], //form
rules: {
displayName: [
{ required: true, message: "请输入名称", trigger: "blur" },
@ -212,13 +205,23 @@ export default {
//
add() {
//this.$message.success(" addContactPerson");
if(!this.customerOrg.customerOrgId){
alert("没有体检单位信息")
return
}
this.form = {customerOrgId:this.customerOrg.customerOrgId}
this.dialogContactPerson = true
this.formTitle = "新增"
this.personId = ''
this.customerOrg.contactMethodList = []
},
edit() {
//this.$message.success(" editContactPerson");
if(!this.personId || !this.customerOrg.customerOrgId){
if(!this.customerOrg.customerOrgId){
alert("没有体检单位信息")
return
}else if(!this.personId){
alert("请先选择要编辑的联系人")
return
}
@ -226,39 +229,88 @@ export default {
this.formTitle = "编辑"
},
//
del() {
this.$message.success("删除 delContactPerson");
//this.$message.success(" delContactPerson");
deletapi(`/api/app/contact-person/${this.personId}`).then(
(res) => {
this.getContactPersonList(this.customerOrg.customerOrgId)
this.customerOrg.contactMethodList = []
this.$message.success("操作成功!");
}
);
},
//
deleteRow (index){
this.customerOrg.contactMethodList.splice(index, 1)
},
//
submit(){
submit(){
let body = {
customerOrgId:'',
displayName: "",
title: "",
remark: "",
}
objCopy(this.form,body)
console.log('body',body)
if(this.formTitle === '新增'){
postapi('api/app/contact-person',form).then(
postapi('/api/app/contact-person',body).then(
(res) => {
//console.log('res.data',res.data)
//console.log('api/app/contact-person')
this.personId = res.data.id
return deletapi(`api/app/contact-method/${this.personId}`)
this.formTitle = '编辑'
return deletapi(`/api/app/contact-method/many/${this.personId}`)
}
).then(
(res) => {
//console.log('res.data',res.data)
this.personId = res.data.id
return postapi('api/app/contact-method/many',contactMethod)
//console.log(`deletapi api/app/contact-method/${this.personId}`)
let contactMethod = [] //form
this.customerOrg.contactMethodList.forEach((item, index) => {
contactMethod.push({
contactMethodValue: item.contactMethodValue,
contactMethodType: item.contactMethodType,
contactPersonId: this.personId
})
});
return postapi('/api/app/contact-method/many',contactMethod)
}
).then(
(res) => {
//console.log('api/app/contact-method/many')
this.getContactPersonList(this.customerOrg.customerOrgId)
this.$message.success("操作成功!");
}
}
);
}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}`)
}
).then(
(res) => {
console.log(`deletapi api/app/contact-method/${this.personId}`)
let contactMethod = [] //form
this.customerOrg.contactMethodList.forEach((item, index) => {
contactMethod.push({
contactMethodValue: item.contactMethodValue,
contactMethodType: item.contactMethodType,
contactPersonId: this.personId
})
});
return postapi('/api/app/contact-method/many',contactMethod)
}
).then(
(res) => {
//console.log('api/app/contact-method/many')
this.getContactPersonList(this.customerOrg.customerOrgId)
this.$message.success("操作成功!");
}
);
}
},
@ -268,14 +320,15 @@ export default {
this.customerOrg.contactMethodList.push({
contactMethodValue: "",
contactMethodType: "0",
contactPersonId: this.personId
contactPersonId: this.personId
})
},
rowClick(row){
// console.log('row',row)
console.log('row',row)
// this.$message.success("rowClick");
this.personId = row.id
this.form = row
this.personId = row.id
this.getContactMethodList(row.id)
},

8
src/utlis/proFunc.js

@ -1,4 +1,5 @@
//多级联动选择数据处理
exports.tcdate = (date) => {
for (var i = 0; i < date.length; i++) {
if (date[i].treeChildren.length == 0) {
@ -8,3 +9,10 @@ exports.tcdate = (date) => {
}
}
}
//json 对像赋值 只从 from 对象 赋值 to 中有的 key 项
exports.objCopy = (from,to) => {
for(let key in to){
to[key] = from[key]
}
}
Loading…
Cancel
Save