瀏覽代碼

应用中心和首页的时间区间格式统一调整

mork 3 周之前
父節點
當前提交
0f0056cc70
共有 4 個文件被更改,包括 62 次插入42 次删除
  1. 21 7
      src/views/HomePage.vue
  2. 21 14
      src/views/skmh/index.vue
  3. 19 5
      src/views/yygl/monitor/index.vue
  4. 1 16
      src/views/yygl/overview/index.vue

+ 21 - 7
src/views/HomePage.vue

@@ -455,7 +455,7 @@
 <script>
 import { countAppUseByUnitName, countServiceUseByApp, countUnitUse, countUserData, topService, topUnit, totalCount, totalCountGroupByTime } from "@/api/count";
 import * as echarts from "echarts";
-
+import moment from "moment";
 let chart1 = null;
 let chartMultiLevelUse = null;
 
@@ -568,7 +568,7 @@ export default {
     this.initchartMultiLevelUse();
     const nowDate = new Date();
     nowDate.setHours(0, 0, 0, 0);
-    this.chartMluTimeRange = [new Date(new Date(nowDate).setDate(nowDate.getDate() - 7)), new Date(nowDate)];
+    this.chartMluTimeRange = [new Date(new Date(nowDate).setDate(nowDate.getDate() - 6)), new Date(nowDate)];
     this.chartMluFocusRoot()
     this.pullTopUnit()
     this.pullTopService()
@@ -596,11 +596,12 @@ export default {
       }
     },
     async initChart1() {
-
       const nowDate = new Date();
       nowDate.setHours(0, 0, 0, 0);
       let end = new Date(nowDate)
       let start = new Date(nowDate.setDate(nowDate.getDate() - 30))
+      start = new Date(moment(start).format("YYYY-MM-DD 00:00:00"));
+      end = new Date(moment(end).format("YYYY-MM-DD 23:59:59"));
       let data = await totalCountGroupByTime(start, end)
       let dataMap = {}
       for (let i = 0; i < data.length; i++) {
@@ -792,7 +793,10 @@ export default {
       this.chartMluFocus()
     },
     async chartMluFocusRoot() {
-      const data = await countUnitUse(...this.chartMluTimeRange);
+      let start = this.chartMluTimeRange[0], end = this.chartMluTimeRange[1];
+      start = new Date(moment(start).format("YYYY-MM-DD 00:00:00"));
+      end = new Date(moment(end).format("YYYY-MM-DD 23:59:59"));
+      const data = await countUnitUse(start, end);
       const names = [];
       const values = [];
       for (let index = 0; index < data.length; index++) {
@@ -803,7 +807,10 @@ export default {
       this.chartMluUpdateData(names, values)
     },
     async chartMluFocusApp(father) {
-      const data = await countAppUseByUnitName(...this.chartMluTimeRange, father);
+      let start = this.chartMluTimeRange[0], end = this.chartMluTimeRange[1];
+      start = new Date(moment(start).format("YYYY-MM-DD 00:00:00"));
+      end = new Date(moment(end).format("YYYY-MM-DD 23:59:59"));
+      const data = await countAppUseByUnitName(start, end, father);
       const names = [];
       const values = [];
       for (let index = 0; index < data.length; index++) {
@@ -814,7 +821,10 @@ export default {
       this.chartMluUpdateData(names, values)
     },
     async chartMluFocusService(father) {
-      const data = await countServiceUseByApp(...this.chartMluTimeRange, father);
+      let start = this.chartMluTimeRange[0], end = this.chartMluTimeRange[1];
+      start = new Date(moment(start).format("YYYY-MM-DD 00:00:00"));
+      end = new Date(moment(end).format("YYYY-MM-DD 23:59:59"));
+      const data = await countServiceUseByApp(start, end, father);
       const names = [];
       const values = [];
       for (let index = 0; index < data.length; index++) {
@@ -849,6 +859,8 @@ export default {
       nowDate.setHours(0, 0, 0, 0);
       let end = new Date(nowDate)
       let start = new Date(nowDate.setDate(nowDate.getDate() - 1))
+      start = new Date(moment(start).format("YYYY-MM-DD 00:00:00"));
+      end = new Date(moment(end).format("YYYY-MM-DD 23:59:59"));
       let data = (await totalCount(start, end))[0]
       this.lastDayCall = data == null ? 0 : data.count
     },
@@ -863,6 +875,8 @@ export default {
       nowDate.setHours(0, 0, 0, 0);
       let end = new Date(nowDate)
       let start = new Date(nowDate.setDate(nowDate.getDate() - days))
+      start = new Date(moment(start).format("YYYY-MM-DD 00:00:00"));
+      end = new Date(moment(end).format("YYYY-MM-DD 23:59:59")); 
       let data = (await totalCount(start, end))[0]
       return data == null ? 0 : data.count
     },
@@ -1275,7 +1289,7 @@ export default {
     .part1-1 {
       width: 1000px;
       height: 200px;
-      background: #09284c;
+      //background: #09284c;
       margin: 0 auto;
       margin-top: 120px;
       overflow: hidden;

+ 21 - 14
src/views/skmh/index.vue

@@ -338,22 +338,22 @@ export default {
         {
           name: "total",
           start: '2000-01-01 00:00:00', // 从2000年1月1日开始
-          end: moment(new Date()).format("YYYY-MM-DD HH:mm:ss") // 到当前时间
+          end: moment(new Date()).format("YYYY-MM-DD 23:59:59") // 到当前一天结束时间
         },
         {
           name: "curWeek",
           start: moment().weekday(1).format("YYYY-MM-DD 00:00:00"), //本周一00:00:00
-          end: moment(new Date()).format("YYYY-MM-DD HH:mm:ss")
+          end: moment(new Date()).format("YYYY-MM-DD 23:59:59") // 到当前一天结束时间
         },
         {
           name: "curMonth",
           start: moment().startOf('month').format('YYYY-MM-DD 00:00:00'), //本月1日00:00:00
-          end: moment(new Date()).format("YYYY-MM-DD HH:mm:ss")
+          end: moment(new Date()).format("YYYY-MM-DD 23:59:59") // 到当前一天结束时间
         },
         {
           name: "lastMonth",
           start: moment().subtract(1, 'month').startOf('month').format('YYYY-MM-DD 00:00:00'), //上月1日00:00:00
-          end:  moment().subtract(1, 'month').endOf('month').format("YYYY-MM-DD HH:mm:ss") //上月最后一天23:59:59
+          end:  moment().subtract(1, 'month').endOf('month').format("YYYY-MM-DD 23:59:59") //上月最后一天23:59:59
         },
       ])
       // console.log(param)
@@ -366,6 +366,8 @@ export default {
     },
     getTotalCountGroupByTime(){
       let start = this.fromTime.date[0], end = this.fromTime.date[1];
+      start = moment(start).format("YYYY-MM-DD 00:00:00");
+      end = moment(end).format("YYYY-MM-DD 23:59:59");
       totalCountGroupByTime(start,end).then(res => {
         this.drawLineChart(res)
       })
@@ -459,21 +461,27 @@ export default {
     },
     getCoutService(){
         let start = this.fromTime.date[0], end = this.fromTime.date[1];
-        coutService(start,end).then(res => {
+        start = moment(start).format("YYYY-MM-DD 00:00:00");
+        end = moment(end).format("YYYY-MM-DD 23:59:59");
+        coutService(new Date(start),new Date(end)).then(res => {
           // console.log('[ res ] >', res)
           let arr = [];
-          res.sort((a, b) => b.count - a.count)
-          res.forEach(item => {
-            // let str = { value: item.count, name: item.service_name, itemStyle: { color: '#52C41A' } }
-            let str = { value: item.count, name: item.service_name }
-            arr.push(str)
-          })
+          if(res !=  undefined){
+            res.sort((a, b) => b.count - a.count)
+            res.forEach(item => {
+              // let str = { value: item.count, name: item.service_name, itemStyle: { color: '#52C41A' } }
+              let str = { value: item.count, name: item.service_name }
+              arr.push(str)
+            })
+          }
           this.initStatusChart(arr)
         })
     },
     getCountUserList(){
       let that = this
       let start = this.fromTime.date[0], end = this.fromTime.date[1];
+      start = moment(start).format("YYYY-MM-DD 00:00:00");
+      end = moment(end).format("YYYY-MM-DD 23:59:59");
       countUserList(start,end).then(res => {
         res.sort((a, b) => b.count - a.count)
         that.tableData = res;
@@ -482,9 +490,8 @@ export default {
     handleType(param){
       const end = new Date()
       const start = new Date()
-      start.setTime(start.getTime() - 3600 * 1000 * 24 * param) //天计算
-      end.setTime(end.getTime() - 3600 * 1000 * 24 * 1) //天计算
-      // start.setMonth(start.getMonth() - 6)
+      start.setDate(start.getDate() - (param - 1))
+      console.log(start,end)
       this.fromTime.date = [start,end];
       this.getTimeRange();
     },

+ 19 - 5
src/views/yygl/monitor/index.vue

@@ -169,7 +169,7 @@ export default {
       typeArrs: [],
       selectAapplications: [],
       selectedAppRange: '',
-      datetimeValue:[new Date(new Date().setMonth(new Date().getMonth() - 1)),new Date()],// 默认显示最近一个月
+      datetimeValue:[new Date(new Date(new Date().setMonth(new Date().getMonth() - 1))).setDate(new Date().getDate() + 1),new Date()],// 默认显示最近一个月
       shortcuts: [
         {
           text: '当天',
@@ -181,11 +181,12 @@ export default {
           },
         },
         {
-          text: '最近7天',
+          text: '最近一周',
           value: () => {
             const end = new Date()
             const start = new Date()
             start.setDate(start.getDate() - 7)
+            start.setDate(start.getDate() + 1)
             return [start, end]
           },
         },
@@ -195,6 +196,17 @@ export default {
             const end = new Date()
             const start = new Date()
             start.setMonth(start.getMonth() - 1)
+            start.setDate(start.getDate() + 1)
+            return [start, end]
+          },
+        },
+        {
+          text: '最近1年',
+          value: () => {
+            const end = new Date()
+            const start = new Date()
+            start.setFullYear(start.getFullYear() - 1)
+            start.setDate(start.getDate() + 1)
             return [start, end]
           },
         },
@@ -235,7 +247,7 @@ export default {
       this.getDmsDataList();
       let param = {
         num: 6,
-        start: moment().subtract(1, "month").format("YYYY-MM-DD"),
+        start: '2000-01-01',
         end: moment().format("YYYY-MM-DD"),
       }
       this.getAppCount(param);
@@ -251,7 +263,7 @@ export default {
             maxv = item.count;
           }
           item.percentage = (item.count/maxv*100).toFixed(1);
-          let str = { name: item.name, count: item.count, percentage: item.percentage }
+          let str = { name: item.name.trim() == '' ? '其他' : item.name, count: item.count, percentage: item.percentage }
           that.hotApps.push(str);
         });
         //  console.log(that.hotApps);
@@ -267,7 +279,9 @@ export default {
     },
     //获取应用统计Charts图表
     getCountAppInfo(){
-      countAppInfo(this.datetimeValue[0],this.datetimeValue[1],this.selectedAppRange).then((res) => {
+      let start = moment(this.datetimeValue[0]).format("YYYY-MM-DD 00:00:00")
+      let end = moment(this.datetimeValue[1]).format("YYYY-MM-DD 23:59:59")
+      countAppInfo(start,end,this.selectedAppRange).then((res) => {
         // console.log(res);
         this.drawLineChart(res);
       })

+ 1 - 16
src/views/yygl/overview/index.vue

@@ -28,21 +28,6 @@
                 </el-radio-group>
             </div>
         </div>
-
-        <!-- 应用范围过滤 -->
-        <div class="filter-tabs">
-          <el-radio-group
-            v-model="activeTab"
-            size="medium"
-            @change="handleTabChange"
-            v-for="item in levelOptions"
-            :key="item.value"
-          >
-            <el-radio-button :label="item.label">{{ item.value }}</el-radio-button>
-            <!-- <el-radio-button label="1">区级</el-radio-button>
-                    <el-radio-button label="2">街镇</el-radio-button> -->
-          </el-radio-group>
-        </div>
     
       <!-- 应用卡片网格 -->
       <div class="app-content">
@@ -231,7 +216,7 @@ export default {
 /* 右侧主内容区 */
 .main-content {
   flex: 1;
-  padding: 20px 30px;
+  padding: 5px 30px;
   overflow-y: auto;
 }