lizhuang 5 lat temu
rodzic
commit
3433360096
2 zmienionych plików z 8 dodań i 5 usunięć
  1. 2 2
      src/utils/helper.js
  2. 6 3
      src/views/doBusiness/index.vue

+ 2 - 2
src/utils/helper.js

@@ -12,10 +12,10 @@ export function toTimestamp(str) {
  * 将时间戳转化成 类似的时间 ‘20190910081000’
  * @param {Number} timestamp 时间戳
  */
-export function timestamp2String(timestamp) {
+export function timestamp2String(timestamp, wasAddOne = false) {
     const date = new Date(timestamp)
     const year = date.getFullYear()
-    const month = add0(date.getMonth() + 1)
+    const month = add0(wasAddOne ? date.getMonth() : date.getMonth() + 1)
     const day = add0(date.getDate())
     const hours = add0(date.getHours()) 
     const minutes = add0(date.getMinutes())

+ 6 - 3
src/views/doBusiness/index.vue

@@ -64,8 +64,10 @@ export default {
     },
   },
   watch:{
-    value(){
-      this.getHours()
+    value(newVal, oldVal){
+      if(newVal.getMonth() != oldVal.getMonth()) {
+        this.getHours()
+      }
     }
   },
   methods: {
@@ -105,7 +107,8 @@ export default {
       let params = {
         postParams:{
           projectId:this.$store.state.projectId,
-          date: timestamp2String(val[0]).substr(0,8),
+          // 这里val[0]月份已经 +1 了, 
+          date: timestamp2String(val[0], true).substr(0,8),
           openTime:timestamp2String(val[0]).substr(8,6),
           endTime: timestamp2String(val[1]).substr(8,6),
         }