继续清理主包内的代码

This commit is contained in:
zhonghua.li
2026-04-15 09:08:05 +08:00
parent b37b9c6ada
commit 56c03a2e0e
4 changed files with 3 additions and 3 deletions

View File

@@ -1,457 +0,0 @@
<template>
<view class="customer-list-container">
<view class="service-status-toolbar">
<text class="toolbar-total">共{{ customerListTotal || list.length }}条</text>
<input
class="toolbar-input"
v-model="salesName"
placeholder="所属销售姓名"
placeholder-style="color: #b0b0b0"
confirm-type="search"
@confirm="handleRefresh"
@input="onInputChange"
/>
<input
class="toolbar-input"
v-model="customerName"
placeholder="客户姓名"
placeholder-style="color: #b0b0b0"
confirm-type="search"
@confirm="handleRefresh"
@input="onInputChange"
/>
<view class="toolbar-actions">
<view class="toolbar-btn toolbar-btn--refresh" @click="handleRefresh">
<uni-icons type="refresh" size="18" color="#2A68FF"></uni-icons>
<text>刷新</text>
</view>
</view>
</view>
<scroll-view class="customer-list" scroll-y>
<view
class="customer-card"
v-for="(item, index) in list"
:key="index"
@click.stop="$emit('itemClick', item)">
<view class="customer-header">
<text class="customer-name-text">{{ item.name }}</text>
<view class="intent-badge" :class="item.intent === '高' ? 'intent-high' : 'intent-medium'">
<text>意向{{ item.intent }}</text>
</view>
</view>
<view class="customer-service-info">
<text>服务人员:{{ item.serviceStaff }} 服务{{ item.serviceCount }}次 上次服务:{{ item.lastService }}</text>
</view>
<view class="customer-tags">
<view
class="tag-item"
:class="'tag-' + tag.color"
v-for="(tag, tagIndex) in item.tags"
:key="tagIndex">
<text>{{ tag.text }}</text>
</view>
</view>
<view class="customer-footer" v-if="item.phone || item.budget">
<text class="customer-phone" v-if="item.phone">{{ item.phone }}</text>
<text class="customer-budget" v-if="item.budget">{{ item.budget }}</text>
</view>
</view>
</scroll-view>
</view>
</template>
<script>
import { getApiUrl } from '@/common/config.js';
export default {
name: 'CustomerList',
props: {},
data() {
return {
salesName: '',
customerName: '',
customerList: [],
customerListTotal: 0,
customerListPage: {
current: 1,
size: 10
}
}
},
computed: {
list() {
return this.customerList;
}
},
mounted() {
// 组件挂载时自动加载数据
this.loadCustomerList();
},
methods: {
onInputChange() {
// 输入框变化时,可以在这里添加实时搜索逻辑(如果需要)
},
handleRefresh() {
// 刷新客户列表
this.refreshCustomerList({
salesName: this.salesName.trim(),
customerName: this.customerName.trim()
});
},
refreshCustomerList(filterParams = {}) {
// 重置分页到第一页
this.customerListPage.current = 1;
// 重新加载数据,传递查询参数
this.loadCustomerList(filterParams);
},
// 加载客户列表
async loadCustomerList(params = {}) {
try {
// 构建查询参数对象(后端使用 @RequestParam,参数需要作为 URL 查询参数传递)
const queryParams = {
current: this.customerListPage.current,
size: this.customerListPage.size
};
// 添加查询参数:客户姓名、所属销售姓名、销售电话、联系方式
const trimmedCustomerName = params.customerName?.trim();
const trimmedSalesName = params.salesName?.trim();
const trimmedSalesPhone = params.salesPhone?.trim();
const trimmedContact = params.contact?.trim();
if (trimmedCustomerName) {
queryParams.customerName = trimmedCustomerName;
}
if (trimmedSalesName) {
queryParams.salesName = trimmedSalesName;
}
if (trimmedSalesPhone) {
queryParams.salesPhone = trimmedSalesPhone;
}
if (trimmedContact) {
queryParams.contact = trimmedContact;
}
// 将参数转换为 URL 查询字符串(因为后端使用 @RequestParam)
const queryString = Object.keys(queryParams)
.filter(key => queryParams[key] !== null && queryParams[key] !== undefined && queryParams[key] !== '')
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(queryParams[key])}`)
.join('&');
// 调试:打印请求参数
console.log('客户列表查询参数:', JSON.stringify(queryParams));
console.log('查询字符串:', queryString);
// 后端使用 @GetMapping 和 @RequestParam,参数需要作为 URL 查询参数传递
const baseUrl = getApiUrl('/api/customerManagement/list');
const url = queryString ? `${baseUrl}?${queryString}` : baseUrl;
// 获取认证信息
let tenantId = '';
let token = '';
try {
tenantId = uni.getStorageSync('backend-tenant-id') || '';
token = uni.getStorageSync('backend-token') || '';
} catch (e) {
console.error('获取认证信息失败:', e);
}
// 构建请求头
const headers = {
'Content-Type': 'application/json'
};
if (token) {
headers['Authorization'] = `Bearer ${token}`;
}
if (tenantId) {
headers['X-Tenant-Id'] = tenantId;
}
const res = await uni.request({
url,
method: 'GET',
header: headers,
timeout: 10000
});
if (res.statusCode === 200 && res.data && res.data.success) {
// 转换后端客户数据为显示格式
const customerRecords = res.data.data || [];
// 将 CustomerManagement 数据映射为显示格式
const mappedList = customerRecords.map(item => {
// 格式化创建时间
let formattedTime = '';
if (item.createTime) {
const date = new Date(item.createTime);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
formattedTime = `${year}-${month}-${day}`;
}
// 构建标签数组(根据业务需求可以从不同字段提取)
const tags = [];
if (item.remark) {
// 从备注中提取标签信息
if (item.remark.includes('优惠') || item.remark.includes('活动')) {
tags.push({ text: '关注优惠活动', color: 'orange' });
}
if (item.remark.includes('颜色') || item.remark.includes('搭配')) {
tags.push({ text: '关注颜色搭配', color: 'orange' });
}
}
// 根据录音条数或联系次数判断意向程度
let intent = '中';
const recordingCount = item.recordingCount || 0;
const contactCount = item.contactCount || 0;
if (recordingCount > 3 || contactCount > 5) {
intent = '高';
}
return {
name: item.customerName || '',
intent: intent,
serviceStaff: item.salesName || '',
serviceCount: item.contactCount || item.recordingCount || 0,
lastService: formattedTime,
lastServiceTime: item.updateTime || item.createTime,
tags: tags,
phone: item.contact || item.salesPhone || '',
budget: item.intendedModel || '', // 意向车型作为预算信息
// 保留原始数据字段,方便后续使用
rawData: item
};
});
// 按更新时间倒序排序
mappedList.sort((a, b) => {
if (!a.lastServiceTime) return 1;
if (!b.lastServiceTime) return -1;
return new Date(b.lastServiceTime) - new Date(a.lastServiceTime);
});
// 分页:第一页或刷新时重置,其他情况追加
if (this.customerListPage.current === 1) {
this.customerList = mappedList;
} else {
this.customerList = this.customerList.concat(mappedList);
}
this.customerListTotal = res.data.total || mappedList.length;
} else {
uni.showToast({
title: res.data.message || '获取客户列表失败',
icon: 'none'
});
}
} catch (error) {
console.error('获取客户列表失败:', error);
uni.showToast({
title: `获取客户列表失败: ${error.errMsg || error.message || '未知错误'}`,
icon: 'none',
duration: 3000
});
}
}
}
}
</script>
<style scoped>
.customer-list-container {
/* 使用绝对定位,从tab页底部开始,到底部导航栏结束 */
position: absolute;
top: 0; /* top值通过父组件的内联样式动态设置 */
left: 0;
right: 0;
bottom: 96rpx; /* 底部导航栏高度 */
display: flex;
flex-direction: column;
background-color: #F5F5F5;
padding: 0 16rpx; /* 移除顶部padding,只保留左右padding,让toolbar紧贴tab */
box-sizing: border-box;
}
.service-status-toolbar {
display: flex;
flex-wrap: nowrap;
align-items: center;
gap: 8rpx;
padding: 12rpx 8rpx;
margin-bottom: 24rpx; /* 与列表项间距保持一致(24rpx) */
background-color: #F8F8FA;
border-radius: 8rpx;
border: 1px solid #EFEFF2;
overflow-x: auto;
min-height: 64rpx;
box-sizing: border-box;
flex-shrink: 0; /* 防止被压缩 */
}
.toolbar-total {
font-size: 24rpx;
color: #666;
white-space: nowrap;
flex-shrink: 0;
margin-right: 8rpx; /* 增加右边距,与搜索框保持距离 */
line-height: 1.2;
padding: 0 4rpx; /* 增加左右内边距 */
}
.toolbar-input {
flex: 1;
min-width: 120rpx; /* 增加最小宽度,避免被挤压变形 */
max-width: 200rpx; /* 设置最大宽度,保持合理比例 */
height: 56rpx; /* 稍微增加高度,提升可用性 */
line-height: 56rpx;
background-color: #F5F6FA;
border-radius: 8rpx;
padding: 0 12rpx; /* 增加左右内边距 */
font-size: 24rpx;
border: 1px solid transparent;
box-sizing: border-box;
flex-shrink: 1; /* 允许适当收缩,但保持最小宽度 */
}
.toolbar-actions {
display: flex;
align-items: center;
margin-left: auto;
flex-shrink: 0;
gap: 8rpx; /* 增加按钮之间的间距 */
}
.toolbar-btn {
padding: 0 12rpx; /* 增加左右内边距 */
height: 56rpx; /* 与输入框高度保持一致 */
min-width: 56rpx;
color: #2A68FF;
display: flex;
align-items: center;
justify-content: center;
gap: 4rpx; /* 增加图标和文字之间的间距 */
font-size: 24rpx;
font-weight: 400;
line-height: 1;
box-sizing: border-box;
}
.toolbar-btn text {
color: #2A68FF;
}
.customer-list {
/* 使用flex填充剩余空间 */
flex: 1;
background-color: transparent;
box-sizing: border-box;
overflow-y: auto;
}
.customer-card {
width: 100%;
box-sizing: border-box;
background-color: #FFFFFF;
border-radius: 16rpx;
padding: 32rpx;
margin-bottom: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
}
.customer-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16rpx;
}
.customer-name-text {
font-size: 32rpx;
font-weight: 600;
color: #333;
}
.intent-badge {
padding: 6rpx 16rpx;
border-radius: 8rpx;
}
.intent-high {
background-color: #E3F2FD;
}
.intent-high text {
font-size: 24rpx;
color: #1976D2;
font-weight: 500;
}
.intent-medium {
background-color: #FFF3E0;
}
.intent-medium text {
font-size: 24rpx;
color: #F57C00;
font-weight: 500;
}
.customer-service-info {
margin-bottom: 20rpx;
}
.customer-service-info text {
font-size: 24rpx;
color: #999;
}
.customer-tags {
display: flex;
flex-wrap: wrap;
margin-bottom: 20rpx;
gap: 12rpx;
}
.tag-item {
padding: 8rpx 16rpx;
border-radius: 8rpx;
}
.tag-orange {
background-color: #FFF3E0;
}
.tag-orange text {
font-size: 24rpx;
color: #F57C00;
}
.tag-blue {
background-color: #E3F2FD;
}
.tag-blue text {
font-size: 24rpx;
color: #1976D2;
}
.customer-footer {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 16rpx;
border-top: 1px solid #F0F0F0;
}
.customer-phone {
font-size: 28rpx;
color: #333;
}
.customer-budget {
font-size: 26rpx;
color: #1976D2;
}
</style>

View File

@@ -1,368 +0,0 @@
<template>
<uni-popup ref="popup" type="bottom" :mask-click="false">
<view class="customer-profile-modal">
<!-- 顶部栏 -->
<view class="profile-header">
<view class="profile-close" @click="close">
<uni-icons type="close" size="24" color="#333"></uni-icons>
</view>
<text class="profile-title">客户档案</text>
</view>
<scroll-view class="profile-content" scroll-y>
<!-- 客户基本信息 -->
<view class="profile-section">
<view class="profile-name-row">
<text class="profile-name">{{ profile.name }}</text>
<view class="profile-intent-badge" :class="profile.intent === '高' ? 'intent-high' : 'intent-medium'">
<text>意向{{ profile.intent }}</text>
</view>
</view>
<view class="profile-service-info">
<text>服务{{ profile.serviceCount }}次 {{ profile.lastService }}</text>
</view>
<view class="profile-details">
<view class="detail-row">
<text class="detail-label">电话:</text>
<text class="detail-value">{{ profile.phone }}</text>
</view>
<view class="detail-row">
<text class="detail-label">服务人员:</text>
<text class="detail-value">{{ profile.serviceStaff }}</text>
</view>
<view class="detail-row">
<text class="detail-label">微信状态:</text>
<text class="detail-value">{{ profile.wechatStatus }}</text>
</view>
<view class="detail-row">
<text class="detail-label">客户地址:</text>
<text class="detail-value">{{ profile.address }}</text>
</view>
<view class="detail-row">
<text class="detail-label">客户来源:</text>
<text class="detail-value">{{ profile.source }}</text>
<view class="collapse-btn" @click="toggleCollapse">
<text>{{ collapsed ? '展开' : '收起' }}</text>
<uni-icons :type="collapsed ? 'down' : 'up'" size="14" color="#666"></uni-icons>
</view>
</view>
</view>
</view>
<!-- 跟进阶段 -->
<view class="profile-section" v-if="!collapsed">
<view class="section-header">
<text class="section-title">跟进阶段</text>
<view class="stage-info">
<text>当前: {{ profile.followStage }}</text>
<uni-icons type="right" size="16" color="#999"></uni-icons>
</view>
</view>
</view>
<!-- 客户画像 -->
<view class="profile-section" v-if="!collapsed">
<view class="section-header">
<view class="section-icon">
<uni-icons type="person" size="20" color="#007AFF"></uni-icons>
</view>
<text class="section-title">客户画像</text>
</view>
<view class="profile-tags">
<view
class="profile-tag tag-blue"
v-for="(tag, index) in profile.systemTags"
:key="'system-' + index">
<text>{{ tag }}</text>
</view>
</view>
<view class="custom-label" v-if="profile.customTags && profile.customTags.length > 0">
<text>自定义</text>
</view>
<view class="profile-tags" v-if="profile.customTags && profile.customTags.length > 0">
<view
class="profile-tag tag-yellow"
v-for="(tag, index) in profile.customTags"
:key="'custom-' + index">
<text>{{ tag }}</text>
</view>
</view>
</view>
<!-- 客户意向 -->
<view class="profile-section" v-if="!collapsed">
<view class="section-header">
<view class="section-icon">
<uni-icons type="star" size="20" color="#007AFF"></uni-icons>
</view>
<text class="section-title">客户意向</text>
<view class="intent-level">
<text>意向{{ profile.intent }}</text>
</view>
</view>
<view class="intent-description">
<text>{{ profile.intentDescription }}</text>
</view>
</view>
</scroll-view>
</view>
</uni-popup>
</template>
<script>
export default {
name: 'CustomerProfileModal',
props: {
profile: {
type: Object,
default: () => ({})
}
},
data() {
return {
collapsed: false
}
},
methods: {
open() {
this.$refs.popup.open();
},
close() {
this.$refs.popup.close();
this.$emit('close');
},
toggleCollapse() {
this.collapsed = !this.collapsed;
}
}
}
</script>
<style scoped>
.customer-profile-modal {
background-color: #FFFFFF;
border-radius: 32rpx 32rpx 0 0;
max-height: 90vh;
display: flex;
flex-direction: column;
overflow: hidden;
}
.profile-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 32rpx;
border-bottom: 1px solid #F0F0F0;
position: relative;
}
.profile-close {
width: 48rpx;
height: 48rpx;
display: flex;
align-items: center;
justify-content: center;
}
.profile-title {
position: absolute;
left: 50%;
transform: translateX(-50%);
font-size: 36rpx;
font-weight: 600;
color: #333;
}
.profile-content {
flex: 1;
padding: 32rpx;
background-color: #FFFFFF;
}
.profile-section {
margin-bottom: 32rpx;
}
.profile-name-row {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.profile-name {
font-size: 36rpx;
font-weight: 600;
color: #333;
margin-right: 16rpx;
}
.profile-intent-badge {
padding: 6rpx 16rpx;
border-radius: 8rpx;
}
.profile-intent-badge.intent-high {
background-color: #E3F2FD;
}
.profile-intent-badge.intent-high text {
font-size: 24rpx;
color: #1976D2;
font-weight: 500;
}
.profile-intent-badge.intent-medium {
background-color: #FFF3E0;
}
.profile-intent-badge.intent-medium text {
font-size: 24rpx;
color: #F57C00;
font-weight: 500;
}
.profile-service-info {
margin-bottom: 24rpx;
}
.profile-service-info text {
font-size: 26rpx;
color: #999;
}
.profile-details {
background-color: #F5F5F5;
border-radius: 16rpx;
padding: 24rpx;
}
.detail-row {
display: flex;
align-items: center;
margin-bottom: 16rpx;
position: relative;
}
.detail-row:last-child {
margin-bottom: 0;
}
.detail-label {
font-size: 28rpx;
color: #666;
width: 160rpx;
flex-shrink: 0;
}
.detail-value {
font-size: 28rpx;
color: #333;
flex: 1;
}
.collapse-btn {
display: flex;
align-items: center;
margin-left: 16rpx;
padding: 4rpx 8rpx;
}
.collapse-btn text {
font-size: 24rpx;
color: #666;
margin-right: 4rpx;
}
.section-header {
display: flex;
align-items: center;
margin-bottom: 24rpx;
}
.section-icon {
margin-right: 8rpx;
}
.section-title {
font-size: 30rpx;
font-weight: 500;
color: #333;
flex: 1;
}
.stage-info {
display: flex;
align-items: center;
}
.stage-info text {
font-size: 28rpx;
color: #333;
margin-right: 8rpx;
}
.profile-tags {
display: flex;
flex-wrap: wrap;
gap: 12rpx;
margin-bottom: 24rpx;
}
.profile-tag {
padding: 8rpx 16rpx;
border-radius: 8rpx;
}
.profile-tag.tag-blue {
background-color: #E3F2FD;
}
.profile-tag.tag-blue text {
font-size: 24rpx;
color: #1976D2;
}
.profile-tag.tag-yellow {
background-color: #FFF3E0;
}
.profile-tag.tag-yellow text {
font-size: 24rpx;
color: #F57C00;
}
.custom-label {
margin-bottom: 16rpx;
}
.custom-label text {
font-size: 26rpx;
color: #666;
}
.intent-level {
padding: 6rpx 16rpx;
background-color: #E3F2FD;
border-radius: 8rpx;
}
.intent-level text {
font-size: 24rpx;
color: #1976D2;
font-weight: 500;
}
.intent-description {
background-color: #F5F5F5;
border-radius: 16rpx;
padding: 24rpx;
}
.intent-description text {
font-size: 28rpx;
color: #333;
line-height: 1.8;
}
</style>

View File

@@ -1,616 +0,0 @@
<template>
<view class="service-list-container">
<view class="service-status-toolbar">
<text class="toolbar-total">共{{ total || list.length }}条</text>
<input
class="toolbar-input"
v-model="salesName"
placeholder="所属销售姓名"
placeholder-style="color: #b0b0b0"
confirm-type="search"
@confirm="handleRefresh"
@input="onInputChange"
/>
<input
class="toolbar-input"
v-model="customerName"
placeholder="客户姓名"
placeholder-style="color: #b0b0b0"
confirm-type="search"
@confirm="handleRefresh"
@input="onInputChange"
/>
<view class="toolbar-actions">
<view class="toolbar-btn toolbar-btn--refresh" @click="handleRefresh">
<uni-icons type="refresh" size="18" color="#2A68FF"></uni-icons>
<text>刷新</text>
</view>
</view>
</view>
<scroll-view class="service-list" scroll-y @scrolltolower="onReachBottom">
<view
class="service-item"
v-for="(item, index) in list"
:key="index"
:class="{ 'service-item--active': selectedServiceItem && selectedServiceItem.id === item.id }"
@click="handleItemClick(item)">
<view class="service-header">
<text class="service-title">{{ item.title }}</text>
<view class="service-menu-button" @click.stop="onMenuButtonClick(item)">
<uni-icons type="more-filled" size="20" color="#999"></uni-icons>
</view>
</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>
<view class="service-customer">
<view class="customer-avatar">
<text class="avatar-text">{{ item.customerName.charAt(0) }}</text>
</view>
<text class="customer-name">{{ item.customerName }}</text>
</view>
<!-- 操作菜单 -->
<view
class="service-action-menu"
v-if="selectedServiceItem && selectedServiceItem.id === item.id && showServiceActionMenu"
@click.stop>
<view class="service-action-menu-item service-action-menu-item--danger" @click="handleDelete(item)">
<text>删除</text>
</view>
<view class="service-action-menu-divider"></view>
<view class="service-action-menu-item" @click="handleView(item)">
<text>查看</text>
</view>
<view class="service-action-menu-divider"></view>
<view class="service-action-menu-item" @click="handleAnalysis(item)">
<text>AI分析</text>
</view>
<view class="service-action-menu-divider"></view>
<view class="service-action-menu-item" @click="handleAudio(item)">
<text>录音</text>
</view>
</view>
</view>
</scroll-view>
<!-- 遮罩层,点击关闭菜单 -->
<view
class="service-action-menu-mask"
v-if="showServiceActionMenu"
@click="closeServiceActionMenu">
</view>
</view>
</template>
<script>
import { getApiUrl } from '@/common/config.js';
export default {
name: 'ServiceList',
props: {
list: {
type: Array,
default: () => []
},
total: {
type: Number,
default: 0
}
},
data() {
return {
salesName: '',
customerName: '',
selectedServiceItem: null,
showServiceActionMenu: false
}
},
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() {
// 输入框变化时,可以在这里添加实时搜索逻辑(如果需要)
},
handleRefresh() {
// 触发刷新事件,并传递查询参数
this.$emit('filterClick', {
salesName: this.salesName.trim(),
customerName: this.customerName.trim()
});
},
onReachBottom() {
this.$emit('reachBottom');
},
// 菜单按钮点击
onMenuButtonClick(item) {
// 如果已经选中当前项,则关闭菜单
if (this.selectedServiceItem && this.selectedServiceItem.id === item.id && this.showServiceActionMenu) {
this.closeServiceActionMenu();
return;
}
// 显示菜单
this.selectedServiceItem = item;
this.showServiceActionMenu = true;
},
// 关闭菜单
closeServiceActionMenu() {
this.showServiceActionMenu = false;
this.selectedServiceItem = null;
},
// 处理删除
handleDelete(item) {
this.closeServiceActionMenu();
this.$emit('menuAction', {
action: 'delete',
item: item
});
},
// 处理查看
handleView(item) {
this.closeServiceActionMenu();
this.$emit('menuAction', {
action: 'view',
item: item
});
},
// 处理AI分析
async handleAnalysis(item) {
this.closeServiceActionMenu();
try {
// 获取录音记录ID
const recordId = item.id || item.rawData?.id;
if (!recordId) {
uni.showToast({
title: '无法获取记录ID',
icon: 'none'
});
return;
}
// 获取完整的 AudioManagement 对象,优先使用 rawData,如果没有则使用 item 的字段构建
const audioManagement = item.rawData || {
id: recordId
};
uni.showLoading({
title: 'AI分析中...'
});
// 调用AI分析接口:/api/audioManagement/AIAnlyzById
const url = getApiUrl('/api/audioManagement/AIAnlyzById');
// 获取认证信息
let tenantId = '';
let token = '';
try {
tenantId = uni.getStorageSync('backend-tenant-id') || '';
token = uni.getStorageSync('backend-token') || '';
} catch (e) {
console.error('获取认证信息失败:', e);
}
// 构建请求头
const headers = {
'Content-Type': 'application/json'
};
if (token) {
headers['Authorization'] = `Bearer ${token}`;
}
if (tenantId) {
headers['X-Tenant-Id'] = tenantId;
}
const res = await uni.request({
url: url,
method: 'POST',
data: audioManagement,
header: headers,
timeout: 60000 // AI分析可能需要较长时间,设置60秒超时
});
uni.hideLoading();
if (res.statusCode === 200 && res.data && res.data.success) {
uni.showToast({
title: res.data.message || 'AI分析请求已提交',
icon: 'success',
duration: 2000
});
// 如果返回了更新后的数据,通知父组件更新列表项
if (res.data.data) {
const d = res.data.data;
const updatedItem = {
...item,
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
};
// 通知父组件更新该项
this.$emit('updateItem', {
recordId: recordId,
data: updatedItem
});
// 触发详情查看事件,使用更新后的数据打开详情页
this.$emit('itemClick', updatedItem);
} else {
// 如果没有返回数据,仍然打开详情页
this.$emit('itemClick', item);
}
} else {
uni.showToast({
title: res.data?.message || 'AI分析失败',
icon: 'none',
duration: 2000
});
}
} catch (error) {
uni.hideLoading();
console.error('AI分析失败:', error);
uni.showToast({
title: `AI分析失败: ${error.errMsg || error.message || '未知错误'}`,
icon: 'none',
duration: 2000
});
}
},
// 处理录音
handleAudio(item) {
this.closeServiceActionMenu();
this.$emit('menuAction', {
action: 'audio',
item: item
});
},
// 处理列表项点击
handleItemClick(item) {
// 如果菜单正在显示,不触发列表项点击
if (this.showServiceActionMenu) {
return;
}
// 触发列表项点击事件,打开详情页面
this.$emit('itemClick', item);
}
}
}
</script>
<style scoped>
.service-list-container {
/* 使用绝对定位,从tab页底部开始,到底部导航栏结束 */
position: absolute;
top: 0; /* top值通过父组件的内联样式动态设置 */
left: 0;
right: 0;
bottom: 96rpx; /* 底部导航栏高度 */
display: flex;
flex-direction: column;
background-color: #F5F5F5;
padding: 0 16rpx; /* 移除顶部padding,只保留左右padding,让toolbar紧贴tab */
box-sizing: border-box;
}
.service-status-toolbar {
display: flex;
flex-wrap: nowrap;
align-items: center;
gap: 8rpx;
padding: 12rpx 8rpx;
margin-bottom: 24rpx; /* 与列表项间距保持一致(24rpx) */
background-color: #F8F8FA;
border-radius: 8rpx;
border: 1px solid #EFEFF2;
overflow-x: auto;
min-height: 64rpx;
box-sizing: border-box;
flex-shrink: 0; /* 防止被压缩 */
}
.toolbar-total {
font-size: 24rpx;
color: #666;
white-space: nowrap;
flex-shrink: 0;
margin-right: 8rpx; /* 增加右边距,与搜索框保持距离 */
line-height: 1.2;
padding: 0 4rpx; /* 增加左右内边距 */
}
.toolbar-input {
flex: 1;
min-width: 120rpx; /* 增加最小宽度,避免被挤压变形 */
max-width: 200rpx; /* 设置最大宽度,保持合理比例 */
height: 56rpx; /* 稍微增加高度,提升可用性 */
line-height: 56rpx;
background-color: #F5F6FA;
border-radius: 8rpx;
padding: 0 12rpx; /* 增加左右内边距 */
font-size: 24rpx;
border: 1px solid transparent;
box-sizing: border-box;
flex-shrink: 1; /* 允许适当收缩,但保持最小宽度 */
}
.toolbar-actions {
display: flex;
align-items: center;
margin-left: auto;
flex-shrink: 0;
gap: 8rpx; /* 增加按钮之间的间距 */
}
.toolbar-btn {
padding: 0 12rpx; /* 增加左右内边距 */
height: 56rpx; /* 与输入框高度保持一致 */
min-width: 56rpx;
color: #2A68FF;
display: flex;
align-items: center;
justify-content: center;
gap: 4rpx; /* 增加图标和文字之间的间距 */
font-size: 24rpx;
font-weight: 400;
line-height: 1;
box-sizing: border-box;
}
.toolbar-btn text {
color: #2A68FF;
}
.service-list {
/* 使用flex填充剩余空间 */
flex: 1;
background-color: transparent;
box-sizing: border-box;
overflow-y: auto;
}
.service-item {
width: 100%;
box-sizing: border-box;
background-color: #FFFFFF;
border-radius: 16rpx;
padding: 32rpx;
margin-bottom: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
position: relative;
}
.service-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16rpx;
position: relative;
}
.service-title {
font-size: 32rpx;
font-weight: 500;
color: #333;
}
.service-menu-button {
width: 48rpx;
height: 48rpx;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.service-action-menu {
position: absolute;
top: 60rpx;
right: 32rpx;
width: 160rpx;
background-color: #FFFFFF;
border-radius: 12rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
z-index: 100;
overflow: hidden;
margin-right: 0;
}
.service-action-menu-item {
padding: 24rpx 32rpx;
font-size: 28rpx;
color: #333;
text-align: center;
background-color: #FFFFFF;
}
.service-action-menu-item:active {
background-color: #F5F5F5;
}
.service-action-menu-item--danger {
color: #FF5722;
}
.service-action-menu-divider {
height: 1rpx;
background-color: #E0E0E0;
margin: 0 16rpx;
}
.service-action-menu-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: transparent;
z-index: 99;
}
.service-meta {
display: flex;
align-items: center;
flex-wrap: wrap;
margin-bottom: 16rpx;
gap: 16rpx;
}
.service-date {
font-size: 24rpx;
color: #999;
}
.service-duration {
font-size: 24rpx;
color: #999;
}
.service-recording-name {
display: flex;
align-items: center;
margin-bottom: 16rpx;
font-size: 24rpx;
color: #666;
}
.recording-name-label {
color: #999;
margin-right: 8rpx;
}
.recording-name-value {
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;
}
.service-desc {
font-size: 28rpx;
color: #666;
line-height: 1.6;
}
.service-customer {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.customer-avatar {
width: 64rpx;
height: 64rpx;
background-color: #2196F3;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 16rpx;
}
.avatar-text {
font-size: 32rpx;
color: #FFFFFF;
font-weight: 500;
}
.customer-name {
font-size: 28rpx;
color: #333;
}
.ai-tag {
padding-top: 16rpx;
border-top: 1px solid #F0F0F0;
}
.ai-tag text {
font-size: 24rpx;
color: #999;
}
</style>