录音时长统计
This commit is contained in:
@@ -136,8 +136,8 @@ export default {
|
||||
timeRangeOptions: ['1个月', '3个月', '6个月'],
|
||||
timeRangeIndex: 0, // 默认选择1个月
|
||||
showTimeRangeDropdown: false, // 控制下拉菜单显示
|
||||
totalDuration: '0 小时',
|
||||
todayDuration: '0 小时',
|
||||
totalDuration: '0 分钟',
|
||||
todayDuration: '0 分钟',
|
||||
dataList: [],
|
||||
loading: false
|
||||
}
|
||||
@@ -259,12 +259,11 @@ export default {
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 格式化时长(分钟转小时)
|
||||
* 格式化时长(显示为分钟)
|
||||
*/
|
||||
formatDuration(minutes) {
|
||||
if (!minutes || minutes === 0) return '0 小时';
|
||||
const hours = (minutes / 60).toFixed(1);
|
||||
return `${hours} 小时`;
|
||||
if (!minutes || minutes === 0) return '0 分钟';
|
||||
return `${minutes} 分钟`;
|
||||
},
|
||||
/**
|
||||
* 格式化日期
|
||||
@@ -353,8 +352,11 @@ export default {
|
||||
if (res.statusCode === 200 && res.data) {
|
||||
const result = res.data;
|
||||
|
||||
// 检查返回结果(根据项目中的返回结构)
|
||||
if (!result.success) {
|
||||
// 检查返回结果(支持两种格式:success 或 code)
|
||||
// code: 0 表示成功,code: 200 也表示成功
|
||||
const isSuccess = result.success === true || result.code === 0 || result.code === 200;
|
||||
|
||||
if (!isSuccess) {
|
||||
const errorMsg = result.msg || result.message || '查询失败';
|
||||
uni.showToast({
|
||||
title: errorMsg,
|
||||
@@ -369,6 +371,7 @@ export default {
|
||||
const statisticsList = result.data || [];
|
||||
|
||||
console.log('[RecordingDuration] 返回数据:', statisticsList);
|
||||
console.log('[RecordingDuration] 返回结果:', result);
|
||||
|
||||
// 处理统计数据
|
||||
this.processStatisticsData(statisticsList);
|
||||
@@ -402,32 +405,31 @@ export default {
|
||||
processStatisticsData(statisticsList) {
|
||||
if (!statisticsList || statisticsList.length === 0) {
|
||||
// 没有数据时重置显示
|
||||
this.totalDuration = '0 小时';
|
||||
this.todayDuration = '0 小时';
|
||||
this.totalDuration = '0 分钟';
|
||||
this.todayDuration = '0 分钟';
|
||||
this.dataList = [];
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算总录音时长和总录音数量
|
||||
let totalDurationMinutes = 0;
|
||||
let totalRecordingCount = 0;
|
||||
// 注意:salesTotalDuration 是销售人员在所有门店的总时长(所有记录的值都相同)
|
||||
// 所以应该使用第一条记录的 salesTotalDuration 作为总时长,而不是累加
|
||||
const firstItem = statisticsList[0];
|
||||
const totalDurationMinutes = firstItem.salesTotalDuration || 0;
|
||||
|
||||
// 构建数据列表
|
||||
// 构建数据列表(展示每个门店的统计数据)
|
||||
const formattedList = statisticsList.map(item => {
|
||||
// 累计总时长(使用销售人员录音总时长)
|
||||
const salesDuration = item.salesTotalDuration || 0;
|
||||
totalDurationMinutes += salesDuration;
|
||||
totalRecordingCount += (item.salesRecordingCount || 0);
|
||||
// 使用门店录音总时长作为该条记录的时长
|
||||
const dealershipDuration = item.dealershipTotalDuration || 0;
|
||||
|
||||
// 格式化日期
|
||||
const date = this.formatDate(item.statisticsDate);
|
||||
|
||||
// 构建描述信息
|
||||
// 构建描述信息(显示门店名称和日期)
|
||||
let description = '';
|
||||
if (item.salesName) {
|
||||
if (item.dealershipName) {
|
||||
description = `${item.dealershipName}`;
|
||||
} else if (item.salesName) {
|
||||
description = `${item.salesName}的录音`;
|
||||
} else if (item.dealershipName) {
|
||||
description = `${item.dealershipName}的录音`;
|
||||
} else {
|
||||
description = '录音统计';
|
||||
}
|
||||
@@ -435,7 +437,7 @@ export default {
|
||||
return {
|
||||
date: date,
|
||||
description: description,
|
||||
duration: this.formatDuration(salesDuration),
|
||||
duration: this.formatDuration(dealershipDuration),
|
||||
// 保存原始数据,方便后续使用
|
||||
rawData: item
|
||||
};
|
||||
@@ -461,15 +463,17 @@ export default {
|
||||
});
|
||||
|
||||
if (todayItem) {
|
||||
this.todayDuration = this.formatDuration(todayItem.salesTotalDuration || 0);
|
||||
// 今日时长使用该日期的门店录音总时长
|
||||
this.todayDuration = this.formatDuration(todayItem.dealershipTotalDuration || 0);
|
||||
} else {
|
||||
this.todayDuration = '0 小时';
|
||||
this.todayDuration = '0 分钟';
|
||||
}
|
||||
|
||||
console.log('[RecordingDuration] 数据处理完成:', {
|
||||
totalDuration: this.totalDuration,
|
||||
todayDuration: this.todayDuration,
|
||||
dataListCount: this.dataList.length
|
||||
dataListCount: this.dataList.length,
|
||||
statisticsListLength: statisticsList.length
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user