Browse Source

页面合并

hzj18279462576@163.com 3 years ago
parent
commit
56600709f9

+ 8 - 8
admin/src/api/hotelAdmin.js

@@ -2,26 +2,26 @@ import http from '../utils/http'
 let resquest = "/api/ihotel/hotelAdmin"
 
 // 管理员登录
-export function hotelAdminLogin(params) {
+export function hotelStaffLogin(params) {
     return http.post(`${resquest}/login`, params)
 }
 
 // 管理员列表
-export function hotelAdminList(params) {
+export function hotelStaffList(params) {
     return http.get(`${resquest}/list`, params)
 }
 
 // 新增管理员
-export function hotelAdminAdd(params) {
-    return http.post(`${resquest}/add`, params)
+export function hotelStaffAdd(data) {
+    return http.post(`${resquest}/add`, data)
 }
 
 // 修改管理员
-export function hotelAdminUpdate(params) {
-    return http.put(`${resquest}/update`, params)
+export function hotelStaffUpdate(data) {
+    return http.put(`${resquest}/update`, data)
 }
 
 // 删除管理员
-export function hotelAdminDelete(params) {
-    return http.delete(`${resquest}/delete`, params)
+export function hotelStaffDelete(data) {
+    return http.delete(`${resquest}/delete`, data)
 }

+ 4 - 4
admin/src/api/hotelStaff.js

@@ -17,11 +17,11 @@ export function hotelStaffSave(params) {
 }
 
 // 修改管理员
-export function hotelStaffUpdate(params) {
-    return http.put(`${resquest}/update`, params)
+export function hotelStaffUpdate(data) {
+    return http.put(`${resquest}/update`, data)
 }
 
 // 删除管理员
-export function hotelStaffDelete(params) {
-    return http.delete(`${resquest}/delete`, params)
+export function hotelStaffDelete(data) {
+    return http.delete(`${resquest}/delete`, data)
 }

+ 153 - 166
admin/src/views/account/index.vue

@@ -14,13 +14,15 @@
             <el-col :span="18">
               <el-input
                 v-model="searchValue"
-                placeholder="请输入账号或员工姓名"
+                placeholder="请输入账号或手机号"
                 prefix-icon="el-icon-search"
+                clearable
+                @clear="getData(1)"
               >
               </el-input>
             </el-col>
             <el-col :span="6">
-              <el-button type="primary">查询</el-button>
+              <el-button type="primary" @click="getData(1)">查询</el-button>
             </el-col>
           </div>
           <div class="right">
@@ -41,13 +43,21 @@
               background: 'rgba(240, 243, 247, 1)',
             }"
           >
-            <el-table-column prop="number" label="账号" align="center">
+            <el-table-column
+              prop="username"
+              align="center"
+              label="员工姓名(账号)"
+            >
             </el-table-column>
 
-            <el-table-column prop="name" align="center" label="员工姓名">
+            <el-table-column prop="phone" label="手机号" align="center">
             </el-table-column>
 
-            <el-table-column prop="identity" align="center" label="角色">
+            <el-table-column align="center" label="角色">
+              <template slot-scope="{ row }">
+                <div v-if="row.adminType == 1">超级管理员</div>
+                <div v-else>管理员</div>
+              </template>
             </el-table-column>
             <el-table-column align="center" label="操作">
               <template slot-scope="{ row }">
@@ -56,7 +66,7 @@
                   <el-button type="text" @click="handleEdit(row)">
                     编辑
                   </el-button>
-                  <el-button type="text" @click="handleDelete(row)"
+                  <el-button type="text" @click="handleDelete(row.id)"
                     >删除
                   </el-button>
                 </el-row>
@@ -71,21 +81,19 @@
             layout="prev, pager, next, jumper"
             :current-page.sync="currentPage"
             :page-size="pageSize"
-            :total="data.length"
+            :total="total"
             @current-change="handleCurrentChange"
           >
           </el-pagination>
         </div>
       </div>
 
-      <!-- 添加账号弹窗区域 -->
+      <!-- 添加编辑账号弹窗区域 -->
       <el-dialog
         :title="popTitle"
-        :destroy-on-close="clean"
         width="30%"
         :visible.sync="dialogVisible"
         :close-on-click-modal="false"
-        :before-close="handleClose"
       >
         <hr class="pop_title" />
 
@@ -98,9 +106,9 @@
         >
           <el-row :gutter="85">
             <el-col :span="12">
-              <el-form-item label="员工姓名" prop="name">
+              <el-form-item label="员工姓名" prop="username">
                 <el-input
-                  v-model="ruleForm.name"
+                  v-model="ruleForm.username"
                   placeholder="请输入员工姓名"
                 ></el-input>
               </el-form-item>
@@ -115,14 +123,30 @@
             </el-col>
           </el-row>
 
-          <el-form-item label="角色" prop="identity">
-            <el-select v-model="ruleForm.identity" placeholder="请选择角色">
-              <el-option label="超级管理员" value="超级管理员"></el-option>
-              <el-option label="管理员" value="管理员"></el-option>
-            </el-select>
-          </el-form-item>
-          <el-form-item label="权限分配" prop="type">
-            <el-checkbox-group v-model="ruleForm.type">
+          <el-row :gutter="85">
+            <el-col :span="12">
+              <el-form-item label="角色" prop="adminType">
+                <el-select
+                  v-model="ruleForm.adminType"
+                  placeholder="请选择角色"
+                >
+                  <el-option label="超级管理员" value="1"></el-option>
+                  <el-option label="管理员" value="2"></el-option>
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="密码" prop="password">
+                <el-input
+                  v-model="ruleForm.password"
+                  placeholder="请输入密码"
+                  :disabled="popTitle == '编辑账号'"
+                ></el-input>
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <!-- <el-form-item label="权限分配" prop="statu">
+            <el-checkbox-group v-model="ruleForm.statu">
               <el-checkbox label="房态管理" name="type"></el-checkbox>
               <el-checkbox label="订单管理" name="type"></el-checkbox>
               <el-checkbox label="员工管理" name="type"></el-checkbox>
@@ -130,7 +154,7 @@
               <el-checkbox label="统计报表" name="type"></el-checkbox>
               <el-checkbox label="系统设置" name="type"></el-checkbox>
             </el-checkbox-group>
-          </el-form-item>
+          </el-form-item> -->
         </el-form>
 
         <span slot="footer" class="dialog-footer">
@@ -145,6 +169,7 @@
 </template>
 
 <script>
+import { RSAencrypt } from "../../utils/rsa";
 export default {
   name: "Account",
   data() {
@@ -153,91 +178,8 @@ export default {
       dialogVisible: false,
       // 添加账号弹窗标题
       popTitle: "添加账号",
-      // 表格显示多少条数据
-      data: [],
       // 表格数据
-      tableData: [
-        {
-          number: "13645895689",
-          name: "王小虎",
-          identity: "超级管理员",
-        },
-        {
-          number: "13645898888",
-          name: "张三",
-          identity: "管理员",
-        },
-        {
-          number: "13645895689",
-          name: "王小虎",
-          identity: "超级管理员",
-        },
-        {
-          number: "13645898888",
-          name: "张三",
-          identity: "管理员",
-        },
-        {
-          number: "13645895689",
-          name: "王小虎",
-          identity: "超级管理员",
-        },
-        {
-          number: "13645898888",
-          name: "张三",
-          identity: "管理员",
-        },
-        {
-          number: "13645895689",
-          name: "王小虎",
-          identity: "超级管理员",
-        },
-        {
-          number: "13645898888",
-          name: "张三",
-          identity: "管理员",
-        },
-        {
-          number: "13645895689",
-          name: "王小虎",
-          identity: "超级管理员",
-        },
-        {
-          number: "13645898888",
-          name: "张三",
-          identity: "管理员",
-        },
-        {
-          number: "13645895689",
-          name: "王小虎",
-          identity: "超级管理员",
-        },
-        {
-          number: "13645898888",
-          name: "张三",
-          identity: "管理员",
-        },
-        {
-          number: "13645895689",
-          name: "王小虎",
-          identity: "超级管理员",
-        },
-        {
-          number: "13645898888",
-          name: "张三",
-          identity: "管理员",
-        },
-        {
-          number: "13645895689",
-          name: "王小虎",
-          identity: "超级管理员",
-        },
-        {
-          number: "13645895689",
-          name: "王小虎",
-          identity: "超级管理员",
-        },
-      ],
+      tableData: [],
       //  搜索框绑定数据
       searchValue: "",
       //   分页器当前页
@@ -245,19 +187,20 @@ export default {
       //   每页条数
       pageSize: 8,
       //   总条数
-      total: 50,
+      total: null,
       // 添加账号弹窗表格绑定数据
       ruleForm: {
-        name: "",
+        username: "",
         phone: "",
-        identity: "",
-        type: [],
+        adminType: "",
+        password: "",
+        // statu: [],
       },
-      // 弹窗表格绑定数据清空
-      clean: false,
       // 添加账号弹窗表格验证规则
       rules: {
-        name: [{ required: true, message: "请输入员工姓名", trigger: "blur" }],
+        username: [
+          { required: true, message: "请输入员工姓名", trigger: "blur" },
+        ],
         phone: [
           { required: true, message: "请输入手机号码", trigger: "blur" },
           {
@@ -267,63 +210,92 @@ export default {
             trigger: "blur",
           },
         ],
-        identity: [
-          { required: true, message: "请选择角色", trigger: "change" },
+        password: [
+          { required: true, message: "请输入密码", trigger: "blur" },
+          // {
+          //   min: 3,
+          //   max: 11,
+          //   message: "长度在 3 到 11 个字符",
+          //   trigger: "blur",
+          // },
         ],
-        type: [
-          {
-            type: "array",
-            required: true,
-            message: "请至少选择一个活动性质",
-            trigger: "change",
-          },
+        adminType: [
+          { required: true, message: "请选择角色", trigger: "change" },
         ],
+        // statu: [
+        //   {
+        //     type: "array",
+        //     required: true,
+        //     message: "请至少选择一个活动性质",
+        //     trigger: "change",
+        //   },
+        // ],
       },
     };
   },
   mounted() {
-    this.data = this.tableData;
-    this.handleCurrentChange(this.currentPage);
+    this.getData();
   },
   methods: {
+    // 获取账号管理页面列表数据
+    async getData(curPage) {
+      let params = {
+        curPage: curPage || this.currentPage,
+        pageSize: this.pageSize,
+        keyword: this.searchValue,
+      };
+      let res = await this.API.hotelAdmin.hotelStaffList(params);
+      // console.log(res);
+      if (res.success) {
+        this.tableData = res.data.list;
+        this.total = res.data.totalCount;
+      } else {
+        this.$message.error(res.message);
+      }
+    },
     // 添加账号按钮回调
     handleAdd() {
-      this.clean = true;
-      this.ruleForm.type = [];
+      this.ruleForm = {
+        phone: "",
+        adminType: "",
+        password: "",
+        username: "",
+      };
       this.dialogVisible = true;
       this.popTitle = "添加账号";
       this.$nextTick(() => {
         this.$refs.ruleForm.resetFields();
       });
-      this.clean = false;
     },
     // 编辑按钮回调
     handleEdit(row) {
-      // console.log(row);
-      this.ruleForm.phone = row.number;
-      this.ruleForm.name = row.name;
-      this.ruleForm.identity = row.identity;
       this.dialogVisible = true;
       this.popTitle = "编辑账号";
+      this.$nextTick(() => {
+        this.$refs.ruleForm.resetFields();
+        this.ruleForm = { ...row };
+      });
     },
     // 删除按钮回调
-    handleDelete(row) {
-      console.log(row);
+    handleDelete(id) {
       this.$confirm("确定删除吗?", "提示", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         type: "warning",
       })
-        .then(() => {
-          this.data.forEach((item, index) => {
-            console.log(row.number == item.number);
-            if (row.number == item.number) {
-              this.data.splice(index, 1);
-            }
-          });
-          this.currentPage = Math.ceil(this.data.length / this.pageSize);
-          this.handleCurrentChange(this.currentPage);
-          this.$message.success("删除成功");
+        .then(async () => {
+          let res = await this.API.hotelAdmin.hotelStaffDelete([id]);
+          // console.log(res);
+          if (res.success) {
+            this.$message.success("删除成功");
+            let totalPage = Math.ceil((this.total - 1) / this.pageSize);
+            let currentPage =
+              this.currentPage > totalPage ? totalPage : this.currentPage;
+            this.currentPage = currentPage < 1 ? 1 : currentPage;
+            this.getData();
+          } else {
+            this.$message.error(res.message);
+          }
         })
         .catch(() => {
           this.$message.info("已取消删除");
@@ -332,34 +304,49 @@ export default {
     // 分页器换页回调
     handleCurrentChange(value) {
       this.currentPage = value;
-      if (this.data.length >= 8) {
-        this.tableData = this.data.slice((value - 1) * 8, value * 8);
-      } else {
-        this.tableData = this.data;
-      }
-    },
-    // 添加账号弹窗关闭弹窗回调
-    handleClose(done) {
-      this.$confirm("确认关闭?")
-        .then((_) => {
-          done();
-        })
-        .catch((_) => {});
+      this.getData();
     },
-    // 添加账号弹窗确定按钮回调
+    // 添加账号/编辑账号 弹窗确定按钮回调
     handleConfirm(formName) {
-      this.$refs[formName].validate((valid) => {
+      this.$refs[formName].validate(async (valid) => {
         if (valid) {
-          console.log("添加成功");
-          let arr = {
-            number: this.ruleForm.phone,
-            name: this.ruleForm.name,
-            identity: this.ruleForm.identity,
-            type: this.ruleForm.type,
+          let rsaPassWord = RSAencrypt(this.ruleForm.password);
+          let data = {
+            phone: this.ruleForm.phone,
+            username: this.ruleForm.username,
+            adminType: this.ruleForm.adminType,
+            password: rsaPassWord,
+            statu: 1,
+          };
+          let data1 = {
+            id: this.ruleForm.id,
+            phone: this.ruleForm.phone,
+            username: this.ruleForm.username,
+            adminType: this.ruleForm.adminType,
+            statu: 1,
           };
-          this.data.push(arr);
-          this.currentPage = Math.ceil(this.data.length / this.pageSize);
-          this.handleCurrentChange(this.currentPage);
+          // 添加账号请求
+          if (this.popTitle == "添加账号") {
+            let res = await this.API.hotelAdmin.hotelStaffAdd(data);
+            // console.log(res);
+            if (res.success) {
+              this.$message.success("添加成功");
+              this.getData();
+            } else {
+              this.$message.error(res.message);
+            }
+          }
+          // 编辑账号请求
+          else {
+            let res = await this.API.hotelAdmin.hotelStaffUpdate(data1);
+            // console.log(res);
+            if (res.success) {
+              this.$message.success("编辑成功");
+              this.getData();
+            } else {
+              this.$message.error(res.message);
+            }
+          }
           this.dialogVisible = false;
         } else {
           console.log("error submit!!");

File diff suppressed because it is too large
+ 236 - 484
admin/src/views/order/index.vue


+ 151 - 227
admin/src/views/staff/index.vue

@@ -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" };
       }
     },
   },

+ 45 - 6
admin/src/views/system/index.vue

@@ -102,7 +102,7 @@
         </div>
 
         <!-- 通知人区域 -->
-        <div>
+        <!-- <div>
           设置清扫/查房通知人<el-input
             class="input-new-tag"
             v-if="informShow"
@@ -120,7 +120,7 @@
           >
             {{ inputValue_inform }}
           </el-button>
-        </div>
+        </div> -->
 
         <!-- 退房区域 -->
         <div>
@@ -173,25 +173,64 @@ export default {
       inputValue_subsidyElectricity: 9,
 
       // 通知人输入框按钮框切换控制
-      informShow: false,
-      // 通知人绑定数据
-      inputValue_inform: 7,
+      // informShow: false,
+      // // 通知人绑定数据
+      // inputValue_inform: 7,
 
       // 退房输入框按钮框切换控制
       refundShow: false,
       // 退房绑定数据
       inputValue_refund: 8,
+      id: "",
     };
   },
+  mounted() {
+    this.getData();
+  },
   methods: {
+    // 获取系统设置页面数据
+    async getData() {
+      let res = await this.API.systemSetup.systemSettingInfo();
+      // console.log(res);
+      if (res.success) {
+        this.inputValue_imprest = res.data.deposit;
+        this.inputValue_reserve = res.data.preDay;
+        this.inputValue_subsidyWater = res.data.freeQuotaOfWater;
+        this.inputValue_subsidyElectricity = res.data.freeQuotaOfElectric;
+        // this.inputValue_inform = res.data.deposit;
+        this.inputValue_refund = res.data.turnOffTime;
+        this.id = res.data.id;
+      } else {
+        this.$message.error(res.message);
+      }
+    },
     // 点击按钮 切换输入框 并聚焦
     showInput(show, value) {
       this[show] = true;
       this[value] = null;
     },
     // 失去焦点 切换回按钮 并更新数据
-    handleInputConfirm(show, value) {
+    async handleInputConfirm(show) {
       this[show] = false;
+      let data = {
+        id: this.id,
+        deposit: this.inputValue_imprest,
+        preDay: this.inputValue_reserve,
+        priceOfWater: 0,
+        priceOfElectric: 0,
+        freeQuotaOfWater: this.inputValue_subsidyWater,
+        freeQuotaOfElectric: this.inputValue_subsidyElectricity,
+        freeTotal: 0,
+        turnOffTime: this.inputValue_refund,
+      };
+      let res = await this.API.systemSetup.systemnoticeUpdate(data);
+      // console.log(res);
+      if (res.success) {
+        this.$message.success("修改成功");
+        this.getData();
+      } else {
+        this.$message.error(res.message);
+      }
     },
   },
 };