新增客户,添加电话邮箱校验

dev
yujialong 3 years ago
parent 51f5c50b5e
commit 240ddcf709
  1. 4
      src/setting.js
  2. 1
      src/utils/api.js
  3. 99
      src/views/customer/AddCustomer.vue

@ -12,8 +12,8 @@ if (isDev) {
// jumpPath = "http://39.108.250.202/judgmentPoint/";
jumpPath = "http://192.168.31.154:8087/"; // 本地调试-需要启动本地判分点系统
host = "http://39.108.250.202:9000";
// host = 'http://192.168.31.151:9000'// 榕
// host = "http://39.108.250.202:9000";
host = 'http://192.168.31.151:9000'// 榕
// host = 'http://192.168.31.125:9000'// 坤
// host = 'http://192.168.31.137:9000'// 赓
} else if (isTest) {

@ -30,6 +30,7 @@ export default {
saveOrUpdate: `${host}/data/data/role/saveOrUpdate`,
doAssign: `${host}/data/data/permission/doAssign`,
updateCustomerByRoleId: `${host}/nakadai/nakadai/customer/updateCustomerByRoleId`,
checkEmailOrPhone: `${host}/nakadai/nakadai/customer/checkEmailOrPhone`, // 新增客户前:校验手机号或者邮箱
resetPwdCustomer: `${host}/nakadai/nakadai/customer/resetPwd`,
queryCustomerIsExists: `${host}/nakadai/nakadai/customer/queryCustomerIsExists`,

@ -75,10 +75,10 @@
<el-input placeholder="请输入联系人姓名" v-model="form.name"></el-input>
</el-form-item>
<el-form-item prop="phone" label="手机号">
<el-input placeholder="请输入联系人手机号" v-model="form.phone" maxlength="11"></el-input>
<el-input placeholder="请输入联系人手机号" v-model="form.phone" maxlength="11" @blur="phoneChange"></el-input>
</el-form-item>
<el-form-item prop="email" label="邮箱">
<el-input placeholder="请输入邮箱" v-model="form.email"></el-input>
<el-input placeholder="请输入邮箱" v-model="form.email" @blur="emailChange"></el-input>
</el-form-item>
</el-col>
</el-form>
@ -272,6 +272,7 @@ export default {
showImg:false,
fileSrc:'',
form: {
customerId: "",
customerName: '',
countries: '中国',
industryClassId: '',
@ -362,7 +363,6 @@ export default {
storeName: '1个月',
total: '2019.01.02 11:00',
payamount: '2019.01.02 11:00',
payamount: '700d12h1min',
swtich: true,
Intranet: '10.20.202.1',
extranet: '10.20.202.1'
@ -373,12 +373,13 @@ export default {
storeName: '1个月',
total: '2019.01.02 11:00',
payamount: '2019.01.02 11:00',
payamount: '700d12h1min',
swtich: true,
Intranet: '',
extranet: ''
}],
NoAdd: true
NoAdd: true,
phoneRepeat: false,
emailRepeat: false,
};
},
mounted() {
@ -389,6 +390,7 @@ export default {
}).then((res) => {
let customer = res.result.customer
this.form = {
customerId: customer.customerId,
schoolId: customer.schoolId,
countries: customer.countries,
industryClassId: customer.industryClassId,
@ -494,9 +496,60 @@ export default {
this.$message.success(val ? '启用成功' : '禁用成功')
}).catch(res => {})
},
phoneChange() { //
let regex = /^1[3456789]\d{9}$/;
if (regex.test(this.form.phone)) {
let url = "";
if (!this.form.customerId) {
url = `${this.api.checkEmailOrPhone}?phone=${this.form.phone}&email=`;
} else {
url = `${this.api.checkEmailOrPhone}?customerId=${this.form.customerId}&phone=${this.form.phone}&email=`;
}
this.$post(url).then(res => {
if (res.status === 200) {
this.phoneRepeat = false;
} else {
this.$message.warning("该手机号已存在")
this.phoneRepeat = true;
}
}).catch(err => {
this.phoneRepeat = true;
});
}
},
async emailChange() { //
let regex = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
if (regex.test(this.form.email)) {
let url = "";
if (!this.form.customerId) {
url = `${this.api.checkEmailOrPhone}?email=${this.form.email}&phone=`;
} else {
url = `${this.api.checkEmailOrPhone}?customerId=${this.form.customerId}&email=${this.form.email}&phone=`;
}
this.$post(url).then(res => {
if (res.status === 200) {
this.emailRepeat = false;
} else {
this.$message.warning("该邮箱已存在")
this.emailRepeat = true;
}
}).catch(err => {
this.emailRepeat = true;
});
}
},
saveAdd(formName){
this.$refs[formName].validate((valid) => {
if (valid) {
console.log(this.phoneRepeat);
if (this.phoneRepeat) {
this.$message.warning("该手机号已存在");
return;
}
if (this.emailRepeat) {
this.$message.warning("该邮箱已存在");
return;
}
if(this.NoAdd){
let obj = {};
obj = this.schoolList.find((item)=>{
@ -530,24 +583,24 @@ export default {
}).catch((res) => {})
}else{
this.$post(this.api.addCustomer,data).then((res) => {
// let customerId = res.customerId
// this.$store.commit('schoolIdData',{schoolId: this.form.schoolId})
// this.$post(this.api.saveOrUpdate,{
// clientId: 0,
// id: '',
// roleName: '',
// remark: '',
// isPort: 2
// }).then(res => {
// let roleId = res.roleId
// let perData = {
// roleId,
// permissionId: ["1408370117262635009","1409351488911056897","1409351867862228993","1408370186435096578","1409352518310699009","1409352550615228418","1409352584240963585","1409352623344459778","1409352647054860289","1409352682471563266","1409352720786530305","1409352742290726913","1408370244584927233","1409352872662278146","1409352903574298626","1409352923509825538","1409352940068937730","1409353018443702273"],
// isPort: 2
// }
// this.$post(this.api.doAssign,perData).then(res => {}).catch(res => {})
// this.$post(`${this.api.updateCustomerByRoleId}?customerId=${customerId}&roleId=${roleId}`).then(res => {}).catch(res => {})
// }).catch(res => {})
let customerId = res.customerId
this.$store.commit('schoolIdData',{schoolId: this.form.schoolId})
this.$post(this.api.saveOrUpdate,{
clientId: 0,
id: '',
roleName: '超级管理员',
remark: '拥有一切权限',
isPort: 2
}).then(res => {
let roleId = res.roleId
let perData = {
roleId,
permissionId: ["1408370117262635009","1409351488911056897","1409351867862228993","1408370186435096578","1409352518310699009","1409352550615228418","1409352584240963585","1409352623344459778","1409352647054860289","1409352682471563266","1409352720786530305","1409352742290726913","1408370244584927233","1409352872662278146","1409352903574298626","1409352923509825538","1409352940068937730","1409353018443702273"],
isPort: 2
}
this.$post(this.api.doAssign,perData).then(res => {}).catch(res => {})
this.$post(`${this.api.updateCustomerByRoleId}?customerId=${customerId}&roleId=${roleId}`).then(res => {}).catch(res => {})
}).catch(res => {})
this.$message.success('添加成功')
this.goback()

Loading…
Cancel
Save