yujialong 1 month ago
parent d857e59090
commit 04dc2b2432
  1. 1
      src/api/index.js
  2. 49
      src/pages/expert/list/index.vue

@ -16,6 +16,7 @@ export default {
examinePassword: `/users/users/userAccount/examinePassword`,
bindPhoneOrEmail: `/users/users/userAccount/bindPhoneOrEmail`,
sendPhoneOrEmailCode: `/users/users/userAccount/sendPhoneOrEmailCode`,
searchForExpertByPhone: `/nakadai/nakadai/backstageStaff/searchForExpertByPhone`,
getUserRolesPermissionMenu: `/users/users/user-role/getUserRolesPermissionMenu`,
getCurrentTime: `/competition/competition/management/getCurrentTime`,

@ -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("编辑成功!")

Loading…
Cancel
Save