|
|
|
@ -42,14 +42,14 @@ |
|
|
|
|
:total="total"></el-pagination> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<el-drawer :title="isDetail ? '查看' : (form.accountId ? '编辑' : '新增') + '专家'" :visible.sync="expertVisible" |
|
|
|
|
size="580px" class="dialog" :wrapperClosable="false" custom-class="expert-dia" @close="closeExpert"> |
|
|
|
|
<el-drawer :title="isDetail ? '查看' : (!isAdd ? '编辑' : '新增') + '专家'" :visible.sync="expertVisible" size="580px" |
|
|
|
|
class="dialog" :wrapperClosable="false" custom-class="expert-dia" @close="closeExpert"> |
|
|
|
|
<el-form class="overflow" ref="form" :model="form" :rules="rules" label-width="120px" :disabled="isDetail"> |
|
|
|
|
<el-form-item prop="userName" label="姓名"> |
|
|
|
|
<el-input v-model.trim="form.userName" placeholder="请输入姓名"></el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item prop="phone" label="手机号"> |
|
|
|
|
<el-input v-model.trim="form.phone" placeholder="请输入手机号" maxlength="11"></el-input> |
|
|
|
|
<el-input v-model.trim="form.phone" placeholder="请输入手机号" maxlength="11" @blur="phoneChange"></el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
<!-- <el-form-item prop="password" label="登录密码"> |
|
|
|
|
<el-input type="password" v-model.trim="form.password" placeholder="为空则默认密码:手机号码后六位" show-password></el-input> |
|
|
|
@ -104,7 +104,6 @@ export default { |
|
|
|
|
if (value) { |
|
|
|
|
const pattern = /^1[3456789]\d{9}$/ |
|
|
|
|
if (pattern.test(value)) { |
|
|
|
|
// this.phoneChange() |
|
|
|
|
callback() |
|
|
|
|
} else { |
|
|
|
|
callback(new Error('请输入正确手机号格式')) |
|
|
|
@ -145,6 +144,7 @@ export default { |
|
|
|
|
universityFrom: '', |
|
|
|
|
sex: 1, |
|
|
|
|
}, |
|
|
|
|
originForm: {}, |
|
|
|
|
rules: { |
|
|
|
|
userName: [ |
|
|
|
|
{ required: true, message: '请输入姓名', trigger: "blur" } |
|
|
|
@ -156,6 +156,9 @@ export default { |
|
|
|
|
{ validator: emailPass, trigger: 'blur' } |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
isAdd: true, |
|
|
|
|
origiPhone: '', |
|
|
|
|
phoneReapeat: false, |
|
|
|
|
educations: [ |
|
|
|
|
{ |
|
|
|
|
id: 1, |
|
|
|
@ -205,6 +208,7 @@ export default { |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
mounted () { |
|
|
|
|
this.originForm = JSON.parse(JSON.stringify(this.form)) |
|
|
|
|
this.getList() |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
@ -260,6 +264,7 @@ export default { |
|
|
|
|
}, |
|
|
|
|
// 添加员工 |
|
|
|
|
add () { |
|
|
|
|
this.isAdd = true |
|
|
|
|
this.expertVisible = true |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
this.$refs.form.clearValidate() |
|
|
|
@ -297,10 +302,45 @@ export default { |
|
|
|
|
// 编辑/查看 |
|
|
|
|
async queryExpert (row, isDetail) { |
|
|
|
|
this.isDetail = isDetail |
|
|
|
|
this.isAdd = false |
|
|
|
|
this.expertVisible = true |
|
|
|
|
const { data } = await this.$get(`${this.api.expertDetail}?accountId=${row.accountId}`) |
|
|
|
|
this.origiPhone = data.phone |
|
|
|
|
this.form = data |
|
|
|
|
}, |
|
|
|
|
// 手机号输入回调 |
|
|
|
|
async phoneChange () { |
|
|
|
|
const { form, isAdd, origiPhone: origin } = this |
|
|
|
|
const { phone, userName } = form |
|
|
|
|
if (phone && /^1[3456789]\d{9}$/.test(phone)) { |
|
|
|
|
// 编辑的时候,修改后的手机号跟原手机号相同则不用判重 |
|
|
|
|
if (origin === phone && !isAdd) { |
|
|
|
|
this.phoneReapeat = false |
|
|
|
|
} else { |
|
|
|
|
const { data } = await this.$get(this.api.searchForExpertByPhone, { |
|
|
|
|
phone, |
|
|
|
|
accountId: form.accountId |
|
|
|
|
}) |
|
|
|
|
if (data) { |
|
|
|
|
if (isAdd) { |
|
|
|
|
this.form = data |
|
|
|
|
this.$refs.form.clearValidate() |
|
|
|
|
} else { |
|
|
|
|
Util.errorMsg('该手机号已存在!') |
|
|
|
|
this.phoneReapeat = true |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (isAdd) { |
|
|
|
|
// 如果该学号没有对应的专家,则清空所有信息,除了姓名手机号 |
|
|
|
|
this.form = JSON.parse(JSON.stringify(this.originForm)) |
|
|
|
|
this.form.phone = phone |
|
|
|
|
this.form.userName = userName |
|
|
|
|
} |
|
|
|
|
this.phoneReapeat = false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 提交 |
|
|
|
|
submitExpert () { |
|
|
|
|
this.$refs.form.validate((valid) => { |
|
|
|
@ -308,6 +348,7 @@ export default { |
|
|
|
|
if (this.submiting) return false |
|
|
|
|
this.submiting = true |
|
|
|
|
const form = JSON.parse(JSON.stringify(this.form)) |
|
|
|
|
if (this.phoneReapeat) return Util.warningMsg('该手机号已存在!') |
|
|
|
|
if (form.accountId) { |
|
|
|
|
this.$post(this.api.modifyExpert, form).then(res => { |
|
|
|
|
Util.successMsg("编辑成功!") |
|
|
|
|