浏览代码

修改时间选择器组件

zhuliu 2 年之前
父节点
当前提交
5e48c6157c

+ 4 - 0
src/router/index.js

@@ -10,6 +10,10 @@ VueRouter.prototype.push = function push(location) {
 }
 const routes = [
   {
+    path: "/route",
+    component: () => import('@/utils/model/route.vue'),
+  },
+  {
     path: "/",
     component: () => import('@/views/index'),
   },

+ 0 - 0
src/utils/model/route.vue


+ 19 - 19
src/utils/model/time/mixins.js

@@ -10,9 +10,9 @@ export const cron = {
             let h = "";
             let date = new Date();
             if (date) {
-              h = date.getHours();
-              m = date.getMinutes();
-              s = date.getSeconds();
+              h = date.getHours()< 10 ? ("0" + date.getHours()) : date.getHours();
+              m = date.getMinutes()< 10 ? ("0" + date.getMinutes()) : date.getMinutes();
+              s = date.getSeconds()< 10 ? ("0" + date.getSeconds()) : date.getSeconds();
           }
           this.$set(this,'value',h+':'+m+':'+s)
             cron = s + " " + m + " " + h + " * * ? *";
@@ -58,9 +58,9 @@ export const cron = {
           this.$set(this,'day',en2cnMap[value1])
           let date = new Date();
           if (date) {
-            h = date.getHours();
-            m = date.getMinutes();
-            s = date.getSeconds();
+            h = date.getHours()< 10 ? ("0" + date.getHours()) : date.getHours();
+            m = date.getMinutes()< 10 ? ("0" + date.getMinutes()) : date.getMinutes();
+            s = date.getSeconds()< 10 ? ("0" + date.getSeconds()) : date.getSeconds();
           }
           this.$set(this, 'time', (h < 10 ? ("0" + h) : h )+ ':' + (m < 10 ? ("0" + m) : m) + ':' + (s < 10 ? ("0" + s) : s))
           this.$set(this, 'value', this.day + " " + this.time)
@@ -74,9 +74,9 @@ export const cron = {
           var date = new Date();
           if (date) {
             mo = date.getDate() 
-            h = date.getHours();
-            m = date.getMinutes();
-            s = date.getSeconds();
+            h = date.getHours()< 10 ? ("0" + date.getHours()) : date.getHours();
+            m = date.getMinutes()< 10 ? ("0" + date.getMinutes()) : date.getMinutes();
+            s = date.getSeconds()< 10 ? ("0" + date.getSeconds()) : date.getSeconds();
           }
           this.$set(this,'day',mo+'日')
           this.$set(this, 'time', (h < 10 ? ("0" + h) : h )+ ':' + (m < 10 ? ("0" + m) : m) + ':' + (s < 10 ? ("0" + s) : s))
@@ -93,12 +93,12 @@ export const cron = {
 
           var date = new Date();
           if (date) {
-            h = date.getHours();
-            m = date.getMinutes();
-            s = date.getSeconds();
+            h = date.getHours()< 10 ? ("0" + date.getHours()) : date.getHours();
+            m = date.getMinutes()< 10 ? ("0" + date.getMinutes()) : date.getMinutes();
+            s = date.getSeconds()< 10 ? ("0" + date.getSeconds()) : date.getSeconds();
             year = date.getFullYear();
-            month =date.getMonth() + 1 
-            day = date.getDate() 
+            month = (date.getMonth() + 1 )< 10 ? ("0" + (date.getMonth() + 1 )) : (date.getMonth() + 1 )
+            day = date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate()
           }
           this.$set(this,'value',date)
           cron =
@@ -193,12 +193,12 @@ export const cron = {
                 var date = this.value;
                 date = new Date(date);
                 if (date) {
-                  h = date.getHours();
-                  m = date.getMinutes();
-                  s = date.getSeconds();
+                  h = date.getHours()< 10 ? ("0" + date.getHours()) : date.getHours();
+                  m = date.getMinutes()< 10 ? ("0" + date.getMinutes()) : date.getMinutes();
+                  s = date.getSeconds()< 10 ? ("0" + date.getSeconds()) : date.getSeconds();
                   year = date.getFullYear();
-                  month = date.getMonth() + 1 
-                  day = date.getDate()
+                  month = (date.getMonth() + 1 )< 10 ? ("0" + (date.getMonth() + 1 )) : (date.getMonth() + 1 )
+                  day = date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate()
                 }
                 cron =
                   s +

+ 1 - 1
src/utils/model/time/timeChoose.vue

@@ -97,7 +97,7 @@ export default {
         case 'year':
                 break;
       }
-      if (!this.cron && this.type) {
+      if (this.type) {
         let cron = this.getCron(this.type)
         this.$emit('value', cron)
       } else if(this.cron && this.type){

+ 1 - 1
src/views/layout/components/UserBar.vue

@@ -170,7 +170,7 @@ export default {
         },
         {
           value:'8',
-          label:'任务',
+          label:'我的任务',
           path:'/rTaskList',
         },
       ],

+ 6 - 6
src/views/workspace/components/common/mixins.js

@@ -193,12 +193,12 @@ export const cron = {
                 var date = this.value;
                 date = new Date(date);
                 if (date) {
-                  h = date.getHours();
-                  m = date.getMinutes();
-                  s = date.getSeconds();
+                  h = date.getHours()< 10 ? ("0" + date.getHours()) : date.getHours();
+                  m = date.getMinutes()< 10 ? ("0" + date.getMinutes()) : date.getMinutes();
+                  s = date.getSeconds()< 10 ? ("0" + date.getSeconds()) : date.getSeconds();
                   year = date.getFullYear();
-                  month = date.getMonth() + 1 
-                  day = date.getDate()
+                  month = (date.getMonth() + 1 )< 10 ? ("0" + (date.getMonth() + 1 )) : (date.getMonth() + 1 )
+                  day = date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate()
                 }
                 cron =
                   s +
@@ -295,7 +295,7 @@ export const cron = {
              var m = date[1];
              var s = date[2];
             this.$set(this, 'time', (h < 10 ? ("0" + h) : h )+ ':' + (m < 10 ? ("0" + m) : m) + ':' + (s < 10 ? ("0" + s) : s))
-            this.$set(this, 'day', toDate.loopValue)
+            this.$set(this, 'day',  new Date(toDate.loopValue).getDay())
             this.$set(this,'value',this.day+" "+this.time)
           } else if (toDate.loopType == "月循环") {
             date = date.split(' ')[1].split(":")

+ 1 - 1
src/views/workspace/components/common/timeChoose.vue

@@ -98,7 +98,7 @@ export default {
         case 'year':
                 break;
       }
-      if (!this.cron && this.type) {
+      if (this.type) {
         let cron = this.getCron(this.type)
         this.$emit('value', cron)
       } else if(this.cron && this.type){