|
|
@@ -1,26 +1,33 @@
|
|
|
<template>
|
|
|
<div class="inform">
|
|
|
<el-card class="box-card" style="width: 1612px; height: 950px">
|
|
|
+ <!-- 标题区域 -->
|
|
|
<div slot="header" class="clearfix">
|
|
|
<div class="inform-title">员工管理</div>
|
|
|
</div>
|
|
|
+ <!-- 主体内容区域 -->
|
|
|
<div class="inform-body">
|
|
|
+ <!-- 筛选条件区域 -->
|
|
|
<div class="order-top">
|
|
|
<div class="username-inquire">
|
|
|
<el-input
|
|
|
placeholder="请输入手机号码或员工姓名"
|
|
|
style="width: 261px"
|
|
|
v-model="value"
|
|
|
+ clearable
|
|
|
+ @clear="getData(1)"
|
|
|
>
|
|
|
<i slot="prefix" class="el-input__icon el-icon-search"></i>
|
|
|
</el-input>
|
|
|
- <el-button @click="inquire">查询</el-button>
|
|
|
+ <el-button @click="getData(1)">查询</el-button>
|
|
|
</div>
|
|
|
<div class="export" @click="addStaff">添加员工</div>
|
|
|
+
|
|
|
+ <!-- 添加员工弹窗 -->
|
|
|
<el-dialog
|
|
|
title="添加员工"
|
|
|
:visible.sync="addStaffShow"
|
|
|
- :before-close="addClose"
|
|
|
+ :close-on-click-modal="false"
|
|
|
>
|
|
|
<div class="info">
|
|
|
<div class="user">
|
|
|
@@ -37,10 +44,10 @@
|
|
|
<div class="name">职位</div>
|
|
|
<el-select v-model="position" placeholder="请选择">
|
|
|
<el-option
|
|
|
- v-for="item in options"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.label"
|
|
|
+ v-for="(item, index) in options"
|
|
|
+ :key="index"
|
|
|
+ :label="item.value"
|
|
|
+ :value="item.value"
|
|
|
>
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
@@ -54,6 +61,7 @@
|
|
|
</span>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
+ <!-- 表格区域 -->
|
|
|
<div class="inform-table">
|
|
|
<el-table
|
|
|
:data="tableData"
|
|
|
@@ -67,6 +75,9 @@
|
|
|
background: 'rgba(240, 243, 247, 1)',
|
|
|
}"
|
|
|
>
|
|
|
+ <el-table-column prop="username" align="center" label="员工姓名">
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
<el-table-column
|
|
|
prop="phone"
|
|
|
width="300"
|
|
|
@@ -75,23 +86,20 @@
|
|
|
>
|
|
|
</el-table-column>
|
|
|
|
|
|
- <el-table-column prop="username" align="center" label="员工姓名">
|
|
|
- </el-table-column>
|
|
|
-
|
|
|
<el-table-column prop="position" align="center" label="职位">
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="address" align="center" label="操作">
|
|
|
<template slot-scope="scope">
|
|
|
- <span
|
|
|
- @click="handleEdit(scope.$index, scope.row)"
|
|
|
- class="operate"
|
|
|
- >
|
|
|
+ <!-- 编辑按钮 -->
|
|
|
+ <span @click="handleEdit(scope.row)" class="operate">
|
|
|
编辑
|
|
|
</span>
|
|
|
+
|
|
|
+ <!-- 编辑员工弹窗 -->
|
|
|
<el-dialog
|
|
|
title="编辑员工"
|
|
|
:visible.sync="editShow"
|
|
|
- :before-close="editClose"
|
|
|
+ :close-on-click-modal="false"
|
|
|
>
|
|
|
<div class="info">
|
|
|
<div class="user">
|
|
|
@@ -108,42 +116,40 @@
|
|
|
<div class="name">职位</div>
|
|
|
<el-select v-model="position" placeholder="请选择">
|
|
|
<el-option
|
|
|
- v-for="item in options"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.label"
|
|
|
+ v-for="(item, index) in options"
|
|
|
+ :key="index"
|
|
|
+ :label="item.value"
|
|
|
+ :value="item.value"
|
|
|
>
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</div>
|
|
|
</div>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click.stop="editCancel()" class="cancel"
|
|
|
+ <el-button @click.stop="editShow = false" class="cancel"
|
|
|
>取消</el-button
|
|
|
>
|
|
|
<el-button @click.stop="editSuccess()">完成</el-button>
|
|
|
</span>
|
|
|
</el-dialog>
|
|
|
|
|
|
- <span
|
|
|
- @click="handleDelete(scope.$index, scope.row)"
|
|
|
- class="operate"
|
|
|
- >
|
|
|
+ <!-- 删除按钮 -->
|
|
|
+ <span @click="handleDelete(scope.row)" class="operate">
|
|
|
删除
|
|
|
</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
</div>
|
|
|
+ <!-- 分页器区域 -->
|
|
|
<div class="block">
|
|
|
<el-pagination
|
|
|
background
|
|
|
@current-change="handleCurrentChange"
|
|
|
- :current-page="currentPage"
|
|
|
- current-page.sync="1"
|
|
|
- :page-size="8"
|
|
|
+ :current-page="curPage"
|
|
|
+ :page-size="pageSize"
|
|
|
layout="prev, pager, next, jumper"
|
|
|
- :total="data.length"
|
|
|
+ :total="total"
|
|
|
>
|
|
|
</el-pagination>
|
|
|
</div>
|
|
|
@@ -154,277 +160,195 @@
|
|
|
|
|
|
<script>
|
|
|
import Cookies from "js-cookie";
|
|
|
-import * as rsa from "@/utils/rsa";
|
|
|
export default {
|
|
|
name: "Inform",
|
|
|
data() {
|
|
|
return {
|
|
|
- //总数据
|
|
|
- data: [],
|
|
|
- datas: [],
|
|
|
-
|
|
|
// 当前页显示的数据
|
|
|
tableData: [],
|
|
|
+ // 职位类型列表
|
|
|
options: [
|
|
|
{
|
|
|
- value: "选项1",
|
|
|
- label: "测试部门",
|
|
|
+ value: "清洁工",
|
|
|
},
|
|
|
{
|
|
|
- value: "选项2",
|
|
|
- label: "软件部",
|
|
|
+ value: "维修工",
|
|
|
},
|
|
|
{
|
|
|
- value: "选项3",
|
|
|
- label: "测试部门",
|
|
|
+ value: "财务总监",
|
|
|
},
|
|
|
{
|
|
|
- value: "选项4",
|
|
|
- label: "测试部门",
|
|
|
+ value: "服务员",
|
|
|
},
|
|
|
{
|
|
|
- value: "选项5",
|
|
|
- label: "测试部门",
|
|
|
+ value: "前台",
|
|
|
},
|
|
|
],
|
|
|
- currentPage: 1,
|
|
|
- state: "",
|
|
|
- value: "", //请输入手机号码或员工姓名
|
|
|
-
|
|
|
- // 添加员工
|
|
|
+ // 搜索框绑定数据
|
|
|
+ value: "",
|
|
|
+ // 员工姓名
|
|
|
staffValue: "",
|
|
|
- phoneValue: "", // 当前的号码
|
|
|
+ // 员工手机号码
|
|
|
+ phoneValue: "",
|
|
|
+ // 员工职位
|
|
|
position: "",
|
|
|
- phoneVal: "", // 修改前的号码
|
|
|
- dialogVisible: false,
|
|
|
- waterTable: [
|
|
|
- {
|
|
|
- start: 36,
|
|
|
- end: 36,
|
|
|
- flow: 20,
|
|
|
- pirce: 2.0,
|
|
|
- subsidy: 5,
|
|
|
- production: 2,
|
|
|
- },
|
|
|
- ],
|
|
|
+ // 添加员工弹窗控制
|
|
|
addStaffShow: false,
|
|
|
+ // 编辑员工弹窗控制
|
|
|
editShow: false,
|
|
|
+ // 总条数
|
|
|
+ total: null,
|
|
|
+ // 当前页
|
|
|
+ curPage: 1,
|
|
|
+ // 每页条数
|
|
|
+ pageSize: 8,
|
|
|
+ // 修改数据的id
|
|
|
+ id: "",
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
- document.getElementsByClassName(
|
|
|
- "el-pagination__jump"
|
|
|
- )[0].childNodes[0].nodeValue = "跳转到";
|
|
|
- this.hotelList();
|
|
|
+ this.getData();
|
|
|
},
|
|
|
methods: {
|
|
|
- hotelList() {
|
|
|
- let cook = Cookies.get("cook");
|
|
|
- this.API.hotelStaff.hotelStaffList().then((res) => {
|
|
|
- console.log(res.data);
|
|
|
- this.data = res.data.list;
|
|
|
- this.datas = JSON.parse(JSON.stringify(this.data));
|
|
|
- this.handleCurrentChange(this.currentPage);
|
|
|
- });
|
|
|
- },
|
|
|
- allRead($event, index) {
|
|
|
- this.className = this.className.map((item) => (item = ""));
|
|
|
- this.className[index] = "active";
|
|
|
- },
|
|
|
- rowbg(row) {
|
|
|
- if (row.rowIndex % 2 != 0) {
|
|
|
- return { background: "rgba(240, 243, 247, 1)", "border-radius": "5px" };
|
|
|
+ // 获取员工管理页面表格数据
|
|
|
+ async getData(curPage) {
|
|
|
+ if (curPage) {
|
|
|
+ this.curPage = curPage;
|
|
|
}
|
|
|
- },
|
|
|
-
|
|
|
- handleCurrentChange(val) {
|
|
|
- if (this.data.length >= 8) {
|
|
|
- this.tableData = this.data.slice((val - 1) * 8, val * 8);
|
|
|
+ let params = {
|
|
|
+ curPage: this.curPage,
|
|
|
+ pageSize: this.pageSize,
|
|
|
+ keyword: this.value,
|
|
|
+ };
|
|
|
+ let res = await this.API.hotelStaff.hotelStaffList(params);
|
|
|
+ // console.log(res);
|
|
|
+ if (res.success) {
|
|
|
+ this.tableData = res.data.list;
|
|
|
+ this.total = res.data.totalCount;
|
|
|
} else {
|
|
|
- this.tableData = this.data;
|
|
|
+ this.$message.error(res.message);
|
|
|
}
|
|
|
- this.currentPage = val;
|
|
|
- // console.log(`当前页: ${val}`);
|
|
|
},
|
|
|
|
|
|
- // 表格操作
|
|
|
-
|
|
|
- handleDelete(index, row) {
|
|
|
- this.$confirm("确认删除?")
|
|
|
- .then((res) => {
|
|
|
- if (res == "confirm") {
|
|
|
- this.data = this.data.filter((item) => {
|
|
|
- return item.phone !== row.phone && item.username !== row.username;
|
|
|
- });
|
|
|
- this.datas = this.datas.filter((item) => {
|
|
|
- return item.phone !== row.phone && item.username !== row.username;
|
|
|
- });
|
|
|
- }
|
|
|
- if (this.tableData.length <= 1) {
|
|
|
- if (this.currentPage == 1) {
|
|
|
- this.currentPage = 1;
|
|
|
- } else {
|
|
|
- this.currentPage = this.currentPage - 1;
|
|
|
- }
|
|
|
+ // 删除按钮回调
|
|
|
+ handleDelete(row) {
|
|
|
+ this.$confirm("确定删除吗?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(async () => {
|
|
|
+ let res = await this.API.hotelStaff.hotelStaffDelete([row.id]);
|
|
|
+ // console.log(res);
|
|
|
+ if (res.success) {
|
|
|
+ this.$message.success("删除成功");
|
|
|
+ let totalPage = Math.ceil((this.total - 1) / this.pageSize);
|
|
|
+ let currentPage =
|
|
|
+ this.curPage > totalPage ? totalPage : this.curPage;
|
|
|
+ this.curPage = currentPage < 1 ? 1 : currentPage;
|
|
|
+ this.getData();
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message);
|
|
|
}
|
|
|
- this.handleCurrentChange(this.currentPage);
|
|
|
})
|
|
|
- .catch((_) => {});
|
|
|
- console.log(this.datas);
|
|
|
- },
|
|
|
- handleClose(done) {
|
|
|
- this.dialogVisible = false;
|
|
|
- },
|
|
|
-
|
|
|
- // 查询
|
|
|
- inquire() {
|
|
|
- this.data = [];
|
|
|
- if (this.value === "") {
|
|
|
- this.data = JSON.parse(JSON.stringify(this.datas));
|
|
|
- } else {
|
|
|
- this.datas.forEach((item, index) => {
|
|
|
- if (
|
|
|
- item.phone.toString().includes(this.value) ||
|
|
|
- item.username.includes(this.value)
|
|
|
- ) {
|
|
|
- this.data.push(item);
|
|
|
- }
|
|
|
+ .catch(() => {
|
|
|
+ this.$message.info("已取消删除");
|
|
|
});
|
|
|
- }
|
|
|
- this.currentPage = 1;
|
|
|
- this.handleCurrentChange(this.currentPage);
|
|
|
},
|
|
|
|
|
|
- // 添加员工
|
|
|
+ // 添加员工按钮回调
|
|
|
addStaff() {
|
|
|
this.addStaffShow = true;
|
|
|
+ this.phoneValue = "";
|
|
|
+ this.staffValue = "";
|
|
|
+ this.position = "";
|
|
|
},
|
|
|
- addClose(done) {
|
|
|
- this.$confirm("确认关闭?")
|
|
|
- .then((_) => {
|
|
|
- done();
|
|
|
- })
|
|
|
- .catch((_) => {});
|
|
|
- },
|
|
|
- addSuccess() {
|
|
|
+
|
|
|
+ // 添加员工弹窗完成按钮回调
|
|
|
+ async addSuccess() {
|
|
|
let reg_tel =
|
|
|
/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
|
|
|
if (reg_tel.test(this.phoneValue)) {
|
|
|
- // console.log("电话号码符合要求");
|
|
|
- let RepeatNumber = this.datas.some((item) => {
|
|
|
- return item.phone == this.phoneValue;
|
|
|
- });
|
|
|
- if (RepeatNumber) {
|
|
|
- this.$message({
|
|
|
- message: "当前电话号码已存在,请换个号码输入",
|
|
|
- type: "error",
|
|
|
- });
|
|
|
- } else if (this.staffValue.trim() == "") {
|
|
|
+ if (this.staffValue.trim() == "") {
|
|
|
this.$message({ message: "输入的姓名不能为空", type: "error" });
|
|
|
} else if (this.position == "") {
|
|
|
this.$message({ message: "职位不能为空", type: "error" });
|
|
|
} else {
|
|
|
- let arr = {
|
|
|
+ let params = {
|
|
|
phone: this.phoneValue,
|
|
|
username: this.staffValue,
|
|
|
position: this.position,
|
|
|
- cardNumber: "16qc87",
|
|
|
- password: rsa.RSAencrypt("abc1234"),
|
|
|
- statu: "1",
|
|
|
+ cardNumber: 666,
|
|
|
+ statu: 1,
|
|
|
};
|
|
|
- // console.log(this.position);
|
|
|
-
|
|
|
- this.API.hotelAdmin.hotelStaffAdd(arr).then((res) => {
|
|
|
- console.log(res);
|
|
|
- });
|
|
|
- this.hotelList();
|
|
|
- this.data = this.datas;
|
|
|
- this.currentPage = Math.ceil(this.data.length / 8);
|
|
|
- this.handleCurrentChange(this.currentPage);
|
|
|
+ let res = await this.API.hotelStaff.hotelStaffSave(params);
|
|
|
+ // console.log(res);
|
|
|
+ if (res.success) {
|
|
|
+ this.$message.success("添加成功");
|
|
|
+ this.getData();
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message);
|
|
|
+ }
|
|
|
this.addStaffShow = false;
|
|
|
- this.phoneValue = "";
|
|
|
- this.staffValue = "";
|
|
|
- this.position = "";
|
|
|
}
|
|
|
} else {
|
|
|
this.$message({ message: "请输入正确的电话号码", type: "error" });
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- // 编辑员工
|
|
|
- editClose() {
|
|
|
- this.$confirm("确认关闭?")
|
|
|
- .then((_) => {
|
|
|
- this.editShow = false;
|
|
|
- this.phoneValue = "";
|
|
|
- this.staffValue = "";
|
|
|
- this.position = "";
|
|
|
- })
|
|
|
- .catch((_) => {});
|
|
|
- },
|
|
|
- editCancel() {
|
|
|
- this.editShow = false;
|
|
|
- this.phoneValue = "";
|
|
|
- this.staffValue = "";
|
|
|
- this.position = "";
|
|
|
- },
|
|
|
- handleEdit(index, row) {
|
|
|
- console.log(row);
|
|
|
+ // 编辑按钮回调
|
|
|
+ handleEdit(row) {
|
|
|
+ // console.log(row);
|
|
|
this.editShow = true;
|
|
|
+ this.id = row.id;
|
|
|
this.phoneValue = row.phone;
|
|
|
- this.phoneVal = row.phone;
|
|
|
this.staffValue = row.username;
|
|
|
this.position = row.position;
|
|
|
- console.log(this.phoneValue);
|
|
|
},
|
|
|
- editSuccess() {
|
|
|
+
|
|
|
+ // 编辑员工弹窗完成按钮回调
|
|
|
+ async editSuccess() {
|
|
|
let reg_tel =
|
|
|
/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
|
|
|
-
|
|
|
- let arrEdit = this.datas.filter((item) => {
|
|
|
- return item.phone != this.phoneVal;
|
|
|
- });
|
|
|
- let editIndex = this.datas.findIndex((item) => {
|
|
|
- return item.phone == this.phoneVal;
|
|
|
- });
|
|
|
- let RepeatNumber = arrEdit.some((item) => {
|
|
|
- return item.phone == this.phoneValue;
|
|
|
- });
|
|
|
-
|
|
|
- if (RepeatNumber) {
|
|
|
- this.$message({
|
|
|
- message: "当前电话号码已存在,请换个号码输入",
|
|
|
- type: "error",
|
|
|
- });
|
|
|
- } else if (this.staffValue.trim() == "") {
|
|
|
- this.$message({ message: "输入的姓名不能为空", type: "error" });
|
|
|
- } else if (this.position == "") {
|
|
|
- this.$message({ message: "职位不能为空", type: "error" });
|
|
|
- } else {
|
|
|
- if (reg_tel.test(this.phoneValue)) {
|
|
|
- // console.log("电话号码符合要求");
|
|
|
- let arr = {
|
|
|
+ if (reg_tel.test(this.phoneValue)) {
|
|
|
+ if (this.staffValue.trim() == "") {
|
|
|
+ this.$message({ message: "输入的姓名不能为空", type: "error" });
|
|
|
+ } else if (this.position == "") {
|
|
|
+ this.$message({ message: "职位不能为空", type: "error" });
|
|
|
+ } else {
|
|
|
+ let data = {
|
|
|
+ id: this.id,
|
|
|
phone: this.phoneValue,
|
|
|
username: this.staffValue,
|
|
|
position: this.position,
|
|
|
- cardNumber: "16qc67",
|
|
|
- password: rsa.RSAencrypt("abc2234"),
|
|
|
- statu: "1",
|
|
|
+ cardNumber: 666,
|
|
|
+ statu: 1,
|
|
|
};
|
|
|
- // console.log(this.position);
|
|
|
-
|
|
|
- this.API.hotelAdmin.hotelStaffUpdate(arr).then((res) => {
|
|
|
- console.log(res);
|
|
|
- });
|
|
|
- this.data = this.datas;
|
|
|
- this.handleCurrentChange(this.currentPage);
|
|
|
+ let res = await this.API.hotelStaff.hotelStaffUpdate(data);
|
|
|
+ // console.log(res);
|
|
|
+ if (res.success) {
|
|
|
+ this.$message.success("编辑成功");
|
|
|
+ this.getData();
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message);
|
|
|
+ }
|
|
|
this.editShow = false;
|
|
|
- this.phoneValue = "";
|
|
|
- this.staffValue = "";
|
|
|
- this.position = "";
|
|
|
- } else {
|
|
|
- this.$message({ message: "请输入正确的电话号码", type: "error" });
|
|
|
}
|
|
|
+ } else {
|
|
|
+ this.$message({ message: "请输入正确的电话号码", type: "error" });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 翻页回调函数
|
|
|
+ handleCurrentChange(val) {
|
|
|
+ this.curPage = val;
|
|
|
+ this.getData();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 表格样式设置
|
|
|
+ rowbg(row) {
|
|
|
+ if (row.rowIndex % 2 != 0) {
|
|
|
+ return { background: "rgba(240, 243, 247, 1)", "border-radius": "5px" };
|
|
|
}
|
|
|
},
|
|
|
},
|