11wqe1 3 months ago
parent
commit
5ceb3bdb92
1 changed files with 39 additions and 2 deletions
  1. 39 2
      src/components/works.vue

+ 39 - 2
src/components/works.vue

@@ -649,7 +649,7 @@
                             }}</span>
                           </div>
-                          <div>提交时间:{{ l.time }}</div>
+                          <div>作业提交时间:{{ workTime(k.toolEList) }}</div>
                         </div>
 
                         <!-- 作业评分 -->
@@ -728,7 +728,7 @@
                             }}</span>
                           </div>
-                          <div>提交时间:{{ l.time }}</div>
+                          <div>作业提交时间:{{ workTime(k.toolEList) }}</div>
                         </div>
 
                         <!-- 作业评分 -->
@@ -1346,9 +1346,46 @@ export default {
 
         return (new1 / data.length).toFixed(1);
       };
+    },
+    workTime(){
+      return function(val) {
+        if (!val.length) return ''
+        let TimeList = []
+        val.forEach(e=>{
+          if (e.time) {
+            const timestamp = new Date(e.time).getTime();
+            TimeList.push(timestamp)
+          }
+        })
+
+        console.log('TimeList',TimeList);
+        TimeList.sort(function(a,b){
+          return a-b;//从小到大排序
+        })
+
+
+        return this.convertToTimestamp(TimeList[0]);
+      };
     }
   },
   methods: {
+    // 时间戳转时间
+    convertToTimestamp(val) {
+      const date = new Date(val);
+
+      // 使用Date对象的方法获取年、月、日、时、分、秒
+      const year = date.getFullYear();
+      const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1
+      const day = String(date.getDate()).padStart(2, '0');
+      const hours = String(date.getHours()).padStart(2, '0');
+      const minutes = String(date.getMinutes()).padStart(2, '0');
+      const seconds = String(date.getSeconds()).padStart(2, '0');
+
+      // 格式化后的日期时间字符串
+      const formattedDateTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+      
+      return formattedDateTime
+    },
     handleOpen(key, keyPath) {
       console.log(key, keyPath);
     },