tmp
This commit is contained in:
@@ -82,6 +82,20 @@
|
||||
{{ item.profile?.email || '-' }}
|
||||
</template>
|
||||
|
||||
<template #cell(province)="{ item }">
|
||||
<template v-if="item.location?.province">
|
||||
{{ item.location.province }}
|
||||
<span v-if="item.location.city" class="text-muted fs-12">/ {{ item.location.city }}</span>
|
||||
</template>
|
||||
<span v-else class="text-muted">-</span>
|
||||
</template>
|
||||
|
||||
<template #cell(profiles)="{ item }">
|
||||
<RouterLink :to="`/profiles?userId=${item._id}`" class="link-reset">
|
||||
{{ profileCounts[item._id] ?? 0 }} 位
|
||||
</RouterLink>
|
||||
</template>
|
||||
|
||||
<template #cell(apps)="{ item }">
|
||||
<template v-if="item.apps?.length">
|
||||
<span
|
||||
@@ -154,6 +168,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref, watch } from 'vue'
|
||||
import { profileApi } from '~/api/profile'
|
||||
import { userApi } from '~/api/user'
|
||||
import ConfirmModal from '~/components/ConfirmModal.vue'
|
||||
import PageBreadcrumb from '~/components/PageBreadcrumb.vue'
|
||||
@@ -185,6 +200,8 @@ const filters = reactive({
|
||||
const fields = [
|
||||
{ key: 'user', label: '用户' },
|
||||
{ key: 'email', label: '邮箱' },
|
||||
{ key: 'province', label: '所在省份' },
|
||||
{ key: 'profiles', label: '就诊人' },
|
||||
{ key: 'apps', label: '应用与角色' },
|
||||
{ key: 'account', label: '账号状态' },
|
||||
{ key: 'createdAt', label: '注册时间' },
|
||||
@@ -192,6 +209,7 @@ const fields = [
|
||||
]
|
||||
|
||||
const users = ref<UserView[]>([])
|
||||
const profileCounts = ref<Record<string, number>>({})
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(20)
|
||||
@@ -200,6 +218,20 @@ const loading = ref(false)
|
||||
const lockVisible = ref(false)
|
||||
const lockTarget = ref<UserView | null>(null)
|
||||
|
||||
// 就诊人数量仅用于展示,接口失败时显示 0,不影响用户列表
|
||||
const loadProfileCounts = async (list: UserView[]) => {
|
||||
if (!list.length) {
|
||||
profileCounts.value = {}
|
||||
return
|
||||
}
|
||||
try {
|
||||
const data = await profileApi.counts(list.map((item) => item._id))
|
||||
profileCounts.value = data.counts
|
||||
} catch {
|
||||
profileCounts.value = {}
|
||||
}
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -213,6 +245,7 @@ const load = async () => {
|
||||
})
|
||||
users.value = data.users
|
||||
total.value = data.total
|
||||
await loadProfileCounts(data.users)
|
||||
const maxPage = Math.max(1, Math.ceil(data.total / pageSize.value))
|
||||
if (page.value > maxPage) {
|
||||
page.value = maxPage
|
||||
|
||||
Reference in New Issue
Block a user