Procházet zdrojové kódy

修改统计页面时间区间显示

Zhouzhendong před 6 roky
rodič
revize
93e29b4b4f

+ 25 - 2
resources/views/weight/package/statistics.blade.php

@@ -98,8 +98,8 @@
                                         </tr>
                                     </table>
                                     <span class="text-muted"
-                                          style="position: absolute; bottom: 10px;left:calc(50% - 165px);transform: scale(0.65)" v-if="filterData.date_start">
-                                        时间区间:@{{ filterData.date_start }}&nbsp;@{{ inputtingAdd_start }} <b v-if="filterData.date_end">-</b> @{{ filterData.date_end }}&nbsp;@{{ inputtingAdd_end }}</span>
+                                          style="position: absolute; bottom: 10px;left:calc(50% - 165px);transform: scale(0.65)" v-if="filterData.date_start || filterData.date_end">
+                                        时间区间:@{{ dateTime }}</span>
 
                                     <div class=" align-items-center d-flex pt-2">
                                         <div class="m-auto d-flex">
@@ -200,6 +200,7 @@
                 checkSign:'',
                 inputtingAdd_start:'',
                 inputtingAdd_end:'',
+                dateTime:'',
             },
             computed:{
                 isBeingFilterConditions:function(){
@@ -262,8 +263,30 @@
                 this.initInputs();
                 $(".tooltipTarget").tooltip({'trigger':'hover'});
                 $('#statistics').removeClass('d-none');
+                let date=new Date();
+                let thisDate=this.getDate(date);
+                let startTime=this.inputtingAdd_start;
+                let endTime=this.inputtingAdd_end;
+                let endDate=this.filterData.date_end;
+                let startDate=this.filterData.date_start;
+                if (this.filterData.date_start && !this.inputtingAdd_start)  startTime="00:00";
+                if (this.filterData.date_end && !this.inputtingAdd_end)  endTime="23:59";
+                if (this.filterData.date_start && !this.filterData.date_end) endDate=thisDate;
+                if (this.filterData.date_end && !this.filterData.date_start) startDate="2020-01-01 00:00";
+                this.dateTime=startDate+" "+startTime+" - "+endDate+" "+endTime;
             },
             methods: {
+                getDate(date){
+                    let da=[
+                        date.getFullYear(),
+                        date.getMonth()+1,
+                        date.getDate(),
+                        date.getHours(),
+                        date.getMinutes(),
+                    ]
+                    return da.slice(0,3).join("-")+" "+
+                        da.slice(3).join(":");
+                },
                 initInputs:function(){
                     let data=this;
                     let uriParts =decodeURI(location.href).split("?");