新增员工时 先判断手机号是否注册 如果已注册 就不能新增 如果没注册 可以新增
// 校验手机号是否已注册
checkOilStaffMobilePhone() {
return new Promise((resolve, reject) => {
checkOilStaffMobilePhone({
mobilePhone: this.ruleForm.mobilePhone
}).then(res => {
resolve(res)
})
})
},
// 新增员工
createOilStaff(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
this.checkOilStaffMobilePhone().then(res => {
if (res) {
createOilStaff(this.ruleForm).then(() => {
this.$message({ message: '保存成功', type: 'success' })
this.newAddStaffDialog = false
this.getStaffList()
})
} else {
this.$message.error('该手机号码已注册')
}
})
}
})
},
C() {
Promise.all([ this.A(), this.B() ]).then(res => {
res为数组 A和B的返回值
}
})
},
A() {
return new Promise((resolve, reject) => {
rechargeOverviewInfo().then(data => {
resolve(data)
})
})
},
B() {
return new Promise((resolve, reject) => {
getRechargeCardInfoToday().then(data => {
resolve(data)
})
})
}
async
async a(){
await this.b()
}
b() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve('成功')
}, 1000)
})
}