Commit 2473756a authored by Marcus's avatar Marcus

新建客户-联系人信息为必填,现在不填手机号也可以新增成功

http://zentao.jdshangmen.com/bug-view-400.html
parent 80860a7f
import request from '@/utils/request'
// 校验手机号
export function validatorMobile(params) {
return request({
url: '/param/validator/mobile',
method: 'post',
params
})
}
......@@ -107,7 +107,7 @@ service.interceptors.response.use(res => {
Notification.error({
title: msg
})
return Promise.reject('error')
return Promise.reject(msg || 'error')
} else {
return res.data
}
......
......@@ -417,6 +417,7 @@ import { getZhongPaoBest, getZhongPaoPage } from '@/api/ecw/zhongPao'
import { getCustomerContactsListByCustomer } from '@/api/ecw/customerContacts'
import { getCountryListAll } from '@/api/ecw/country'
import Template from "@/views/cms/template";
import {validatorMobile} from "@/api/ecw/validate"
export default {
name: "edit",
......@@ -436,6 +437,10 @@ export default {
this.form.customerContacts = r.data
})
})
} else {
const obj = Object.assign({}, this.$route, { title: "自定义标题" })
this.$tab.updatePage(obj);
this.$tab.updatePage({...this.$route, meta: {...this.$route.meta, name: 'abc'}})
}
getNodeList().then(r => {
......@@ -492,7 +497,11 @@ export default {
contactRules: {
name: [{ required: true, message: "请输入联系人", trigger: "blur" }],
areaCode: [{ required: true, message: "请选择区号", trigger: "change" }],
phoneNew: [{ required: true, message: "请输入联系方式", trigger: "blur" }],
phoneNew: [{
required: true,
trigger: "blur",
validator: this.phoneValidator
}],
},
// 网点
nodeList: [],
......@@ -515,6 +524,24 @@ export default {
},
methods: {
phoneValidator(rule, value, callback){
if (!value) {
return callback(new Error('请输入联系方式'));
}
validatorMobile({
code: this.form.customerContacts.find(e => e.phoneNew === value).areaCode,
mobile: value
}).then(r => {
if (r.data){
callback()
} else {
callback(new Error(r.msg || '手机号验证失败'))
}
}).catch(e => {
console.error(e)
callback(new Error('手机号验证失败'))
})
},
handleDefaultChange($index){
// 只有一个联系人,设置成非默认
if (this.form.customerContacts.length === 1 && this.form.customerContacts[0].isDefault === 0){
......@@ -549,6 +576,10 @@ export default {
},
/** 提交按钮 */
submitForm() {
if(this.form.customerContacts.length === 0){
this.$modal.alert('至少添加一位联系人')
return
}
this.$refs["contactForm"].validate(valid1 => {
this.$refs["form"].validate(valid2 => {
if (!valid1 || !valid2) {
......
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