feat: 历史周报+图片预览+照片管理+导入优化+用户合并
新增: - 历史周报: Dashboard/周报详情支持周选择器翻看往周,归档只读 - 图片预览: 全屏大图(移动端+PC端),点击遮罩关闭 - PC端照片管理: 编辑时可上传/删除照片 - 客户导入改为更新模式: 重名自动更新信息,显示操作明细 - 导入跳过原因: 旧周报导入也显示每条跳过原因 优化: - 填报进度权限: 经理只看到自己,支局长/领导看全员 - 客户经理暖灰色hash标签列 - 用户去重合并(4组),数据完整迁移 - CLAUDE.md 更新到最新状态 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,10 @@ const customers = ref<any[]>([])
|
||||
const allUsers = ref<any[]>([])
|
||||
const plannedVisitors = ref<string[]>([])
|
||||
const dialogTimeRange = ref<any>(null)
|
||||
const previewImageUrl = ref('')
|
||||
const uploading = ref(false)
|
||||
const previewDialogVisible = ref(false)
|
||||
const photoUrls = ref<Record<string, string>>({})
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const dialogMode = ref<'create' | 'edit'>('create')
|
||||
@@ -66,6 +70,19 @@ async function loadAll() {
|
||||
visits.value = v.data; workPlans.value = w.data
|
||||
miniBusiness.value = m.data; dailyNotes.value = d.data
|
||||
keyVisits.value = k.data
|
||||
// Load photo previews
|
||||
for (const visit of visits.value) {
|
||||
if (visit.photos?.length) {
|
||||
for (const key of visit.photos) {
|
||||
if (!photoUrls.value[key]) {
|
||||
try {
|
||||
const urlRes = await api.get('/upload/download-url', { params: { object_key: key } })
|
||||
photoUrls.value[key] = urlRes.data.download_url
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: any) { ElMessage.error('加载失败') }
|
||||
finally { loading.value = false }
|
||||
}
|
||||
@@ -92,9 +109,62 @@ function openEdit(type: string, item: any) {
|
||||
if (type === 'key') {
|
||||
plannedVisitors.value = item.planned_visitor ? item.planned_visitor.split('、') : []
|
||||
}
|
||||
// Load photo URLs for visit editing
|
||||
if (type === 'visit' && item.photos?.length) {
|
||||
for (const key of item.photos) {
|
||||
if (!photoUrls.value[key]) {
|
||||
api.get('/upload/download-url', { params: { object_key: key } }).then(r => {
|
||||
photoUrls.value[key] = r.data.download_url
|
||||
}).catch(() => {})
|
||||
}
|
||||
}
|
||||
}
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
function previewPhoto(url: string) { previewImageUrl.value = url; previewDialogVisible.value = true }
|
||||
|
||||
async function handleDialogPhotoUpload(event: Event) {
|
||||
const target = event.target as HTMLInputElement
|
||||
if (!target.files?.length) return
|
||||
if ((form.value.photos || []).length >= 9) { ElMessage.warning('最多9张照片'); return }
|
||||
uploading.value = true
|
||||
for (const file of Array.from(target.files)) {
|
||||
if ((form.value.photos || []).length >= 9) break
|
||||
try {
|
||||
// Get presigned URL
|
||||
const presignRes = await api.post('/upload/presigned-url', null, { params: { filename: file.name, content_type: file.type || 'image/jpeg' } })
|
||||
// Upload directly to MinIO (not through our API)
|
||||
const axios = (await import('axios')).default
|
||||
await axios.put(presignRes.data.upload_url, file, { headers: { 'Content-Type': file.type || 'image/jpeg' } })
|
||||
const key = presignRes.data.object_key
|
||||
if (!form.value.photos) form.value.photos = []
|
||||
form.value.photos.push(key)
|
||||
form.value.photos = [...form.value.photos]
|
||||
// Load preview
|
||||
try {
|
||||
const urlRes = await api.get('/upload/download-url', { params: { object_key: key } })
|
||||
photoUrls.value[key] = urlRes.data.download_url
|
||||
} catch (_) {}
|
||||
} catch (e: any) {
|
||||
ElMessage.error('上传失败: ' + (e.response?.data?.detail || e.message))
|
||||
}
|
||||
}
|
||||
uploading.value = false
|
||||
target.value = ''
|
||||
}
|
||||
|
||||
function removePhotoFromEdit(idx: number) {
|
||||
if (!form.value.photos) return
|
||||
const key = form.value.photos[idx]
|
||||
form.value.photos.splice(idx, 1)
|
||||
form.value.photos = [...form.value.photos]
|
||||
// Clean up preview URL
|
||||
if (photoUrls.value[key]) {
|
||||
delete photoUrls.value[key]
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
const t = dialogType.value; const d = form.value
|
||||
try {
|
||||
@@ -203,6 +273,12 @@ const notesByDate = computed(() => {
|
||||
</el-table-column>
|
||||
<el-table-column prop="visit_method" label="方式" width="60" />
|
||||
<el-table-column prop="time_range" label="时间" width="100" />
|
||||
<el-table-column label="照片" width="60">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.photos?.length">📷{{ row.photos.length }}</span>
|
||||
<span v-else style="color:var(--c-text-muted)">-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="communication_content" label="沟通内容" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="70">
|
||||
<template #default="{ row }">
|
||||
@@ -367,6 +443,23 @@ const notesByDate = computed(() => {
|
||||
<el-form-item label="拜访人电话"><el-input v-model="form.visitor_phone" placeholder="联系电话(可选)" /></el-form-item>
|
||||
<el-form-item label="沟通内容"><el-input v-model="form.communication_content" type="textarea" :rows="3" /></el-form-item>
|
||||
<el-form-item label="客户需求"><el-input v-model="form.customer_demand" type="textarea" :rows="2" /></el-form-item>
|
||||
<el-form-item v-if="dialogMode === 'edit' && form.photos?.length" label="照片">
|
||||
<div style="display:flex;gap:8px;flex-wrap:wrap">
|
||||
<div v-for="(key, idx) in form.photos" :key="key" style="position:relative">
|
||||
<img :src="photoUrls[key]" style="width:80px;height:80px;object-fit:cover;border:1px solid var(--warm-border);cursor:pointer" v-if="photoUrls[key]" @click.stop="previewPhoto(photoUrls[key])" />
|
||||
<span v-else style="width:80px;height:80px;display:flex;align-items:center;justify-content:center;background:var(--paper);border:1px solid var(--warm-border);font-size:11px;color:var(--warm-gray)">加载中...</span>
|
||||
<button type="button" style="position:absolute;top:-6px;right:-6px;background:var(--vermilion);color:#fff;border:none;width:18px;height:18px;font-size:12px;cursor:pointer;line-height:1;border-radius:50%" @click="removePhotoFromEdit(idx)" title="删除照片">×</button>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top:4px;font-size:11px;color:var(--warm-gray)">点击 × 移除照片,点击「保存」提交更改</div>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="dialogType === 'visit'" label="添加照片">
|
||||
<label style="cursor:pointer;display:inline-flex;align-items:center;gap:6px;padding:8px 14px;border:1px dashed var(--warm-border);color:var(--warm-gray);font-size:13px">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>
|
||||
{{ uploading ? '上传中...' : '上传照片(最多9张)' }}
|
||||
<input type="file" accept="image/*" multiple style="display:none" @change="handleDialogPhotoUpload" />
|
||||
</label>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<template v-if="dialogType === 'note'">
|
||||
<el-form-item label="分类"><div style="display:flex;flex-wrap:wrap;gap:6px"><el-button v-for="c in categories" :key="c" :type="form.category===c?'primary':''" size="small" @click="form.category=c">{{ c }}</el-button></div></el-form-item>
|
||||
@@ -408,6 +501,14 @@ const notesByDate = computed(() => {
|
||||
<el-button type="primary" @click="handleSave">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- Image Preview -->
|
||||
<teleport to="body">
|
||||
<div v-if="previewDialogVisible" class="image-preview-overlay" @click="previewDialogVisible = false">
|
||||
<img :src="previewImageUrl" class="image-preview-full" @click.stop />
|
||||
<button class="image-preview-close" @click="previewDialogVisible = false">✕</button>
|
||||
</div>
|
||||
</teleport>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user