<template>
|
<div class="main tabs_main">
|
<div class="main_header">
|
<div class="header_item">
|
<span class="header_label">班组名称:</span>
|
<el-input v-model="groupName" :size="size" clearable placeholder="请输入班组名称"></el-input>
|
</div>
|
<div class="header_item">
|
<el-button icon="el-icon-search" @click="searchTeamgroupList(true)">查询</el-button>
|
<el-button class="search_btn" icon="el-icon-plus" @click="propInsert()">新增</el-button>
|
<!-- <el-button :size="size" icon="el-icon-upload2" @click="exportExcel()">导出Excel</el-button> -->
|
</div>
|
</div>
|
<div class="main_content">
|
<el-table
|
v-loading="loading"
|
:data="teamgroupList"
|
height="100%">
|
<el-table-column label="序号" width="55" align="center">
|
<template #default="scope">
|
<span>{{(pageNum - 1) * pageSize + scope.$index + 1}}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="departName" label="部门名称" align="center"></el-table-column>
|
<el-table-column prop="groupName" label="班组名称" align="center"></el-table-column>
|
<el-table-column prop="groupUserCount" label="人数" align="center"></el-table-column>
|
<el-table-column label="操作" width="300" align="center">
|
<template #default="{ row }">
|
<el-button class="table_btn" size="mini" v-if="showButton('update')" @click="propManage(row)">班组管理内容</el-button>
|
<el-button class="table_btn" size="mini" v-if="showButton('update')" @click="propUpdate(row)">修改</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
<div class="main_footer">
|
<el-pagination
|
background
|
@current-change="changePageNum"
|
@size-change="changePageSize"
|
:current-page="pageNum"
|
:page-sizes="[10, 20, 50, 100]"
|
:page-size="pageSize"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="total">
|
</el-pagination>
|
</div>
|
<!-- 新增 修改 -->
|
<el-dialog
|
class="prop_dialog"
|
:title="asyncTitle ? '新增班组' : '修改班组信息'"
|
:visible.sync="asyncTeamgroup"
|
width="35%">
|
<el-form ref="form" :model="formTeamgroup" :rules="rulesTeamgroup" label-width="auto" class="rule_form">
|
<el-form-item label="部门:" prop="departId">
|
<el-select v-model="formTeamgroup.departId" :size="size" clearable placeholder="请选择部门">
|
<el-option
|
v-for="item in departmentData"
|
:key="item.departId"
|
:label="item.departName"
|
:value="item.departId">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="班组名称:" prop="groupName">
|
<el-input v-model="formTeamgroup.groupName" :size="size" clearable placeholder="请输入班组名称"></el-input>
|
</el-form-item>
|
</el-form>
|
<div slot="footer">
|
<el-button @click="asyncTeamgroup = false">取 消</el-button>
|
<el-button class="submit_btn" @click="asyncTitle ? submitInsertForm() : submitUpdateForm()"> 提 交</el-button>
|
</div>
|
</el-dialog>
|
<!-- 班组管理内容 -->
|
<el-dialog
|
class="prop_dialog"
|
title="班组管理内容"
|
:visible.sync="asyncManage"
|
width="35">
|
<div class="dialog_content">
|
<div class="dialog_content_header">
|
统计:
|
<div class="content_header_item">
|
当前班组:{{teamgroupStaffInfo.groupName}}
|
</div>
|
<div class="content_header_item">
|
班组成员个数:{{teamgroupStaffInfo.groupUserCount}}
|
</div>
|
<div class="content_header_item">
|
班组负责人:{{teamgroupStaffInfo.groupAdminName}}
|
</div>
|
</div>
|
<div class="main dialog_content_main">
|
<div class="main_header">
|
<div class="header_item">
|
<span class="header_label">员工姓名:</span>
|
<el-input v-model="realName" :size="size" clearable placeholder="请输入员工姓名"></el-input>
|
</div>
|
<div class="header_item">
|
<el-button icon="el-icon-search" @click="searchGroupAllUser()">查询</el-button>
|
<el-button icon="el-icon-plus" @click="propStaff()">新增班组员工</el-button>
|
<!-- <el-button :size="size" icon="el-icon-upload2" @click="exportExcels()">导出Excel</el-button> -->
|
</div>
|
</div>
|
<div class="main_content">
|
<el-table
|
v-loading="loadings"
|
:data="teamgroupStaffList"
|
height="100%"
|
:header-cell-style="() => 'background-color: #082F57; color: #19F7F7'">
|
<el-table-column prop="realName" label="员工姓名" align="center"></el-table-column>
|
<el-table-column prop="sexStr" width="60" label="性别" align="center"></el-table-column>
|
<el-table-column prop="phone" label="账号" align="center"></el-table-column>
|
<el-table-column prop="phone" label="联系方式" align="center"></el-table-column>
|
<el-table-column label="操作" align="center">
|
<template #default="{ row }">
|
<template v-if="row.isAdmin === 1">
|
<el-button class="table_btn" size="mini" v-if="showButton('delete')" @click="callChangeAdmin(row)">取消设为负责人</el-button>
|
</template>
|
<template v-else>
|
<el-button class="table_btn" size="mini" v-if="showButton('delete')" @click="changeSetAdmin(row)">设为负责人</el-button>
|
</template>
|
<el-button class="delete_btn" size="mini" v-if="showButton('delete')" @click="deleteGroupInfo(row)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
</div>
|
</div>
|
</el-dialog>
|
<!-- 新增员工班组 -->
|
<el-dialog
|
append-to-body
|
class="prop_dialog"
|
title="新增班组员工"
|
:visible.sync="asyncStaff"
|
width="45%">
|
<div class="dialog_content dialog_contents">
|
<div class="main dialog_content_main dialog_mains">
|
<div class="main_header">
|
<div class="header_item">
|
<span class="header_label">员工姓名:</span>
|
<el-input v-model="insertStaffName" :size="size" clearable placeholder="请输入员工姓名"></el-input>
|
</div>
|
<div class="header_item">
|
<el-button :size="size" icon="el-icon-search" @click="searchAllStaffList(true)">查询</el-button>
|
</div>
|
</div>
|
<div class="main_content">
|
<el-table
|
ref="table"
|
v-loading="allLoading"
|
:data="allStaffList"
|
height="100%"
|
@select="selectTionChange"
|
:header-cell-style="() => 'background-color: #082F57; color: #19F7F7'">
|
<el-table-column type="selection" align="center" width="60"></el-table-column>
|
<el-table-column prop="realName" label="员工姓名" align="center"></el-table-column>
|
<el-table-column prop="sexStr" label="性别" align="center"></el-table-column>
|
<el-table-column prop="phone" label="账号" align="center"></el-table-column>
|
<el-table-column prop="phone" label="联系方式" align="center"></el-table-column>
|
</el-table>
|
</div>
|
<div class="main_footer">
|
<el-pagination
|
background
|
@current-change="allChangePageNum"
|
@size-change="allChangePageSize"
|
:current-page="allPageNum"
|
:page-sizes="[10, 20, 50, 100]"
|
:page-size="allPageSize"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="allTotal">
|
</el-pagination>
|
</div>
|
</div>
|
</div>
|
<div slot="footer">
|
<el-button @click="asyncStaff = false">取 消</el-button>
|
<el-button class="submit_btn" @click="submitInsertUser()">提 交</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { buttonPinia } from '../../../../pinia/index';
|
import { changeSize, throttle, downLoadFile } from '../../../../plugins/public';
|
export default {
|
name: 'TeamgroupIndex',
|
data() {
|
return {
|
size: changeSize(),
|
groupName: '',
|
pageNum: 1,
|
pageSize: 10,
|
total: 0,
|
loading: false,
|
teamgroupList: [], // 列表信息
|
asyncTitle: true, // 弹窗标题 true 添加班组 false 修改班组信息
|
asyncTeamgroup:false, // 弹窗
|
rulesTeamgroup: {
|
departId: [{
|
required: true,
|
message: '请选择部门',
|
triggrt: ['blur', 'change']
|
}],
|
groupName: [{
|
required: true,
|
message: '请输入班组名称',
|
triggrt: 'blur'
|
}]
|
}, // 表单校验规则
|
formTeamgroup: {}, // 表单信息
|
departmentData: [], // 部门信息
|
asyncManage: false, // 班组管理弹窗
|
teamgroupStaffInfo: {}, // 班组信息
|
loadings: false,
|
teamgroupStaffList: [], // 班组员工列表
|
staffName: '', //
|
asyncStaff: false, // 班组员工弹窗
|
insertStaffName: '',
|
allpageNum: 1,
|
allPageSize: 10,
|
allTotal: 0,
|
allLoading: false,
|
allStaffList: [], // 全部员工列表
|
allUserIdList: [],// 选择的员工
|
realName: ''
|
}
|
},
|
mounted() {
|
const that = this;
|
// 根据窗口大小动态修改组件尺寸
|
window.onresize = () => {
|
that.size = changeSize();
|
}
|
that.searchTeamgroupList(true);
|
},
|
methods: {
|
async getDepartmentInfoData() {
|
const { data } = await this.$api.Personnerl.GETDEPARTMENTDATA();
|
this.departmentData = data;
|
},
|
// 查询班组列表信息
|
searchTeamgroupList(bol) {
|
if(bol) {
|
this.pageNum = 1;
|
}
|
this.loading = true;
|
this.teamgroupList = [];
|
this.$api.Personnerl.SEARCHTEAMGROUPLIST({
|
groupName: this.groupName,
|
pageNum: this.pageNum,
|
pageSize: this.pageSize
|
}).then((res) => {
|
if(res.success) {
|
this.total = res.data.total;
|
this.teamgroupList = res.data.list;
|
}
|
this.loading = false;
|
}).catch(() => {
|
this.loading = false;
|
})
|
},
|
// 打开添加信息
|
propInsert() {
|
this.asyncTitle = true;
|
this.asyncTeamgroup = true;
|
},
|
// 打开修改信息
|
propUpdate(row) {
|
this.asyncTitle = false;
|
this.asyncTeamgroup = true;
|
this.$set(this.formTeamgroup, 'groupId', row.groupId);
|
this.$set(this.formTeamgroup, 'departId', row.departId);
|
this.$set(this.formTeamgroup, 'groupName', row.groupName);
|
},
|
// 导出班组Excel
|
exportExcel() {
|
this.$api.System.GETEXPORTTOKENDATA({
|
groupName: this.groupName,
|
}).then((res) => {
|
if(res.success) {
|
downLoadFile(res.data, '/staff/group/export');
|
}
|
})
|
},
|
// 打开班组管理内容
|
propManage(row) {
|
this.asyncManage = true;
|
this.teamgroupStaffInfo = row;
|
this.groupId = row.groupId;
|
this.searchGroupAllUser(row.groupId, true);
|
},
|
// 查询班组下人员信息
|
searchGroupAllUser() {
|
this.loadings = true;
|
this.teamgroupStaffList = [];
|
this.$api.Personnerl.SEARCHGROUPALLUSERLIST({
|
groupId: this.groupId,
|
realName: this.realName
|
}).then((res) => {
|
if(res.success) {
|
this.teamgroupStaffList = res.data.list;
|
}
|
this.loadings = false;
|
}).catch(() => {
|
this.loadings = false;
|
})
|
},
|
// 打开添加员工班组
|
propStaff() {
|
this.asyncStaff = true;
|
this.searchAllStaffList(true).then(() => {
|
this.allUserIdList = this.teamgroupStaffList.map(item => item.userId);
|
})
|
},
|
// 查询全部员工信息
|
async searchAllStaffList(bol) {
|
if(bol) {
|
this.allPageNum = 1;
|
}
|
this.allLoading = true;
|
this.allStaffList = [];
|
await this.$api.Personnerl.SEARCHMORTGAGEELIST({
|
realName: this.insertStaffName,
|
pageNum: this.allPageNum,
|
pageSize: this.allPageSize
|
}).then( (res) => {
|
if(res.success) {
|
this.allTotal = res.data.total;
|
this.allStaffList = res.data.list;
|
const list = this.teamgroupStaffList.map(item => item.userId);
|
list.forEach(item => {
|
const row = this.allStaffList.find(element => element.userId === item);
|
this.$nextTick(() => {
|
this.$refs.table.toggleRowSelection(row, true);
|
})
|
});
|
}
|
this.allLoading = false;
|
}).catch(() => {
|
this.allLoading = false;
|
})
|
},
|
// 导出班组人员信息
|
exportExcels() {
|
this.$api.System.GETEXPORTTOKENDATA({
|
groupId: this.groupId,
|
groupName: this.groupName,
|
}).then((res) => {
|
if(res.success) {
|
downLoadFile(res.data, '/staff/group/groupUserExport');
|
}
|
})
|
},
|
// 删除班组信息
|
deleteInfo(row) {
|
this.$confirm("该操作将删除该班组,是否继续删除?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
this.$api.Personnerl.DELETETEAMGROUPINFO({groupId: row.groupId})
|
.then(res => {
|
if(res.success) {
|
this.searchTeamgroupList();
|
this.$message.success("删除成功!");
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
})
|
.catch(() => {
|
this.$message.warning("您已取消");
|
})
|
},
|
// 设置为负责人
|
changeSetAdmin(row) {
|
this.$api.Personnerl.CHANGESETADMIN({
|
groupId: this.groupId,
|
userId: row.userId
|
}).then((res) => {
|
if(res.success) {
|
this.$message.success('设置成功!');
|
this.searchGroupAllUser(this.groupId, true);
|
this.searchTeamgroupList(true);
|
this.$nextTick(() => {
|
this.$set(this.teamgroupStaffInfo, 'groupAdminName', res.data);
|
})
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
},
|
// 取消设置负责人
|
callChangeAdmin(row) {
|
this.$api.Personnerl.CALLCHANGESETADMIN({
|
groupId: this.groupId,
|
userId: row.userId
|
}).then((res) => {
|
if(res.success) {
|
this.$message.success('取消成功!');
|
this.searchGroupAllUser(this.groupId, true);
|
this.searchTeamgroupList(true);
|
this.$nextTick(() => {
|
this.$set(this.teamgroupStaffInfo, 'groupAdminName', '');
|
})
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
},
|
// 删除班组员工信息
|
deleteGroupInfo(row) {
|
this.$confirm("该操作将删除该班组员工,是否继续删除?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
this.$api.Personnerl.DELETEGROUPUSERINFO({
|
groupId: this.groupId,
|
userId: row.userId
|
}).then(res => {
|
if(res.success) {
|
this.searchGroupAllUser(this.groupId, true);
|
this.searchTeamgroupList(true);
|
this.$message.success("删除成功!");
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
})
|
.catch(() => {
|
this.$message.warning("您已取消");
|
})
|
},
|
// 提交添加信息
|
submitInsertForm: throttle(function() {
|
this.$refs.form.validate((valid) => {
|
if(valid) {
|
const params = Object.assign({}, this.formTeamgroup);
|
this.$api.Personnerl.INSERTTEAMGROUPINFO(params).then((res) => {
|
if(res.success) {
|
this.asyncTeamgroup = false;
|
this.searchTeamgroupList(true);
|
this.$message.success('添加成功!');
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
}
|
})
|
}, 3000),
|
// 提交修改信息
|
submitUpdateForm: throttle(function() {
|
this.$refs.form.validate((valid) => {
|
if(valid) {
|
const params = Object.assign({}, this.formTeamgroup);
|
this.$api.Personnerl.UPDATETEAMGROUPINFO(params).then((res) => {
|
if(res.success) {
|
this.asyncTeamgroup = false;
|
this.searchTeamgroupList(true);
|
this.$message.success('修改成功!');
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
}
|
})
|
}, 3000),
|
// 人员列表选择项变化事件
|
selectTionChange(selection, row) {
|
if(this.allUserIdList.includes(row.userId)) {
|
const num = this.allUserIdList.indexOf(row.userId);
|
this.allUserIdList.splice(num, 1);
|
} else {
|
this.allUserIdList.push(row.userId);
|
}
|
},
|
// 提交新增班组员工信息
|
submitInsertUser: throttle(function() {
|
const userIds = this.allUserIdList.join(',');
|
this.$api.Personnerl.INSERTGROUPUSERINFO({
|
groupId: this.groupId,
|
userIds: userIds
|
}).then((res) => {
|
if(res.success) {
|
this.asyncStaff = false;
|
this.$message.success('添加成功!');
|
this.searchGroupAllUser(this.groupId, true);
|
this.searchTeamgroupList(true);
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
}, 3000),
|
// 切换页数
|
changePageNum(page) {
|
this.pageNum = page;
|
this.searchTeamgroupList();
|
},
|
// 切换每页条数
|
changePageSize(size) {
|
this.pageSize = size;
|
this.searchTeamgroupList();
|
},
|
// 判断按钮权限信息
|
showButton(str) {
|
const pinia = buttonPinia();
|
return pinia.$state.buttonInfo.includes(str);
|
},
|
// 切换页数
|
allChangePageNum(page) {
|
this.allPageNum = page;
|
this.searchAllStaffList();
|
},
|
// 切换每页条数
|
allChangePageSize(size) {
|
this.allPageSize = size;
|
this.searchAllStaffList();
|
}
|
},
|
watch: {
|
asyncTeamgroup(bol) {
|
if(!bol) {
|
this.formTeamgroup = {};
|
this.$refs.form.resetFields();
|
} else {
|
this.getDepartmentInfoData();
|
}
|
},
|
asyncManage(bol) {
|
if(!bol) {
|
this.groupId = '';
|
this.realName = ''
|
}
|
},
|
asyncStaff(bol) {
|
if(!bol) {
|
this.allUserIdList = [];
|
}
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import'@/style/layout-main.scss';
|
|
.dialog_content {
|
position: relative;
|
height: 500px;
|
|
.dialog_content_header {
|
position: relative;
|
display: flex;
|
align-items: center;
|
padding: 5px 20px;
|
height: 30px;
|
color: #EAEAEA;
|
background: #13B9C6;
|
|
.content_header_item {
|
padding: 0 30px;
|
width: auto;
|
}
|
|
&::before {
|
content: "";
|
position: absolute;
|
top: 50%;
|
left: 0;
|
transform: translateY(-50%);
|
width: 5px;
|
height: 50%;
|
background: #FFFFFF;
|
}
|
}
|
|
.dialog_content_main {
|
margin: 0;
|
width: 100%;
|
height: calc(100% - 40px);
|
|
background: transparent;
|
}
|
|
.dialog_mains {
|
height: 100%;
|
}
|
}
|
|
.dialog_contents {
|
height: 400px;
|
}
|
</style>
|