|
|
@ -45,15 +45,15 @@ |
|
|
|
|
|
|
|
|
|
|
|
<el-dialog :title="isDetail ? '查看员工' : (isAdd ? '新增员工' : '编辑员工')" :visible.sync="teacherVisible" |
|
|
|
<el-dialog :title="isDetail ? '查看员工' : (isAdd ? '新增员工' : '编辑员工')" :visible.sync="teacherVisible" |
|
|
|
width="30%" @close="closeTeacher" class="dialog" :close-on-click-modal="false"> |
|
|
|
width="30%" @close="closeTeacher" class="dialog" :close-on-click-modal="false"> |
|
|
|
<el-form ref="teacherForm" :model="teacherForm" :rules="rules" label-width="150px" :disabled="isDetail" style='margin-right: 80px;'> |
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="150px" :disabled="isDetail" style='margin-right: 80px;'> |
|
|
|
<el-form-item prop="account" label="账号"> |
|
|
|
<el-form-item prop="workNumber" label="工号"> |
|
|
|
<el-input v-model.trim="teacherForm.account" placeholder="请输入职工账号"></el-input> |
|
|
|
<el-input v-model.trim="form.workNumber" placeholder="请输入职工工号"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="userName" label="用户姓名"> |
|
|
|
<el-form-item prop="userName" label="用户姓名"> |
|
|
|
<el-input v-model.trim="teacherForm.userName" placeholder="请输入员工姓名"></el-input> |
|
|
|
<el-input v-model.trim="form.userName" placeholder="请输入员工姓名"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="roleValue" label="账号角色"> |
|
|
|
<el-form-item prop="roleValue" label="账号角色"> |
|
|
|
<el-select v-model="teacherForm.roleValue" @change="roleChange" @remove-tag="roleRemove" multiple style="width: 100%;height: 32px"> |
|
|
|
<el-select v-model="form.roleValue" @change="roleChange" @remove-tag="roleRemove" multiple style="width: 100%;height: 32px"> |
|
|
|
<el-option |
|
|
|
<el-option |
|
|
|
v-for="item in roleList" |
|
|
|
v-for="item in roleList" |
|
|
|
:key="item.id" |
|
|
|
:key="item.id" |
|
|
@ -63,12 +63,9 @@ |
|
|
|
</el-select> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="uniqueIdentification" label="唯一标识"> |
|
|
|
<el-form-item prop="uniqueIdentification" label="唯一标识"> |
|
|
|
<el-input disabled v-model.trim="teacherForm.uniqueIdentification" placeholder="请输入职工工号获取唯一标识"></el-input> |
|
|
|
<el-input disabled v-model.trim="form.uniqueIdentification" placeholder="请输入职工工号获取唯一标识"></el-input> |
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
<el-form-item prop="workNumber" label="工号"> |
|
|
|
|
|
|
|
<el-input v-model.trim="teacherForm.workNumber" placeholder="请输入职工工号"></el-input> |
|
|
|
|
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item v-for="item in teacherForm.roleAndDeptList" :label="`${item.roleName}所属部门`" :rules="{ |
|
|
|
<el-form-item v-for="item in form.roleAndDeptList" :label="`${item.roleName}所属部门`" :rules="{ |
|
|
|
required: true, message: '请选择', trigger: 'change' |
|
|
|
required: true, message: '请选择', trigger: 'change' |
|
|
|
}"> |
|
|
|
}"> |
|
|
|
<el-cascader |
|
|
|
<el-cascader |
|
|
@ -79,15 +76,18 @@ |
|
|
|
></el-cascader> |
|
|
|
></el-cascader> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="phone" label="手机号"> |
|
|
|
<el-form-item prop="phone" label="手机号"> |
|
|
|
<el-input v-model.trim="teacherForm.phone" placeholder="请输入手机号" maxlength="11" @blur="phoneChange"></el-input> |
|
|
|
<el-input v-model.trim="form.phone" placeholder="请输入手机号" maxlength="11" @blur="phoneChange"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="email" label="邮箱"> |
|
|
|
<el-form-item prop="email" label="邮箱"> |
|
|
|
<el-input v-model.trim="teacherForm.email" placeholder="请输入邮箱" @blur="emailChange"></el-input> |
|
|
|
<el-input v-model.trim="form.email" placeholder="请输入邮箱" @blur="emailChange"></el-input> |
|
|
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
<el-form-item prop="account" label="账号"> |
|
|
|
|
|
|
|
<el-input disabled v-model.trim="form.account" placeholder="请输入职工账号"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
</el-form> |
|
|
|
<span slot="footer" class="dialog-footer" v-if="!isDetail"> |
|
|
|
<span slot="footer" class="dialog-footer" v-if="!isDetail"> |
|
|
|
<el-button @click="closeTeacher">取 消</el-button> |
|
|
|
<el-button @click="closeTeacher">取 消</el-button> |
|
|
|
<el-button type="primary" @click="saveSure('teacherForm')">确 定</el-button> |
|
|
|
<el-button type="primary" @click="saveSure('form')">确 定</el-button> |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
</el-dialog> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
|
|
|
@ -165,7 +165,7 @@ export default { |
|
|
|
casProps: { |
|
|
|
casProps: { |
|
|
|
value: 'id' |
|
|
|
value: 'id' |
|
|
|
}, |
|
|
|
}, |
|
|
|
teacherForm: { |
|
|
|
form: { |
|
|
|
accountId: "", |
|
|
|
accountId: "", |
|
|
|
account: "", |
|
|
|
account: "", |
|
|
|
userName: "", |
|
|
|
userName: "", |
|
|
@ -289,7 +289,7 @@ export default { |
|
|
|
}).catch(res => {}); |
|
|
|
}).catch(res => {}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
closeTeacher() { // 关闭新增/编辑员工对话框 |
|
|
|
closeTeacher() { // 关闭新增/编辑员工对话框 |
|
|
|
this.teacherForm = { |
|
|
|
this.form = { |
|
|
|
accountId: "", |
|
|
|
accountId: "", |
|
|
|
account: "", |
|
|
|
account: "", |
|
|
|
userName: "", |
|
|
|
userName: "", |
|
|
@ -300,7 +300,7 @@ export default { |
|
|
|
phone: "", |
|
|
|
phone: "", |
|
|
|
email: "" |
|
|
|
email: "" |
|
|
|
}; |
|
|
|
}; |
|
|
|
this.$refs.teacherForm.clearValidate(); |
|
|
|
this.$refs.form.clearValidate(); |
|
|
|
this.teacherVisible = false; |
|
|
|
this.teacherVisible = false; |
|
|
|
}, |
|
|
|
}, |
|
|
|
addTeacher() { // 新增员工 |
|
|
|
addTeacher() { // 新增员工 |
|
|
@ -312,13 +312,13 @@ export default { |
|
|
|
getStaffDetail(accountId) { // 获取员工详情 |
|
|
|
getStaffDetail(accountId) { // 获取员工详情 |
|
|
|
this.$get(`${this.api.staffDetail}?accountId=${accountId}`).then(res => { |
|
|
|
this.$get(`${this.api.staffDetail}?accountId=${accountId}`).then(res => { |
|
|
|
let { data } = res; |
|
|
|
let { data } = res; |
|
|
|
this.teacherForm = data; |
|
|
|
this.form = data; |
|
|
|
this.teacherForm.roleValue = data.roleAndDeptList.map(i => i.roleId); |
|
|
|
this.form.roleValue = data.roleAndDeptList.map(i => i.roleId); |
|
|
|
this.teacherForm.roleAndDeptList = data.roleAndDeptList.map(i => { |
|
|
|
this.form.roleAndDeptList = data.roleAndDeptList.map(i => { |
|
|
|
i.cascaderValue = [i.staffArchitectureId, i.gradeId] |
|
|
|
i.cascaderValue = [i.staffArchitectureId, i.gradeId] |
|
|
|
return i; |
|
|
|
return i; |
|
|
|
}); |
|
|
|
}); |
|
|
|
console.log(22, this.teacherForm) |
|
|
|
console.log(22, this.form) |
|
|
|
}).catch(res => {}); |
|
|
|
}).catch(res => {}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
resetPassword(row) { // 重置密码 |
|
|
|
resetPassword(row) { // 重置密码 |
|
|
@ -345,12 +345,12 @@ export default { |
|
|
|
this.getStaffDetail(row.accountId); |
|
|
|
this.getStaffDetail(row.accountId); |
|
|
|
}, |
|
|
|
}, |
|
|
|
accountChange() { // 切换账号 |
|
|
|
accountChange() { // 切换账号 |
|
|
|
if (this.teacherForm.account) { |
|
|
|
if (this.form.account) { |
|
|
|
let url = ""; |
|
|
|
let url = ""; |
|
|
|
if (this.isAdd) { |
|
|
|
if (this.isAdd) { |
|
|
|
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=${Setting.platformType}&account=${this.teacherForm.account}&workNumber=`; |
|
|
|
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=${Setting.platformType}&account=${this.form.account}&workNumber=`; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=${Setting.platformType}&accountId=${this.teacherForm.accountId}&account=${this.teacherForm.account}&workNumber=`; |
|
|
|
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=${Setting.platformType}&accountId=${this.form.accountId}&account=${this.form.account}&workNumber=`; |
|
|
|
} |
|
|
|
} |
|
|
|
this.$post(url).then(res => { |
|
|
|
this.$post(url).then(res => { |
|
|
|
if (res.status === 200) { |
|
|
|
if (res.status === 200) { |
|
|
@ -362,30 +362,20 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
workNumberChange() { // 切换工号 |
|
|
|
workNumberChange() { // 切换工号 |
|
|
|
if (this.teacherForm.workNumber) { |
|
|
|
if (this.form.workNumber) { |
|
|
|
let url = ""; |
|
|
|
this.$post(`${this.api.getDetailByAccount}?workNumber=${this.form.workNumber}&platformId=${Setting.platformId}&type=0`).then(res => { |
|
|
|
if (this.isAdd) { |
|
|
|
this.form = res.data |
|
|
|
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=${Setting.platformType}&workNumber=${this.teacherForm.workNumber}&account=`; |
|
|
|
}).catch(res => {}) |
|
|
|
} else { |
|
|
|
|
|
|
|
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=${Setting.platformType}&accountId=${this.teacherForm.accountId}&workNumber=${this.teacherForm.workNumber}&account=`; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.$post(url).then(res => { |
|
|
|
|
|
|
|
if (res.status === 200) { |
|
|
|
|
|
|
|
this.workNumberReapeat = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).catch( err => { |
|
|
|
|
|
|
|
this.workNumberReapeat = true; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
phoneChange() { // 切换手机号 |
|
|
|
phoneChange() { // 切换手机号 |
|
|
|
let regex = /^1[3456789]\d{9}$/; |
|
|
|
let regex = /^1[3456789]\d{9}$/; |
|
|
|
if (regex.test(this.teacherForm.phone)) { |
|
|
|
if (regex.test(this.form.phone)) { |
|
|
|
let url = ""; |
|
|
|
let url = ""; |
|
|
|
if (this.isAdd) { |
|
|
|
if (this.isAdd) { |
|
|
|
url = `${this.api.checkEmailOrPhone}?phone=${this.teacherForm.phone}&email=`; |
|
|
|
url = `${this.api.checkEmailOrPhone}?phone=${this.form.phone}&email=`; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
url = `${this.api.checkEmailOrPhone}?accountId=${this.teacherForm.accountId}&phone=${this.teacherForm.phone}&email=`; |
|
|
|
url = `${this.api.checkEmailOrPhone}?accountId=${this.form.accountId}&phone=${this.form.phone}&email=`; |
|
|
|
} |
|
|
|
} |
|
|
|
this.$post(url).then(res => { |
|
|
|
this.$post(url).then(res => { |
|
|
|
if (res.status === 200) { |
|
|
|
if (res.status === 200) { |
|
|
@ -398,12 +388,12 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
emailChange() { // 切换邮箱 |
|
|
|
emailChange() { // 切换邮箱 |
|
|
|
let regex = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/; |
|
|
|
let regex = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/; |
|
|
|
if (regex.test(this.teacherForm.email)) { |
|
|
|
if (regex.test(this.form.email)) { |
|
|
|
let url = ""; |
|
|
|
let url = ""; |
|
|
|
if (this.isAdd) { |
|
|
|
if (this.isAdd) { |
|
|
|
url = `${this.api.checkEmailOrPhone}?email=${this.teacherForm.email}&phone=`; |
|
|
|
url = `${this.api.checkEmailOrPhone}?email=${this.form.email}&phone=`; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
url = `${this.api.checkEmailOrPhone}?accountId=${this.teacherForm.accountId}&email=${this.teacherForm.email}&phone=`; |
|
|
|
url = `${this.api.checkEmailOrPhone}?accountId=${this.form.accountId}&email=${this.form.email}&phone=`; |
|
|
|
} |
|
|
|
} |
|
|
|
this.$post(url).then(res => { |
|
|
|
this.$post(url).then(res => { |
|
|
|
if (res.status === 200) { |
|
|
|
if (res.status === 200) { |
|
|
@ -415,9 +405,9 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
roleChange(value) { // 处理切换角色 |
|
|
|
roleChange(value) { // 处理切换角色 |
|
|
|
console.log(this.teacherForm.roleValue) |
|
|
|
console.log(this.form.roleValue) |
|
|
|
if (value.length) { |
|
|
|
if (value.length) { |
|
|
|
let ids = this.teacherForm.roleAndDeptList.map(e => e.roleId); |
|
|
|
let ids = this.form.roleAndDeptList.map(e => e.roleId); |
|
|
|
this.roleList.forEach(i => { |
|
|
|
this.roleList.forEach(i => { |
|
|
|
let obj = { |
|
|
|
let obj = { |
|
|
|
roleId: "", |
|
|
|
roleId: "", |
|
|
@ -428,26 +418,26 @@ export default { |
|
|
|
console.log(i) |
|
|
|
console.log(i) |
|
|
|
obj.roleId = i.id; |
|
|
|
obj.roleId = i.id; |
|
|
|
obj.roleName = i.roleName; |
|
|
|
obj.roleName = i.roleName; |
|
|
|
this.teacherForm.roleAndDeptList.push(obj); |
|
|
|
this.form.roleAndDeptList.push(obj); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.teacherForm.roleAndDeptList.splice(0); |
|
|
|
this.form.roleAndDeptList.splice(0); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
roleRemove(value) { // 处理移除角色 |
|
|
|
roleRemove(value) { // 处理移除角色 |
|
|
|
let list = []; |
|
|
|
let list = []; |
|
|
|
for(var i=0;i<this.teacherForm.roleAndDeptList.length;i++){ |
|
|
|
for(var i=0;i<this.form.roleAndDeptList.length;i++){ |
|
|
|
if (this.teacherForm.roleAndDeptList[i].roleId == value){ |
|
|
|
if (this.form.roleAndDeptList[i].roleId == value){ |
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
list.push(this.teacherForm.roleAndDeptList[i]) |
|
|
|
list.push(this.form.roleAndDeptList[i]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.teacherForm.roleAndDeptList = list |
|
|
|
this.form.roleAndDeptList = list |
|
|
|
}, |
|
|
|
}, |
|
|
|
async saveSure(teacherForm) { |
|
|
|
async saveSure(form) { |
|
|
|
this.$refs[teacherForm].validate((valid) => { |
|
|
|
this.$refs[form].validate((valid) => { |
|
|
|
if (valid) { |
|
|
|
if (valid) { |
|
|
|
if (this.submiting) return false |
|
|
|
if (this.submiting) return false |
|
|
|
if (this.accountReapeat) return util.warningMsg("该账号已存在"); |
|
|
|
if (this.accountReapeat) return util.warningMsg("该账号已存在"); |
|
|
@ -455,32 +445,32 @@ export default { |
|
|
|
if (this.phoneRepeat) return util.warningMsg("该手机号已存在"); |
|
|
|
if (this.phoneRepeat) return util.warningMsg("该手机号已存在"); |
|
|
|
if (this.emailRepeat) return util.warningMsg("该邮箱已存在"); |
|
|
|
if (this.emailRepeat) return util.warningMsg("该邮箱已存在"); |
|
|
|
let data = { |
|
|
|
let data = { |
|
|
|
accountId: this.teacherForm.accountId, |
|
|
|
accountId: this.form.accountId, |
|
|
|
account: this.teacherForm.account, |
|
|
|
account: this.form.account, |
|
|
|
userName: this.teacherForm.userName, |
|
|
|
userName: this.form.userName, |
|
|
|
roleAndDeptList: [], |
|
|
|
roleAndDeptList: [], |
|
|
|
uniqueIdentification: this.teacherForm.uniqueIdentification ? this.teacherForm.uniqueIdentification : new Date().getTime(), |
|
|
|
uniqueIdentification: this.form.uniqueIdentification ? this.form.uniqueIdentification : new Date().getTime(), |
|
|
|
workNumber: this.teacherForm.workNumber, |
|
|
|
workNumber: this.form.workNumber, |
|
|
|
phone: this.teacherForm.phone, |
|
|
|
phone: this.form.phone, |
|
|
|
email: this.teacherForm.email |
|
|
|
email: this.form.email |
|
|
|
}; |
|
|
|
}; |
|
|
|
if (this.teacherForm.roleAndDeptList.length){ |
|
|
|
if (this.form.roleAndDeptList.length){ |
|
|
|
for (let i = 0; i < this.teacherForm.roleAndDeptList.length; i++) { |
|
|
|
for (let i = 0; i < this.form.roleAndDeptList.length; i++) { |
|
|
|
if (this.teacherForm.roleAndDeptList[i].cascaderValue.length < 2) { |
|
|
|
if (this.form.roleAndDeptList[i].cascaderValue.length < 2) { |
|
|
|
util.warningMsg(`请选择${this.teacherForm.roleAndDeptList[i].roleName}所属部门`) |
|
|
|
util.warningMsg(`请选择${this.form.roleAndDeptList[i].roleName}所属部门`) |
|
|
|
return; |
|
|
|
return; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
let obj = { |
|
|
|
let obj = { |
|
|
|
roleId: this.teacherForm.roleAndDeptList[i].roleId, |
|
|
|
roleId: this.form.roleAndDeptList[i].roleId, |
|
|
|
staffArchitectureId: this.teacherForm.roleAndDeptList[i].cascaderValue[0], |
|
|
|
staffArchitectureId: this.form.roleAndDeptList[i].cascaderValue[0], |
|
|
|
gradeId: this.teacherForm.roleAndDeptList[i].cascaderValue[1] |
|
|
|
gradeId: this.form.roleAndDeptList[i].cascaderValue[1] |
|
|
|
}; |
|
|
|
}; |
|
|
|
data.roleAndDeptList.push(obj); |
|
|
|
data.roleAndDeptList.push(obj); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.submiting = true |
|
|
|
this.submiting = true |
|
|
|
if (this.teacherForm.accountId) { |
|
|
|
if (this.form.accountId) { |
|
|
|
this.$post(this.api.modifyStaff, data).then(res => { |
|
|
|
this.$post(this.api.modifyStaff, data).then(res => { |
|
|
|
util.successMsg("编辑成功"); |
|
|
|
util.successMsg("编辑成功"); |
|
|
|
this.closeTeacher(); |
|
|
|
this.closeTeacher(); |
|
|
|