liyongyong 1 anno fa
parent
commit
25fd3b02c4
3 ha cambiato i file con 35 aggiunte e 13 eliminazioni
  1. 1 1
      manpower/index.html
  2. 22 12
      manpower/js/index.js
  3. 12 0
      manpower/js/request.js

+ 1 - 1
manpower/index.html

@@ -24,7 +24,7 @@
     <div id="app">
       <header class="my-header">
         <span>数智人力&nbsp;&nbsp;智慧山西</span>
-        <span class="right">2023-1-16 10:23:00</span>
+        <span class="right">{{time}}</span>
       </header>
       <div class="main">
         <div class="left">

+ 22 - 12
manpower/js/index.js

@@ -4,6 +4,7 @@ let app = new Vue({
   el: '#app',
   data() {
     return {
+      time: '',
       year: '2022',
       config1: {
         number: [100],
@@ -127,6 +128,10 @@ let app = new Vue({
     }
   },
   mounted() {
+    this.time = formatDate()
+    this.timer = setInterval(()=> {
+      this.time = formatDate()
+    },1000)
     this.centerData = data
     // 左侧图表
     this.initChartL1()
@@ -150,6 +155,11 @@ let app = new Vue({
     this.initChartR7()
     this.initChartR8()
   },
+  beforeDestroy() {
+    if (this.timer) {
+      clearInterval(this.timer);
+    }
+  },
   methods: {
     numFormat(value) {
       if (!value) return '0'
@@ -626,18 +636,18 @@ let app = new Vue({
             },
             markLine: {
               data: [
-                // {
-                //   name: '省属企业平均水平(万/人)',
-                //   yAxis: 50.13,
-                //   lineStyle: {
-                //     color: '#fff',
-                //   },
-                //   label: {
-                //     formatter: '{b}',
-                //     position: 'middle',
-                //     color: '#fff',
-                //   },
-                // },
+                {
+                  name: '省属企业平均水平(万/人)',
+                  yAxis: 50.13,
+                  lineStyle: {
+                    color: '#fff',
+                  },
+                  label: {
+                    formatter: '{b}',
+                    position: 'end',
+                    color: '#fff',
+                  },
+                },
                 {
                   name: '央企平均水平(万/人)',
                   yAxis: 69.4,

+ 12 - 0
manpower/js/request.js

@@ -177,3 +177,15 @@ function stringify(data) {
   ret = ret.substring(0, ret.lastIndexOf('&'))
   return ret
 }
+
+// 格式化日期
+function formatDate(time) {
+  let date = time ? new Date(Number(time)) : new Date();
+  let Y = date.getFullYear() + '-';
+  let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
+  let D = date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' ';
+  let h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':';
+  let m = date.getMinutes() < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':';
+  let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
+  return Y + M + D + h + m + s;
+}