Browse Source

解决 IOS 下 按钮不显示的问题

zhulu 1 year ago
parent
commit
a99a33af40
3 changed files with 25 additions and 10 deletions
  1. 15 0
      src/utils/date.js
  2. 5 5
      src/views/menu/rehearsalTask/index.vue
  3. 5 5
      src/views/menu/training/index.vue

+ 15 - 0
src/utils/date.js

@@ -87,3 +87,18 @@ export function durationText (minutes){
 
   return text
 }
+
+export function compatibleWithIOSStringToDate(dateStr)
+{
+  if(!dateStr)
+  {
+    return new Date(null);
+  }
+  dateStr = JSON.parse(JSON.stringify(dateStr))
+  let formatDateStr=dateStr.replace(/-/g,"/");
+  let date = Date.parse(new Date(dateStr))
+  if(!date){
+    date = Date.parse(new Date(formatDateStr));
+  }
+  return date
+}

+ 5 - 5
src/views/menu/rehearsalTask/index.vue

@@ -137,7 +137,7 @@ import { getdrillTask, getsignUserList } from '@/api/drillTask.js'
 
 import { Toast } from 'vant'
 import OrgTree from '@/components/orgTree'
-import { newDateMonth } from '@/utils/date.js'
+import { newDateMonth,compatibleWithIOSStringToDate } from '@/utils/date.js'
 export default {
   data() {
     return {
@@ -244,8 +244,8 @@ export default {
       //当前时间再时间范围内且签名是待签名状态且签名列表存在当前登录人未签名的情况才可以进行签名
       if (list.startDate && list.endDate && list.status == 1) {
         let date = new Date().getTime()
-        let startDate = Date.parse(new Date(list.startDate))
-        let endDate = Date.parse(new Date(list.endDate))
+        let startDate =compatibleWithIOSStringToDate(list.startDate);// Date.parse(new Date(list.startDate))
+        let endDate =compatibleWithIOSStringToDate(list.endDate);// Date.parse(new Date(list.endDate))
 
         if (date >= startDate && date <= endDate) {
           console.log(list.id, 'ssss')
@@ -292,8 +292,8 @@ export default {
       let timefalg = false
       //value1 当前登陆用户ID
       let date = new Date().getTime()
-      let startDate = Date.parse(new Date(list.startDate))
-      let endDate = Date.parse(new Date(list.endDate))
+      let startDate =compatibleWithIOSStringToDate(list.startDate);// Date.parse(new Date(list.startDate))
+      let endDate =compatibleWithIOSStringToDate(list.endDate);// Date.parse(new Date(list.endDate))
       //任务处于待记录状态,且任务在规定完成时间范围内,登录人所在机构和角色与任务培训角色、培训机构一致才显示
 
       if (

+ 5 - 5
src/views/menu/training/index.vue

@@ -157,7 +157,7 @@ import { gettrainingList, getsignUserList } from '@/api/training.js'
 import { deptTreeList } from '@/api/toConsult.js'
 
 import OrgTree from '@/components/orgTree'
-import { newDateMonth } from '@/utils/date.js'
+import { newDateMonth,compatibleWithIOSStringToDate } from '@/utils/date.js'
 export default {
   data() {
     return {
@@ -248,8 +248,8 @@ export default {
       //当前时间再时间范围内且签名是待签名状态且签名列表存在当前登录人未签名的情况才可以进行签名
       if (list.startDate && list.endDate && list.status == 1) {
         let date = new Date().getTime()
-        let startDate = Date.parse(new Date(list.startDate))
-        let endDate = Date.parse(new Date(list.endDate))
+        let startDate =compatibleWithIOSStringToDate(list.startDate);// Date.parse(new Date(list.startDate))
+        let endDate =compatibleWithIOSStringToDate(list.endDate);// Date.parse(new Date(list.endDate))
 
         if (date >= startDate && date <= endDate) {
           console.log(list.id, 'ssss')
@@ -278,8 +278,8 @@ export default {
       let timefalg = false
       //value1 当前登陆用户ID
       let date = new Date().getTime()
-      let startDate = Date.parse(new Date(list.startDate))
-      let endDate = Date.parse(new Date(list.endDate))
+      let startDate =compatibleWithIOSStringToDate(list.startDate);// Date.parse(new Date(list.startDate))
+      let endDate =compatibleWithIOSStringToDate(list.endDate);// Date.parse(new Date(list.endDate))
       //任务处于待培训状态,且任务在规定完成时间范围内,登录人所在机构和与任务培训机构一致才显示
 
       if (list.startDate && list.endDate && (list.status == 0 || list.status == 4)) {