From 8aa3edd56c279100c9053576f3e90fa55459fe77 Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Mon, 16 Jan 2023 16:15:55 +0800
Subject: [PATCH] 修改

---
 src/views/parcel/parcelKind.vue |  148 +++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 136 insertions(+), 12 deletions(-)

diff --git a/src/views/parcel/parcelKind.vue b/src/views/parcel/parcelKind.vue
index b396769..ff87846 100644
--- a/src/views/parcel/parcelKind.vue
+++ b/src/views/parcel/parcelKind.vue
@@ -13,6 +13,7 @@
                @row-save="rowSave"
                @row-del="rowDel"
                @row-click="rowClick"
+               :search.sync="search"
                @search-change="searchChange"
                @search-reset="searchReset"
                @selection-change="selectionChange"
@@ -30,6 +31,27 @@
           >查看包裹图片
         </el-button>
       </template> -->
+       <template slot="menuLeft">
+          <el-button
+            v-bind:class="activeClass == 0 ? 'btn-color' : ''"
+            size="small "
+            @click="getParcelKindData(0)"
+            >本日
+          </el-button>
+          <el-button
+            v-bind:class="activeClass == 1 ? 'btn-color' : ''"
+            size="small "
+            @click="getParcelKindData(1)"
+            >本周
+          </el-button>
+          <el-button
+            v-bind:class="activeClass == 2 ? 'btn-color' : ''"
+            size="small "
+            @click="getParcelKindData(2)"
+            >本月
+          </el-button>
+        </template>
+
        <template slot="menuLeft">
           <el-button type="warning"
                       size="small"
