后台账号联调

dev_2022-03-03
yujialong 3 years ago
parent e312e8e4ba
commit 4822994d2d
  1. 3
      src/utils/api.js
  2. 360
      src/views/system/staff.vue

@ -10,6 +10,9 @@ export default {
bindPhoneOrEmail: `users/users/userAccount/bindPhoneOrEmail`,// 绑定手机 bindPhoneOrEmail: `users/users/userAccount/bindPhoneOrEmail`,// 绑定手机
sendPhoneOrEmailCode: `users/users/userAccount/sendPhoneOrEmailCode`,// 手机验证码 sendPhoneOrEmailCode: `users/users/userAccount/sendPhoneOrEmailCode`,// 手机验证码
checkEmailOrPhone: `occupationlab/architecture/checkEmailOrPhone`, // 新增学生前:校验手机号或者邮箱
checkWorkNumOrAccount: `occupationlab/architecture/checkWorkNumOrAccount`, // 新增/编辑学生前:校验学号或者学生账号
// 订单管理 // 订单管理
orderAdd: `nakadai/nakadai/order/add`,// 订单添加 orderAdd: `nakadai/nakadai/order/add`,// 订单添加
orderDelete: `nakadai/nakadai/order/delete`,// 删除定单 orderDelete: `nakadai/nakadai/order/delete`,// 删除定单

@ -103,15 +103,13 @@
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column> <el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
<el-table-column prop="userName" label="员工姓名" align="center" min-width="100"></el-table-column> <el-table-column prop="userName" label="员工姓名" align="center" min-width="100"></el-table-column>
<el-table-column prop="account" label="账号" align="center" min-width="100"></el-table-column> <el-table-column prop="account" label="账号" align="center" min-width="100"></el-table-column>
<el-table-column prop="className" label="手机号" align="center" width="120"></el-table-column> <el-table-column prop="phone" label="手机号" align="center" width="120"></el-table-column>
<el-table-column prop="loginNumber" label="所在部门" align="center" min-width="100"></el-table-column> <el-table-column prop="staffArchitectureName" label="所在部门" align="center" min-width="100"></el-table-column>
<el-table-column prop="countries" label="授权角色" align="center" width="100"> <el-table-column prop="roleName" label="授权角色" align="center" width="100"></el-table-column>
<template slot-scope="scope">员工</template>
</el-table-column>
<el-table-column label="操作" align="center" width="300"> <el-table-column label="操作" align="center" width="300">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" @click="editStaff(scope.row,true)">查看</el-button> <el-button type="text" @click="queryStaff(scope.row,true)">查看</el-button>
<el-button type="text" @click="editStaff(scope.row,false)">编辑</el-button> <el-button type="text" @click="queryStaff(scope.row,false)">编辑</el-button>
<el-button type="text" @click="resetPassword(scope.row)">重置密码</el-button> <el-button type="text" @click="resetPassword(scope.row)">重置密码</el-button>
<el-button type="text" @click="delStaff(scope.row)">删除</el-button> <el-button type="text" @click="delStaff(scope.row)">删除</el-button>
</template> </template>
@ -121,7 +119,7 @@
<el-pagination background @current-change="currentChange" :current-page="page" layout="total, prev, pager, next" :total="total"></el-pagination> <el-pagination background @current-change="currentChange" :current-page="page" layout="total, prev, pager, next" :total="total"></el-pagination>
</div> </div>
<el-dialog :title="isDetail ? '查看' : (form.accountId ? '编辑' : '新增') + '员工'" :visible.sync="staffVisible" width="580px" class="dialog" :close-on-click-modal="false"> <el-dialog :title="isDetail ? '查看' : (form.accountId ? '编辑' : '新增') + '员工'" :visible.sync="staffVisible" width="580px" class="dialog" :close-on-click-modal="false" @close="closeStaff">
<el-form ref="form" :model="form" :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="workNumber" label="工号"> <el-form-item prop="workNumber" label="工号">
<el-input v-model.trim="form.workNumber" placeholder="请输入工号"></el-input> <el-input v-model.trim="form.workNumber" placeholder="请输入工号"></el-input>
@ -133,13 +131,13 @@
<el-input v-model.trim="form.account" placeholder="请输入账号"></el-input> <el-input v-model.trim="form.account" placeholder="请输入账号"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="phone" label="手机号"> <el-form-item prop="phone" label="手机号">
<el-input v-model.trim="form.phone" placeholder="请输入手机号" maxlength="11" @blur="phoneChange"></el-input> <el-input v-model.trim="form.phone" placeholder="请输入手机号" maxlength="11"></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="form.email" placeholder="请输入邮箱" @blur="emailChange"></el-input> <el-input v-model.trim="form.email" placeholder="请输入邮箱"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="roleValue" label="授权角色"> <el-form-item prop="roleList" label="授权角色">
<el-select v-model="form.roleValue" @change="roleChange" @remove-tag="roleRemove" multiple style="width: 100%;"> <el-select class="w-100" v-model="form.roleList" multiple>
<template v-for="item in roleList"> <template v-for="item in roleList">
<!-- 不显示超管 --> <!-- 不显示超管 -->
<el-option <el-option
@ -151,17 +149,17 @@
</template> </template>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item v-for="(item, i) in form.roleAndDeptList" :key="i" :label="`${item.roleName}所在部门`"> <el-form-item label="所在部门">
<el-cascader <el-cascader
v-model="item.cascaderValue" class="w-100"
v-model="form.staffArchitectureId"
:options="orgList" :options="orgList"
:props="casProps" :props="casProps"
style="width: 100%"
></el-cascader> ></el-cascader>
</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="closeStudent">取消</el-button> <el-button @click="staffVisible = false">取消</el-button>
<el-button type="primary" @click="submitStaff">确定</el-button> <el-button type="primary" @click="submitStaff">确定</el-button>
</span> </span>
</el-dialog> </el-dialog>
@ -206,33 +204,58 @@ import OrgTree from "@/components/org-tree/src/tree";
export default { export default {
components: { OrgTree }, components: { OrgTree },
data() { data() {
var accountPass = (rule, value, callback) => { const accountPass = (rule, value, callback) => {
if (value === '') { if (value === '') {
callback(new Error('请输入账号')); callback(new Error('请输入账号'))
} else { } else {
var pattern = /^[A-Za-z0-9]*$/; const pattern = /^[A-Za-z0-9]*$/
if(pattern.test(value)){ if(pattern.test(value)){
this.accountChange(); this.accountChange()
callback(); callback()
}else{ }else{
callback(new Error('请输入正确账号格式')); callback(new Error('请输入正确账号格式'))
} }
} }
}; }
var workNumberPass = (rule, value, callback) => { const workNumberPass = (rule, value, callback) => {
if (value === '') { if (value === '') {
callback(new Error('请输入号')); callback(new Error('请输入工号'))
} else { } else {
var pattern = /^[A-Za-z0-9]*$/; const pattern = /^[A-Za-z0-9]*$/
if(pattern.test(value)){ if(pattern.test(value)){
this.worknumberChange(); this.worknumberChange()
callback(); callback()
}else{ }else{
callback(new Error('请输入正确员工学号格式')); callback(new Error('请输入正确工号格式'))
}
}
}
const phonePass = (rule, value, callback) => {
if (value) {
const pattern = /^1[3456789]\d{9}$/
if(pattern.test(value)){
this.phoneChange()
callback()
}else{
callback(new Error('请输入正确手机号格式'))
}
} else {
callback()
}
}
const emailPass = (rule, value, callback) => {
if (value) {
const pattern = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/
if(pattern.test(value)){
this.emailChange()
callback()
}else{
callback(new Error('请输入正确邮箱格式'))
}
} else {
callback()
} }
} }
};
let that = this;
return { return {
orgList: [], orgList: [],
orgListDia: [], orgListDia: [],
@ -262,12 +285,10 @@ export default {
uniqueIdentification: '', uniqueIdentification: '',
workNumber: '', workNumber: '',
email: '', email: '',
account: '' account: '',
staffArchitectureId: []
}, },
rules: { rules: {
organizationName: [
{ required: true, message: "请输入名称", trigger: "blur" }
],
account: [ account: [
{ required: true,validator: accountPass, trigger: 'blur' } { required: true,validator: accountPass, trigger: 'blur' }
], ],
@ -277,19 +298,14 @@ export default {
workNumber: [ workNumber: [
{ required: true,validator: workNumberPass, trigger: 'blur' } { required: true,validator: workNumberPass, trigger: 'blur' }
], ],
roleList: [
{ required: true, message: "请选择授权角色", trigger: "change" }
],
phone: [ phone: [
{ { validator: phonePass, trigger: 'blur' }
pattern: /^1[3456789]\d{9}$/,
message: "请输入正确的手机号",
trigger: "blur"
}
], ],
email: [ email: [
{ { validator: emailPass, trigger: 'blur' }
pattern: /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/,
message: "请输入正确的邮箱",
trigger: "blur"
}
] ]
}, },
listData: [], listData: [],
@ -305,7 +321,6 @@ export default {
originWorkNumber: '', originWorkNumber: '',
phoneRepeat: false, phoneRepeat: false,
emailRepeat: false, emailRepeat: false,
defaultCheckedKeys: [],
casProps: { casProps: {
multiple: true, multiple: true,
checkStrictly: true, checkStrictly: true,
@ -445,16 +460,15 @@ export default {
}, },
// //
getStaff() { getStaff() {
let data = { this.$post(this.api.staffList, {
type: this.studentType || '', type: this.studentType || 1,
staffArchitectureId: this.$refs.orgTree.getCurrentKey() || '', staffArchitectureId: this.$refs.orgTree.getCurrentKey() || '',
keyWord: this.keyWord, keyWord: this.keyWord,
pageNum: this.page, pageNum: this.page,
pageSize: this.pageSize pageSize: this.pageSize
}; }).then(res => {
this.$post(this.api.staffList, data).then(res => { this.listData = res.page.records
this.listData = res.records this.total = res.page.total
this.total = res.total
}).catch(err => {}) }).catch(err => {})
}, },
// //
@ -478,29 +492,28 @@ export default {
this.$post(`${this.api.delStaff}?accountIds=${row.accountId}`).then(res => { this.$post(`${this.api.delStaff}?accountIds=${row.accountId}`).then(res => {
util.successMsg("删除成功") util.successMsg("删除成功")
this.getStaff() this.getStaff()
}).catch(res => { }).catch(res => {})
});
}).catch(() => {}) }).catch(() => {})
}, },
resetPassword(row) { // //
resetPassword(row) {
this.$confirm(`重置后的密码为:${Setting.initialPassword},确定重置?`, "提示", { type: "warning" }).then(() => { this.$confirm(`重置后的密码为:${Setting.initialPassword},确定重置?`, "提示", { type: "warning" }).then(() => {
this.$get(`${this.api.resetPassword}?userId=${row.userId}&newPwd=111aaa`).then(res => { this.$get(`${this.api.resetPassword}?userId=${row.userId}&newPwd=111aaa`).then(res => {
util.successMsg("重置成功"); util.successMsg("重置成功")
}).catch(res => { }).catch(res => {})
}); }).catch(() => {})
}).catch(() => {
});
}, },
// //
addStaff() { addStaff() {
this.staffVisible = true this.staffVisible = true
}, },
// / // /
editStaff(row, isDetail) { queryStaff(row, isDetail) {
this.isDetail = isDetail this.isDetail = isDetail
this.staffVisible = true this.staffVisible = true
this.$post(`${this.api.staffDetail}?accountId=${row.accountId}`).then(res => { this.$get(`${this.api.staffDetail}?accountId=${row.accountId}`).then(res => {
const { data } = res const { data } = res
data.staffArchitectureId = data.staffArchitectureId.split(',')
this.form = data this.form = data
this.originAccount = data.account this.originAccount = data.account
this.originWorkNumber = data.workNumber this.originWorkNumber = data.workNumber
@ -513,131 +526,60 @@ export default {
this.roleList = res.rolePage.records this.roleList = res.rolePage.records
}).catch(res => {}) }).catch(res => {})
}, },
// //
roleChange(value) { accountChange() {
if (value.length) { const form = this.form
let ids = this.form.roleAndDeptList.map(e => e.roleId); const { account } = form
this.roleList.forEach(i => { if (account === this.originAccount) {
let obj = { this.accountReapeat = false
roleId: "",
roleName: "",
cascaderValue: []
};
if (value.includes(i.id) && !ids.includes(i.id)) {
console.log(i)
obj.roleId = i.id;
obj.roleName = i.roleName;
this.form.roleAndDeptList.push(obj);
}
});
} else {
this.form.roleAndDeptList.splice(0);
}
},
roleRemove(value) { //
let list = [];
for(var i=0;i<this.form.roleAndDeptList.length;i++){
if (this.form.roleAndDeptList[i].roleId == value){
}else{
list.push(this.form.roleAndDeptList[i])
}
}
this.form.roleAndDeptList = list
},
accountChange() { //
if (this.form.account) {
let url = "";
if (this.form.accountId) {
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=1&account=${this.form.account}&workNumber=`;
} else {
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=1&accountId=${this.form.accountId}&account=${this.form.account}&workNumber=`;
}
this.$post(url).then(res => {
this.disableds = false
if (this.form.accountId) {
this.$refs.form.clearValidate();
this.form = {
account: this.form.account,
userName: '',
phone: '',
uniqueIdentification: '',
workNumber: '',
email: '',
classId: ""
};
this.$refs.classTree.setCheckedKeys([]);
} else { } else {
this.$refs.form.clearValidate(); const { accountId } = form
} this.$post(`${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=2&account=${account}${accountId ? `&accountId=${accountId}` : ''}`).then(res => {
this.accountReapeat = false; this.accountReapeat = false
}).catch(err => { }).catch(err => {
this.accountReapeat = true
if (this.form.accountId) { })
} else {
this.accountReapeat = true;
}
});
} }
}, },
//
worknumberChange() { worknumberChange() {
if (this.form.workNumber) { const form = this.form
let url = ""; const { workNumber } = form
if (!this.form.accountId) { if (workNumber === this.originWorkNumber) {
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=1&workNumber=${this.form.workNumber}&account=`; this.workNumberReapeat = false
} else { } else {
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=1&accountId=${this.form.accountId}&workNumber=${this.form.workNumber}&account=`; const { accountId } = form
} this.$post(`${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=2&workNumber=${workNumber}${accountId ? `&accountId=${accountId}` : ''}`).then(res => {
this.$post(url).then(res => { this.workNumberReapeat = false
if (res.status === 200) {
this.workNumberReapeat = false;
}
}).catch(err => { }).catch(err => {
this.$post(`${this.api.getDetailByAccount}?workNumber=${this.form.workNumber}&platformId=${Setting.platformId}&type=1`).then(res => { this.workNumberReapeat = true
let classId = res.data.classList.map(e => e.id); })
this.form.classId = classId.toString();
delete this.form.classList;
this.accountReapeat = false;
this.$refs.form.clearValidate();
}).catch(res => {});
this.workNumberReapeat = true;
});
} }
}, },
//
phoneChange() { phoneChange() {
let regex = /^1[3456789]\d{9}$/; const form = this.form
if (regex.test(this.form.phone)) { const { phone } = form
let url = ""; if (phone) {
if (!this.form.accountId) { const { accountId } = form
url = `${this.api.checkEmailOrPhone}?phone=${this.form.phone}&email=`; this.$post(`${this.api.checkEmailOrPhone}?phone=${phone}${accountId ? `&accountId=${accountId}` : ''}`).then(res => {
} else { this.phoneRepeat = false
url = `${this.api.checkEmailOrPhone}?accountId=${this.form.accountId}&phone=${this.form.phone}&email=`;
}
this.$post(url).then(res => {
if (res.status === 200) {
this.phoneRepeat = false;
}
}).catch(err => { }).catch(err => {
this.phoneRepeat = true; this.phoneRepeat = true
}); })
} }
}, },
//
emailChange() { emailChange() {
let regex = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/; const form = this.form
if (regex.test(this.form.email)) { const { email } = form
let url = ""; if (email) {
if (!this.form.accountId) { const { accountId } = form
url = `${this.api.checkEmailOrPhone}?email=${this.form.email}&phone=`; this.$post(`${this.api.checkEmailOrPhone}?email=${email}${accountId ? `&accountId=${accountId}` : ''}`).then(res => {
} else { this.emailRepeat = false
url = `${this.api.checkEmailOrPhone}?accountId=${this.form.accountId}&email=${this.form.email}&phone=`;
}
this.$post(url).then(res => {
if (res.status === 200) {
this.emailRepeat = false;
}
}).catch(err => { }).catch(err => {
this.emailRepeat = true; this.emailRepeat = true
}); })
} }
}, },
// / // /
@ -646,29 +588,18 @@ export default {
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("该账号已存在")
if (this.workNumberReapeat) return util.warningMsg("该号已存在") if (this.workNumberReapeat) return util.warningMsg("该工号已存在")
if (this.phoneRepeat) return util.warningMsg("该手机号已存在") if (this.phoneRepeat) return util.warningMsg("该手机号已存在")
if (this.emailRepeat) return util.warningMsg("该邮箱已存在") if (this.emailRepeat) return util.warningMsg("该邮箱已存在")
const form = this.form
if (this.teacherForm.roleAndDeptList.length){
for (let i = 0; i < this.teacherForm.roleAndDeptList.length; i++) {
if (this.teacherForm.roleAndDeptList[i].cascaderValue.length < 2) {
util.warningMsg(`请选择${this.teacherForm.roleAndDeptList[i].roleName}所属部门`)
return;
} else {
data.roleAndDeptList.push({
roleId: this.teacherForm.roleAndDeptList[i].roleId,
staffArchitectureId: this.teacherForm.roleAndDeptList[i].cascaderValue[0],
gradeId: this.teacherForm.roleAndDeptList[i].cascaderValue[1]
})
}
}
}
this.submiting = true this.submiting = true
const form = this.form
const ids = form.staffArchitectureId
form.staffArchitectureId = ids.map(e => e[e.length - 1])
console.log("🚀 ~ file: staff.vue ~ line 622 ~ this.$refs.form.validate ~ form", form)
if (form.accountId) { if (form.accountId) {
this.$post(this.api.modifyStaff, form).then(res => { this.$post(this.api.modifyStaff, form).then(res => {
util.successMsg("编辑成功!") util.successMsg("编辑成功!")
this.closeStudent() this.staffVisible = false
setTimeout(() => { setTimeout(() => {
this.submiting = false this.submiting = false
}, 2000) }, 2000)
@ -681,7 +612,7 @@ export default {
form.uniqueIdentification = new Date().getTime() form.uniqueIdentification = new Date().getTime()
this.$post(this.api.saveStaff, form).then(res => { this.$post(this.api.saveStaff, form).then(res => {
util.successMsg("新增成功!") util.successMsg("新增成功!")
this.closeStudent() this.staffVisible = false
setTimeout(() => { setTimeout(() => {
this.submiting = false this.submiting = false
}, 2000) }, 2000)
@ -695,7 +626,7 @@ export default {
}) })
}, },
// //
closeStudent() { closeStaff() {
this.$refs.form.clearValidate() this.$refs.form.clearValidate()
this.form = { this.form = {
accountId: '', accountId: '',
@ -705,44 +636,44 @@ export default {
uniqueIdentification: '', uniqueIdentification: '',
workNumber: '', workNumber: '',
email: '', email: '',
classId: '' staffArchitectureId: [],
roleList: []
}; };
this.defaultCheckedKeys = []
this.isDetail = false this.isDetail = false
this.staffVisible = false this.staffVisible = false
this.getStaff() this.getStaff()
}, },
// //
batchImport() { batchImport() {
this.importVisible = true; this.importVisible = true
this.uploadList = []; this.uploadList = []
this.uploadFaild = false; this.uploadFaild = false
}, },
// //
downLoad() { downLoad() {
location.href = this.api.studentTemplate; location.href = this.api.studentTemplate
}, },
// //
handleExceed(files, fileList) { handleExceed(files, fileList) {
util.warningMsg( util.warningMsg(
`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!` `当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`
); )
}, },
// //
showFaild() { showFaild() {
location.href = `${this.api.exportFailure}?exportCode=${this.exportCode}`; location.href = `${this.api.exportFailure}?exportCode=${this.exportCode}`
}, },
uploadSuccess(res, file, fileList) { uploadSuccess(res, file, fileList) {
this.uploadFaild = false; this.uploadFaild = false
if (res.status === 200) { if (res.status === 200) {
if (res.data.exportCode) { if (res.data.exportCode) {
this.exportCode = res.data.exportCode; this.exportCode = res.data.exportCode
this.uploadFaild = true; this.uploadFaild = true
} }
util.successMsg(`上传成功${res.data.successNum},上传失败${res.data.failureNum}`); util.successMsg(`上传成功${res.data.successNum},上传失败${res.data.failureNum}`)
util.successMsg(`本次上传有${res.data.failureNum}个错误信息录入`); util.successMsg(`本次上传有${res.data.failureNum}个错误信息录入`)
} else { } else {
res.message ? util.errorMsg(res.message) : util.errorMsg("上传失败,请检查数据"); res.message ? util.errorMsg(res.message) : util.errorMsg("上传失败,请检查数据")
} }
}, },
uploadError(err, file, fileList) { uploadError(err, file, fileList) {
@ -750,20 +681,20 @@ export default {
message: "上传出错,请重试!", message: "上传出错,请重试!",
type: "error", type: "error",
center: true center: true
}); })
}, },
beforeRemove(file, fileList) { beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${file.name}`); return this.$confirm(`确定移除 ${file.name}`)
}, },
handleRemove(file, fileList) { handleRemove(file, fileList) {
this.uploadList = fileList; this.uploadList = fileList
this.uploadFaild = false; this.uploadFaild = false
}, },
uploadSure() { uploadSure() {
this.importVisible = false; this.importVisible = false
this.studentType = 1; this.studentType = 1
this.keyWord = ""; this.keyWord = ''
this.initData(); this.initData()
} }
} }
}; };
@ -776,4 +707,7 @@ export default {
.org-name { .org-name {
margin-right: 20px; margin-right: 20px;
} }
.w-100 {
width: 100%;
}
</style> </style>
Loading…
Cancel
Save