diff --git a/frontend/src/views/desktop/ManagerWorkspace.vue b/frontend/src/views/desktop/ManagerWorkspace.vue index 06d4bef..11eaf1a 100644 --- a/frontend/src/views/desktop/ManagerWorkspace.vue +++ b/frontend/src/views/desktop/ManagerWorkspace.vue @@ -13,11 +13,34 @@ const activeTab = ref('visits') const loading = ref(false) const allManagers = ref([]) +// Period filter +const period = ref('month') +const searchText = ref('') +const pageSize = ref(25) + const visits = ref([]) const workPlans = ref([]) const miniBusiness = ref([]) const dailyNotes = ref([]) const keyVisits = ref([]) + +// Pagination per tab +const page = ref>({ visits: 1, notes: 1, plans: 1, mini: 1, key: 1 }) +const total = ref>({ visits: 0, notes: 0, plans: 0, mini: 0, key: 0 }) + +function getDateRange() { + const now = new Date() + const today = now.toISOString().slice(0, 10) + if (period.value === 'week') { + const d = new Date(now); d.setDate(d.getDate() - d.getDay() + 1) + return { from: d.toISOString().slice(0, 10), to: today } + } else if (period.value === 'month') { + return { from: `${now.getFullYear()}-${String(now.getMonth()+1).padStart(2,'0')}-01`, to: today } + } else if (period.value === 'year') { + return { from: `${now.getFullYear()}-01-01`, to: today } + } + return { from: '', to: '' } +} const customers = ref([]) const allUsers = ref([]) const plannedVisitors = ref([]) @@ -92,18 +115,39 @@ async function handleQuickCreate() { } } +function buildParams(tabKey: string) { + const { from, to } = getDateRange() + const params: any = { page: page.value[tabKey] || 1, page_size: pageSize.value } + if (from) { params.date_from = from; params.date_to = to } + if (searchText.value) params.search = searchText.value + return params +} + async function loadAll() { loading.value = true try { - const [v, w, m, d, k] = await Promise.all([ - api.get('/visits/'), api.get('/work-plans/'), - api.get('/mini-business/'), api.get('/daily-notes/'), - api.get('/key-visits/'), + const [v, d] = await Promise.all([ + api.get('/visits/', { params: buildParams('visits') }), + api.get('/daily-notes/', { params: buildParams('notes') }), ]) - visits.value = v.data; workPlans.value = w.data - miniBusiness.value = m.data; dailyNotes.value = d.data - keyVisits.value = k.data - // Load photo previews + visits.value = Array.isArray(v.data) ? v.data : (v.data.items || []) + dailyNotes.value = Array.isArray(d.data) ? d.data : (d.data.items || []) + total.value.visits = v.data.total || visits.value.length + total.value.notes = d.data.total || dailyNotes.value.length + + const [w, m, k] = await Promise.all([ + api.get('/work-plans/', { params: buildParams('plans') }), + api.get('/mini-business/', { params: buildParams('mini') }), + api.get('/key-visits/', { params: buildParams('key') }), + ]) + workPlans.value = Array.isArray(w.data) ? w.data : (w.data.items || []) + miniBusiness.value = Array.isArray(m.data) ? m.data : (m.data.items || []) + keyVisits.value = Array.isArray(k.data) ? k.data : (k.data.items || []) + total.value.plans = w.data.total || workPlans.value.length + total.value.mini = m.data.total || miniBusiness.value.length + total.value.key = k.data.total || keyVisits.value.length + + // Load photo previews for visits for (const visit of visits.value) { if (visit.photos?.length) { for (const key of visit.photos) { @@ -120,6 +164,11 @@ async function loadAll() { finally { loading.value = false } } +function onTabChange(tab: string) { activeTab.value = tab; loadAll() } +function onPeriodChange() { Object.keys(page.value).forEach(k => page.value[k] = 1); loadAll() } +function onPageChange(tabKey: string, p: number) { page.value[tabKey] = p; loadAll() } +function onSizeChange() { Object.keys(page.value).forEach(k => page.value[k] = 1); loadAll() } + function openCreate(type: string) { dialogMode.value = 'create'; dialogType.value = type dialogTimeRange.value = null @@ -308,8 +357,23 @@ const notesByDate = computed(() => {
+ +
+
+ + 本周 + 本月 + 本年 + 全部 + + + + +
+
+ - +
+ 新建拜访
@@ -469,6 +533,18 @@ const notesByDate = computed(() => {
暂无数据
+
+ +