录音时长统计
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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -51,8 +51,8 @@ const _sfc_main = {
|
||||
// 默认选择1个月
|
||||
showTimeRangeDropdown: false,
|
||||
// 控制下拉菜单显示
|
||||
totalDuration: "0 小时",
|
||||
todayDuration: "0 小时",
|
||||
totalDuration: "0 分钟",
|
||||
todayDuration: "0 分钟",
|
||||
dataList: [],
|
||||
loading: false
|
||||
};
|
||||
@@ -155,13 +155,12 @@ const _sfc_main = {
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 格式化时长(分钟转小时)
|
||||
* 格式化时长(显示为分钟)
|
||||
*/
|
||||
formatDuration(minutes) {
|
||||
if (!minutes || minutes === 0)
|
||||
return "0 小时";
|
||||
const hours = (minutes / 60).toFixed(1);
|
||||
return `${hours} 小时`;
|
||||
return "0 分钟";
|
||||
return `${minutes} 分钟`;
|
||||
},
|
||||
/**
|
||||
* 格式化日期
|
||||
@@ -212,8 +211,8 @@ const _sfc_main = {
|
||||
const queryString = Object.keys(queryParams).filter((key) => queryParams[key] !== null && queryParams[key] !== void 0 && queryParams[key] !== "").map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(queryParams[key])}`).join("&");
|
||||
const baseUrl = common_config.getApiUrl("/api/audio-statistics/sales");
|
||||
const url = queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:338", "[RecordingDuration] 请求参数:", queryParams);
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:339", "[RecordingDuration] 请求URL:", url);
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:337", "[RecordingDuration] 请求参数:", queryParams);
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:338", "[RecordingDuration] 请求URL:", url);
|
||||
common_vendor.index.showLoading({
|
||||
title: "加载中...",
|
||||
mask: true
|
||||
@@ -222,7 +221,8 @@ const _sfc_main = {
|
||||
common_vendor.index.hideLoading();
|
||||
if (res.statusCode === 200 && res.data) {
|
||||
const result = res.data;
|
||||
if (!result.success) {
|
||||
const isSuccess = result.success === true || result.code === 0 || result.code === 200;
|
||||
if (!isSuccess) {
|
||||
const errorMsg = result.msg || result.message || "查询失败";
|
||||
common_vendor.index.showToast({
|
||||
title: errorMsg,
|
||||
@@ -233,7 +233,8 @@ const _sfc_main = {
|
||||
return;
|
||||
}
|
||||
const statisticsList = result.data || [];
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:371", "[RecordingDuration] 返回数据:", statisticsList);
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:373", "[RecordingDuration] 返回数据:", statisticsList);
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:374", "[RecordingDuration] 返回结果:", result);
|
||||
this.processStatisticsData(statisticsList);
|
||||
common_vendor.index.showToast({
|
||||
title: "刷新成功",
|
||||
@@ -245,7 +246,7 @@ const _sfc_main = {
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:389", "[RecordingDuration] 加载数据失败:", error);
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:392", "[RecordingDuration] 加载数据失败:", error);
|
||||
common_vendor.index.showToast({
|
||||
title: error.message || "加载失败,请重试",
|
||||
icon: "none",
|
||||
@@ -260,30 +261,28 @@ const _sfc_main = {
|
||||
*/
|
||||
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;
|
||||
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 = "录音统计";
|
||||
}
|
||||
return {
|
||||
date,
|
||||
description,
|
||||
duration: this.formatDuration(salesDuration),
|
||||
duration: this.formatDuration(dealershipDuration),
|
||||
// 保存原始数据,方便后续使用
|
||||
rawData: item
|
||||
};
|
||||
@@ -304,14 +303,15 @@ const _sfc_main = {
|
||||
return itemDate === todayStr;
|
||||
});
|
||||
if (todayItem) {
|
||||
this.todayDuration = this.formatDuration(todayItem.salesTotalDuration || 0);
|
||||
this.todayDuration = this.formatDuration(todayItem.dealershipTotalDuration || 0);
|
||||
} else {
|
||||
this.todayDuration = "0 小时";
|
||||
this.todayDuration = "0 分钟";
|
||||
}
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:469", "[RecordingDuration] 数据处理完成:", {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:472", "[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