Commit 6fc8b14b authored by 黄卓's avatar 黄卓

新建客户,至少填写一个联系人信息

http://zentao.jdshangmen.com/bug-view-8.html
parent dea2266a
......@@ -2,7 +2,7 @@
<div>
<el-row type="flex" style="margin-top: 15px;margin-bottom: 15px" justify="center">
<el-col :xs="24" :sm="24" :md="24" :lg="20" :xl="16">
<el-col :xs="24" :sm="24" :md="24" :lg="22" :xl="20">
<el-form ref="form" :model="form" :rules="rules" label-width="150px">
<el-row :gutter="10">
<el-col :span="12">
......@@ -207,6 +207,7 @@
<span>联系人</span>
<el-button style="float: right;" size="small" type="primary" @click="handleAddContact">+</el-button>
</div>
<el-form ref="contactForm" :rules="contactRules" :model="form">
<el-table
:data="form.customerContacts"
style="width: 100%"
......@@ -216,8 +217,10 @@
label="部门"
width=""
>
<template v-slot="{ row, column, $index }">
<el-input v-model="row.department" placeholder="请输入部门" size="mini"/>
<template v-slot="{ row }">
<el-form-item label="">
<el-input v-model="row.department" placeholder="请输入部门" size="mini"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
......@@ -226,43 +229,51 @@
width=""
>
<template v-slot="{row}">
<el-input v-model="row.position" placeholder="请输入职位" size="mini"/>
<el-form-item label="">
<el-input v-model="row.position" placeholder="请输入职位" size="mini"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
prop="name"
label="联系人"
>
<template v-slot:header>
<template slot="header">
联系人 <span style="color: #ff0000">*</span>
</template>
<template v-slot="{row}">
<el-input v-model="row.name" placeholder="请输入联系人" size="mini"/>
<template v-slot="{row, cellValue, $index}">
<el-form-item :rules="contactRules.name" :prop="'customerContacts.' + $index + '.name'" label="">
<el-input v-model="row.name" placeholder="请输入联系人" size="mini"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
prop="areaCode"
label="区号"
>
<template v-slot:header>
<template slot="header">
区号 <span style="color: #ff0000">*</span>
</template>
<template v-slot="{row}">
<el-select v-model="row.areaCode" placeholder="请选择区号" filterable size="mini">
<el-option v-for="(item, index) in countryList"
:key="index" :label="item.nameShort + item.nameZh + '(' + item.tel + ')'" :value="item.tel" />
</el-select>
<template v-slot="{row, cellValue, $index}">
<el-form-item :rules="contactRules.areaCode" :prop="'customerContacts.' + $index + '.areaCode'" label="">
<el-select v-model="row.areaCode" placeholder="请选择区号" filterable size="mini">
<el-option v-for="(item, index) in countryList"
:key="index" :label="item.nameShort + item.nameZh + '(' + item.tel + ')'" :value="item.tel" />
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column
prop="phoneNew"
label="联系方式"
>
<template v-slot:header>
<template slot="header">
联系方式 <span style="color: #ff0000">*</span>
</template>
<template v-slot="{row}">
<el-input v-model="row.phoneNew" placeholder="请输入联系方式" size="mini"/>
<template v-slot="{row, cellValue, $index}">
<el-form-item :rules="contactRules.phoneNew" :prop="'customerContacts.' + $index + '.phoneNew'" label="">
<el-input v-model="row.phoneNew" placeholder="请输入联系方式" size="mini"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
......@@ -270,9 +281,11 @@
label="关联账号"
>
<template v-slot = "{row}">
<el-select v-model="row.userid" @change="selectBD" size="mini">
<el-option v-for="(item,index) in memberList" :value="item.id" :key="item.id" :label="item.nickname + '(' + item.mobile + ')'" ></el-option>
</el-select>
<el-form-item label="">
<el-select v-model="row.userid" @change="selectBD" size="mini">
<el-option v-for="(item,index) in memberList" :value="item.id" :key="item.id" :label="item.nickname + '(' + item.mobile + ')'" ></el-option>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column
......@@ -280,10 +293,12 @@
label="社交软件"
>
<template v-slot="{row}">
<el-select v-model="row.social" placeholder="请选择社交软件" size="mini">
<el-option v-for="dict in getDictDatas(DICT_TYPE.SOCIAL)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
</el-select>
<el-form-item label="">
<el-select v-model="row.social" placeholder="请选择社交软件" size="mini">
<el-option v-for="dict in getDictDatas(DICT_TYPE.SOCIAL)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column
......@@ -291,7 +306,9 @@
label="社交软件号码"
>
<template v-slot="{row}">
<el-input v-model="row.socialNumber" placeholder="请输入社交软件号码" size="mini"/>
<el-form-item label="">
<el-input v-model="row.socialNumber" placeholder="请输入社交软件号码" size="mini"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
......@@ -299,7 +316,9 @@
label="邮箱"
>
<template v-slot="{row}">
<el-input v-model="row.email" placeholder="请输入邮箱" size="mini"/>
<el-form-item label="">
<el-input v-model="row.email" placeholder="请输入邮箱" size="mini"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
......@@ -307,10 +326,12 @@
label="设为默认"
>
<template v-slot="{ row, column, $index }">
<el-select v-model="row.isDefault" placeholder="设为默认" @change="handleDefaultChange($index)" size="mini">
<el-option v-for="dict in getDictDatas(DICT_TYPE.IS_DEFAULT)"
:key="dict.value" :label="dict.label" :value="Number(dict.value)" />
</el-select>
<el-form-item label="">
<el-select v-model="row.isDefault" placeholder="设为默认" @change="handleDefaultChange($index)" size="mini">
<el-option v-for="dict in getDictDatas(DICT_TYPE.IS_DEFAULT)"
:key="dict.value" :label="dict.label" :value="Number(dict.value)" />
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column
......@@ -318,10 +339,13 @@
label="操作"
>
<template v-slot="{ row, column, $index }">
<el-button type="danger" @click="form.customerContacts.splice($index, 1)">删除</el-button>
<el-form-item label="">
<el-button type="danger" @click="handleDeleteContact($index)" size="mini">删除</el-button>
</el-form-item>
</template>
</el-table-column>
</el-table>
</el-form>
</el-card>
<el-row :gutter="10" style="margin-top: 15px">
......@@ -367,7 +391,7 @@
</el-col>
</el-row>
</el-form>
<div style="text-align: right">
<div style="text-align: center">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
......@@ -462,6 +486,13 @@ export default {
customerService: [{ required: true, message: "客户经理不能为空", trigger: "blur" }],
status: [{ required: true, message: "客户状态不能为空", trigger: "blur" }],
founder: [{ required: true, message: "创建人不能为空", trigger: "blur" }],
},
contactRules: {
name: [{ required: true, message: "请输入联系人", trigger: "blur" }],
areaCode: [{ required: true, message: "请选择区号", trigger: "change" }],
phoneNew: [{ required: true, message: "请输入联系方式", trigger: "blur" }],
},
// 网点
nodeList: [],
......@@ -485,18 +516,27 @@ export default {
methods: {
handleDefaultChange($index){
// 只有一个联系人,设置成非默认
if (this.form.customerContacts.length === 1 && this.form.customerContacts[0].isDefault === 0){
this.$modal.msgWarning('至少拥有一个默认联系人')
this.form.customerContacts[0].isDefault = 1
return
}
let i = 0
this.form.customerContacts.forEach(e => {
if (i !== $index){
e.isDefault = 0
}
i++
})
// 设置默认联系人
if (this.form.customerContacts[$index].isDefault === 1) {
// 其他的置否
let i = 0
this.form.customerContacts.forEach(e => {
if (i !== $index){
e.isDefault = 0
}
i++
})
} else {
// 第一个置是
this.form.customerContacts[0].isDefault = 1
}
},
selectBD(){
this.$forceUpdate();
......@@ -508,6 +548,13 @@ export default {
},
/** 提交按钮 */
submitForm() {
// this.$refs["contactForm"].validate(valid => {
// if (!valid) {
// return;
// }
// // todo
// console.log(1)
// })
this.$refs["form"].validate(valid => {
if (!valid) {
return;
......@@ -515,6 +562,16 @@ export default {
if (this.form.customerContacts.length === 0){
this.$modal.msgError("至少填写一个联系人信息");
return
} else {
this.form.customerContacts.forEach(e => {
if (!e.name) {
this.$modal.msgWarning('请输入联系人')
} else if (!e.areaCode) {
this.$modal.msgWarning('请选择区号')
} else if (!e.phoneNew) {
this.$modal.msgWarning('请输入联系方式')
}
})
}
// 修改的提交
if (this.form.id != null) {
......@@ -622,6 +679,16 @@ export default {
// "username": ""
})
},
handleDeleteContact($index){
this.form.customerContacts.splice($index, 1)
if (this.form.customerContacts.length > 0) {
this.$refs['contactForm'].clearValidate()
if (!this.form.customerContacts.find(e => e.isDefault)){
this.form.customerContacts[0].isDefault = 1
}
}
},
getZhongPao(){
getZhongPaoBest({
customerId: this.customerId,
......@@ -651,6 +718,19 @@ export default {
}
</script>
<style scoped>
<style scoped lang="scss">
::v-deep .el-table__cell {
padding-bottom: 0;
.cell {
.el-form-item {
margin-bottom: 9px;
}
.el-form-item__error {
z-index: 1;
padding-top: 0;
top: 32px;
}
}
}
</style>
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