跟进详细页面补充文件下载功能
This commit is contained in:
parent
8a184a90d2
commit
dee37e4e2b
|
|
@ -95,8 +95,8 @@
|
||||||
<text class="action-text">电话</text>
|
<text class="action-text">电话</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="action-item" @click.stop="handleMore(customer)">
|
<view class="action-item" @click.stop="handleMore(customer)">
|
||||||
|
<text class="action-icon">+</text>
|
||||||
<text class="action-text">更多</text>
|
<text class="action-text">更多</text>
|
||||||
<text class="action-arrow">›</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
<view class="delete-btn" @click.stop="handleDelete(item)">
|
<view class="delete-btn" @click.stop="handleDelete(item)">
|
||||||
<text class="delete-icon">🗑️</text>
|
<text class="delete-icon">🗑️</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="followup-arrow">›</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text class="followup-text">{{ item.content }}</text>
|
<text class="followup-text">{{ item.content }}</text>
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,26 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 附件列表 -->
|
||||||
|
<view class="info-card" v-if="followupAttachments.length > 0">
|
||||||
|
<view class="card-title">附件</view>
|
||||||
|
<view class="attachments-list">
|
||||||
|
<view
|
||||||
|
class="attachment-item"
|
||||||
|
v-for="(file, index) in followupAttachments"
|
||||||
|
:key="index"
|
||||||
|
@click="previewAttachment(file)"
|
||||||
|
>
|
||||||
|
<text class="file-icon">{{ getFileIcon(file.name || file.path) }}</text>
|
||||||
|
<view class="file-info">
|
||||||
|
<text class="file-name">{{ file.name || getFileNameFromUrl(file.path) }}</text>
|
||||||
|
<text class="file-size" v-if="file.size">{{ formatFileSize(file.size) }}</text>
|
||||||
|
</view>
|
||||||
|
<text class="preview-arrow">›</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<!-- 下次跟进 -->
|
<!-- 下次跟进 -->
|
||||||
<view class="info-card" v-if="followupDetail.nextFollowTime">
|
<view class="info-card" v-if="followupDetail.nextFollowTime">
|
||||||
<view class="card-title">时间信息</view>
|
<view class="card-title">时间信息</view>
|
||||||
|
|
@ -206,6 +226,60 @@ const followupImages = computed(() => {
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 计算附件列表
|
||||||
|
const followupAttachments = computed(() => {
|
||||||
|
const detail = followupDetail.value;
|
||||||
|
const attachments = [];
|
||||||
|
|
||||||
|
const normalizeAttachment = (item) => {
|
||||||
|
if (!item) return null;
|
||||||
|
|
||||||
|
if (typeof item === 'string') {
|
||||||
|
const trimmed = item.trim();
|
||||||
|
if (!trimmed) return null;
|
||||||
|
return {
|
||||||
|
path: trimmed,
|
||||||
|
name: getFileNameFromUrl(trimmed),
|
||||||
|
size: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof item === 'object' && item.path) {
|
||||||
|
return {
|
||||||
|
path: item.path,
|
||||||
|
name: item.name || getFileNameFromUrl(item.path),
|
||||||
|
size: item.size || 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const attachSources = [
|
||||||
|
detail.attaches,
|
||||||
|
detail.attachments,
|
||||||
|
detail.files
|
||||||
|
];
|
||||||
|
|
||||||
|
attachSources.forEach((source) => {
|
||||||
|
if (!source) return;
|
||||||
|
|
||||||
|
if (typeof source === 'string') {
|
||||||
|
source.split(',').forEach((url) => {
|
||||||
|
const normalized = normalizeAttachment(url);
|
||||||
|
if (normalized) attachments.push(normalized);
|
||||||
|
});
|
||||||
|
} else if (Array.isArray(source)) {
|
||||||
|
source.forEach((item) => {
|
||||||
|
const normalized = normalizeAttachment(item);
|
||||||
|
if (normalized) attachments.push(normalized);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return attachments;
|
||||||
|
});
|
||||||
|
|
||||||
// 获取页面参数
|
// 获取页面参数
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
if (options && options.followId) {
|
if (options && options.followId) {
|
||||||
|
|
@ -360,6 +434,118 @@ const previewFollowupImages = (images, currentIndex) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 获取文件名
|
||||||
|
function getFileNameFromUrl(url = '') {
|
||||||
|
try {
|
||||||
|
const decodedUrl = decodeURIComponent(url);
|
||||||
|
const parts = decodedUrl.split('/');
|
||||||
|
return parts.pop() || decodedUrl;
|
||||||
|
} catch (err) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取文件图标
|
||||||
|
function getFileIcon(filename = '') {
|
||||||
|
const ext = filename.split('.').pop()?.toLowerCase() || '';
|
||||||
|
const iconMap = {
|
||||||
|
pdf: '📄',
|
||||||
|
doc: '📝',
|
||||||
|
docx: '📝',
|
||||||
|
xls: '📊',
|
||||||
|
xlsx: '📊',
|
||||||
|
ppt: '📈',
|
||||||
|
pptx: '📈',
|
||||||
|
txt: '📄',
|
||||||
|
zip: '📦',
|
||||||
|
rar: '📦',
|
||||||
|
jpg: '🖼️',
|
||||||
|
jpeg: '🖼️',
|
||||||
|
png: '🖼️',
|
||||||
|
gif: '🖼️',
|
||||||
|
mp4: '🎞️',
|
||||||
|
mp3: '🎵'
|
||||||
|
};
|
||||||
|
return iconMap[ext] || '📁';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 格式化文件大小
|
||||||
|
function formatFileSize(bytes) {
|
||||||
|
if (!bytes || bytes <= 0) return '';
|
||||||
|
const k = 1024;
|
||||||
|
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||||
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||||
|
return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 预览或下载附件
|
||||||
|
const previewAttachment = (file) => {
|
||||||
|
if (!file || !file.path) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '文件不存在',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const imageExts = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
|
||||||
|
const filename = file.name || getFileNameFromUrl(file.path);
|
||||||
|
const ext = filename.split('.').pop()?.toLowerCase() || '';
|
||||||
|
|
||||||
|
if (imageExts.includes(ext)) {
|
||||||
|
uni.previewImage({
|
||||||
|
urls: [file.path],
|
||||||
|
current: file.path
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// #ifdef H5
|
||||||
|
window.open(file.path, '_blank');
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
if (typeof plus !== 'undefined' && plus.runtime) {
|
||||||
|
plus.runtime.openURL(file.path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// 其他平台尝试下载并打开
|
||||||
|
uni.downloadFile({
|
||||||
|
url: file.path,
|
||||||
|
success: (res) => {
|
||||||
|
if (res.statusCode === 200) {
|
||||||
|
uni.openDocument({
|
||||||
|
filePath: res.tempFilePath,
|
||||||
|
success: () => {
|
||||||
|
console.log('打开附件成功');
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error('打开附件失败:', err);
|
||||||
|
uni.showToast({
|
||||||
|
title: '无法打开此文件',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '下载文件失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error('下载附件失败:', err);
|
||||||
|
uni.showToast({
|
||||||
|
title: '下载文件失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// 返回
|
// 返回
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
|
|
@ -534,6 +720,53 @@ onMounted(() => {
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.attachments-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 12px 0;
|
||||||
|
border-bottom: 1px solid #f5f5f5;
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-icon {
|
||||||
|
font-size: 24px;
|
||||||
|
margin-right: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-info {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-name {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #333;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-size {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-arrow {
|
||||||
|
font-size: 20px;
|
||||||
|
color: #bbb;
|
||||||
|
margin-left: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
.status-badge {
|
.status-badge {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 4px 12px;
|
padding: 4px 12px;
|
||||||
|
|
|
||||||
|
|
@ -1207,7 +1207,5 @@ const handleCancel = () => {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-top: 1px solid #e0e0e0;
|
border-top: 1px solid #e0e0e0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user