From 4cfbfd1b425f7b22b876ae6cae95c4fc29ae6bfb Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期五, 23 二月 2024 09:25:33 +0800
Subject: [PATCH] 盘库修改

---
 src/views/stock/statePurchaseStatistics.vue |   76 +++++++++++++++++++++----------------
 1 files changed, 43 insertions(+), 33 deletions(-)

diff --git a/src/views/stock/statePurchaseStatistics.vue b/src/views/stock/statePurchaseStatistics.vue
index 3a5cd8d..951b9af 100644
--- a/src/views/stock/statePurchaseStatistics.vue
+++ b/src/views/stock/statePurchaseStatistics.vue
@@ -43,7 +43,7 @@
                     <el-date-picker
                         value-format="yyyy-MM-dd HH:mm:ss"
                         v-model="validTime"
-                        type="datetimerange"
+                        type="daterange"
                         :default-time="['00:00:00','23:59:59']"
                         :picker-options="pickerOptions"
                         range-separator="-"
@@ -171,14 +171,6 @@
                         const end = new Date();
                         const start = new Date();
                         start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
-                        picker.$emit('pick', [start, end]);
-                    }
-                }, {
-                    text: '最近三个月',
-                    onClick(picker) {
-                        const end = new Date();
-                        const start = new Date();
-                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                         picker.$emit('pick', [start, end]);
                     }
                 }]
@@ -324,7 +316,6 @@
         },
 
         reset() {
-            this.initValidTime()
             this.listQuery = {
                 startTime: '',
                 endTime: '',
@@ -333,38 +324,57 @@
                 city: '',
                 district: '',
             }
+            this.validTime = ['', '']
+            this.initValidTime()
             this.getRegionPifaBox()
         },
         searchProductSearch() {
+            const date1 = new Date(this.validTime[0]);
+            const date2 = new Date(this.validTime[1]);
+            const differenceInMs = Math.abs(date2 - date1);
+            const differenceInDays = differenceInMs / (1000 * 60 * 60 * 24)
+            if(differenceInDays > 32){
+                this.$message({
+                    type: 'warning',
+                    message: '时间跨度超过一个月的,请联系管理员查询数据'
+                })
+                return
+            }
             this.getRegionPifaBox()
         },
 
         initValidTime() {
+            // const end = new Date();
+            // if (end.getDate() - 1 === 0) {
+            //     this.validTime[0] = [end.getFullYear(), end.getMonth(), this.returnDay(end.getMonth(), end.getFullYear())].join("-") + " 00:00:00";
+            //     this.validTime[1] = [end.getFullYear(), end.getMonth(), this.returnDay(end.getMonth(), end.getFullYear())].join("-") + " 23:59:59";
+            // } else if (end.getDate() - 1 === 0 && end.getMonth() === 0) {
+            //     this.validTime[0] = [end.getFullYear() - 1, 12, 31].join("-") + " 00:00:00";
+            //     this.validTime[1] = [end.getFullYear() - 1, 12, 31].join("-") + " 23:59:59";
+            // } else {
+            //     this.validTime[0] = [end.getFullYear(), end.getMonth() + 1, end.getDate() - 1].join("-") + " 00:00:00";
+            //     this.validTime[1] = [end.getFullYear(), end.getMonth() + 1, end.getDate() - 1].join("-") + " 23:59:59";
+            // }
             const end = new Date();
-            if (end.getDate() - 1 === 0) {
-                this.validTime[0] = [end.getFullYear(), end.getMonth(), this.returnDay(end.getMonth(), end.getFullYear())].join("-") + " 00:00:00";
-                this.validTime[1] = [end.getFullYear(), end.getMonth(), this.returnDay(end.getMonth(), end.getFullYear())].join("-") + " 23:59:59";
-            } else if (end.getDate() - 1 === 0 && end.getMonth() === 0) {
-                this.validTime[0] = [end.getFullYear() - 1, 12, 31].join("-") + " 00:00:00";
-                this.validTime[1] = [end.getFullYear() - 1, 12, 31].join("-") + " 23:59:59";
-            } else {
-                this.validTime[0] = [end.getFullYear(), end.getMonth() + 1, end.getDate() - 1].join("-") + " 00:00:00";
-                this.validTime[1] = [end.getFullYear(), end.getMonth() + 1, end.getDate() - 1].join("-") + " 23:59:59";
-            }
+            // const start = new Date(end);
+            // start.setDate(start.getDate() - 7);
+            // this.validTime[0] = start.toISOString().slice(0, 10) + " 00:00:00";
+            this.validTime[0] = end.toISOString().slice(0, 10) + " 00:00:00";
+            this.validTime[1] = end.toISOString().slice(0, 10) + " 23:59:59";
         },
-        returnDay(value, year) {
-            if (value === 1 || value === 3 || value === 5 || value === 7 || value === 8 || value === 10 || value === 12) {
-                return 31
-            } else if (value === 2) {
-                if (year % 4 === 0) {
-                    return 29
-                } else {
-                    return 28
-                }
-            } else {
-                return 30
-            }
-        },
+        // returnDay(value, year) {
+        //     if (value === 1 || value === 3 || value === 5 || value === 7 || value === 8 || value === 10 || value === 12) {
+        //         return 31
+        //     } else if (value === 2) {
+        //         if (year % 4 === 0) {
+        //             return 29
+        //         } else {
+        //             return 28
+        //         }
+        //     } else {
+        //         return 30
+        //     }
+        // },
         showDetail(param) {
             if( this.validTime !== null ){
                 if(param.subRegionData){

--
Gitblit v1.9.2