zhulizhen 5 anni fa
parent
commit
c7dd25f72b

+ 19 - 8
src/views/doBusiness/index.vue

@@ -3,7 +3,7 @@
   <div class="business">
     <Head :headText="headText"></Head>
     <div class="count-top-right">
-      <date-temp :types="1"  @pickerVal="pickerVal"></date-temp>
+      <month-temp @pickerVal="pickerVal"></month-temp>
     </div>
     <el-calendar class="doBusinessContainer" :first-day-of-week="7">
       <template slot="dateCell" slot-scope="{date, data}">
@@ -17,6 +17,7 @@
             end-placeholder="结束时间"
             placeholder="选择时间范围"
             format="hh:mm"
+            value-format="hh:mm"
             @change="setHours"
           ></el-time-picker>
         </div>
@@ -27,21 +28,29 @@
 </template>
 <script>
 import Head from "../main/index";
-import DateTemp from "../evaluate/dateTemp";
+import MonthTemp from "./monthTemp";
 import {queryHours,updateHours} from '@/api/doBusiness/business.js'
 export default {
   data() {
     return {
       headText: "营业时间调整",
       value1: [new Date(), new Date()],
-      date:""
+      date:"",
+      today:''
     };
   },
   components: {
     Head,
-    DateTemp
+    MonthTemp
   },
   methods: {
+    formatTime(){
+      let year = new Date().getFullYear()
+      let month = new Date().getMonth()+1>10?(new Date().getMonth()+1): ('0'+(new Date().getMonth()+1))
+      let date = new Date().getDate()>10?new Date().getDate():('0'+new Date.getDate())
+      console.log(year,month,date)
+      return this.today = year + ''+ month+''+date
+    },
     pickerVal(val) {
       console.log(val);
       this.date = val
@@ -51,7 +60,7 @@ export default {
         postParams:{
           criteria:{
             projectId:'Pj4419000005',
-            date:'201902'
+            date:this.today
           }
         }
       }
@@ -60,12 +69,13 @@ export default {
       })
     },
     setHours(){
+      console.log(this.value1)
       let params = {
         postParams:{
           projectId:'Pj4419000005',
-          date:'201902',
-          openTime:'080000',
-          endTime:'220000'
+          date: this.today,
+          openTime:this.value1.split('-')[0].slice(0,2)+''+this.value1.split('-')[0].slice(2,4),
+          endTime:this.value1.split('-')[1].slice(0,2)+''+this.value1.split('-')[1].slice(2,4),
         }
       }
       updateHours(params).then(res=>{
@@ -74,6 +84,7 @@ export default {
     }
   },
   mounted(){
+    this.formatTime()
     this.getHours()
   }
 };

+ 121 - 0
src/views/doBusiness/monthTemp.vue

@@ -0,0 +1,121 @@
+<template>
+  <div class="date-temp">
+    <span class="arrow-left" @click="pickerChangeLeft"></span>
+    <span class="arrow-line arrow-line1" @click="pickerChangeLeft"></span>
+    <el-date-picker  v-model="pickerVal1" type="month" format="yyyy.MM" value-format="yyyy.MM"></el-date-picker>
+    <span class="arrow-line" @click="pickerChangeRight"></span>
+    <span class="arrow-right" @click="pickerChangeRight"></span>
+  </div>
+</template>
+<script>
+var moment = require("moment");
+import "moment/locale/zh-cn";
+export default {
+  data() {
+    return {
+      pickerVal1: new Date()
+    };
+  },
+  methods: {
+    formatter(date) {
+      return moment.unix(date / 1000).format("YYYYMMDD");
+    },
+    pickerChangeLeft() {
+      if (this.pickerVal1) {
+        let dateTime = new Date(this.pickerVal1);
+        console.log(dateTime)
+        let newData = this.formatter(
+          new Date(dateTime.setMonth(dateTime.getMonth() - 1))
+        );
+        this.pickerVal1 =
+          newData.slice(0, 4) +
+          "." +
+          newData.slice(4, 6) +
+          "." +
+          newData.slice(6, 8);
+      }
+      this.$emit("pickerVal", this.pickerVal1);
+    },
+    pickerChangeRight() {
+        console.log('111')
+      if (this.pickerVal1) {
+        let dateTime = new Date(this.pickerVal1);
+        console.log(dateTime)
+        let newData = this.formatter(
+          new Date(dateTime.setMonth(dateTime.getMonth() + 1))
+        );
+        console.log(newData)
+        this.pickerVal1 =
+          newData.slice(0, 4) +
+          "." +
+          newData.slice(4, 6) +
+          "." +
+          newData.slice(6, 8);
+      }
+      this.$emit("pickerVal", this.pickerVal1);
+    }
+  },
+  mounted(){
+   
+  }
+};
+</script>
+<style lang="scss">
+.date-temp {
+  background: rgba(255, 255, 255, 1);
+  border-radius: 4px;
+  border: 1px solid rgba(195, 198, 203, 1);
+  display: flex;
+  align-items: center;
+  .arrow-left {
+    width: 0;
+    height: 0;
+    border-top: 5px solid transparent;
+    border-bottom: 5px solid transparent;
+    border-right: 5px solid #9ca2a9;
+    margin-right: 5px;
+    margin-left: 7px;
+    cursor: pointer;
+  }
+  .arrow-right {
+    width: 0;
+    height: 0;
+    border-top: 5px solid transparent;
+    border-bottom: 5px solid transparent;
+    border-left: 5px solid #9ca2a9;
+    margin-right: 7px;
+    margin-left: 5px;
+    cursor: pointer;
+  }
+  .arrow-line {
+    display: inline-block;
+    width: 2px;
+    height: 16px;
+    background: rgba(228, 229, 231, 1);
+  }
+  .arrow-line1 {
+    margin-right: 3.5px;
+  }
+}
+</style>
+<style lang="scss">
+.date-temp {
+  text-align: center;
+  .el-input__inner {
+    width: 93px !important;
+    margin: 7px 6px;
+    height: 22px;
+    line-height: 22px;
+    border: none;
+  }
+  .el-input__icon {
+    display: none;
+  }
+  .el-input--prefix .el-input__inner {
+    padding-left: 5px;
+  }
+  .el-input--suffix .el-input__inner {
+    padding-right: 5px;
+  }
+}
+</style>

+ 1 - 2
src/views/evaluate/dateTemp.vue

@@ -2,8 +2,7 @@
   <div class="date-temp">
     <span class="arrow-left" @click="pickerChangeLeft"></span>
     <span class="arrow-line arrow-line1" @click="pickerChangeLeft"></span>
-    <el-date-picker v-if="types==1" v-model="pickerVal" type="month" format="yyyy.MM" value-format="yyyy.MM"></el-date-picker>
-    <el-date-picker v-if="types==0" v-model="pickerVal" type="date" format="yyyy.MM.dd" value-format="yyyy.MM.dd"></el-date-picker>
+    <el-date-picker v-model="pickerVal" type="date" format="yyyy.MM.dd" value-format="yyyy.MM.dd"></el-date-picker>
     <span class="arrow-line" @click="pickerChangeRight"></span>
     <span class="arrow-right" @click="pickerChangeRight"></span>
   </div>

+ 1 - 1
src/views/evaluate/evTwoLevelMenu.vue

@@ -15,7 +15,7 @@
             <li :class="{current: num==3}" @click="change(3)">执行率</li>
           </div>
           <div class="count-top-right">
-            <date-temp :types="0"  @pickerVal="pickerVal"></date-temp>
+            <date-temp  @pickerVal="pickerVal"></date-temp>
           </div>
         </ul>
         <div class="count-bottom">