解决课程练习和考试记录的nan问题

This commit is contained in:
田岩
2025-11-05 14:09:48 +08:00
parent 88cdc408ff
commit 0ee6d73240
4 changed files with 24 additions and 24 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002'
# app入口
VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001'
#VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001'
# VITE_APP_BASE_API_Url = 'http://25.16.122.91:9786'
# VITE_APP_BASE_API_Url = 'http://25.18.122.66:9786'
@@ -40,7 +40,7 @@
</view>
<view class="list_small_item">
<image src="@/static/images/courseRecord/duration.png" class="icon_img"></image>
<view class="prompt">练习时长{{ formatDuration(item_list.exrStartTm, item_list.exrEndTm) }}</view>
<view class="prompt">练习时长{{ item_list.item_list || '--' }}</view>
</view>
</view>
<view class="fl1"></view>
@@ -61,7 +61,7 @@
import { computed, ref, reactive } from 'vue';
import common from '@/common/common';
import { queryPracticeHis } from '@/api/courseRecord.js';
import { useItemList, formatDuration } from '../useItemList.js';
import { useItemList } from '../useItemList.js';
const props = defineProps({
item: {
@@ -40,7 +40,7 @@
</view>
<view class="list_small_item">
<image src="@/static/images/courseRecord/duration.png" class="icon_img"></image>
<view class="prompt">学习时长{{ formatDuration(item_list.startTm, item_list.endTm) }}</view>
<view class="prompt">学习时长{{ item_list.item_list || '--' }}</view>
</view>
</view>
<view class="fl1"></view>
@@ -61,7 +61,7 @@
import { computed } from 'vue';
import common from '@/common/common';
import { queryStdyBatchByCrsId } from '@/api/courseRecord.js';
import { useItemList, formatDuration, secondsToHours } from '../useItemList.js';
import { useItemList, secondsToHours } from '../useItemList.js';
const props = defineProps({
item: {
type: Object,
+19 -19
View File
@@ -7,25 +7,25 @@ import {
// 计算两个标准时间的时间差值
export const formatDuration = (startTm, endTm) => {
if (endTm === null || startTm === null) return "00:00:00";
// 解析时间字符串为时间戳(毫秒)
const startTime = new Date(startTm).getTime();
const endTime = new Date(endTm).getTime();
// 计算时间差(秒),确保为正数
const seconds = Math.abs(Math.floor((endTime - startTime) / 1000));
// 计算时、分、秒
const hours = Math.floor(seconds / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
const remainingSeconds = seconds % 60;
// 补零格式化函数(统一处理所有单位)
const formatNumber = (num) => num.toString().padStart(2, '0');
// 小时、分钟、秒均保持两位数格式
return `${formatNumber(hours)}:${formatNumber(minutes)}:${formatNumber(remainingSeconds)}`;
};
// export const formatDuration = (startTm, endTm) => {
// if (endTm === null || startTm === null) return "00:00:00";
// // 解析时间字符串为时间戳(毫秒)
// const startTime = new Date(startTm).getTime();
// const endTime = new Date(endTm).getTime();
//
// // 计算时间差(秒),确保为正数
// const seconds = Math.abs(Math.floor((endTime - startTime) / 1000));
// // 计算时、分、秒
// const hours = Math.floor(seconds / 3600);
// const minutes = Math.floor((seconds % 3600) / 60);
// const remainingSeconds = seconds % 60;
//
// // 补零格式化函数(统一处理所有单位)
// const formatNumber = (num) => num.toString().padStart(2, '0');
//
// // 小时、分钟、秒均保持两位数格式
// return `${formatNumber(hours)}:${formatNumber(minutes)}:${formatNumber(remainingSeconds)}`;
// };
// 秒数转换成小时,带小数点的小时
export const secondsToHours = (seconds) => {