feat: 商机跟单默认筛选跟进中 + 已流失置底 + 清空列收

- 后端: 状态改为已流失时自动清空 expected_revenue_date
- PC端: 默认筛选跟进中,排序 跟进中→已签约→已流失
- 移动端: 列表自动排序,已流失在最底部

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-07-12 20:49:01 +08:00
parent 78962e45d7
commit 20f5b01987
3 changed files with 12 additions and 3 deletions
+3
View File
@@ -104,6 +104,9 @@ async def update_mini_business(
update_data.pop("manager_id", None)
for k, v in update_data.items():
setattr(m, k, v)
# Auto-clear expected revenue date when status becomes 已流失
if m.status == "已流失" and m.expected_revenue_date:
m.expected_revenue_date = ""
new_snapshot = {"customer_id": str(m.customer_id), "product_type": m.product_type, "amount": m.amount, "follow_up_detail": m.follow_up_detail, "status": m.status, "expected_revenue_date": m.expected_revenue_date}
changes = compute_diff(old_snapshot, new_snapshot)
if changes:
+3 -1
View File
@@ -39,7 +39,7 @@ const logSaving = ref(false)
// ── Filters ──
const filterManager = ref('')
const filterStatus = ref('')
const filterStatus = ref('跟进中')
const managerOptions = computed(() => {
const seen = new Set<string>()
@@ -49,10 +49,12 @@ const managerOptions = computed(() => {
.sort()
})
const statusOrder: Record<string, number> = { '跟进中': 0, '已签约': 1, '已流失': 2 }
const filteredItems = computed(() => {
let list = miniBusiness.value
if (filterManager.value) list = list.filter((m: any) => (m.manager_name || '未知') === filterManager.value)
if (filterStatus.value) list = list.filter((m: any) => m.status === filterStatus.value)
list.sort((a: any, b: any) => (statusOrder[a.status] ?? 9) - (statusOrder[b.status] ?? 9))
return list
})
+6 -2
View File
@@ -7,13 +7,17 @@ import { miniBusinessApi } from '@/api/miniBusiness'
const router = useRouter()
const loading = ref(false)
const items = ref<any[]>([])
const statusOrder: Record<string, number> = { '跟进中': 0, '已签约': 1, '已流失': 2 }
onMounted(loadItems)
async function loadItems() {
loading.value = true
try { const res = await miniBusinessApi.list(); items.value = Array.isArray(res.data) ? res.data : (res.data.items || []) }
catch (_) {}
try {
const res = await miniBusinessApi.list()
const raw = Array.isArray(res.data) ? res.data : (res.data.items || [])
items.value = raw.sort((a: any, b: any) => (statusOrder[a.status] ?? 9) - (statusOrder[b.status] ?? 9))
} catch (_) {}
finally { loading.value = false }
}