@@ -76,7 +98,9 @@
       return {
         form: {},
         query: {},
+        search:{},
         showViewer: false, // 显示查看器
+        activeClass:0,
         imgUrl:'',
         loading: true,
         page: {
@@ -88,7 +112,7 @@
         option: {
           menu:false,
           height:'auto',
-          calcHeight: 30,
+          calcHeight: 54,
           tip: false,
           searchShow: true,
           searchMenuSpan: 4,
@@ -221,9 +245,12 @@
         this.query = {};
         //清空this.$route.query
         this.$router.push({ query: {} });
+        this.activeClass=0;
         this.onLoad(this.page);
       },
       searchChange(params, done) {
+        //清空this.$route.query
+        this.$router.push({ query: {} });
         this.query = params;
         this.page.currentPage = 1;
         this.onLoad(this.page, params);
@@ -256,13 +283,101 @@
            if (this.$route.query.startTime != undefined && this.$route.query.startTime != null && this.$route.query.startTime != "" ) {
              return this.$route.query.startTime
            }
-           return '';
+           // 当前时间
+          var date = new Date();
+          //年
+          var Y = date.getFullYear();
+          //月
+          var M = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
+          //日
+          var D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
+           return Y + "-" + M + "-" + D+ " 00:00:00";
       },
       getEndTime(){
            if (this.$route.query.endTime != undefined && this.$route.query.endTime != null && this.$route.query.endTime != "" ) {
              return this.$route.query.endTime
            }
-           return '';
+            // 当前时间
+            var date = new Date();
+            //年
+            var Y = date.getFullYear();
+            //月
+            var M = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
+            //日
+            var D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
+            return Y + "-" + M + "-" + D+ " 23:59:59";
+      },
+      getParcelKindData(e) {
+        var that = this;
+        this.query={};
+        //清空this.$route.query
+        this.$router.push({ query: {} });
+        that.activeClass = e;
+        var today = new Date();
+        var params ={};
+        if(e==0){
+          params = {
+            startTime:this.showToDay(today)+ " 00:00:00",
+            endTime:this.showToDay(today)+ " 23:59:59"
+          };
+          //修改搜索框中的值
+          this.search.dateTime=[this.showToDay(today)+ " 00:00:00",this.showToDay(today)+ " 23:59:59"]
+        }
+        if(e==1){
+          params = {
+            startTime:this.showWeekFirstDay(today)+ " 00:00:00",
+            endTime:this.showToDay(today)+ " 23:59:59"
+          };
+          //修改搜索框中的值
+          this.search.dateTime=[this.showWeekFirstDay(today)+ " 00:00:00",this.showToDay(today)+ " 23:59:59"]
+        }
+        if(e==2){
+          params = {
+            startTime:this.showMonthFirstDay(today)+ " 00:00:00",
+            endTime:this.showToDay(today)+ " 23:59:59"
+          };
+          //修改搜索框中的值
+          this.search.dateTime=[this.showMonthFirstDay(today)+ " 00:00:00",this.showToDay(today)+ " 23:59:59"]
+        }
+        this.query = params;
+        this.page.currentPage = 1;
+        this.onLoad(this.page, params);
+      },
+      //本日
+      showToDay(Nowdate){
+        var M=Number(Nowdate.getMonth())+1;
+        if(M<10){
+          M="0"+M;
+        }
+        var day = Nowdate.getDate();
+        if(day<10){
+          day = "0"+day;
+        }
+        return Nowdate.getFullYear()+"-"+M+"-"+day;
+      },
+
+      //本周第一天
+      showWeekFirstDay(Nowdate){
+        var WeekFirstDay=new Date(Nowdate-(Nowdate.getDay()-1)*86400000);
+        var M=Number(WeekFirstDay.getMonth())+1;
+        if(M<10){
+          M="0"+M;
+        }
+        var day = WeekFirstDay.getDate();
+        if(day<10){
+          day = "0"+day;
+        }
+        return WeekFirstDay.getFullYear()+"-"+M+"-"+day;
+      },
+
+      //本月第一天
+      showMonthFirstDay(Nowdate){
+        var MonthFirstDay=new Date(Nowdate.getFullYear(),Nowdate.getMonth(),1);
+        var M=Number(MonthFirstDay.getMonth())+1;
+        if(M<10){
+          M="0"+M;
+        }
+        return MonthFirstDay.getFullYear()+"-"+M+"-"+"0"+MonthFirstDay.getDate();
       },
       //给行加颜色
       rowStyle({row, column, rowIndex}){
@@ -277,18 +392,11 @@
           cancelButtonText: "取消",
           type: "warning"
         }).then(() => {
-          
-          console.log(this.$route.query.timeDesc,111);
           window.open(`/api/blade-jfpts/parcel/parcel/export-parcelKind?startTime=${this.$route.query.startTime}&endTime=${this.$route.query.endTime}&decisioDiagramResult=${this.$route.query.decisioDiagramResult}&timeDesc=${this.$route.query.timeDesc}`);
         });
       },
       //数据报表导出
       handleExportStatis() {
-        this.$confirm("是否导出违禁品报表数据?", "提示", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(() => {
           let startTime = this.$route.query.startTime==undefined? '':this.$route.query.startTime;
           let endTime = this.$route.query.endTime==undefined? '':this.$route.query.endTime;
           let decisioDiagramResult = this.$route.query.decisioDiagramResult==undefined? '':this.$route.query.decisioDiagramResult;
@@ -296,9 +404,8 @@
           //window.open(`http://localhost:8108/ureport/excel?_u=blade-parcelKind.statis.ureport.xml&startTime=${startTime}&endTime=${endTime}&decisioDiagramResult=${decisioDiagramResult}&timeDesc=${timeDesc}`);
           //window.open(`http://localhost:8108/ureport/preview?_u=blade-parcelKind.statis.ureport.xml&startTime=${startTime}&endTime=${endTime}&decisioDiagramResult=${decisioDiagramResult}&timeDesc=${timeDesc}`);
           window.open(`https://web.byisf.com/api/blade-report/ureport/preview?_u=blade-parcelKind.statis.ureport.xml&startTime=${startTime}&endTime=${endTime}&decisioDiagramResult=${decisioDiagramResult}&timeDesc=${timeDesc}`);
-        });
       },
-      onLoad(page, params = {}) {
+      onLoad(page, params={}) {
         const { dateTime } = this.query;
         let values = {
           ...params,
@@ -318,6 +425,23 @@
                 decisioDiagramResult:this.$route.query.decisioDiagramResult
               };
             }
+            this.activeClass=4;
+        }
+
+        if(this.activeClass==0){
+          this.page.currentPage = 1;
+          // 当前时间
+          var date = new Date();
+          //年
+          var Y = date.getFullYear();
+          //月
+          var M = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
+          //日
+          var D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
+          params = {
+            startTime:Y + "-" + M + "-" + D + " 00:00:00",
+            endTime:Y +"-" +M +"-" + D +  " 23:59:59"
+          }
         }
 
         if (dateTime) {

--
Gitblit v1.9.3