Browse Source

员工列表数据渲染

hzj18279462576@163.com 3 years ago
parent
commit
f3bc1935fd

+ 0 - 1
admin/src/main.js

@@ -7,7 +7,6 @@ import router from './router'
 import axios from "axios";
 import axios from "axios";
 import store from './store';
 import store from './store';
 
 
-
 import API from './api/api'
 import API from './api/api'
 import ElementUI from 'element-ui';
 import ElementUI from 'element-ui';
 import 'element-ui/lib/theme-chalk/index.css';
 import 'element-ui/lib/theme-chalk/index.css';

+ 2 - 1
admin/src/store/modules/user.js

@@ -1,5 +1,6 @@
+import Cookies from 'js-cookie'
 import { login, logout, getInfo } from '@/api/acl/user'
 import { login, logout, getInfo } from '@/api/acl/user'
-// import { getToken, setToken, removeToken } from '@/utils/auth'
+import { getToken, setToken, removeToken } from '@/utils/auth'
 import { resetRouter } from '@/router'
 import { resetRouter } from '@/router'
 import api from '@/api/api'
 import api from '@/api/api'
 const getDefaultState = () => {
 const getDefaultState = () => {

+ 1 - 1
admin/src/utils/auth.js

@@ -1,6 +1,6 @@
 import Cookies from 'js-cookie'
 import Cookies from 'js-cookie'
 
 
-const TokenKey = 'vue_admin_template_token'
+const TokenKey = 'cook'
 
 
 export function getToken() {
 export function getToken() {
   return Cookies.get(TokenKey)
   return Cookies.get(TokenKey)

+ 5 - 4
admin/src/utils/request.js

@@ -3,6 +3,7 @@
 import axios from 'axios'
 import axios from 'axios'
 // 使用element-ui Message做消息提醒
 // 使用element-ui Message做消息提醒
 import { Message } from 'element-ui';
 import { Message } from 'element-ui';
+import Cookies from 'js-cookie'
 //1. 创建新的axios实例,
 //1. 创建新的axios实例,
 const service = axios.create({
 const service = axios.create({
     // 公共接口--这里注意后面会讲
     // 公共接口--这里注意后面会讲
@@ -19,10 +20,10 @@ service.interceptors.request.use(config => {
     // }
     // }
     // config.headers = { 'Content-Type': 'application/x-www-form-urlencoded' } //配置请求头
     // config.headers = { 'Content-Type': 'application/x-www-form-urlencoded' } //配置请求头
     //如有需要:注意使用token的时候需要引入cookie方法或者用本地localStorage等方法,推荐js-cookie
     //如有需要:注意使用token的时候需要引入cookie方法或者用本地localStorage等方法,推荐js-cookie
-    const token = getCookie('cook');//这里取token之前,你肯定需要先拿到token,存一下
+    const token = Cookies.get('cook');//这里取token之前,你肯定需要先拿到token,存一下
     if (token) {
     if (token) {
-        config.params = { 'token': token } //如果要求携带在参数中
-        config.headers.token = token; //如果要求携带在请求头中
+        config.params = { 'admin_token': token } //如果要求携带在参数中
+        config.headers['admin_token'] = token; //如果要求携带在请求头中
     }
     }
     return config
     return config
 }, error => {
 }, error => {
@@ -33,7 +34,7 @@ service.interceptors.request.use(config => {
 service.interceptors.response.use(response => {
 service.interceptors.response.use(response => {
     //接收到响应数据并成功后的一些共有的处理,关闭loading等
     //接收到响应数据并成功后的一些共有的处理,关闭loading等
 
 
-    return response
+    return response.data
 }, error => {
 }, error => {
     /***** 接收到异常响应的处理开始 *****/
     /***** 接收到异常响应的处理开始 *****/
     if (error && error.response) {
     if (error && error.response) {

+ 0 - 1
admin/src/views/login/index.vue

@@ -125,7 +125,6 @@ export default {
           encryptor.setPublicKey(publicKey); // 设置公钥
           encryptor.setPublicKey(publicKey); // 设置公钥
           let rsaPassWord = encryptor.encrypt(this.loginForm.password); // 对密码进行加密
           let rsaPassWord = encryptor.encrypt(this.loginForm.password); // 对密码进行加密
           console.log(rsaPassWord);
           console.log(rsaPassWord);
-          this.API.hotelStaff.hotelStaffLogin();
           this.$store
           this.$store
             .dispatch("user/login", {
             .dispatch("user/login", {
               username: this.loginForm.username,
               username: this.loginForm.username,

+ 30 - 126
admin/src/views/staff/index.vue

@@ -6,7 +6,7 @@
       </div>
       </div>
       <div class="inform-body">
       <div class="inform-body">
         <div class="order-top">
         <div class="order-top">
-          <div class="staff-inquire">
+          <div class="username-inquire">
             <el-input
             <el-input
               placeholder="请输入手机号码或员工姓名"
               placeholder="请输入手机号码或员工姓名"
               style="width: 261px"
               style="width: 261px"
@@ -35,7 +35,7 @@
             <div class="info">
             <div class="info">
               <div class="user">
               <div class="user">
                 <div class="name">职位</div>
                 <div class="name">职位</div>
-                <el-select v-model="positionValue" placeholder="请选择">
+                <el-select v-model="position" placeholder="请选择">
                   <el-option
                   <el-option
                     v-for="item in options"
                     v-for="item in options"
                     :key="item.value"
                     :key="item.value"
@@ -75,10 +75,10 @@
             >
             >
             </el-table-column>
             </el-table-column>
 
 
-            <el-table-column prop="staff" align="center" label="员工姓名">
+            <el-table-column prop="username" align="center" label="员工姓名">
             </el-table-column>
             </el-table-column>
 
 
-            <el-table-column prop="positionValue" align="center" label="职位">
+            <el-table-column prop="position" align="center" label="职位">
             </el-table-column>
             </el-table-column>
             <el-table-column prop="address" align="center" label="操作">
             <el-table-column prop="address" align="center" label="操作">
               <template slot-scope="scope">
               <template slot-scope="scope">
@@ -106,7 +106,7 @@
                   <div class="info">
                   <div class="info">
                     <div class="user">
                     <div class="user">
                       <div class="name">职位</div>
                       <div class="name">职位</div>
-                      <el-select v-model="positionValue" placeholder="请选择">
+                      <el-select v-model="position" placeholder="请选择">
                         <el-option
                         <el-option
                           v-for="item in options"
                           v-for="item in options"
                           :key="item.value"
                           :key="item.value"
@@ -153,113 +153,13 @@
 </template>
 </template>
 
 
 <script>
 <script>
+import Cookies from "js-cookie";
 export default {
 export default {
   name: "Inform",
   name: "Inform",
   data() {
   data() {
     return {
     return {
       //总数据
       //总数据
-      data: [
-        {
-          phone: 13611110232,
-          staff: "刘德华",
-          positionValue: "歌星",
-        },
-        {
-          phone: 13620220232,
-          staff: "刘",
-          positionValue: "歌星",
-        },
-        {
-          phone: 1363636320232,
-          staff: "德华",
-          positionValue: "歌星",
-        },
-        {
-          phone: 1344540232,
-          staff: "华",
-          positionValue: "歌星",
-        },
-        {
-          phone: 1360468880232,
-          staff: "刘德",
-          positionValue: "歌星",
-        },
-        {
-          phone: 13602220232,
-          staff: "德",
-          positionValue: "歌星",
-        },
-        {
-          phone: 1360888832,
-          staff: "刘华",
-          positionValue: "歌星",
-        },
-        {
-          phone: 13655550232,
-          staff: "华",
-          positionValue: "歌星",
-        },
-        {
-          phone: 13605656232,
-          staff: "刘",
-          positionValue: "歌星",
-        },
-        {
-          phone: 13464520232,
-          staff: "德",
-          positionValue: "歌星",
-        },
-        {
-          phone: 1365650232,
-          staff: "华",
-          positionValue: "歌星",
-        },
-        {
-          phone: 13605656232,
-          staff: "刘",
-          positionValue: "歌星",
-        },
-        {
-          phone: 13464520232,
-          staff: "德",
-          positionValue: "歌星",
-        },
-        {
-          phone: 1365650232,
-          staff: "华",
-          positionValue: "歌星",
-        },
-        {
-          phone: 13605656232,
-          staff: "刘",
-          positionValue: "歌星",
-        },
-        {
-          phone: 13464520232,
-          staff: "德",
-          positionValue: "歌星",
-        },
-        {
-          phone: 1365650232,
-          staff: "华",
-          positionValue: "歌星",
-        },
-        {
-          phone: 13605656232,
-          staff: "刘",
-          positionValue: "歌星",
-        },
-        {
-          phone: 13464520232,
-          staff: "德",
-          positionValue: "歌星",
-        },
-        {
-          phone: 1365650232,
-          staff: "华",
-          positionValue: "歌星",
-        },
-      ],
+      data: [],
       datas: [],
       datas: [],
 
 
       // 当前页显示的数据
       // 当前页显示的数据
@@ -293,7 +193,7 @@ export default {
       // 添加员工
       // 添加员工
       staffValue: "",
       staffValue: "",
       phoneValue: "", // 当前的号码
       phoneValue: "", // 当前的号码
-      positionValue: "",
+      position: "",
       phoneVal: "", // 修改前的号码
       phoneVal: "", // 修改前的号码
       dialogVisible: false,
       dialogVisible: false,
       waterTable: [
       waterTable: [
@@ -314,8 +214,12 @@ export default {
     document.getElementsByClassName(
     document.getElementsByClassName(
       "el-pagination__jump"
       "el-pagination__jump"
     )[0].childNodes[0].nodeValue = "跳转到";
     )[0].childNodes[0].nodeValue = "跳转到";
-    this.handleCurrentChange(this.currentPage);
-    this.datas = JSON.parse(JSON.stringify(this.data));
+    let cook = Cookies.get("cook");
+    this.API.hotelStaff.hotelStaffList(cook).then((res) => {
+      this.data = res.data.list;
+      this.datas = JSON.parse(JSON.stringify(this.data));
+      this.handleCurrentChange(this.currentPage);
+    });
   },
   },
   methods: {
   methods: {
     allRead($event, index) {
     allRead($event, index) {
@@ -345,10 +249,10 @@ export default {
         .then((res) => {
         .then((res) => {
           if (res == "confirm") {
           if (res == "confirm") {
             this.data = this.data.filter((item) => {
             this.data = this.data.filter((item) => {
-              return item.phone !== row.phone && item.staff !== row.staff;
+              return item.phone !== row.phone && item.username !== row.username;
             });
             });
             this.datas = this.datas.filter((item) => {
             this.datas = this.datas.filter((item) => {
-              return item.phone !== row.phone && item.staff !== row.staff;
+              return item.phone !== row.phone && item.username !== row.username;
             });
             });
           }
           }
           if (this.tableData.length <= 1) {
           if (this.tableData.length <= 1) {
@@ -376,7 +280,7 @@ export default {
         this.datas.forEach((item, index) => {
         this.datas.forEach((item, index) => {
           if (
           if (
             item.phone.toString().includes(this.value) ||
             item.phone.toString().includes(this.value) ||
-            item.staff.includes(this.value)
+            item.username.includes(this.value)
           ) {
           ) {
             this.data.push(item);
             this.data.push(item);
           }
           }
@@ -412,15 +316,15 @@ export default {
           });
           });
         } else if (this.staffValue.trim() == "") {
         } else if (this.staffValue.trim() == "") {
           this.$message({ message: "输入的姓名不能为空", type: "error" });
           this.$message({ message: "输入的姓名不能为空", type: "error" });
-        } else if (this.positionValue == "") {
+        } else if (this.position == "") {
           this.$message({ message: "职位不能为空", type: "error" });
           this.$message({ message: "职位不能为空", type: "error" });
         } else {
         } else {
           let arr = {
           let arr = {
             phone: this.phoneValue,
             phone: this.phoneValue,
-            staff: this.staffValue,
-            positionValue: this.positionValue,
+            username: this.staffValue,
+            position: this.position,
           };
           };
-          // console.log(this.positionValue);
+          // console.log(this.position);
           this.datas.push(arr);
           this.datas.push(arr);
           this.data = this.datas;
           this.data = this.datas;
           this.currentPage = Math.ceil(this.data.length / 8);
           this.currentPage = Math.ceil(this.data.length / 8);
@@ -428,7 +332,7 @@ export default {
           this.addStaffShow = false;
           this.addStaffShow = false;
           this.phoneValue = "";
           this.phoneValue = "";
           this.staffValue = "";
           this.staffValue = "";
-          this.positionValue = "";
+          this.position = "";
         }
         }
       } else {
       } else {
         this.$message({ message: "请输入正确的电话号码", type: "error" });
         this.$message({ message: "请输入正确的电话号码", type: "error" });
@@ -442,7 +346,7 @@ export default {
           this.editShow = false;
           this.editShow = false;
           this.phoneValue = "";
           this.phoneValue = "";
           this.staffValue = "";
           this.staffValue = "";
-          this.positionValue = "";
+          this.position = "";
         })
         })
         .catch((_) => {});
         .catch((_) => {});
     },
     },
@@ -450,15 +354,15 @@ export default {
       this.editShow = false;
       this.editShow = false;
       this.phoneValue = "";
       this.phoneValue = "";
       this.staffValue = "";
       this.staffValue = "";
-      this.positionValue = "";
+      this.position = "";
     },
     },
     handleEdit(index, row) {
     handleEdit(index, row) {
       // console.log(row);
       // console.log(row);
       this.editShow = true;
       this.editShow = true;
       this.phoneValue = row.phone;
       this.phoneValue = row.phone;
       this.phoneVal = row.phone;
       this.phoneVal = row.phone;
-      this.staffValue = row.staff;
-      this.positionValue = row.positionValue;
+      this.staffValue = row.username;
+      this.position = row.position;
     },
     },
     editSuccess() {
     editSuccess() {
       let reg_tel =
       let reg_tel =
@@ -481,15 +385,15 @@ export default {
         });
         });
       } else if (this.staffValue.trim() == "") {
       } else if (this.staffValue.trim() == "") {
         this.$message({ message: "输入的姓名不能为空", type: "error" });
         this.$message({ message: "输入的姓名不能为空", type: "error" });
-      } else if (this.positionValue == "") {
+      } else if (this.position == "") {
         this.$message({ message: "职位不能为空", type: "error" });
         this.$message({ message: "职位不能为空", type: "error" });
       } else {
       } else {
         if (reg_tel.test(this.phoneValue)) {
         if (reg_tel.test(this.phoneValue)) {
           // console.log("电话号码符合要求");
           // console.log("电话号码符合要求");
           let arr = {
           let arr = {
             phone: this.phoneValue,
             phone: this.phoneValue,
-            staff: this.staffValue,
-            positionValue: this.positionValue,
+            username: this.staffValue,
+            position: this.position,
           };
           };
           this.datas[editIndex] = arr;
           this.datas[editIndex] = arr;
           this.data = this.datas;
           this.data = this.datas;
@@ -497,7 +401,7 @@ export default {
           this.editShow = false;
           this.editShow = false;
           this.phoneValue = "";
           this.phoneValue = "";
           this.staffValue = "";
           this.staffValue = "";
-          this.positionValue = "";
+          this.position = "";
         } else {
         } else {
           this.$message({ message: "请输入正确的电话号码", type: "error" });
           this.$message({ message: "请输入正确的电话号码", type: "error" });
         }
         }