Commit 979e03ac authored by 柳 佳乐's avatar 柳 佳乐
Browse files

20221125

parent a0a55082
<template>
<!-- 员工管理 -->
<div class="container">
<div class="container" style="margin:20px 1%">
<div class="header">
<el-form :inline="true" :model="staffQurey">
<el-form-item label="员工姓名">
<el-input
v-model="staffQurey.userName"
placeholder="员工姓名"
></el-input>
<el-input v-model="staffQurey.userName" placeholder="员工姓名"></el-input>
</el-form-item>
<el-form-item label="员工手机号">
<el-input
v-model="staffQurey.userPhone"
placeholder="员工手机号"
></el-input>
<el-input v-model="staffQurey.userPhone" placeholder="员工手机号"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="qurey()">查询</el-button>
<el-button
type="primary"
icon="el-icon-refresh-right"
@click="reset()"
>重置</el-button
>
<el-button
type="success"
icon="el-icon-circle-plus-outline"
@click="addstaff()"
>添加员工</el-button
>
<el-button type="primary" icon="el-icon-refresh-right" @click="reset()">重置</el-button>
<el-button type="success" icon="el-icon-circle-plus-outline" @click="addstaff()">添加员工</el-button>
</el-form-item>
</el-form>
</div>
......@@ -38,33 +22,73 @@
:data="staffList"
style="width: 100%; text-align: center"
border
:cell-style="{'text-align':'center'}"
:header-cell-style="{'text-align':'center'}"
>
<el-table-column type="expand">
<template slot-scope="props">
<el-descriptions
class="margin-top"
title="关于员工"
:column="1"
:size="medium"
style="width:60%; margin:20px 20px"
border
>
<el-descriptions-item label="员工姓名:" :labelStyle="{'width':'120px'}" >{{ props.row.userName }}</el-descriptions-item>
<el-descriptions-item label="员工角色:">
<el-tag
v-for="item in props.row.roleList"
:key="item.rlId"
style="margin-right:10px;"
>{{item.rlName}}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="修改员工角色:">
<el-button
style="margin:5px"
size="mini"
icon="el-icon-edit"
type="info"
@click="staffrole(props.row)"
:disabled="props.row.roles.indexOf(2)>-1"
>修改员工角色</el-button>
</el-descriptions-item>
</el-descriptions>
</template>
</el-table-column>
<el-table-column label="序号" width="50px">
<template slot-scope="scope">
{{
(staffQurey.pageNum - 1) * staffQurey.pageSize + scope.$index + 1
(staffQurey.pageNum - 1) * staffQurey.pageSize + scope.$index + 1
}}
</template>
</el-table-column>
<el-table-column prop="userName" label="姓名" />
<el-table-column prop="userSex" label="性别" width="50">
<template slot-scope="scope">
{{scope.row.userSex == '0' ? '' : ''}}
</template>
<el-table-column prop="userSex" label="性别">
<template slot-scope="scope">{{scope.row.userSex == '0' ? '' : ''}}</template>
</el-table-column>
<el-table-column prop="userPhone" label="手机号" />
<el-table-column prop="userIdentification" label="身份证" />
<el-table-column prop="userBankNumber" label="银行卡号" />
<el-table-column prop="userBankAddress" label="开户银行" />
<el-table-column label="员工角色" >
<!-- <el-table-column label="员工角色">
<template slot-scope="scope">
<el-tag v-for="item in scope.row.roleList" :key="item.rlId" style="margin-right:10px;">{{item.rlName}}</el-tag>
<el-tag
v-for="item in scope.row.roleList"
:key="item.rlId"
style="margin-right:10px;"
>{{item.rlName}}</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" >
</el-table-column>-->
<el-table-column label="操作">
<template slot-scope="scope">
<el-button style="margin:5px" size="mini" icon="el-icon-edit" type="info" @click="updataStaff(scope.row)">修改信息</el-button>
<el-button style="margin:5px" size="mini" icon="el-icon-edit" type="info" @click="staffrole(scope.row)" :disabled="scope.row.roles.indexOf(2)>-1">修改员工角色</el-button>
<el-button
style="margin:5px"
size="mini"
icon="el-icon-edit"
type="info"
@click="updataStaff(scope.row)"
>修改信息</el-button>
</template>
</el-table-column>
</el-table>
......@@ -77,33 +101,32 @@
:page-size="staffQurey.pageSize"
layout="total, prev, pager, next"
:total="total"
>
</el-pagination>
></el-pagination>
</div>
<el-dialog
:title="staffdata.userName"
:visible.sync="dialogVisible"
width="30%"
>
<el-dialog :title="staffdata.userName" :visible.sync="dialogVisible" width="30%">
<p>角色</p>
<el-checkbox-group v-model="staffdata.roles">
<el-checkbox v-for="item in rolesList" :key="item.rlId" :label="item.rlId" name="type" >{{item.rlName}}</el-checkbox>
<el-checkbox
v-for="item in rolesList"
:key="item.rlId"
:label="item.rlId"
name="type"
>{{item.rlName}}</el-checkbox>
</el-checkbox-group>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="updataStaffRole">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {selectAllByCompanyId} from '@/api/role'
import {secletStaff,updateRole} from '@/api/user'
import { selectAllByCompanyId } from "@/api/role";
import { secletStaff, updateRole } from "@/api/user";
export default {
data() {
......@@ -113,52 +136,56 @@ export default {
pageNum: 1,
pageSize: 10,
userName: null,
userPhone: null,
userPhone: null
},
total: 0,
staffList: [],
dialogVisible:false,
staffdata:{},
rolesList:[],
dialogVisible: false,
staffdata: {},
rolesList: []
};
},
created() {
this.staffQurey.companyId = this.$store.getters.companyId
this.getSatff()
this.staffQurey.companyId = this.$store.getters.companyId;
this.getSatff();
this.getRoles();
},
methods: {
//获取权限
getRoles() {
selectAllByCompanyId({companyId:this.$store.getters.companyId}).then((res)=>{
if(res.status == "success"){
this.rolesList = res.data
}else{
this.$message.error(res.data)
}
}).catch((error)=>{
this.$message.error("查询角色失败")
})
selectAllByCompanyId({ companyId: this.$store.getters.companyId })
.then(res => {
if (res.success) {
this.rolesList = res.data;
} else {
this.$message.error(res.data);
}
})
.catch(error => {
this.$message.error("查询角色失败");
});
},
//获取员工
getSatff(){
secletStaff(this.staffQurey).then((res)=>{
if(res.success){
// console.log(res.status)
this.staffList = res.data.list
this.total = res.data.total
}else{
this.$message.error(res.data)
}
}).catch((error)=>{
this.$message.error("获取员工失败")
})
getSatff() {
secletStaff(this.staffQurey)
.then(res => {
if (res.success) {
// console.log(res.status)
this.staffList = res.data.list;
this.total = res.data.total;
} else {
this.$message.error(res.data);
}
})
.catch(error => {
this.$message.error("获取员工失败");
});
},
//查询
qurey() {
this.staffQurey.pageNum = 1
this.getSatff()
this.staffQurey.pageNum = 1;
this.getSatff();
},
//重置
reset() {
......@@ -167,62 +194,59 @@ export default {
pageNum: 1,
pageSize: 10,
userName: null,
userPhone: null,
}
this.getSatff()
userPhone: null
};
this.getSatff();
},
//添加员工
addstaff() {
this.$router.push('/addStaff')
this.$router.push("/addStaff");
},
//换页
handleCurrentChange(val) {
this.staffQurey.pageNum = val
this.getSatff()
this.staffQurey.pageNum = val;
this.getSatff();
},
//修改员工信息
updataStaff(data){
updataStaff(data) {
this.$router.push({
path: '/updataStaff',
query:{
id:data.userId,
path: "/updataStaff",
query: {
id: data.userId
}
})
});
},
//修改员工角色
staffrole(data){
let roles = this.$store.getters.roles
console.log(data)
if(roles.indexOf(2) > -1){
staffrole(data) {
let roles = this.$store.getters.roles;
console.log(data);
if (roles.indexOf(2) > -1) {
this.staffdata = data;
this.staffdata = data
this.dialogVisible = true
}else{
this.$message.warning("只有管理员有权限修改员工角色")
this.dialogVisible = true;
} else {
this.$message.warning("只有管理员有权限修改员工角色");
}
},
//修改员工角色提交方法
updataStaffRole(){
updataStaffRole() {
// console.log(this.staffdata)
let param={
userId:this.staffdata.userId,
roles:this.staffdata.roles
}
console.log(param)
updateRole(param).then(res=>{
if(res.successs){
this.getSatff()
}else{
this.$message.error(res.data)
let param = {
userId: this.staffdata.userId,
roles: this.staffdata.roles
};
console.log(param);
updateRole(param).then(res => {
if (res.success) {
this.getSatff();
} else {
this.$message.error(res.data);
}
})
this.dialogVisible=false
});
this.dialogVisible = false;
}
},
}
};
</script>
......@@ -236,4 +260,7 @@ export default {
.footer {
text-align: right;
}
.my-label {
background: rgb(85, 255, 0);
}
</style>
\ No newline at end of file
......@@ -111,7 +111,7 @@ export default {
getStaff(){
getOneself({userId:this.userId}).then((res)=>{
if(res.status == "success"){
if(res.success){
this.staffData = res.data
}else{
this.$message.error(res.data)
......@@ -129,7 +129,7 @@ export default {
this.$refs.form.validate((valida)=>{
if(valida){
update(this.staffData).then((res)=>{
if(res.status == "success"){
if(res.success){
this.$message.success("修改成功")
this.$store.dispatch('tagsView/delView', this.$route)
this.$router.push("/staffList")
......@@ -153,7 +153,7 @@ export default {
userId:this.staffData.userId
}
staffpassword(param).then((res)=>{
if(res.status == "success"){
if(res.success){
this.$message.success("修改成功")
this.password=''
}else{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment