管理系统PC前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dm-manage-web/src/views/system/employee/index.vue

511 lines
17 KiB

2 years ago
<template>
<div class="app-container">
<el-row :gutter="20">
<!--部门数据-->
<el-col :span="4" :xs="24">
<div class="head-container">
<el-input v-model="deptName" placeholder="请输入部门名称" clearable size="small" prefix-icon="el-icon-search" style="margin-bottom: 20px" />
</div>
<div class="head-container">
2 years ago
<el-tree ref="tree" :data="deptOptions" :props="defaultProps" :expand-on-click-node="false" :filter-node-method="filterNode" default-expand-all highlight-current @node-click="handleNodeClick" />
2 years ago
</div>
</el-col>
<!--用户数据-->
<el-col :span="20" :xs="24">
<el-form ref="queryForm" :model="queryParams" :inline="true" label-width="68px">
<el-form-item prop="userOrPhone">
<el-input v-model="queryParams.employeeName" placeholder="请输入姓名/手机号" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="入职时间">
<el-date-picker v-model="queryParams.hiredate" style="width: 240px" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
</el-form-item>
2 years ago
<el-form-item prop="status">
<el-select v-model="queryParams.status" placeholder="用户状态" clearable>
<el-option v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
</el-select>
</el-form-item>
2 years ago
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
<el-button v-hasPermi="['system:employee:add']" type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="userList">
<el-table-column label="姓名" prop="employeeName" />
<el-table-column label="手机号" prop="phone" />
<el-table-column label="部门" prop="orgName" />
<el-table-column label="上级领导" prop="leaderName" />
<el-table-column label="入职时间" prop="hiredate" width="160">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.hiredate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" width="260">
<template slot-scope="scope">
2 years ago
<el-button v-hasPermi="['system:employee:edit']" type="text" @click="handleUpdate(scope.row)">修改</el-button>
<el-button v-hasPermi="['system:employee:logoff']" type="text" @click="handleLogoff(scope.row)">注销</el-button>
<el-button v-hasPermi="['system:employee:release']" type="text" @click="handleRelease(scope.row)">释放线索</el-button>
<el-button v-hasPermi="['system:employee:remove']" type="text" @click="handleRemove(scope.row)">删除</el-button>
2 years ago
<!-- <el-button
v-hasPermi="['system:employee:resetPwd']"
type="text"
icon="el-icon-key"
@click="handleReset(scope.row)"
>重置密码</el-button>-->
</template>
</el-table-column>
</el-table>
2 years ago
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
2 years ago
</el-col>
</el-row>
<!-- 添加或修改参数配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="700px" custom-class="dialog500" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-row>
<el-col :span="12">
<el-form-item label="姓名" prop="employeeName">
<el-input v-model="form.employeeName" placeholder="请输入员工姓名" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="手机号" prop="phone">
<el-input v-model="form.phone" placeholder="请输入手机号码" maxlength="11" />
</el-form-item>
</el-col>
2 years ago
</el-row>
<el-row>
2 years ago
<el-col :span="12">
<el-form-item label="角色" prop="roleIdList">
2 years ago
<el-select v-model="form.roleIdList" multiple placeholder="请选择" class="wp100">
2 years ago
<el-option v-for="item in roleOptions" :key="item.id" :label="item.name" :value="item.id" :disabled="item.status == 1" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="归属部门" prop="orgId">
2 years ago
<treeselect v-model="form.orgId" class="wp100" :options="deptOptions" :disable-branch-nodes="true" :show-count="true" placeholder="请选择归属部门" />
2 years ago
</el-form-item>
</el-col>
2 years ago
</el-row>
<el-row>
2 years ago
<el-col :span="12">
<el-form-item label="权重" prop="weight">
2 years ago
<el-input v-model="form.weight" placeholder="权重,1-100" type="number" />
2 years ago
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="用户性别">
2 years ago
<el-select v-model="form.sex" placeholder="请选择" class="wp100">
2 years ago
<el-option v-for="dict in sexOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
</el-select>
</el-form-item>
</el-col>
2 years ago
</el-row>
<el-row>
2 years ago
<el-col :span="12">
<el-form-item label="入职日期">
2 years ago
<el-date-picker v-model="form.hiredate" :editable="false" type="date" value-format="yyyy-MM-dd" placeholder="请选择入职时间" style="width: 100%;" />
2 years ago
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="状态">
2 years ago
<el-radio-group v-model="form.status" class="wp100">
2 years ago
<el-radio v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictValue">{{ dict.dictLabel }}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
2 years ago
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="所属报名点">
<el-select v-model="form.signPlace" placeholder="请选择" class="wp100">
<el-option v-for="dict in signPlaceOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
</el-select>
</el-form-item>
</el-col>
2 years ago
<el-col :span="12">
<el-form-item label="最大线索数">
2 years ago
<el-input v-model="form.maxClueNum" placeholder="请输入" />
2 years ago
</el-form-item>
</el-col>
2 years ago
</el-row>
<el-row>
2 years ago
<el-col :span="12">
<el-form-item label="是否考勤">
2 years ago
<el-radio-group v-model="form.checkin" class="wp100">
2 years ago
<el-radio :label="true"></el-radio>
<el-radio :label="false"></el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否参与统计">
2 years ago
<el-radio-group v-model="form.count" class="wp100">
2 years ago
<el-radio :label="true"></el-radio>
<el-radio :label="false"></el-radio>
</el-radio-group>
</el-form-item>
</el-col>
2 years ago
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="所属区域" prop="areaList">
<el-select v-model="form.areaList" multiple placeholder="请选择">
<el-option v-for="dict in areaOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
</el-select>
</el-form-item>
</el-col>
2 years ago
<el-col :span="12">
<el-form-item label="微信openId" prop="openId">
<el-input v-model="form.openId" placeholder="请输入" />
</el-form-item>
</el-col>
2 years ago
</el-row>
1 year ago
<el-row>
<el-col :span="24">
<el-form-item label="数据权限" prop="openId">
1 year ago
<el-radio-group v-model="form.dataScope">
<el-radio :label="1">全部数据</el-radio>
1 year ago
<!-- <el-radio :label="2">部门数据</el-radio> -->
1 year ago
<el-radio :label="3">个人数据</el-radio>
</el-radio-group>
</el-form-item>
1 year ago
</el-col>
</el-row>
2 years ago
<el-row>
2 years ago
<el-col :span="24">
<el-form-item label="备注">
<!-- <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input> -->
2 years ago
<editor v-model="form.remark" :height="200" />
2 years ago
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
2 years ago
import empAPi from '@/api/system/employee';
import { deptTreeSelect } from '@/api/system/dept';
import { getRoleOptions } from '@/api/system/role';
import { resetUserPwd } from '@/api/system/user';
import Treeselect from '@riophae/vue-treeselect';
import '@riophae/vue-treeselect/dist/vue-treeselect.css';
import editor from '@/components/Editor';
2 years ago
export default {
name: 'Employee',
components: { Treeselect, editor },
1 year ago
data() {
2 years ago
return {
// 遮罩层
loading: true,
userId: localStorage.getItem('userId'),
// 总条数
total: 0,
// 用户表格数据
userList: null,
// 弹出层标题
title: '',
// 部门树选项
deptOptions: undefined,
// 是否显示弹出层
open: false,
// 部门名称
deptName: undefined,
// 默认密码
initPassword: undefined,
// 状态数据字典
statusOptions: [],
// 性别状态字典
sexOptions: [],
// 角色选项
roleOptions: [],
// 表单参数
form: {},
defaultProps: {
children: 'children',
2 years ago
label: 'label'
2 years ago
},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
nameOrPhone: undefined,
status: '0',
orgId: undefined,
roleId: undefined,
2 years ago
hiredate: []
2 years ago
},
// 表单校验
rules: {
2 years ago
employeeName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
2 years ago
roleIdList: [
{
required: true,
type: 'array',
message: '角色不能为空',
2 years ago
trigger: 'blur,change'
}
2 years ago
],
orgId: [
{
required: true,
message: '归属部门不能为空',
2 years ago
trigger: 'blur,change'
}
2 years ago
],
weight: [
{
required: true,
message: '权重不能为空',
2 years ago
trigger: 'blur,change'
}
2 years ago
],
phone: [
{ required: true, message: '手机号码不能为空', trigger: 'blur' },
{
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: '请输入正确的手机号码',
2 years ago
trigger: 'blur'
}
]
2 years ago
},
userOptions: [],
2 years ago
areaOptions: [],
signPlaceOptions: []
2 years ago
};
2 years ago
},
watch: {
// 根据名称筛选部门树
1 year ago
deptName(val) {
2 years ago
this.$refs.tree.filter(val);
}
2 years ago
},
1 year ago
created() {
2 years ago
this.getList();
2 years ago
this.getDeptTree();
2 years ago
this._getRoleOptions();
2 years ago
this.getDicts('sys_normal_disable').then((response) => {
2 years ago
this.statusOptions = response.data;
});
2 years ago
this.getDicts('sys_user_sex').then((response) => {
2 years ago
this.sexOptions = response.data;
});
2 years ago
this.getDicts('dm_area').then((response) => {
2 years ago
this.areaOptions = response.data;
});
2 years ago
this.getDicts('sign_place').then((response) => {
this.signPlaceOptions = response.data;
});
2 years ago
this.getConfigKey('sys.user.initPassword').then((response) => {
2 years ago
this.initPassword = response.msg;
});
2 years ago
empAPi.getEmployee().then((resp) => {
if (resp.code === 200) {
2 years ago
this.userOptions = resp.data;
2 years ago
// this.userOptions.push({
// id: '6ce3239c8c154f83befb9eb7441a01c7',
// name: 'DM',
// })
}
2 years ago
});
2 years ago
},
methods: {
/** 查询用户列表 */
1 year ago
getList() {
2 years ago
this.loading = true;
empAPi.pageList(this.queryParams).then((response) => {
this.userList = response.rows;
this.total = response.total;
this.loading = false;
});
2 years ago
},
1 year ago
_getRoleOptions() {
2 years ago
getRoleOptions().then((resp) => {
2 years ago
this.roleOptions = resp.data;
});
2 years ago
},
/** 查询部门下拉树结构 */
1 year ago
getDeptTree() {
2 years ago
deptTreeSelect().then((response) => {
2 years ago
this.deptOptions = response.data;
});
},
// 筛选节点
1 year ago
filterNode(value, data) {
2 years ago
if (!value) return true;
return data.label.indexOf(value) !== -1;
2 years ago
},
// 节点单击事件
1 year ago
handleNodeClick(data) {
2 years ago
this.queryParams.orgId = data.id;
this.getList();
2 years ago
},
// 用户状态修改
1 year ago
handleStatusChange(row) {
2 years ago
const text = row.status === '0' ? '启用' : '停用';
this.$confirm('确认要"' + text + '""' + row.userName + '"用户吗?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
2 years ago
.then(function () {
2 years ago
const model = {
2 years ago
employeeId: row.employeeId,
status: row.status
2 years ago
};
return empAPi.update(model);
2 years ago
})
.then(() => {
2 years ago
this.msgSuccess(text + '成功');
2 years ago
})
.catch(function () {
2 years ago
row.status = row.status === '0' ? '1' : '0';
});
2 years ago
},
// 取消按钮
1 year ago
cancel() {
2 years ago
this.open = false;
this.reset();
2 years ago
},
// 表单重置
1 year ago
reset() {
2 years ago
this.form = {
orgId: undefined,
employeeName: undefined,
phone: undefined,
sex: '0',
status: '0',
remark: undefined,
roleIdList: [],
hiredate: undefined,
leader: this.userId,
discardClue: false,
maxPublicClue: undefined,
checkin: true,
areaList: [],
weight: undefined,
2 years ago
count: true,
1 year ago
signPlace: undefined,
dataScope: 3// 默认个人数据
2 years ago
};
this.resetForm('form');
2 years ago
},
/** 搜索按钮操作 */
1 year ago
handleQuery() {
2 years ago
this.queryParams.page = 1;
this.getList();
2 years ago
},
/** 重置按钮操作 */
1 year ago
resetQuery() {
2 years ago
this.resetForm('queryForm');
this.handleQuery();
2 years ago
},
/** 新增按钮操作 */
1 year ago
handleAdd() {
2 years ago
this.reset();
2 years ago
this.getDeptTree();
2 years ago
this.open = true;
this.title = '添加员工';
2 years ago
},
/** 修改按钮操作 */
1 year ago
handleUpdate(row) {
2 years ago
this.reset();
2 years ago
this.getDeptTree();
2 years ago
this.form = Object.assign({}, row);
this.open = true;
this.title = '修改员工';
2 years ago
},
/** 重置密码按钮操作 */
1 year ago
handleReset(row) {
2 years ago
resetUserPwd({ employeeId: row.employeeId }).then((response) => {
if (response.code === 200) {
2 years ago
this.msgSuccess('重置密码成功!');
2 years ago
}
2 years ago
});
2 years ago
},
/** 提交按钮 */
1 year ago
submitForm() {
2 years ago
this.$refs['form'].validate((valid) => {
if (valid) {
2 years ago
this.$set(this.form, 'deptId', this.$store.getters.schoolId);
2 years ago
if (this.form.employeeId) {
empAPi.update(this.form).then((response) => {
if (response.code === 200) {
this.$message.success('修改成功');
2 years ago
this.open = false;
this.getList();
2 years ago
}
2 years ago
});
2 years ago
} else {
empAPi.add(this.form).then((response) => {
if (response.code === 200) {
this.$message.success('新增成功');
2 years ago
this.open = false;
this.getList();
2 years ago
}
2 years ago
});
2 years ago
}
}
2 years ago
});
2 years ago
},
1 year ago
handleLogoff(row) {
2 years ago
this.$confirm('注销后将立即释放线索,并禁用该员工,是否确认注销?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
// 走释放线索逻辑,并禁用该用户
}).then(() => {
this.msgSuccess('注销成功!');
});
},
1 year ago
handleRelease(row) {
2 years ago
this.$confirm('是否立刻释放该员工拥有的线索?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
// 应该只释放未成交的线索
}).then(() => {
this.msgSuccess('释放成功!');
});
2 years ago
},
1 year ago
handleRemove(row) {
2 years ago
this.$confirm('是否删除该员工,建议只在数据错误时删除?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
// 检查一下,如果被使用,提示不可删除
}).then(() => {
this.msgSuccess('删除成功!');
});
}
2 years ago
}
};
2 years ago
</script>
<style>
.el-dropdown-link {
cursor: pointer;
color: #409eff;
}
2 years ago
2 years ago
.el-icon-arrow-down {
font-size: 12px;
}
</style>