seimin 1 day ago
parent
commit
1f3524e4fd
2 changed files with 12 additions and 5 deletions
  1. 8 1
      src/main.js
  2. 4 4
      src/views/AppIndex.vue

+ 8 - 1
src/main.js

@@ -19,7 +19,14 @@ Vue.prototype.$moment = moment
19
 // 分钟转为时分
19
 // 分钟转为时分
20
 Vue.filter('formatHourMinute', (value) => {
20
 Vue.filter('formatHourMinute', (value) => {
21
   if (!value) return '0分'
21
   if (!value) return '0分'
22
-  return moment.utc(value * 60 * 1000).format('HH时mm分')
22
+  const duration = moment.duration(value, 'minutes')
23
+  const hours = Math.floor(duration.asHours())
24
+  const minutes = duration.minutes()
25
+  if (hours) {
26
+    return `${hours}时${minutes}分`
27
+  } else {
28
+    return `${minutes}分`
29
+  }
23
 })
30
 })
24
 
31
 
25
 Vue.config.productionTip = false
32
 Vue.config.productionTip = false

+ 4 - 4
src/views/AppIndex.vue

@@ -153,24 +153,24 @@ export default {
153
 
153
 
154
   },
154
   },
155
   provide () {
155
   provide () {
156
-    console.log('params', this.$route.params)
156
+    console.log('route', this.$route)
157
     let hosId, dutyId, parentDutyId
157
     let hosId, dutyId, parentDutyId
158
     if (this.$route.params.queryType === '1') {
158
     if (this.$route.params.queryType === '1') {
159
       hosId = undefined
159
       hosId = undefined
160
       dutyId = undefined
160
       dutyId = undefined
161
       parentDutyId = undefined
161
       parentDutyId = undefined
162
     } else if (this.$route.params.queryType === '2') {
162
     } else if (this.$route.params.queryType === '2') {
163
-      hosId = +this.$route.query.hosId
163
+      hosId = this.$route.query.hosId ? +this.$route.query.hosId : undefined
164
       dutyId = undefined
164
       dutyId = undefined
165
       parentDutyId = undefined
165
       parentDutyId = undefined
166
     } else if (this.$route.params.queryType === '3') {
166
     } else if (this.$route.params.queryType === '3') {
167
       hosId = undefined
167
       hosId = undefined
168
-      dutyId = +this.$route.query.dutyId
168
+      dutyId = this.$route.query.dutyId ? +this.$route.query.dutyId : undefined
169
       parentDutyId = undefined
169
       parentDutyId = undefined
170
     } else if (this.$route.params.queryType === '4') {
170
     } else if (this.$route.params.queryType === '4') {
171
       hosId = undefined
171
       hosId = undefined
172
       dutyId = undefined
172
       dutyId = undefined
173
-      parentDutyId = +this.$route.query.dutyId
173
+      parentDutyId = this.$route.query.dutyId ? +this.$route.query.dutyId : undefined
174
     }
174
     }
175
     console.log(parentDutyId, hosId, dutyId)
175
     console.log(parentDutyId, hosId, dutyId)
176
     return {
176
     return {