Bläddra i källkod

大屏闪现修复、餐饮数据逢双休调整

wangtao 3 år sedan
förälder
incheckning
2d217e1c82

+ 19 - 4
src/assets/js/dataFormate.js

@@ -12,6 +12,20 @@ lastMonthDate.setDate(1);
 lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
 // var lastYear = lastMonthDate.getYear();
 var lastMonth = lastMonthDate.getMonth();
+// 获取本周几
+function getWeekDate() {
+    let weeks = new Array(
+        "周日",
+        "周一",
+        "周二",
+        "周三",
+        "周四",
+        "周五",
+        "周六"
+    );
+    var week = weeks[nowDayOfWeek];
+    return week;
+}
 //格式化日期:yyyy-MM-dd
 function formatDate(date) {
     var myyear = date.getFullYear();
@@ -176,10 +190,10 @@ function timestampToTime(timestamp) {
 //date 为时间对象
 function getNYRSFM() {
     var year = now.getFullYear() + '年'
-    var month = now.getMonth() + 1 +'月'
-    var day = now.getDate()  +'日'
+    var month = now.getMonth() + 1 + '月'
+    var day = now.getDate() + '日'
     var sfb = now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds()
-    return year  + month  + day + " " + sfb;
+    return year + month + day + " " + sfb;
 }
 /**
  * 获得相对当前周AddWeekCount个周的起止日期
@@ -273,5 +287,6 @@ export {
     getThisDateBeforMonth,
     getThisDateNextMonth,
     YearMonthDate,
-    getNYRSFM
+    getNYRSFM,
+    getWeekDate
 }

+ 28 - 5
src/components2/restaurant/index.vue

@@ -6,7 +6,7 @@
         <el-image :src="restaurant1" fit="scale-down" />
         <el-col class="name"
           >今日营业额<el-col class="num"
-            >38155<span class="unit">元</span></el-col
+            >{{num[0]}}<span class="unit">元</span></el-col
           ></el-col
         >
       </el-col>
@@ -14,7 +14,7 @@
         <el-image :src="restaurant1" fit="scale-down" />
         <el-col class="name"
           >今日销售人/次<el-col class="num"
-            >15642<span class="unit">份</span></el-col
+            >{{num[1]}}<span class="unit">份</span></el-col
           ></el-col
         >
       </el-col>
@@ -43,6 +43,7 @@ import restaurant3 from "@/assets/images2/排名-右边.png";
 import num1 from "@/assets/images2/第一名icon.png";
 import num2 from "@/assets/images2/第二名icon.png";
 import num3 from "@/assets/images2/第三名icon.png";
+import { getWeekDate } from "@/assets/js/dataFormate.js";
 export default {
   name: "restaurant",
   data() {
@@ -61,9 +62,26 @@ export default {
         {id:num1,name:"清炒时蔬",num:412},
         {id:num2,name:"柠檬鸭",num:315},
         {id:num3,name:"番茄炒蛋",num:267},
-      ]
+      ],
+      num:[38155,15642],
+      tapNo:false,
     };
   },
+  created(){
+    console.log(getWeekDate())
+    if(getWeekDate() == "周一" || getWeekDate() == "周日"){
+      this.list2 = [
+        {id:num1,name:"未营业",num:0},
+        {id:num2,name:"未营业",num:0},
+        {id:num3,name:"未营业",num:0},
+      ]
+      this.num = [0,0]
+      this.tapNo = true
+    }
+    if(getWeekDate() == "周六" || getWeekDate() == "周日"){
+      this.num = [0,0]
+    }
+  },
   mounted() {
     this.init()
     this.timing()
@@ -99,7 +117,12 @@ export default {
       },1000 * 60 * 5)
     },
     canyin(id){
-      this.$emit("canyinClick",id)
+      if(this.tapNo == true){
+        //禁止跳转(周六周日休业)
+      }else{
+        this.$emit("canyinClick",id)
+      }
+
     }
   },
 };
@@ -193,7 +216,7 @@ export default {
         font-family: 'DINAlternate-Bold';
       }
       .dishName{
-       
+
         display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
       }
     }

+ 5 - 5
src/components2/seHeader/index.vue

@@ -33,11 +33,11 @@ export default {
     this.timer = setInterval(function() {
         let myDate = new Date()
         let year = myDate.getFullYear() + '年'
-        let month = myDate.getMonth() + 1 > 10 ? (myDate.getMonth() + 1) + '月' : '0' + (myDate.getMonth() + 1)  + '月'
-        let day = myDate.getDate() > 10 ?  myDate.getDate() + '日' : '0' + myDate.getDate() + '日 '
-        let s = myDate.getHours() > 10 ? myDate.getHours() : '0' + myDate.getHours()
-        let f = myDate.getMinutes() > 10 ? myDate.getMinutes() : '0' + myDate.getMinutes()
-        let m = myDate.getSeconds() > 10  ? myDate.getSeconds() : '0' + myDate.getSeconds()
+        let month = myDate.getMonth() + 1 > 9 ? (myDate.getMonth() + 1) + '月' : '0' + (myDate.getMonth() + 1)  + '月'
+        let day = myDate.getDate() > 9 ?  myDate.getDate() + '日' : '0' + myDate.getDate() + '日 '
+        let s = myDate.getHours() > 9 ? myDate.getHours() : '0' + myDate.getHours()
+        let f = myDate.getMinutes() > 9 ? myDate.getMinutes() : '0' + myDate.getMinutes()
+        let m = myDate.getSeconds() > 9  ? myDate.getSeconds() : '0' + myDate.getSeconds()
         that.date = year + month + day + ' ' + s + ":" + f + ":" + m
     });
   },