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

---
 src/views/flow/inStorage.vue |   60 ++++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 36 insertions(+), 24 deletions(-)

diff --git a/src/views/flow/inStorage.vue b/src/views/flow/inStorage.vue
index 2494064..12ca151 100644
--- a/src/views/flow/inStorage.vue
+++ b/src/views/flow/inStorage.vue
@@ -61,17 +61,17 @@
                 <div style="display: block">
                     <div class="basic_search" style="padding-top: 10px;">
                     <span>按时间查询:</span>
-                    <el-date-picker
-                        value-format="yyyy-MM-dd HH:mm:ss"
-                        v-model="validTime"
-                        type="datetimerange"
-                        :default-time="['00:00:00','23:59:59']"
-                        :picker-options="pickerOptions"
-                        range-separator="-"
-                        start-placeholder="开始日期"
-                        end-placeholder="结束日期"
-                    >
-                    </el-date-picker>
+                        <el-date-picker
+                            value-format="yyyy-MM-dd HH:mm:ss"
+                            v-model="validTime"
+                            type="daterange"
+                            :default-time="['00:00:00','23:59:59']"
+                            :picker-options="pickerOptions"
+                            range-separator="-"
+                            start-placeholder="开始日期"
+                            end-placeholder="结束日期"
+                        >
+                        </el-date-picker>
                 </div>
                     <div class="basic_search" style="padding-top: 10px;margin-left: 15px">
                         <span>安全监管分类:</span>
@@ -250,14 +250,6 @@
                 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]);
-              }
             }]
           },
         }
@@ -379,9 +371,24 @@
                     transportcert: '',
                 },
             }
+            this.validTime = ['', '']
+            this.initValidTime()
+            this.getInStorageData()
         },
 
         searchProductSearch(){
+            this.listQuery.pageIndex = 1
+            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.getInStorageData()
         },
 
@@ -396,6 +403,13 @@
 
 
         async exportToExcel(){
+            if( this.validTime !== null ){
+                this.listQuery.filter.starttime = this.validTime[0]
+                this.listQuery.filter.endtime = this.validTime[1]
+            }else{
+                this.listQuery.filter.starttime = ''
+                this.listQuery.filter.endtime = ''
+            }
             let res = await exportInStorage(this.listQuery)
             if(res.data.code === '200'){
                 if(res.data.result === null ||res.data.result === [] || res.data.result.length === 0){
@@ -534,11 +548,9 @@
             }
         },
       initValidTime(){
-        const start = new Date();
-        const end = new Date();
-        start.setTime(end.getTime() - 3600 * 1000 * 24 * 0);
-        this.validTime[0] = [start.getFullYear(), start.getMonth() + 1, start.getDate()].join("-") + " 00:00:00" ;
-        this.validTime[1] = [end.getFullYear(), end.getMonth() + 1, end.getDate()].join("-") +" 23:59:59";
+          const end = new Date();
+          this.validTime[0] = end.toISOString().slice(0, 10) + " 00:00:00";
+          this.validTime[1] = end.toISOString().slice(0, 10) + " 23:59:59";
       }
 
     },

--
Gitblit v1.9.2