Ver Fonte

pms 格式化任务计划 开始时间 结束时间

zhangcl há 4 semanas atrás
pai
commit
2563a56a5f
1 ficheiros alterados com 21 adições e 26 exclusões
  1. 21 26
      src/views/pms/iotprojecttask/index.vue

+ 21 - 26
src/views/pms/iotprojecttask/index.vue

@@ -197,7 +197,8 @@
             v-model="scope.row.startTime"
             type="datetime"
             placeholder="选择开始时间"
-            value-format="YYYY-MM-DD HH:mm:ss"
+            value-format="YYYY-MM-DD HH:mm"
+            format="YYYY-MM-DD HH:mm"
             class="w-full"
           />
         </template>
@@ -208,7 +209,8 @@
             v-model="scope.row.endTime"
             type="datetime"
             placeholder="选择结束时间"
-            value-format="YYYY-MM-DD HH:mm:ss"
+            value-format="YYYY-MM-DD HH:mm"
+            format="YYYY-MM-DD HH:mm"
             class="w-full"
             v-if="rowShowEndTime(scope.row)"
           />
@@ -240,9 +242,6 @@ import { dateFormatter } from '@/utils/formatTime'
 import download from '@/utils/download'
 import { IotProjectTaskScheduleApi } from '@/api/pms/iotprojecttaskschedule'
 import { IotProjectTaskApi, IotProjectTaskVO} from '@/api/pms/iotprojecttask'
-import IotProjectTaskForm from './IotProjectTaskForm.vue'
-import * as DictDataApi from '@/api/system/dict/dict.data'
-import { DictDataVO } from '@/api/system/dict/dict.data'
 import dayjs from 'dayjs'
 import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
 import { ref, reactive, onMounted, computed, nextTick, watch, onUnmounted } from 'vue'
@@ -355,9 +354,23 @@ const getTechnologyDictOptions = async () => {
 }
 
 /** 时间戳转换为日期时间字符串(使用dayjs处理) */
-const timestampToDateTime = (timestamp: number | null): string => {
-  if (!timestamp) return ''
-  return dayjs(timestamp).format('YYYY-MM-DD HH:mm:ss')
+const timestampToDateTime = (timestamp: number | string | null | undefined): string => {
+  if (timestamp === null || timestamp === undefined || timestamp === '') {
+    return '';
+  }
+  // 转换为数字
+  let ts = typeof timestamp === 'string' ? parseInt(timestamp) : timestamp;
+
+  // 检查是否为有效数字
+  if (isNaN(ts)) {
+    console.warn('无效的时间戳:', timestamp);
+    return '';
+  }
+  // 如果时间戳是秒级,转换为毫秒级
+  if (ts < 1000000000000) {
+    ts *= 1000;
+  }
+  return dayjs(ts).format('YYYY-MM-DD HH:mm')
 }
 
 /** 获取施工进度字典数据 */
@@ -370,24 +383,6 @@ const getWorkProgressDictOptions = async () => {
   }
 }
 
-/** 时间戳转换为日期时间字符串(修正时区问题)
-const timestampToDateTime = (timestamp: number | null): string => {
-  if (!timestamp) return ''
-
-  // 直接使用时间戳创建Date对象
-  const date = new Date(timestamp)
-
-  // 使用UTC方法获取日期时间组件,避免时区影响
-  const year = date.getUTCFullYear()
-  const month = String(date.getUTCMonth() + 1).padStart(2, '0')
-  const day = String(date.getUTCDate()).padStart(2, '0')
-  const hours = String(date.getUTCHours()).padStart(2, '0')
-  const minutes = String(date.getUTCMinutes()).padStart(2, '0')
-  const seconds = String(date.getUTCSeconds()).padStart(2, '0')
-
-  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
-} */
-
 /** 打开计划对话框 */
 const openPlanDialog = async (row: IotProjectTaskVO) => {
   currentRow.value = row