服务列表显示补充内容
This commit is contained in:
@@ -42,11 +42,25 @@
|
||||
</view>
|
||||
<view class="service-meta">
|
||||
<text class="service-date">{{ item.date }}</text>
|
||||
<text
|
||||
class="service-duration"
|
||||
v-if="durationPresent(item.duration)">
|
||||
录音时长:{{ formatRecordingMinutes(item.duration) }} 分钟
|
||||
</text>
|
||||
<text
|
||||
class="service-duration"
|
||||
v-if="getRecordingFileExtension(item)">
|
||||
格式:{{ getRecordingFileExtension(item) }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="service-recording-name" v-if="item.recordingName">
|
||||
<text class="recording-name-label">记录名称:</text>
|
||||
<text class="recording-name-value">{{ item.recordingName }}</text>
|
||||
</view>
|
||||
<view class="service-recording-text" v-if="getRecordingText(item)">
|
||||
<text class="recording-text-label">录音文本:</text>
|
||||
<view class="recording-text-body">{{ getRecordingText(item) }}</view>
|
||||
</view>
|
||||
<view class="service-content">
|
||||
<text class="service-desc">{{ item.description }}</text>
|
||||
</view>
|
||||
@@ -113,6 +127,43 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
durationPresent(val) {
|
||||
if (val === null || val === undefined || val === '') return false;
|
||||
const n = Number(val);
|
||||
return !Number.isNaN(n) && n >= 0;
|
||||
},
|
||||
/** 后端 duration 为分钟(可小数),页面原样按分钟展示,最多保留两位小数 */
|
||||
formatRecordingMinutes(minutes) {
|
||||
const n = Number(minutes);
|
||||
if (Number.isNaN(n) || n < 0) return '0';
|
||||
return String(parseFloat(n.toFixed(2)));
|
||||
},
|
||||
formatFileExtension(ext) {
|
||||
if (ext == null || ext === '') return '';
|
||||
const s = String(ext).trim();
|
||||
if (!s) return '';
|
||||
return s.startsWith('.') ? s.slice(1) : s;
|
||||
},
|
||||
getRecordingFileExtension(item) {
|
||||
const raw = item.rawData || {};
|
||||
const fromField = this.formatFileExtension(item.audioFileExtension ?? raw.audioFileExtension);
|
||||
if (fromField) return fromField;
|
||||
const name = raw.audioFileOriginalName;
|
||||
if (name && typeof name === 'string') {
|
||||
const idx = name.lastIndexOf('.');
|
||||
if (idx !== -1 && idx < name.length - 1) {
|
||||
return name.slice(idx + 1).trim().toLowerCase();
|
||||
}
|
||||
}
|
||||
return '';
|
||||
},
|
||||
getRecordingText(item) {
|
||||
const raw = item.rawData || {};
|
||||
const t = item.recordingText ?? raw.recordingText;
|
||||
if (t == null || t === '') return '';
|
||||
const s = String(t).trim();
|
||||
return s;
|
||||
},
|
||||
onInputChange() {
|
||||
// 输入框变化时,可以在这里添加实时搜索逻辑(如果需要)
|
||||
},
|
||||
@@ -226,11 +277,14 @@
|
||||
|
||||
// 如果返回了更新后的数据,通知父组件更新列表项
|
||||
if (res.data.data) {
|
||||
// 构建更新后的item数据
|
||||
const d = res.data.data;
|
||||
const updatedItem = {
|
||||
...item,
|
||||
rawData: res.data.data,
|
||||
description: res.data.data.summary || item.description
|
||||
rawData: d,
|
||||
description: d.summary || item.description,
|
||||
duration: d.duration != null ? d.duration : item.duration,
|
||||
audioFileExtension: d.audioFileExtension != null ? d.audioFileExtension : item.audioFileExtension,
|
||||
recordingText: d.recordingText != null ? d.recordingText : item.recordingText
|
||||
};
|
||||
|
||||
// 通知父组件更新该项
|
||||
@@ -488,6 +542,29 @@
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.service-recording-text {
|
||||
margin-bottom: 16rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.recording-text-label {
|
||||
color: #999;
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.recording-text-body {
|
||||
color: #333;
|
||||
line-height: 1.5;
|
||||
word-break: break-word;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
line-clamp: 2;
|
||||
}
|
||||
|
||||
.service-content {
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
@@ -2424,6 +2424,14 @@
|
||||
if (res.statusCode === 200 && res.data && res.data.success) {
|
||||
// 转换后端数据为页面需要的格式
|
||||
const mappedList = res.data.data.map(item => {
|
||||
const extensionFromName = () => {
|
||||
const n = item.audioFileOriginalName;
|
||||
if (n && typeof n === 'string') {
|
||||
const i = n.lastIndexOf('.');
|
||||
if (i !== -1 && i < n.length - 1) return n.slice(i + 1);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
// 格式化时间:将 ISO 格式转换为 YYYY-MM-DD HH:mm:ss
|
||||
let formattedTime = '';
|
||||
if (item.createTime) {
|
||||
@@ -2444,6 +2452,11 @@
|
||||
description: item.summary || '',
|
||||
customerName: item.customerName || '',
|
||||
recordingName: item.recordingName || '', // 记录名称
|
||||
duration: item.duration,
|
||||
audioFileExtension: item.audioFileExtension != null && item.audioFileExtension !== ''
|
||||
? item.audioFileExtension
|
||||
: extensionFromName(),
|
||||
recordingText: item.recordingText || '',
|
||||
// 保留原始数据,用于详情页
|
||||
rawData: item
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user