浏览代码

营业时间

lizhuang 5 年之前
父节点
当前提交
ca682d17f1
共有 1 个文件被更改,包括 29 次插入25 次删除
  1. 29 25
      src/views/doBusiness/index.vue

+ 29 - 25
src/views/doBusiness/index.vue

@@ -2,15 +2,15 @@
 <template>
   <div class="business">
     <Head :headText="headText"></Head>
-    <div class="count-top-right">
+    <!-- <div class="count-top-right">
       <month-temp @pickerVal="pickerVal"></month-temp>
-    </div>
-    <el-calendar class="doBusinessContainer" :first-day-of-week="7">
+    </div> -->
+    <el-calendar class="doBusinessContainer" v-model="value" :first-day-of-week="7">
       <template slot="dateCell" slot-scope="{date, data}">
-        <template v-for="(item,index) in content" >
+        <template v-for="item in content" >
           <div 
           class="time-duration" 
-          :key="index"
+          :key="item.id"
           v-if="showTimeDuration(date, item)"
           >
           <el-time-picker
@@ -42,7 +42,8 @@ export default {
     return {
       headText: "营业时间调整",
       content:[],
-      date:timestamp2String(+new Date())
+      date:timestamp2String(+new Date()),
+      value: new Date(),
     };
   },
   components: {
@@ -51,16 +52,22 @@ export default {
   },
   computed:{
     gte(){
-      let month = parseInt(this.date.slice(4,6))-1
-      return this.date.slice(0,4) + (month > 10 ? month : ('0'+month) )+ this.date.slice(6,8)
+      let date = timestamp2String(+this.value)
+      let month = parseInt(date.slice(4,6))-1
+      return date.slice(0,4) + (month > 10 ? month : ('0'+month) )+ date.slice(6,8)
      
     },
     lt(){
-       let month = parseInt(this.date.slice(4,6))+1
-       return this.date.slice(0,4) + (month > 10 ? month : ('0'+month) )+ this.date.slice(6,8)
+       let date = timestamp2String(+this.value)
+       let month = parseInt(date.slice(4,6))+1
+       return date.slice(0,4) + (month > 10 ? month : ('0'+month) )+ date.slice(6,8)
     },
   },
-
+  watch:{
+    value(){
+      this.getHours()
+    }
+  },
   methods: {
     translate(){
       this.content.forEach(el=>{
@@ -68,11 +75,12 @@ export default {
       })
     },
     pickerVal(val) {
-      console.log(val);
       this.date = val
+      console.log(this.date)
+      
     },
     getHours(){
-      console.log(this.date)
+      this.content = []
       let params = {
         postParams:{
           criteria:{
@@ -106,8 +114,11 @@ export default {
         console.log(res)
       })
     },
+    // 只展示当前月份的
     showTimeDuration(date, item) {
-      return timestamp2String(+date).substr(0, 8) == item.date
+      const currentMonth = this.value.getMonth() + 1
+      const nodeMonth = date.getMonth() + 1
+      return currentMonth == nodeMonth && timestamp2String(+date).substr(0, 8) == item.date
     }
   },
   mounted(){
@@ -144,14 +155,7 @@ export default {
       background: rgba(245, 246, 247, 1);
     }
   }
-  .dataJoin {
-    height: 22px;
-    font-size: 16px;
-    font-family: PingFangSC-Regular, PingFang SC;
-    font-weight: 400;
-    color: rgba(31, 36, 41, 1);
-    line-height: 22px;
-  }
+
 }
 </style>
 <style lang="scss">
@@ -166,9 +170,9 @@ export default {
     line-height: 20px;
     padding-right: 15px;
   }
-  .el-calendar__header {
-    display: none;
-  }
+  // .el-calendar__header {
+  //   display: none;
+  // }
   .el-range-editor--mini .el-range-input {
     background: #f5f6f7;
   }