后台账号联调

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

@ -10,6 +10,9 @@ export default {
bindPhoneOrEmail: `users/users/userAccount/bindPhoneOrEmail`,// 绑定手机
sendPhoneOrEmailCode: `users/users/userAccount/sendPhoneOrEmailCode`,// 手机验证码
checkEmailOrPhone: `occupationlab/architecture/checkEmailOrPhone`, // 新增学生前:校验手机号或者邮箱
checkWorkNumOrAccount: `occupationlab/architecture/checkWorkNumOrAccount`, // 新增/编辑学生前:校验学号或者学生账号
// 订单管理
orderAdd: `nakadai/nakadai/order/add`,// 订单添加
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 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="className" 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="countries" label="授权角色" align="center" width="100">
<template slot-scope="scope">员工</template>
</el-table-column>
<el-table-column prop="phone" label="手机号" align="center" width="120"></el-table-column>
<el-table-column prop="staffArchitectureName" label="所在部门" align="center" min-width="100"></el-table-column>
<el-table-column prop="roleName" label="授权角色" align="center" width="100"></el-table-column>
<el-table-column label="操作" align="center" width="300">
<template slot-scope="scope">
<el-button type="text" @click="editStaff(scope.row,true)">查看</el-button>
<el-button type="text" @click="editStaff(scope.row,false)">编辑</el-button>
<el-button type="text" @click="queryStaff(scope.row,true)">查看</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="delStaff(scope.row)">删除</el-button>
</template>
@ -121,7 +119,7 @@
<el-pagination background @current-change="currentChange" :current-page="page" layout="total, prev, pager, next" :total="total"></el-pagination>
</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-item prop="workNumber" label="工号">
<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-form-item>
<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 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 prop="roleValue" label="授权角色">
<el-select v-model="form.roleValue" @change="roleChange" @remove-tag="roleRemove" multiple style="width: 100%;">
<el-form-item prop="roleList" label="授权角色">
<el-select class="w-100" v-model="form.roleList" multiple>
<template v-for="item in roleList">
<!-- 不显示超管 -->
<el-option
@ -151,17 +149,17 @@
</template>
</el-select>
</el-form-item>
<el-form-item v-for="(item, i) in form.roleAndDeptList" :key="i" :label="`${item.roleName}所在部门`">
<el-form-item label="所在部门">
<el-cascader
v-model="item.cascaderValue"
class="w-100"
v-model="form.staffArchitectureId"
:options="orgList"
:props="casProps"
style="width: 100%"
></el-cascader>
</el-form-item>
</el-form>
<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>
</span>
</el-dialog>
@ -206,33 +204,58 @@ import OrgTree from "@/components/org-tree/src/tree";
export default {
components: { OrgTree },
data() {
var accountPass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入账号'));
} else {
var pattern = /^[A-Za-z0-9]*$/;
if(pattern.test(value)){
this.accountChange();
callback();
}else{
callback(new Error('请输入正确账号格式'));
}
const accountPass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入账号'))
} else {
const pattern = /^[A-Za-z0-9]*$/
if(pattern.test(value)){
this.accountChange()
callback()
}else{
callback(new Error('请输入正确账号格式'))
}
};
var workNumberPass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入员工学号'));
} else {
var pattern = /^[A-Za-z0-9]*$/;
if(pattern.test(value)){
this.worknumberChange();
callback();
}else{
callback(new Error('请输入正确员工学号格式'));
}
}
}
const workNumberPass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入工号'))
} else {
const pattern = /^[A-Za-z0-9]*$/
if(pattern.test(value)){
this.worknumberChange()
callback()
}else{
callback(new Error('请输入正确工号格式'))
}
};
let that = this;
}
}
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()
}
}
return {
orgList: [],
orgListDia: [],
@ -262,34 +285,27 @@ export default {
uniqueIdentification: '',
workNumber: '',
email: '',
account: ''
account: '',
staffArchitectureId: []
},
rules: {
organizationName: [
{ required: true, message: "请输入名称", trigger: "blur" }
],
account: [
{ required: true,validator: accountPass, trigger: 'blur' }
{ required: true,validator: accountPass, trigger: 'blur' }
],
userName: [
{ required: true, message: "请输入姓名", trigger: "blur" }
{ required: true, message: "请输入姓名", trigger: "blur" }
],
workNumber: [
{ required: true,validator: workNumberPass, trigger: 'blur' }
{ required: true,validator: workNumberPass, trigger: 'blur' }
],
roleList: [
{ required: true, message: "请选择授权角色", trigger: "change" }
],
phone: [
{
pattern: /^1[3456789]\d{9}$/,
message: "请输入正确的手机号",
trigger: "blur"
}
{ validator: phonePass, trigger: 'blur' }
],
email: [
{
pattern: /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/,
message: "请输入正确的邮箱",
trigger: "blur"
}
{ validator: emailPass, trigger: 'blur' }
]
},
listData: [],
@ -305,7 +321,6 @@ export default {
originWorkNumber: '',
phoneRepeat: false,
emailRepeat: false,
defaultCheckedKeys: [],
casProps: {
multiple: true,
checkStrictly: true,
@ -325,10 +340,10 @@ export default {
};
},
watch: {
keyWord: function(val) {
clearTimeout(this.searchTimer);
this.searchTimer = setTimeout(this.getStaff, 500);
}
keyWord: function(val) {
clearTimeout(this.searchTimer);
this.searchTimer = setTimeout(this.getStaff, 500);
}
},
mounted() {
this.getOrg()
@ -445,17 +460,16 @@ export default {
},
//
getStaff() {
let data = {
type: this.studentType || '',
staffArchitectureId: this.$refs.orgTree.getCurrentKey() || '',
keyWord: this.keyWord,
pageNum: this.page,
pageSize: this.pageSize
};
this.$post(this.api.staffList, data).then(res => {
this.listData = res.records
this.total = res.total
}).catch(err => {})
this.$post(this.api.staffList, {
type: this.studentType || 1,
staffArchitectureId: this.$refs.orgTree.getCurrentKey() || '',
keyWord: this.keyWord,
pageNum: this.page,
pageSize: this.pageSize
}).then(res => {
this.listData = res.page.records
this.total = res.page.total
}).catch(err => {})
},
//
currentChange(val) {
@ -466,41 +480,40 @@ export default {
this.multipleSelection = val
},
initData() {
this.$refs.table.clearSelection()
this.page = 1
this.getStaff()
this.$refs.table.clearSelection()
this.page = 1
this.getStaff()
},
//
delStaff(row) {
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
this.$post(`${this.api.delStaff}?accountIds=${row.accountId}`).then(res => {
util.successMsg("删除成功")
this.getStaff()
}).catch(res => {
});
}).catch(() => {})
},
resetPassword(row) { //
this.$confirm(`重置后的密码为:${Setting.initialPassword},确定重置?`, "提示", { type: "warning" }).then(() => {
this.$get(`${this.api.resetPassword}?userId=${row.userId}&newPwd=111aaa`).then(res => {
util.successMsg("重置成功");
}).catch(res => {
});
}).catch(() => {
});
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
this.$post(`${this.api.delStaff}?accountIds=${row.accountId}`).then(res => {
util.successMsg("删除成功")
this.getStaff()
}).catch(res => {})
}).catch(() => {})
},
//
resetPassword(row) {
this.$confirm(`重置后的密码为:${Setting.initialPassword},确定重置?`, "提示", { type: "warning" }).then(() => {
this.$get(`${this.api.resetPassword}?userId=${row.userId}&newPwd=111aaa`).then(res => {
util.successMsg("重置成功")
}).catch(res => {})
}).catch(() => {})
},
//
addStaff() {
this.staffVisible = true
},
// /
editStaff(row, isDetail) {
queryStaff(row, isDetail) {
this.isDetail = isDetail
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
data.staffArchitectureId = data.staffArchitectureId.split(',')
this.form = data
this.originAccount = data.account
this.originWorkNumber = data.workNumber
@ -513,189 +526,107 @@ export default {
this.roleList = res.rolePage.records
}).catch(res => {})
},
//
roleChange(value) {
if (value.length) {
let ids = this.form.roleAndDeptList.map(e => e.roleId);
this.roleList.forEach(i => {
let obj = {
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 {
this.$refs.form.clearValidate();
}
this.accountReapeat = false;
}).catch(err => {
if (this.form.accountId) {
} else {
this.accountReapeat = true;
}
});
}
//
accountChange() {
const form = this.form
const { account } = form
if (account === this.originAccount) {
this.accountReapeat = false
} else {
const { accountId } = form
this.$post(`${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=2&account=${account}${accountId ? `&accountId=${accountId}` : ''}`).then(res => {
this.accountReapeat = false
}).catch(err => {
this.accountReapeat = true
})
}
},
//
worknumberChange() {
if (this.form.workNumber) {
let url = "";
if (!this.form.accountId) {
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=1&workNumber=${this.form.workNumber}&account=`;
} else {
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=1&accountId=${this.form.accountId}&workNumber=${this.form.workNumber}&account=`;
}
this.$post(url).then(res => {
if (res.status === 200) {
this.workNumberReapeat = false;
}
}).catch(err => {
this.$post(`${this.api.getDetailByAccount}?workNumber=${this.form.workNumber}&platformId=${Setting.platformId}&type=1`).then(res => {
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;
});
}
const form = this.form
const { workNumber } = form
if (workNumber === this.originWorkNumber) {
this.workNumberReapeat = false
} else {
const { accountId } = form
this.$post(`${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=2&workNumber=${workNumber}${accountId ? `&accountId=${accountId}` : ''}`).then(res => {
this.workNumberReapeat = false
}).catch(err => {
this.workNumberReapeat = true
})
}
},
//
phoneChange() {
let regex = /^1[3456789]\d{9}$/;
if (regex.test(this.form.phone)) {
let url = "";
if (!this.form.accountId) {
url = `${this.api.checkEmailOrPhone}?phone=${this.form.phone}&email=`;
} else {
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 => {
this.phoneRepeat = true;
});
}
const form = this.form
const { phone } = form
if (phone) {
const { accountId } = form
this.$post(`${this.api.checkEmailOrPhone}?phone=${phone}${accountId ? `&accountId=${accountId}` : ''}`).then(res => {
this.phoneRepeat = false
}).catch(err => {
this.phoneRepeat = true
})
}
},
//
emailChange() {
let regex = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
if (regex.test(this.form.email)) {
let url = "";
if (!this.form.accountId) {
url = `${this.api.checkEmailOrPhone}?email=${this.form.email}&phone=`;
} else {
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 => {
this.emailRepeat = true;
});
}
const form = this.form
const { email } = form
if (email) {
const { accountId } = form
this.$post(`${this.api.checkEmailOrPhone}?email=${email}${accountId ? `&accountId=${accountId}` : ''}`).then(res => {
this.emailRepeat = false
}).catch(err => {
this.emailRepeat = true
})
}
},
// /
submitStaff() {
this.$refs.form.validate((valid) => {
if (valid) {
if (this.submiting) return false
if (this.accountReapeat) return util.warningMsg("该账号已存在")
if (this.workNumberReapeat) return util.warningMsg("该员工学号已存在")
if (this.phoneRepeat) 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
if (form.accountId) {
this.$post(this.api.modifyStaff, form).then(res => {
util.successMsg("编辑成功!")
this.closeStudent()
setTimeout(() => {
this.submiting = false
}, 2000)
}).catch(res => {
setTimeout(() => {
this.submiting = false
}, 2000)
})
} else {
form.uniqueIdentification = new Date().getTime()
this.$post(this.api.saveStaff, form).then(res => {
util.successMsg("新增成功!")
this.closeStudent()
setTimeout(() => {
this.submiting = false
}, 2000)
}).catch(res => {
setTimeout(() => {
this.submiting = false
}, 2000)
})
}
}
})
this.$refs.form.validate((valid) => {
if (valid) {
if (this.submiting) return false
if (this.accountReapeat) return util.warningMsg("该账号已存在")
if (this.workNumberReapeat) return util.warningMsg("该工号已存在")
if (this.phoneRepeat) return util.warningMsg("该手机号已存在")
if (this.emailRepeat) return util.warningMsg("该邮箱已存在")
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) {
this.$post(this.api.modifyStaff, form).then(res => {
util.successMsg("编辑成功!")
this.staffVisible = false
setTimeout(() => {
this.submiting = false
}, 2000)
}).catch(res => {
setTimeout(() => {
this.submiting = false
}, 2000)
})
} else {
form.uniqueIdentification = new Date().getTime()
this.$post(this.api.saveStaff, form).then(res => {
util.successMsg("新增成功!")
this.staffVisible = false
setTimeout(() => {
this.submiting = false
}, 2000)
}).catch(res => {
setTimeout(() => {
this.submiting = false
}, 2000)
})
}
}
})
},
//
closeStudent() {
closeStaff() {
this.$refs.form.clearValidate()
this.form = {
accountId: '',
@ -705,65 +636,65 @@ export default {
uniqueIdentification: '',
workNumber: '',
email: '',
classId: ''
staffArchitectureId: [],
roleList: []
};
this.defaultCheckedKeys = []
this.isDetail = false
this.staffVisible = false
this.getStaff()
},
//
batchImport() {
this.importVisible = true;
this.uploadList = [];
this.uploadFaild = false;
this.importVisible = true
this.uploadList = []
this.uploadFaild = false
},
//
downLoad() {
location.href = this.api.studentTemplate;
location.href = this.api.studentTemplate
},
//
handleExceed(files, fileList) {
util.warningMsg(
`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`
);
util.warningMsg(
`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`
)
},
//
showFaild() {
location.href = `${this.api.exportFailure}?exportCode=${this.exportCode}`;
location.href = `${this.api.exportFailure}?exportCode=${this.exportCode}`
},
uploadSuccess(res, file, fileList) {
this.uploadFaild = false;
if (res.status === 200) {
if (res.data.exportCode) {
this.exportCode = res.data.exportCode;
this.uploadFaild = true;
}
util.successMsg(`上传成功${res.data.successNum},上传失败${res.data.failureNum}`);
util.successMsg(`本次上传有${res.data.failureNum}个错误信息录入`);
} else {
res.message ? util.errorMsg(res.message) : util.errorMsg("上传失败,请检查数据");
this.uploadFaild = false
if (res.status === 200) {
if (res.data.exportCode) {
this.exportCode = res.data.exportCode
this.uploadFaild = true
}
util.successMsg(`上传成功${res.data.successNum},上传失败${res.data.failureNum}`)
util.successMsg(`本次上传有${res.data.failureNum}个错误信息录入`)
} else {
res.message ? util.errorMsg(res.message) : util.errorMsg("上传失败,请检查数据")
}
},
uploadError(err, file, fileList) {
this.$message({
message: "上传出错,请重试!",
type: "error",
center: true
});
this.$message({
message: "上传出错,请重试!",
type: "error",
center: true
})
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${file.name}`);
return this.$confirm(`确定移除 ${file.name}`)
},
handleRemove(file, fileList) {
this.uploadList = fileList;
this.uploadFaild = false;
this.uploadList = fileList
this.uploadFaild = false
},
uploadSure() {
this.importVisible = false;
this.studentType = 1;
this.keyWord = "";
this.initData();
this.importVisible = false
this.studentType = 1
this.keyWord = ''
this.initData()
}
}
};
@ -776,4 +707,7 @@ export default {
.org-name {
margin-right: 20px;
}
.w-100 {
width: 100%;
}
</style>
Loading…
Cancel
Save