feat(staff): action buttons → filtered customer/group list

Adds groups.user_id filter; viewCustomers/viewGroups push owner_account_id query; CustomerList/GroupList read it.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
浅念
2026-08-05 19:06:27 +08:00
parent 02a709ba93
commit dfdd0595d2
6 changed files with 109 additions and 21 deletions
+28 -4
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
import { useRoute, useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { getGroups } from '@/api'
import type { Channel, Group } from '@/api/types'
@@ -8,9 +8,14 @@ import { useChannelStore } from '@/stores/channel'
import { channelLabel, formatTime } from '@/utils/format'
import { buildGroupSections, readField } from '@/utils/groupFields'
const route = useRoute()
const router = useRouter()
const channelStore = useChannelStore()
const ownerId = computed<string | null>(() =>
route.query.owner_account_id ? String(route.query.owner_account_id) : null,
)
const groups = ref<Group[]>([])
const total = ref(0)
const page = ref(1)
@@ -48,6 +53,7 @@ async function load(): Promise<void> {
channel: channelStore.channel,
page: page.value,
page_size: pageSize.value,
owner_account_id: ownerId.value ?? undefined,
})
groups.value = res.items
total.value = res.total
@@ -70,15 +76,22 @@ function handlePageSizeChange(s: number): void {
load()
}
// React to the top-bar channel filter.
// React to the top-bar channel filter + owner_account_id query.
watch(
() => channelStore.channel,
() => [channelStore.channel, ownerId.value] as const,
() => {
page.value = 1
load()
},
)
/** Drop the ``owner_account_id`` query param while preserving any others. */
function clearOwnerFilter(): void {
const { owner_account_id: _drop, ...rest } = route.query
void _drop
router.replace({ query: rest })
}
/**
* Read a raw_json camelCase key off a group, preferring the structured
* snake_case column when it is populated. The first argument is the row so the
@@ -148,7 +161,9 @@ onMounted(load)
<div>
<h2 style="margin: 0 0 4px; font-size: 16px">群列表</h2>
<span class="yk-groups__sub">
共 {{ total }} 条 · 渠道:{{ channelLabelCurrent }}
共 {{ total }} 条
<template v-if="ownerId"> · 员工账号:{{ ownerId }}</template>
· 渠道:{{ channelLabelCurrent }}
</span>
</div>
<div class="yk-groups__filters">
@@ -165,6 +180,15 @@ onMounted(load)
{{ opt.label }}
</el-radio-button>
</el-radio-group>
<el-button
v-if="ownerId"
size="small"
type="info"
plain
@click="clearOwnerFilter"
>
清除员工筛选
</el-button>
</div>
</div>