Browse Source

no message

hzj18279462576@163.com 3 years ago
parent
commit
aab7b16f87
2 changed files with 98 additions and 48 deletions
  1. 1 1
      admin/src/api/room.js
  2. 97 47
      admin/src/views/home/index.vue

+ 1 - 1
admin/src/api/room.js

@@ -8,7 +8,7 @@ export function roomPage(params) {
 
 // 房间列表(分页分组)
 export function roomPageGroup(params) {
-    return http.get(`${resquest}/page/group?${params}`)
+    return http.get(`${resquest}/page/group`, params)
 }
 
 // 新增房间

+ 97 - 47
admin/src/views/home/index.vue

@@ -1,5 +1,5 @@
 <template >
-  <el-card class="box-card">
+  <el-card class="box-card" v-show="cardShow">
     <div slot="header" class="clearfix">
       <div class="header-left">
         <span class="title">房态管理 </span>
@@ -336,7 +336,7 @@
                 @change="handleCheckAllChange"
                 >全选</el-checkbox
               >
-              <span class="all">150间</span>
+              <span class="all">{{ roomData.length }}间</span>
             </div>
             <div style="margin: 15px 0"></div>
             <el-checkbox-group
@@ -346,10 +346,10 @@
             >
               <el-checkbox
                 size="mini"
-                v-for="city in cities"
+                v-for="(city, ind) in cities"
                 :label="city"
                 :key="city"
-                >{{ city }} <span>50间</span></el-checkbox
+                >{{ city }} <span>{{ citiesNum[ind] }}间</span></el-checkbox
               >
             </el-checkbox-group>
           </div>
@@ -371,6 +371,7 @@ export default {
   name: "Home",
   data() {
     return {
+      cardShow: false,
       clickId: "",
       // 门锁管理
       doorLock: false,
@@ -408,7 +409,11 @@ export default {
       ],
       floorRoomDatas: [],
       roomData: [],
-
+      roomDatas: [],
+      augument: {
+        curPage: 1,
+        pageSize: 20,
+      }, // 当前数据为第一页
       defaultProps: {
         children: "children",
         label: "label",
@@ -451,7 +456,8 @@ export default {
       // 房态筛选数据
       checkAll: false,
       checkedCities: [],
-      cities: ["入住", "空闲", "锁定", "脏房", "预定"],
+      cities: ["空闲", "预定", "入住", "脏房", "锁定"],
+      citiesNum: [0, 0, 0, 0, 0],
       isIndeterminate: false,
     };
   },
@@ -466,13 +472,15 @@ export default {
       "el-button--plain"
     )[2].children[0].innerText = ">";
     this.roomList();
+
+    alert(parseInt(3, 8));
   },
   created() {
     // let arr = {
-    //   roomNo: "2-2-1001",
-    //   build: 2,
-    //   floor: "2",
-    //   roomTypeId: 1,
+    //   roomNo: "1-5-1007",
+    //   build: 1,
+    //   floor: "5",
+    //   roomTypeId: 2,
     //   roomTypeName: "测试房",
     //   enableUse: "1",
     // };
@@ -488,51 +496,72 @@ export default {
   },
   methods: {
     // 数据滚动加载
-    lazyLoading() {
-      // 滚动到底部,再加载的处理事件
-      //滚动高度
-      let scrollTop =
-        document.getElementsByClassName("room-floor")[0].scrollTop;
-      // console.log(scrollTop, "scrollTop");
-      //可视区高度
-      let clientHeight =
-        document.getElementsByClassName("room-floor")[0].clientHeight;
-      // console.log(clientHeight, "clientHeight");
-      //滚动页面的高度
-      let scrollHeight = this.$refs.scrollBlock.scrollHeight;
-      // console.log(scrollHeight, "scrollHeight");
-      if (scrollTop + clientHeight >= scrollHeight) {
-        // 滚动到底部,逻辑代码
-        //事件处理
-        console.log("滚动到底部,触发"); //此处可以添加数据请求
-        // 这这里可以写一些业务逻辑,请求数据等
-      }
-    },
+    // lazyLoading() {
+    //   // 滚动到底部,再加载的处理事件
+    //   //滚动高度
+    //   let scrollTop =
+    //     document.getElementsByClassName("room-floor")[0].scrollTop;
+    //   // console.log(scrollTop, "scrollTop");
+    //   //可视区高度
+    //   let clientHeight =
+    //     document.getElementsByClassName("room-floor")[0].clientHeight;
+    //   // console.log(clientHeight, "clientHeight");
+    //   //滚动页面的高度
+    //   let scrollHeight = this.$refs.scrollBlock.scrollHeight;
+    //   // console.log(scrollHeight, "scrollHeight");
+    //   if (scrollTop + clientHeight >= scrollHeight) {
+    //     // 滚动到底部,逻辑代码
+    //     //事件处理
+    //     // let augument = {
+    //     //   curPage: 2,
+    //     //   pageSize: 25,
+    //     // };
+    //     // this.API.room.roomPageGroup(augument).then((res) => {
+    //     //   console.log(res);
+    //     // });
+    //     console.log("滚动到底部,触发"); //此处可以添加数据请求
+    //     // 这这里可以写一些业务逻辑,请求数据等
+    //   }
+    // },
 
-    roomList() {
-      this.API.room.roomPageGroup("pageSize=40").then((res) => {
+    roomList(augument) {
+      if (!augument) {
+        augument = this.augument;
+      }
+      this.API.room.roomPageGroup(augument).then((res) => {
         this.floorRoomDatas = [];
-        // console.log(res);
-        let arr = [];
+        console.log(res);
+        console.log(res.data.list);
+
+        let arrays = [];
         res.data.list.forEach((items) => {
           console.log(items);
           items.floors.forEach((item) => {
-            console.log(item);
-            if (item.floor == 1) {
-              //  arr.push(...items.room);
-              console.log(item.room);
-            }
+            // console.log(item);
+            arrays.push(item);
           });
-          this.floorRoomDatas.push(items.floors[0]);
         });
-        console.log(res.data.list);
+
+        var res = []; // 层数
+        var narr = []; // 每层对应的数组
+        for (var i = 0; i < arrays.length; i++) {
+          var n = res.indexOf(arrays[i].floor);
+          if (n == -1) {
+            res.push(arrays[i].floor);
+            narr.push({ floor: arrays[i].floor, room: [...arrays[i].room] });
+          } else {
+            narr[n].room.push(...arrays[i].room);
+          }
+        }
+        console.log(res, narr);
+        this.floorRoomDatas = narr;
         console.log(this.floorRoomDatas);
         this.floorRoomDatas.forEach((item) => {
           item.room.forEach((items) => {
             items.roomno =
               items.roomNo.split("-")[0] +
               "单元" +
-              items.roomNo.split("-")[1] +
+              items.floor +
               "层" +
               items.roomNo.split("-")[2] +
               "房";
@@ -566,14 +595,19 @@ export default {
           this.roomData.forEach((resItem) => {
             if (resItem.statu == 1) {
               resItem.statuName = "空闲";
+              this.citiesNum[resItem.statu - 1] += 1;
             } else if (resItem.statu == 2) {
               resItem.statuName = "预定";
+              this.citiesNum[resItem.statu - 1] += 1;
             } else if (resItem.statu == 3) {
               resItem.statuName = "入住";
+              this.citiesNum[resItem.statu - 1] += 1;
             } else if (resItem.statu == 4) {
               resItem.statuName = "脏房";
+              this.citiesNum[resItem.statu - 1] += 1;
             } else if (resItem.statu == 5) {
               resItem.statuName = "锁定";
+              this.citiesNum[resItem.statu - 1] += 1;
             }
           });
           this.data[0].children = [];
@@ -601,6 +635,8 @@ export default {
           });
           // this.showTime(this.enableEndTime);
           console.log(this.roomData);
+          this.roomDatas = this.roomData;
+          this.cardShow = true;
         });
       });
     },
@@ -777,11 +813,13 @@ export default {
       let roomId = item.roomId;
       this.API.roomThirdSetting.changeElectric(roomId, operType).then((res) => {
         console.log(res);
-        this.$message({
-          message: "关电成功",
-          type: "success",
-        });
-        this.roomList();
+        if (res.success) {
+          this.$message({
+            message: "关电成功",
+            type: "success",
+          });
+          this.roomList();
+        }
       });
     },
 
@@ -794,6 +832,13 @@ export default {
     },
     handleCheckedCitiesChange(value) {
       console.log(value);
+      let arr = this.roomDatas.filter((item) => {
+        for (let i in value) {
+          console.log(i);
+          return item.statuName == value[i];
+        }
+      });
+      console.log(arr);
       let checkedCount = value.length;
       this.checkAll = checkedCount === this.cities.length;
       this.isIndeterminate =
@@ -816,6 +861,11 @@ export default {
         .then((_) => {
           this.API.doorLock.sendPassword(item.id).then((res) => {
             console.log(res);
+            this.$message({
+              message: "下发密码成功",
+              type: "success",
+            });
+            this.doorLock = false;
           });
         })
         .catch((_) => {});