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

20221125

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