feat: add super comment governance and finance oversight

This commit is contained in:
2026-01-16 10:37:24 +08:00
parent f7db11a4df
commit 3af3c854c9
16 changed files with 4139 additions and 285 deletions

View File

@@ -146,5 +146,49 @@ export const ContentService = {
granularity
};
return requestJson('/super/v1/contents/statistics', { query });
},
async listComments({ page, limit, id, tenant_id, tenant_code, tenant_name, content_id, content_title, user_id, username, keyword, status, created_at_from, created_at_to, sortField, sortOrder } = {}) {
const iso = (d) => {
if (!d) return undefined;
const date = d instanceof Date ? d : new Date(d);
if (Number.isNaN(date.getTime())) return undefined;
return date.toISOString();
};
const query = {
page,
limit,
id,
tenant_id,
tenant_code,
tenant_name,
content_id,
content_title,
user_id,
username,
keyword,
status,
created_at_from: iso(created_at_from),
created_at_to: iso(created_at_to)
};
if (sortField && sortOrder) {
if (sortOrder === 1) query.asc = sortField;
if (sortOrder === -1) query.desc = sortField;
}
const data = await requestJson('/super/v1/comments', { query });
return {
page: data?.page ?? page ?? 1,
limit: data?.limit ?? limit ?? 10,
total: data?.total ?? 0,
items: normalizeItems(data?.items)
};
},
async deleteComment(id, { reason } = {}) {
if (!id) throw new Error('id is required');
return requestJson(`/super/v1/comments/${id}/delete`, {
method: 'POST',
body: { reason }
});
}
};

View File

@@ -55,5 +55,98 @@ export const FinanceService = {
method: 'POST',
body: { reason }
});
},
async listLedgers({ page, limit, id, tenant_id, tenant_code, tenant_name, user_id, username, order_id, type, amount_min, amount_max, created_at_from, created_at_to, sortField, sortOrder } = {}) {
const iso = (d) => {
if (!d) return undefined;
const date = d instanceof Date ? d : new Date(d);
if (Number.isNaN(date.getTime())) return undefined;
return date.toISOString();
};
const query = {
page,
limit,
id,
tenant_id,
tenant_code,
tenant_name,
user_id,
username,
order_id,
type,
amount_min,
amount_max,
created_at_from: iso(created_at_from),
created_at_to: iso(created_at_to)
};
if (sortField && sortOrder) {
if (sortOrder === 1) query.asc = sortField;
if (sortOrder === -1) query.desc = sortField;
}
const data = await requestJson('/super/v1/finance/ledgers', { query });
return {
page: data?.page ?? page ?? 1,
limit: data?.limit ?? limit ?? 10,
total: data?.total ?? 0,
items: normalizeItems(data?.items)
};
},
async listBalanceAnomalies({ page, limit, user_id, username, issue, sortField, sortOrder } = {}) {
const query = {
page,
limit,
user_id,
username,
issue
};
if (sortField && sortOrder) {
if (sortOrder === 1) query.asc = sortField;
if (sortOrder === -1) query.desc = sortField;
}
const data = await requestJson('/super/v1/finance/anomalies/balances', { query });
return {
page: data?.page ?? page ?? 1,
limit: data?.limit ?? limit ?? 10,
total: data?.total ?? 0,
items: normalizeItems(data?.items)
};
},
async listOrderAnomalies({ page, limit, id, tenant_id, tenant_code, tenant_name, user_id, username, type, issue, created_at_from, created_at_to, sortField, sortOrder } = {}) {
const iso = (d) => {
if (!d) return undefined;
const date = d instanceof Date ? d : new Date(d);
if (Number.isNaN(date.getTime())) return undefined;
return date.toISOString();
};
const query = {
page,
limit,
id,
tenant_id,
tenant_code,
tenant_name,
user_id,
username,
type,
issue,
created_at_from: iso(created_at_from),
created_at_to: iso(created_at_to)
};
if (sortField && sortOrder) {
if (sortOrder === 1) query.asc = sortField;
if (sortOrder === -1) query.desc = sortField;
}
const data = await requestJson('/super/v1/finance/anomalies/orders', { query });
return {
page: data?.page ?? page ?? 1,
limit: data?.limit ?? limit ?? 10,
total: data?.total ?? 0,
items: normalizeItems(data?.items)
};
}
};

View File

@@ -8,6 +8,7 @@ import { useRoute } from 'vue-router';
const toast = useToast();
const route = useRoute();
const tabValue = ref('contents');
const loading = ref(false);
const contents = ref([]);
@@ -34,6 +35,31 @@ const sortField = ref('id');
const sortOrder = ref(-1);
const selectedContents = ref([]);
const commentLoading = ref(false);
const comments = ref([]);
const commentTotalRecords = ref(0);
const commentPage = ref(1);
const commentRows = ref(10);
const commentID = ref(null);
const commentTenantID = ref(null);
const commentTenantCode = ref('');
const commentTenantName = ref('');
const commentContentID = ref(null);
const commentContentTitle = ref('');
const commentUserID = ref(null);
const commentUsername = ref('');
const commentKeyword = ref('');
const commentStatus = ref('active');
const commentCreatedAtFrom = ref(null);
const commentCreatedAtTo = ref(null);
const commentSortField = ref('created_at');
const commentSortOrder = ref(-1);
const commentDeleteDialogVisible = ref(false);
const commentDeleteLoading = ref(false);
const commentDeleteReason = ref('');
const commentDeleteTarget = ref(null);
const reviewDialogVisible = ref(false);
const reviewSubmitting = ref(false);
const reviewAction = ref('approve');
@@ -60,6 +86,12 @@ const visibilityOptions = [
{ label: 'private', value: 'private' }
];
const commentStatusOptions = [
{ label: '全部', value: 'all' },
{ label: '正常', value: 'active' },
{ label: '已删除', value: 'deleted' }
];
function getQueryValue(value) {
if (Array.isArray(value)) return value[0];
return value ?? null;
@@ -111,6 +143,25 @@ function resetFilters() {
sortOrder.value = -1;
}
function resetCommentFilters() {
commentID.value = null;
commentTenantID.value = null;
commentTenantCode.value = '';
commentTenantName.value = '';
commentContentID.value = null;
commentContentTitle.value = '';
commentUserID.value = null;
commentUsername.value = '';
commentKeyword.value = '';
commentStatus.value = 'active';
commentCreatedAtFrom.value = null;
commentCreatedAtTo.value = null;
commentSortField.value = 'created_at';
commentSortOrder.value = -1;
commentPage.value = 1;
commentRows.value = 10;
}
function applyRouteQuery(query) {
resetFilters();
@@ -175,6 +226,21 @@ function getContentVisibilitySeverity(value) {
}
}
function getCommentStatusSeverity(isDeleted) {
if (isDeleted) return 'danger';
return 'success';
}
function getCommentStatusLabel(isDeleted) {
return isDeleted ? '已删除' : '正常';
}
function formatCommentContent(value) {
const text = String(value || '');
if (text.length <= 60) return text || '-';
return `${text.slice(0, 60)}...`;
}
const selectedCount = computed(() => selectedContents.value.length);
const reviewTargetCount = computed(() => reviewTargetIDs.value.length);
@@ -290,6 +356,80 @@ function onSort(event) {
loadContents();
}
async function loadComments() {
commentLoading.value = true;
try {
const result = await ContentService.listComments({
page: commentPage.value,
limit: commentRows.value,
id: commentID.value || undefined,
tenant_id: commentTenantID.value || undefined,
tenant_code: commentTenantCode.value,
tenant_name: commentTenantName.value,
content_id: commentContentID.value || undefined,
content_title: commentContentTitle.value,
user_id: commentUserID.value || undefined,
username: commentUsername.value,
keyword: commentKeyword.value,
status: commentStatus.value || undefined,
created_at_from: commentCreatedAtFrom.value || undefined,
created_at_to: commentCreatedAtTo.value || undefined,
sortField: commentSortField.value,
sortOrder: commentSortOrder.value
});
comments.value = result.items;
commentTotalRecords.value = result.total;
} catch (error) {
toast.add({ severity: 'error', summary: '加载失败', detail: error?.message || '无法加载评论列表', life: 4000 });
} finally {
commentLoading.value = false;
}
}
function onCommentSearch() {
commentPage.value = 1;
loadComments();
}
function onCommentReset() {
resetCommentFilters();
loadComments();
}
function onCommentPage(event) {
commentPage.value = (event.page ?? 0) + 1;
commentRows.value = event.rows ?? commentRows.value;
loadComments();
}
function onCommentSort(event) {
commentSortField.value = event.sortField ?? commentSortField.value;
commentSortOrder.value = event.sortOrder ?? commentSortOrder.value;
loadComments();
}
function openCommentDeleteDialog(comment) {
commentDeleteTarget.value = comment;
commentDeleteReason.value = '';
commentDeleteDialogVisible.value = true;
}
async function confirmCommentDelete() {
const id = Number(commentDeleteTarget.value?.id ?? 0);
if (!id) return;
commentDeleteLoading.value = true;
try {
await ContentService.deleteComment(id, { reason: commentDeleteReason.value.trim() || undefined });
toast.add({ severity: 'success', summary: '已删除', detail: `评论ID: ${id}`, life: 3000 });
commentDeleteDialogVisible.value = false;
await loadComments();
} catch (error) {
toast.add({ severity: 'error', summary: '删除失败', detail: error?.message || '无法删除评论', life: 4000 });
} finally {
commentDeleteLoading.value = false;
}
}
const unpublishDialogVisible = ref(false);
const unpublishLoading = ref(false);
const unpublishItem = ref(null);
@@ -320,9 +460,21 @@ async function confirmUnpublish() {
}
}
watch(
() => tabValue.value,
(value) => {
if (value === 'comments') {
loadComments();
} else if (value === 'contents') {
loadContents();
}
}
);
watch(
() => route.query,
(query) => {
tabValue.value = 'contents';
applyRouteQuery(query);
page.value = 1;
rows.value = 10;
@@ -334,166 +486,314 @@ watch(
<template>
<div class="card">
<div class="flex items-center justify-between mb-4">
<div class="flex flex-col">
<div class="flex flex-col">
<h4 class="m-0">内容列表</h4>
<span class="text-muted-color">平台侧汇总跨租户</span>
</div>
<div class="flex items-center gap-2">
<span class="text-sm text-muted-color">已选 {{ selectedCount }} </span>
<Button label="批量通过" icon="pi pi-check" severity="success" :disabled="selectedCount === 0" @click="openBatchReviewDialog('approve')" />
<Button label="批量驳回" icon="pi pi-times" severity="danger" :disabled="selectedCount === 0" @click="openBatchReviewDialog('reject')" />
<Button label="刷新" icon="pi pi-refresh" severity="secondary" @click="loadContents" :disabled="loading" />
<h4 class="m-0">内容治理</h4>
<span class="text-muted-color">平台侧内容与评论管理</span>
</div>
</div>
<div class="flex flex-col gap-4">
<SearchPanel :loading="loading" @search="onSearch" @reset="onReset">
<SearchField label="ContentID">
<InputNumber v-model="contentID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="TenantID">
<InputNumber v-model="tenantID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="TenantCode">
<InputText v-model="tenantCode" placeholder="模糊匹配" class="w-full" @keyup.enter="onSearch" />
</SearchField>
<SearchField label="TenantName">
<InputText v-model="tenantName" placeholder="模糊匹配" class="w-full" @keyup.enter="onSearch" />
</SearchField>
<SearchField label="OwnerUserID">
<InputNumber v-model="ownerUserID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="OwnerUsername">
<InputText v-model="ownerUsername" placeholder="模糊匹配" class="w-full" @keyup.enter="onSearch" />
</SearchField>
<SearchField label="Keyword">
<InputText v-model="keyword" placeholder="标题关键词" class="w-full" @keyup.enter="onSearch" />
</SearchField>
<SearchField label="状态">
<Select v-model="status" :options="statusOptions" optionLabel="label" optionValue="value" placeholder="请选择" class="w-full" />
</SearchField>
<SearchField label="可见性">
<Select v-model="visibility" :options="visibilityOptions" optionLabel="label" optionValue="value" placeholder="请选择" class="w-full" />
</SearchField>
<SearchField label="价格 From(分)">
<InputNumber v-model="priceAmountMin" :min="0" placeholder=">= 0" class="w-full" />
</SearchField>
<SearchField label="价格 To(分)">
<InputNumber v-model="priceAmountMax" :min="0" placeholder=">= 0" class="w-full" />
</SearchField>
<SearchField label="发布时间 From">
<DatePicker v-model="publishedAtFrom" showIcon showButtonBar placeholder="开始时间" class="w-full" />
</SearchField>
<SearchField label="发布时间 To">
<DatePicker v-model="publishedAtTo" showIcon showButtonBar placeholder="结束时间" class="w-full" />
</SearchField>
<SearchField label="创建时间 From">
<DatePicker v-model="createdAtFrom" showIcon showButtonBar placeholder="开始时间" class="w-full" />
</SearchField>
<SearchField label="创建时间 To">
<DatePicker v-model="createdAtTo" showIcon showButtonBar placeholder="结束时间" class="w-full" />
</SearchField>
</SearchPanel>
<Tabs v-model:value="tabValue" value="contents" class="mt-4">
<TabList>
<Tab value="contents">内容列表</Tab>
<Tab value="comments">评论治理</Tab>
</TabList>
<TabPanels>
<TabPanel value="contents">
<div class="flex items-center justify-between mb-4">
<div class="flex items-center gap-2">
<span class="text-sm text-muted-color">已选 {{ selectedCount }} </span>
</div>
<div class="flex items-center gap-2">
<Button label="批量通过" icon="pi pi-check" severity="success" :disabled="selectedCount === 0" @click="openBatchReviewDialog('approve')" />
<Button label="批量驳回" icon="pi pi-times" severity="danger" :disabled="selectedCount === 0" @click="openBatchReviewDialog('reject')" />
<Button label="刷新" icon="pi pi-refresh" severity="secondary" @click="loadContents" :disabled="loading" />
</div>
</div>
<DataTable
:value="contents"
dataKey="__key"
v-model:selection="selectedContents"
:loading="loading"
lazy
:paginator="true"
:rows="rows"
:totalRecords="totalRecords"
:first="(page - 1) * rows"
:rowsPerPageOptions="[10, 20, 50, 100]"
sortMode="single"
:sortField="sortField"
:sortOrder="sortOrder"
@page="onPage"
@sort="onSort"
currentPageReportTemplate="显示第 {first} - {last} 条,共 {totalRecords} 条"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
scrollable
scrollHeight="640px"
responsiveLayout="scroll"
>
<Column selectionMode="multiple" headerStyle="width: 3rem" />
<Column header="ID" sortable sortField="id" style="min-width: 8rem">
<template #body="{ data }">
<span class="text-muted-color">{{ data?.content?.id ?? '-' }}</span>
</template>
</Column>
<Column header="标题" sortable sortField="title" style="min-width: 22rem">
<template #body="{ data }">
<div class="flex flex-col gap-4">
<SearchPanel :loading="loading" @search="onSearch" @reset="onReset">
<SearchField label="ContentID">
<InputNumber v-model="contentID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="TenantID">
<InputNumber v-model="tenantID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="TenantCode">
<InputText v-model="tenantCode" placeholder="模糊匹配" class="w-full" @keyup.enter="onSearch" />
</SearchField>
<SearchField label="TenantName">
<InputText v-model="tenantName" placeholder="模糊匹配" class="w-full" @keyup.enter="onSearch" />
</SearchField>
<SearchField label="OwnerUserID">
<InputNumber v-model="ownerUserID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="OwnerUsername">
<InputText v-model="ownerUsername" placeholder="模糊匹配" class="w-full" @keyup.enter="onSearch" />
</SearchField>
<SearchField label="Keyword">
<InputText v-model="keyword" placeholder="标题关键词" class="w-full" @keyup.enter="onSearch" />
</SearchField>
<SearchField label="状态">
<Select v-model="status" :options="statusOptions" optionLabel="label" optionValue="value" placeholder="请选择" class="w-full" />
</SearchField>
<SearchField label="可见性">
<Select v-model="visibility" :options="visibilityOptions" optionLabel="label" optionValue="value" placeholder="请选择" class="w-full" />
</SearchField>
<SearchField label="价格 From(分)">
<InputNumber v-model="priceAmountMin" :min="0" placeholder=">= 0" class="w-full" />
</SearchField>
<SearchField label="价格 To(分)">
<InputNumber v-model="priceAmountMax" :min="0" placeholder=">= 0" class="w-full" />
</SearchField>
<SearchField label="发布时间 From">
<DatePicker v-model="publishedAtFrom" showIcon showButtonBar placeholder="开始时间" class="w-full" />
</SearchField>
<SearchField label="发布时间 To">
<DatePicker v-model="publishedAtTo" showIcon showButtonBar placeholder="结束时间" class="w-full" />
</SearchField>
<SearchField label="创建时间 From">
<DatePicker v-model="createdAtFrom" showIcon showButtonBar placeholder="开始时间" class="w-full" />
</SearchField>
<SearchField label="创建时间 To">
<DatePicker v-model="createdAtTo" showIcon showButtonBar placeholder="结束时间" class="w-full" />
</SearchField>
</SearchPanel>
<DataTable
:value="contents"
dataKey="__key"
v-model:selection="selectedContents"
:loading="loading"
lazy
:paginator="true"
:rows="rows"
:totalRecords="totalRecords"
:first="(page - 1) * rows"
:rowsPerPageOptions="[10, 20, 50, 100]"
sortMode="single"
:sortField="sortField"
:sortOrder="sortOrder"
@page="onPage"
@sort="onSort"
currentPageReportTemplate="显示第 {first} - {last} 条,共 {totalRecords} 条"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
scrollable
scrollHeight="640px"
responsiveLayout="scroll"
>
<Column selectionMode="multiple" headerStyle="width: 3rem" />
<Column header="ID" sortable sortField="id" style="min-width: 8rem">
<template #body="{ data }">
<span class="text-muted-color">{{ data?.content?.id ?? '-' }}</span>
</template>
</Column>
<Column header="标题" sortable sortField="title" style="min-width: 22rem">
<template #body="{ data }">
<div class="flex flex-col">
<span class="font-medium truncate max-w-[520px]">{{ data?.content?.title ?? '-' }}</span>
<span class="text-muted-color">TenantID: {{ data?.tenant?.id ?? data?.content?.tenant_id ?? '-' }}</span>
</div>
</template>
</Column>
<Column header="租户" sortable sortField="tenant_id" style="min-width: 18rem">
<template #body="{ data }">
<router-link v-if="data?.tenant?.id" class="inline-flex items-center gap-1 font-medium text-primary hover:underline" :to="`/superadmin/tenants/${data.tenant.id}`">
<span class="truncate max-w-[220px]">{{ data?.tenant?.name ?? data?.tenant?.code ?? '-' }}</span>
<i class="pi pi-external-link text-xs" />
</router-link>
<span v-else class="font-medium text-muted-color">{{ data?.tenant?.name ?? data?.tenant?.code ?? '-' }}</span>
<div class="flex flex-col">
<span class="text-muted-color">ID: {{ data?.tenant?.id ?? data?.content?.tenant_id ?? '-' }}</span>
<span class="text-muted-color">Code: {{ data?.tenant?.code ?? '-' }}</span>
</div>
</template>
</Column>
<Column header="Owner" sortable sortField="user_id" style="min-width: 14rem">
<template #body="{ data }">
<router-link
v-if="(data?.owner?.id ?? data?.content?.user_id) > 0"
class="inline-flex items-center gap-1 font-medium text-primary hover:underline"
:to="`/superadmin/users/${data?.owner?.id ?? data?.content?.user_id}`"
>
<span class="truncate max-w-[200px]">{{ data?.owner?.username ?? `ID:${data?.content?.user_id ?? '-'}` }}</span>
<i class="pi pi-external-link text-xs" />
</router-link>
<span v-else class="font-medium text-muted-color">-</span>
<div class="flex flex-col">
<span class="text-muted-color">ID: {{ data?.content?.user_id ?? '-' }}</span>
</div>
</template>
</Column>
<Column header="状态" sortable sortField="status" style="min-width: 12rem">
<template #body="{ data }">
<Tag :value="data?.status_description || data?.content?.status || '-'" :severity="getContentStatusSeverity(data?.content?.status)" />
</template>
</Column>
<Column header="可见性" sortable sortField="visibility" style="min-width: 12rem">
<template #body="{ data }">
<Tag :value="data?.visibility_description || data?.content?.visibility || '-'" :severity="getContentVisibilitySeverity(data?.content?.visibility)" />
</template>
</Column>
<Column header="价格" style="min-width: 10rem">
<template #body="{ data }">
<span v-if="data?.price && (data.price.price_amount ?? null) !== null">
{{ Number(data.price.price_amount) === 0 ? '免费' : formatCny(data.price.price_amount) }}
</span>
<span v-else class="text-muted-color">-</span>
</template>
</Column>
<Column header="发布时间" sortable sortField="published_at" style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data?.content?.published_at) }}
</template>
</Column>
<Column header="创建时间" sortable sortField="created_at" style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data?.content?.created_at) }}
</template>
</Column>
<Column header="操作" style="min-width: 10rem">
<template #body="{ data }">
<Button v-if="data?.content?.status === 'reviewing'" label="审核" icon="pi pi-check-square" text size="small" class="p-0 mr-3" @click="openReviewDialog(data)" />
<Button v-else-if="data?.content?.status === 'published'" label="下架" icon="pi pi-ban" severity="danger" text size="small" class="p-0" @click="openUnpublishDialog(data)" />
<span v-else class="text-muted-color">-</span>
</template>
</Column>
</DataTable>
</div>
</TabPanel>
<TabPanel value="comments">
<div class="flex items-center justify-between mb-4">
<div class="flex flex-col">
<span class="font-medium truncate max-w-[520px]">{{ data?.content?.title ?? '-' }}</span>
<span class="text-muted-color">TenantID: {{ data?.tenant?.id ?? data?.content?.tenant_id ?? '-' }}</span>
<span class="font-medium">评论列表</span>
<span class="text-muted-color">跨租户评论审查</span>
</div>
</template>
</Column>
<Column header="租户" sortable sortField="tenant_id" style="min-width: 18rem">
<template #body="{ data }">
<router-link v-if="data?.tenant?.id" class="inline-flex items-center gap-1 font-medium text-primary hover:underline" :to="`/superadmin/tenants/${data.tenant.id}`">
<span class="truncate max-w-[220px]">{{ data?.tenant?.name ?? data?.tenant?.code ?? '-' }}</span>
<i class="pi pi-external-link text-xs" />
</router-link>
<span v-else class="font-medium text-muted-color">{{ data?.tenant?.name ?? data?.tenant?.code ?? '-' }}</span>
<div class="flex flex-col">
<span class="text-muted-color">ID: {{ data?.tenant?.id ?? data?.content?.tenant_id ?? '-' }}</span>
<span class="text-muted-color">Code: {{ data?.tenant?.code ?? '-' }}</span>
</div>
</template>
</Column>
<Column header="Owner" sortable sortField="user_id" style="min-width: 14rem">
<template #body="{ data }">
<router-link v-if="(data?.owner?.id ?? data?.content?.user_id) > 0" class="inline-flex items-center gap-1 font-medium text-primary hover:underline" :to="`/superadmin/users/${data?.owner?.id ?? data?.content?.user_id}`">
<span class="truncate max-w-[200px]">{{ data?.owner?.username ?? `ID:${data?.content?.user_id ?? '-'}` }}</span>
<i class="pi pi-external-link text-xs" />
</router-link>
<span v-else class="font-medium text-muted-color">-</span>
<div class="flex flex-col">
<span class="text-muted-color">ID: {{ data?.content?.user_id ?? '-' }}</span>
</div>
</template>
</Column>
<Column header="状态" sortable sortField="status" style="min-width: 12rem">
<template #body="{ data }">
<Tag :value="data?.status_description || data?.content?.status || '-'" :severity="getContentStatusSeverity(data?.content?.status)" />
</template>
</Column>
<Column header="可见性" sortable sortField="visibility" style="min-width: 12rem">
<template #body="{ data }">
<Tag :value="data?.visibility_description || data?.content?.visibility || '-'" :severity="getContentVisibilitySeverity(data?.content?.visibility)" />
</template>
</Column>
<Column header="价格" style="min-width: 10rem">
<template #body="{ data }">
<span v-if="data?.price && (data.price.price_amount ?? null) !== null">
{{ Number(data.price.price_amount) === 0 ? '免费' : formatCny(data.price.price_amount) }}
</span>
<span v-else class="text-muted-color">-</span>
</template>
</Column>
<Column header="发布时间" sortable sortField="published_at" style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data?.content?.published_at) }}
</template>
</Column>
<Column header="创建时间" sortable sortField="created_at" style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data?.content?.created_at) }}
</template>
</Column>
<Column header="操作" style="min-width: 10rem">
<template #body="{ data }">
<Button v-if="data?.content?.status === 'reviewing'" label="审核" icon="pi pi-check-square" text size="small" class="p-0 mr-3" @click="openReviewDialog(data)" />
<Button v-else-if="data?.content?.status === 'published'" label="下架" icon="pi pi-ban" severity="danger" text size="small" class="p-0" @click="openUnpublishDialog(data)" />
<span v-else class="text-muted-color">-</span>
</template>
</Column>
</DataTable>
</div>
<Button label="刷新" icon="pi pi-refresh" severity="secondary" @click="loadComments" :disabled="commentLoading" />
</div>
<div class="flex flex-col gap-4">
<SearchPanel :loading="commentLoading" @search="onCommentSearch" @reset="onCommentReset">
<SearchField label="CommentID">
<InputNumber v-model="commentID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="TenantID">
<InputNumber v-model="commentTenantID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="TenantCode">
<InputText v-model="commentTenantCode" placeholder="模糊匹配" class="w-full" @keyup.enter="onCommentSearch" />
</SearchField>
<SearchField label="TenantName">
<InputText v-model="commentTenantName" placeholder="模糊匹配" class="w-full" @keyup.enter="onCommentSearch" />
</SearchField>
<SearchField label="ContentID">
<InputNumber v-model="commentContentID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="ContentTitle">
<InputText v-model="commentContentTitle" placeholder="内容标题" class="w-full" @keyup.enter="onCommentSearch" />
</SearchField>
<SearchField label="UserID">
<InputNumber v-model="commentUserID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="用户名">
<InputText v-model="commentUsername" placeholder="模糊匹配" class="w-full" @keyup.enter="onCommentSearch" />
</SearchField>
<SearchField label="Keyword">
<InputText v-model="commentKeyword" placeholder="评论关键字" class="w-full" @keyup.enter="onCommentSearch" />
</SearchField>
<SearchField label="状态">
<Select v-model="commentStatus" :options="commentStatusOptions" optionLabel="label" optionValue="value" placeholder="请选择" class="w-full" />
</SearchField>
<SearchField label="创建时间 From">
<DatePicker v-model="commentCreatedAtFrom" showIcon showButtonBar placeholder="开始时间" class="w-full" />
</SearchField>
<SearchField label="创建时间 To">
<DatePicker v-model="commentCreatedAtTo" showIcon showButtonBar placeholder="结束时间" class="w-full" />
</SearchField>
</SearchPanel>
<DataTable
:value="comments"
dataKey="id"
:loading="commentLoading"
lazy
:paginator="true"
:rows="commentRows"
:totalRecords="commentTotalRecords"
:first="(commentPage - 1) * commentRows"
:rowsPerPageOptions="[10, 20, 50, 100]"
sortMode="single"
:sortField="commentSortField"
:sortOrder="commentSortOrder"
@page="onCommentPage"
@sort="onCommentSort"
currentPageReportTemplate="显示第 {first} - {last} 条,共 {totalRecords} 条"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
scrollable
scrollHeight="640px"
responsiveLayout="scroll"
>
<Column field="id" header="评论ID" sortable style="min-width: 8rem" />
<Column header="内容" style="min-width: 18rem">
<template #body="{ data }">
<div class="flex flex-col">
<span class="font-medium truncate max-w-[280px]">{{ data?.content_title || '-' }}</span>
<span class="text-xs text-muted-color">ContentID: {{ data?.content_id ?? '-' }}</span>
</div>
</template>
</Column>
<Column header="租户" style="min-width: 16rem">
<template #body="{ data }">
<div class="flex flex-col">
<span class="font-medium">{{ data?.tenant_name || '-' }}</span>
<span class="text-xs text-muted-color">Code: {{ data?.tenant_code || '-' }} / ID: {{ data?.tenant_id ?? '-' }}</span>
</div>
</template>
</Column>
<Column header="用户" style="min-width: 14rem">
<template #body="{ data }">
<div class="flex flex-col">
<span class="font-medium">{{ data?.username || '-' }}</span>
<span class="text-xs text-muted-color">ID: {{ data?.user_id ?? '-' }}</span>
</div>
</template>
</Column>
<Column header="评论内容" style="min-width: 22rem">
<template #body="{ data }">
<span class="text-sm">{{ formatCommentContent(data?.content) }}</span>
</template>
</Column>
<Column field="reply_to" header="回复ID" style="min-width: 8rem">
<template #body="{ data }">
<span class="text-muted-color">{{ data?.reply_to || '-' }}</span>
</template>
</Column>
<Column field="likes" header="点赞" sortable style="min-width: 8rem" />
<Column header="状态" style="min-width: 10rem">
<template #body="{ data }">
<Tag :value="getCommentStatusLabel(data?.is_deleted)" :severity="getCommentStatusSeverity(data?.is_deleted)" />
</template>
</Column>
<Column field="created_at" header="创建时间" sortable style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data?.created_at) }}
</template>
</Column>
<Column field="deleted_at" header="删除时间" style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data?.deleted_at) }}
</template>
</Column>
<Column header="操作" style="min-width: 10rem">
<template #body="{ data }">
<Button label="删除" icon="pi pi-trash" severity="danger" text size="small" class="p-0" :disabled="data?.is_deleted" @click="openCommentDeleteDialog(data)" />
</template>
</Column>
</DataTable>
</div>
</TabPanel>
</TabPanels>
</Tabs>
</div>
<Dialog v-model:visible="unpublishDialogVisible" :modal="true" :style="{ width: '460px' }">
@@ -537,4 +837,23 @@ watch(
<Button label="确认审核" icon="pi pi-check" severity="success" @click="confirmReview" :loading="reviewSubmitting" :disabled="reviewSubmitting || (reviewAction === 'reject' && !reviewReason.trim())" />
</template>
</Dialog>
<Dialog v-model:visible="commentDeleteDialogVisible" :modal="true" :style="{ width: '520px' }">
<template #header>
<div class="flex items-center gap-2">
<span class="font-medium">删除评论</span>
</div>
</template>
<div class="flex flex-col gap-4">
<div class="text-sm text-muted-color">确认删除该评论删除后在前端将不可见</div>
<div>
<label class="block font-medium mb-2">删除原因</label>
<InputText v-model="commentDeleteReason" placeholder="可选,便于审计" class="w-full" />
</div>
</div>
<template #footer>
<Button label="取消" icon="pi pi-times" text @click="commentDeleteDialogVisible = false" :disabled="commentDeleteLoading" />
<Button label="确认删除" icon="pi pi-trash" severity="danger" @click="confirmCommentDelete" :loading="commentDeleteLoading" />
</template>
</Dialog>
</template>

View File

@@ -8,6 +8,7 @@ import { useRoute } from 'vue-router';
const toast = useToast();
const route = useRoute();
const tabValue = ref('withdrawals');
const withdrawals = ref([]);
const loading = ref(false);
@@ -32,6 +33,55 @@ const amountPaidMax = ref(null);
const sortField = ref('id');
const sortOrder = ref(-1);
const ledgers = ref([]);
const ledgerLoading = ref(false);
const ledgerTotalRecords = ref(0);
const ledgerPage = ref(1);
const ledgerRows = ref(10);
const ledgerID = ref(null);
const ledgerTenantID = ref(null);
const ledgerTenantCode = ref('');
const ledgerTenantName = ref('');
const ledgerUserID = ref(null);
const ledgerUsername = ref('');
const ledgerOrderID = ref(null);
const ledgerType = ref('');
const ledgerAmountMin = ref(null);
const ledgerAmountMax = ref(null);
const ledgerCreatedAtFrom = ref(null);
const ledgerCreatedAtTo = ref(null);
const ledgerSortField = ref('id');
const ledgerSortOrder = ref(-1);
const balanceAnomalies = ref([]);
const balanceLoading = ref(false);
const balanceTotalRecords = ref(0);
const balancePage = ref(1);
const balanceRows = ref(10);
const balanceUserID = ref(null);
const balanceUsername = ref('');
const balanceIssue = ref('');
const balanceSortField = ref('id');
const balanceSortOrder = ref(-1);
const orderAnomalies = ref([]);
const orderAnomalyLoading = ref(false);
const orderAnomalyTotalRecords = ref(0);
const orderAnomalyPage = ref(1);
const orderAnomalyRows = ref(10);
const orderAnomalyID = ref(null);
const orderAnomalyTenantID = ref(null);
const orderAnomalyTenantCode = ref('');
const orderAnomalyTenantName = ref('');
const orderAnomalyUserID = ref(null);
const orderAnomalyUsername = ref('');
const orderAnomalyType = ref('');
const orderAnomalyIssue = ref('');
const orderAnomalyCreatedAtFrom = ref(null);
const orderAnomalyCreatedAtTo = ref(null);
const orderAnomalySortField = ref('id');
const orderAnomalySortOrder = ref(-1);
const statusOptions = [
{ label: '全部', value: '' },
{ label: 'created', value: 'created' },
@@ -39,6 +89,35 @@ const statusOptions = [
{ label: 'failed', value: 'failed' }
];
const ledgerTypeOptions = [
{ label: '全部', value: '' },
{ label: '内容收入', value: 'debit_purchase' },
{ label: '退款冲回', value: 'credit_refund' },
{ label: '提现扣减', value: 'credit_withdrawal' },
{ label: '冻结', value: 'freeze' },
{ label: '解冻', value: 'unfreeze' },
{ label: '调整', value: 'adjustment' }
];
const balanceIssueOptions = [
{ label: '全部', value: '' },
{ label: '可用余额为负', value: 'negative_balance' },
{ label: '冻结余额为负', value: 'negative_frozen' }
];
const orderTypeOptions = [
{ label: '全部', value: '' },
{ label: '内容购买', value: 'content_purchase' },
{ label: '充值', value: 'recharge' },
{ label: '提现', value: 'withdrawal' }
];
const orderIssueOptions = [
{ label: '全部', value: '' },
{ label: '支付时间缺失', value: 'missing_paid_at' },
{ label: '退款时间缺失', value: 'missing_refunded_at' }
];
function getQueryValue(value) {
if (Array.isArray(value)) return value[0];
return value ?? null;
@@ -114,6 +193,53 @@ function getStatusSeverity(value) {
}
}
function formatLedgerType(value) {
switch (value) {
case 'debit_purchase':
return '内容收入';
case 'credit_refund':
return '退款冲回';
case 'credit_withdrawal':
return '提现扣减';
case 'freeze':
return '冻结';
case 'unfreeze':
return '解冻';
case 'adjustment':
return '调整';
default:
return value || '-';
}
}
function formatOrderType(value) {
switch (value) {
case 'content_purchase':
return '内容购买';
case 'recharge':
return '充值';
case 'withdrawal':
return '提现';
default:
return value || '-';
}
}
function formatOrderStatus(value) {
switch (value) {
case 'paid':
return '已支付';
case 'refunded':
return '已退款';
case 'created':
return '待处理';
case 'failed':
return '失败';
default:
return value || '-';
}
}
async function loadWithdrawals() {
loading.value = true;
try {
@@ -221,6 +347,197 @@ function onSort(event) {
loadWithdrawals();
}
async function loadLedgers() {
ledgerLoading.value = true;
try {
const result = await FinanceService.listLedgers({
page: ledgerPage.value,
limit: ledgerRows.value,
id: ledgerID.value || undefined,
tenant_id: ledgerTenantID.value || undefined,
tenant_code: ledgerTenantCode.value,
tenant_name: ledgerTenantName.value,
user_id: ledgerUserID.value || undefined,
username: ledgerUsername.value,
order_id: ledgerOrderID.value || undefined,
type: ledgerType.value || undefined,
amount_min: ledgerAmountMin.value ?? undefined,
amount_max: ledgerAmountMax.value ?? undefined,
created_at_from: ledgerCreatedAtFrom.value || undefined,
created_at_to: ledgerCreatedAtTo.value || undefined,
sortField: ledgerSortField.value,
sortOrder: ledgerSortOrder.value
});
ledgers.value = result.items;
ledgerTotalRecords.value = result.total;
} catch (error) {
toast.add({ severity: 'error', summary: '加载失败', detail: error?.message || '无法加载资金流水', life: 4000 });
} finally {
ledgerLoading.value = false;
}
}
function resetLedgerFilters() {
ledgerID.value = null;
ledgerTenantID.value = null;
ledgerTenantCode.value = '';
ledgerTenantName.value = '';
ledgerUserID.value = null;
ledgerUsername.value = '';
ledgerOrderID.value = null;
ledgerType.value = '';
ledgerAmountMin.value = null;
ledgerAmountMax.value = null;
ledgerCreatedAtFrom.value = null;
ledgerCreatedAtTo.value = null;
ledgerSortField.value = 'id';
ledgerSortOrder.value = -1;
ledgerPage.value = 1;
ledgerRows.value = 10;
}
function onLedgerSearch() {
ledgerPage.value = 1;
loadLedgers();
}
function onLedgerReset() {
resetLedgerFilters();
loadLedgers();
}
function onLedgerPage(event) {
ledgerPage.value = (event.page ?? 0) + 1;
ledgerRows.value = event.rows ?? ledgerRows.value;
loadLedgers();
}
function onLedgerSort(event) {
ledgerSortField.value = event.sortField ?? ledgerSortField.value;
ledgerSortOrder.value = event.sortOrder ?? ledgerSortOrder.value;
loadLedgers();
}
async function loadBalanceAnomalies() {
balanceLoading.value = true;
try {
const result = await FinanceService.listBalanceAnomalies({
page: balancePage.value,
limit: balanceRows.value,
user_id: balanceUserID.value || undefined,
username: balanceUsername.value,
issue: balanceIssue.value || undefined,
sortField: balanceSortField.value,
sortOrder: balanceSortOrder.value
});
balanceAnomalies.value = result.items;
balanceTotalRecords.value = result.total;
} catch (error) {
toast.add({ severity: 'error', summary: '加载失败', detail: error?.message || '无法加载余额异常', life: 4000 });
} finally {
balanceLoading.value = false;
}
}
function resetBalanceFilters() {
balanceUserID.value = null;
balanceUsername.value = '';
balanceIssue.value = '';
balanceSortField.value = 'id';
balanceSortOrder.value = -1;
balancePage.value = 1;
balanceRows.value = 10;
}
function onBalanceSearch() {
balancePage.value = 1;
loadBalanceAnomalies();
}
function onBalanceReset() {
resetBalanceFilters();
loadBalanceAnomalies();
}
function onBalancePage(event) {
balancePage.value = (event.page ?? 0) + 1;
balanceRows.value = event.rows ?? balanceRows.value;
loadBalanceAnomalies();
}
function onBalanceSort(event) {
balanceSortField.value = event.sortField ?? balanceSortField.value;
balanceSortOrder.value = event.sortOrder ?? balanceSortOrder.value;
loadBalanceAnomalies();
}
async function loadOrderAnomalies() {
orderAnomalyLoading.value = true;
try {
const result = await FinanceService.listOrderAnomalies({
page: orderAnomalyPage.value,
limit: orderAnomalyRows.value,
id: orderAnomalyID.value || undefined,
tenant_id: orderAnomalyTenantID.value || undefined,
tenant_code: orderAnomalyTenantCode.value,
tenant_name: orderAnomalyTenantName.value,
user_id: orderAnomalyUserID.value || undefined,
username: orderAnomalyUsername.value,
type: orderAnomalyType.value || undefined,
issue: orderAnomalyIssue.value || undefined,
created_at_from: orderAnomalyCreatedAtFrom.value || undefined,
created_at_to: orderAnomalyCreatedAtTo.value || undefined,
sortField: orderAnomalySortField.value,
sortOrder: orderAnomalySortOrder.value
});
orderAnomalies.value = result.items;
orderAnomalyTotalRecords.value = result.total;
} catch (error) {
toast.add({ severity: 'error', summary: '加载失败', detail: error?.message || '无法加载订单异常', life: 4000 });
} finally {
orderAnomalyLoading.value = false;
}
}
function resetOrderAnomalyFilters() {
orderAnomalyID.value = null;
orderAnomalyTenantID.value = null;
orderAnomalyTenantCode.value = '';
orderAnomalyTenantName.value = '';
orderAnomalyUserID.value = null;
orderAnomalyUsername.value = '';
orderAnomalyType.value = '';
orderAnomalyIssue.value = '';
orderAnomalyCreatedAtFrom.value = null;
orderAnomalyCreatedAtTo.value = null;
orderAnomalySortField.value = 'id';
orderAnomalySortOrder.value = -1;
orderAnomalyPage.value = 1;
orderAnomalyRows.value = 10;
}
function onOrderAnomalySearch() {
orderAnomalyPage.value = 1;
loadOrderAnomalies();
}
function onOrderAnomalyReset() {
resetOrderAnomalyFilters();
loadOrderAnomalies();
}
function onOrderAnomalyPage(event) {
orderAnomalyPage.value = (event.page ?? 0) + 1;
orderAnomalyRows.value = event.rows ?? orderAnomalyRows.value;
loadOrderAnomalies();
}
function onOrderAnomalySort(event) {
orderAnomalySortField.value = event.sortField ?? orderAnomalySortField.value;
orderAnomalySortOrder.value = event.sortOrder ?? orderAnomalySortOrder.value;
loadOrderAnomalies();
}
function openApproveDialog(order) {
approveOrder.value = order;
approveDialogVisible.value = true;
@@ -264,9 +581,24 @@ async function confirmReject() {
}
}
watch(
() => tabValue.value,
(value) => {
if (value === 'ledgers') {
loadLedgers();
} else if (value === 'anomalies') {
loadBalanceAnomalies();
loadOrderAnomalies();
} else if (value === 'withdrawals') {
loadWithdrawals();
}
}
);
watch(
() => route.query,
(query) => {
tabValue.value = 'withdrawals';
applyRouteQuery(query);
loadWithdrawals();
},
@@ -277,133 +609,450 @@ watch(
<template>
<div class="card">
<div class="flex items-center justify-between mb-4">
<h4 class="m-0">提现审核</h4>
<div class="flex flex-col">
<h4 class="m-0">财务与钱包</h4>
<span class="text-muted-color">提现审核资金流水与异常排查</span>
</div>
</div>
<SearchPanel :loading="loading" @search="onSearch" @reset="onReset">
<SearchField label="OrderID">
<InputNumber v-model="orderID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="TenantID">
<InputNumber v-model="tenantID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="Tenant Code">
<InputText v-model="tenantCode" placeholder="模糊匹配" class="w-full" @keyup.enter="onSearch" />
</SearchField>
<SearchField label="Tenant Name">
<InputText v-model="tenantName" placeholder="模糊匹配" class="w-full" @keyup.enter="onSearch" />
</SearchField>
<SearchField label="UserID">
<InputNumber v-model="userID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="用户名">
<IconField>
<InputIcon>
<i class="pi pi-search" />
</InputIcon>
<InputText v-model="username" placeholder="模糊匹配" class="w-full" @keyup.enter="onSearch" />
</IconField>
</SearchField>
<SearchField label="状态">
<Select v-model="status" :options="statusOptions" optionLabel="label" optionValue="value" placeholder="请选择" class="w-full" />
</SearchField>
<SearchField label="创建时间 From">
<DatePicker v-model="createdAtFrom" showIcon showButtonBar placeholder="开始时间" class="w-full" />
</SearchField>
<SearchField label="创建时间 To">
<DatePicker v-model="createdAtTo" showIcon showButtonBar placeholder="结束时间" class="w-full" />
</SearchField>
<SearchField label="支付时间 From">
<DatePicker v-model="paidAtFrom" showIcon showButtonBar placeholder="开始时间" class="w-full" />
</SearchField>
<SearchField label="支付时间 To">
<DatePicker v-model="paidAtTo" showIcon showButtonBar placeholder="结束时间" class="w-full" />
</SearchField>
<SearchField label="金额 Min">
<InputNumber v-model="amountPaidMin" :min="0" placeholder=">= 0" class="w-full" />
</SearchField>
<SearchField label="金额 Max">
<InputNumber v-model="amountPaidMax" :min="0" placeholder=">= 0" class="w-full" />
</SearchField>
</SearchPanel>
<Tabs v-model:value="tabValue" value="withdrawals" class="mt-4">
<TabList>
<Tab value="withdrawals">提现审核</Tab>
<Tab value="ledgers">钱包流水</Tab>
<Tab value="anomalies">异常排查</Tab>
</TabList>
<TabPanels>
<TabPanel value="withdrawals">
<div class="flex items-center justify-between mb-4">
<div class="flex flex-col">
<span class="font-medium">提现审核</span>
<span class="text-muted-color">跨租户提现申请</span>
</div>
<Button label="刷新" icon="pi pi-refresh" severity="secondary" @click="loadWithdrawals" :disabled="loading" />
</div>
<DataTable
:value="withdrawals"
dataKey="id"
:loading="loading"
lazy
:paginator="true"
:rows="rows"
:totalRecords="totalRecords"
:first="(page - 1) * rows"
:rowsPerPageOptions="[10, 20, 50, 100]"
sortMode="single"
:sortField="sortField"
:sortOrder="sortOrder"
@page="onPage"
@sort="onSort"
currentPageReportTemplate="显示第 {first} - {last} 条,共 {totalRecords} 条"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
scrollable
scrollHeight="flex"
responsiveLayout="scroll"
>
<Column field="id" header="订单ID" sortable style="min-width: 7rem" />
<Column header="租户" style="min-width: 16rem">
<template #body="{ data }">
<div class="flex flex-col">
<span class="font-medium">{{ data.tenant?.name || '-' }}</span>
<span class="text-xs text-muted-color">Code: {{ data.tenant?.code || '-' }}</span>
<SearchPanel :loading="loading" @search="onSearch" @reset="onReset">
<SearchField label="OrderID">
<InputNumber v-model="orderID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="TenantID">
<InputNumber v-model="tenantID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="Tenant Code">
<InputText v-model="tenantCode" placeholder="模糊匹配" class="w-full" @keyup.enter="onSearch" />
</SearchField>
<SearchField label="Tenant Name">
<InputText v-model="tenantName" placeholder="模糊匹配" class="w-full" @keyup.enter="onSearch" />
</SearchField>
<SearchField label="UserID">
<InputNumber v-model="userID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="用户名">
<IconField>
<InputIcon>
<i class="pi pi-search" />
</InputIcon>
<InputText v-model="username" placeholder="模糊匹配" class="w-full" @keyup.enter="onSearch" />
</IconField>
</SearchField>
<SearchField label="状态">
<Select v-model="status" :options="statusOptions" optionLabel="label" optionValue="value" placeholder="请选择" class="w-full" />
</SearchField>
<SearchField label="创建时间 From">
<DatePicker v-model="createdAtFrom" showIcon showButtonBar placeholder="开始时间" class="w-full" />
</SearchField>
<SearchField label="创建时间 To">
<DatePicker v-model="createdAtTo" showIcon showButtonBar placeholder="结束时间" class="w-full" />
</SearchField>
<SearchField label="支付时间 From">
<DatePicker v-model="paidAtFrom" showIcon showButtonBar placeholder="开始时间" class="w-full" />
</SearchField>
<SearchField label="支付时间 To">
<DatePicker v-model="paidAtTo" showIcon showButtonBar placeholder="结束时间" class="w-full" />
</SearchField>
<SearchField label="金额 Min">
<InputNumber v-model="amountPaidMin" :min="0" placeholder=">= 0" class="w-full" />
</SearchField>
<SearchField label="金额 Max">
<InputNumber v-model="amountPaidMax" :min="0" placeholder=">= 0" class="w-full" />
</SearchField>
</SearchPanel>
<DataTable
:value="withdrawals"
dataKey="id"
:loading="loading"
lazy
:paginator="true"
:rows="rows"
:totalRecords="totalRecords"
:first="(page - 1) * rows"
:rowsPerPageOptions="[10, 20, 50, 100]"
sortMode="single"
:sortField="sortField"
:sortOrder="sortOrder"
@page="onPage"
@sort="onSort"
currentPageReportTemplate="显示第 {first} - {last} 条,共 {totalRecords} 条"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
scrollable
scrollHeight="flex"
responsiveLayout="scroll"
>
<Column field="id" header="订单ID" sortable style="min-width: 7rem" />
<Column header="租户" style="min-width: 16rem">
<template #body="{ data }">
<div class="flex flex-col">
<span class="font-medium">{{ data.tenant?.name || '-' }}</span>
<span class="text-xs text-muted-color">Code: {{ data.tenant?.code || '-' }}</span>
</div>
</template>
</Column>
<Column header="申请人" style="min-width: 12rem">
<template #body="{ data }">
<span v-if="data.buyer?.username">{{ data.buyer.username }}</span>
<span v-else class="text-muted-color">{{ data.buyer?.id ?? '-' }}</span>
</template>
</Column>
<Column header="收款账户" style="min-width: 16rem">
<template #body="{ data }">
<div v-if="resolveWithdrawalSnapshot(data)" class="flex flex-col">
<span class="font-medium">{{ resolveWithdrawalSnapshot(data).account_realname || '-' }}</span>
<span class="text-xs text-muted-color">
{{ formatWithdrawMethod(resolveWithdrawalSnapshot(data).method) }} · {{ resolveWithdrawalSnapshot(data).account_type || '-' }} ·
{{ resolveWithdrawalSnapshot(data).account || '-' }}
</span>
</div>
<span v-else class="text-muted-color">-</span>
</template>
</Column>
<Column field="amount_paid" header="金额" sortable style="min-width: 10rem">
<template #body="{ data }">
{{ formatCny(data.amount_paid) }}
</template>
</Column>
<Column field="status" header="状态" style="min-width: 10rem">
<template #body="{ data }">
<Tag :value="data.status_description || data.status || '-'" :severity="getStatusSeverity(data.status)" />
</template>
</Column>
<Column field="created_at" header="创建时间" sortable style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data.created_at) }}
</template>
</Column>
<Column field="paid_at" header="支付时间" sortable style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data.paid_at) }}
</template>
</Column>
<Column header="操作" style="min-width: 12rem">
<template #body="{ data }">
<div class="flex items-center gap-2">
<Button label="通过" icon="pi pi-check" size="small" severity="success" :disabled="data.status !== 'created'" @click="openApproveDialog(data)" />
<Button label="驳回" icon="pi pi-times" size="small" severity="danger" :disabled="data.status !== 'created'" @click="openRejectDialog(data)" />
</div>
</template>
</Column>
</DataTable>
</TabPanel>
<TabPanel value="ledgers">
<div class="flex items-center justify-between mb-4">
<div class="flex flex-col">
<span class="font-medium">资金流水</span>
<span class="text-muted-color">跨租户流水审查</span>
</div>
<Button label="刷新" icon="pi pi-refresh" severity="secondary" @click="loadLedgers" :disabled="ledgerLoading" />
</div>
</template>
</Column>
<Column header="申请人" style="min-width: 12rem">
<template #body="{ data }">
<span v-if="data.buyer?.username">{{ data.buyer.username }}</span>
<span v-else class="text-muted-color">{{ data.buyer?.id ?? '-' }}</span>
</template>
</Column>
<Column header="收款账户" style="min-width: 16rem">
<template #body="{ data }">
<div v-if="resolveWithdrawalSnapshot(data)" class="flex flex-col">
<span class="font-medium">{{ resolveWithdrawalSnapshot(data).account_realname || '-' }}</span>
<span class="text-xs text-muted-color">
{{ formatWithdrawMethod(resolveWithdrawalSnapshot(data).method) }} · {{ resolveWithdrawalSnapshot(data).account_type || '-' }} ·
{{ resolveWithdrawalSnapshot(data).account || '-' }}
</span>
<SearchPanel :loading="ledgerLoading" @search="onLedgerSearch" @reset="onLedgerReset">
<SearchField label="LedgerID">
<InputNumber v-model="ledgerID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="TenantID">
<InputNumber v-model="ledgerTenantID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="Tenant Code">
<InputText v-model="ledgerTenantCode" placeholder="模糊匹配" class="w-full" @keyup.enter="onLedgerSearch" />
</SearchField>
<SearchField label="Tenant Name">
<InputText v-model="ledgerTenantName" placeholder="模糊匹配" class="w-full" @keyup.enter="onLedgerSearch" />
</SearchField>
<SearchField label="UserID">
<InputNumber v-model="ledgerUserID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="用户名">
<InputText v-model="ledgerUsername" placeholder="模糊匹配" class="w-full" @keyup.enter="onLedgerSearch" />
</SearchField>
<SearchField label="OrderID">
<InputNumber v-model="ledgerOrderID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="类型">
<Select v-model="ledgerType" :options="ledgerTypeOptions" optionLabel="label" optionValue="value" placeholder="请选择" class="w-full" />
</SearchField>
<SearchField label="金额 Min">
<InputNumber v-model="ledgerAmountMin" :min="0" placeholder=">= 0" class="w-full" />
</SearchField>
<SearchField label="金额 Max">
<InputNumber v-model="ledgerAmountMax" :min="0" placeholder=">= 0" class="w-full" />
</SearchField>
<SearchField label="创建时间 From">
<DatePicker v-model="ledgerCreatedAtFrom" showIcon showButtonBar placeholder="开始时间" class="w-full" />
</SearchField>
<SearchField label="创建时间 To">
<DatePicker v-model="ledgerCreatedAtTo" showIcon showButtonBar placeholder="结束时间" class="w-full" />
</SearchField>
</SearchPanel>
<DataTable
:value="ledgers"
dataKey="id"
:loading="ledgerLoading"
lazy
:paginator="true"
:rows="ledgerRows"
:totalRecords="ledgerTotalRecords"
:first="(ledgerPage - 1) * ledgerRows"
:rowsPerPageOptions="[10, 20, 50, 100]"
sortMode="single"
:sortField="ledgerSortField"
:sortOrder="ledgerSortOrder"
@page="onLedgerPage"
@sort="onLedgerSort"
currentPageReportTemplate="显示第 {first} - {last} 条,共 {totalRecords} 条"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
scrollable
scrollHeight="640px"
responsiveLayout="scroll"
>
<Column field="id" header="流水ID" sortable style="min-width: 8rem" />
<Column header="租户" style="min-width: 16rem">
<template #body="{ data }">
<div class="flex flex-col">
<span class="font-medium">{{ data?.tenant_name || '-' }}</span>
<span class="text-xs text-muted-color">Code: {{ data?.tenant_code || '-' }} / ID: {{ data?.tenant_id ?? '-' }}</span>
</div>
</template>
</Column>
<Column header="用户" style="min-width: 14rem">
<template #body="{ data }">
<div class="flex flex-col">
<span class="font-medium">{{ data?.username || '-' }}</span>
<span class="text-xs text-muted-color">ID: {{ data?.user_id ?? '-' }}</span>
</div>
</template>
</Column>
<Column field="order_id" header="订单ID" style="min-width: 10rem" />
<Column field="type" header="类型" style="min-width: 12rem">
<template #body="{ data }">
{{ formatLedgerType(data?.type) }}
</template>
</Column>
<Column field="amount" header="金额" sortable style="min-width: 10rem">
<template #body="{ data }">
{{ formatCny(data?.amount) }}
</template>
</Column>
<Column header="余额变化" style="min-width: 14rem">
<template #body="{ data }">
<div class="flex flex-col">
<span>{{ formatCny(data?.balance_before) }} {{ formatCny(data?.balance_after) }}</span>
<span class="text-xs text-muted-color">冻结 {{ formatCny(data?.frozen_before) }} {{ formatCny(data?.frozen_after) }}</span>
</div>
</template>
</Column>
<Column field="remark" header="备注" style="min-width: 18rem">
<template #body="{ data }">
<span class="text-sm">{{ data?.remark || '-' }}</span>
</template>
</Column>
<Column field="created_at" header="时间" sortable style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data?.created_at) }}
</template>
</Column>
</DataTable>
</TabPanel>
<TabPanel value="anomalies">
<div class="flex flex-col gap-6">
<div class="flex flex-col gap-4">
<div class="flex items-center justify-between">
<div class="flex flex-col">
<span class="font-medium">余额异常</span>
<span class="text-muted-color">负余额与冻结异常</span>
</div>
<Button label="刷新" icon="pi pi-refresh" severity="secondary" @click="loadBalanceAnomalies" :disabled="balanceLoading" />
</div>
<SearchPanel :loading="balanceLoading" @search="onBalanceSearch" @reset="onBalanceReset">
<SearchField label="UserID">
<InputNumber v-model="balanceUserID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="用户名">
<InputText v-model="balanceUsername" placeholder="模糊匹配" class="w-full" @keyup.enter="onBalanceSearch" />
</SearchField>
<SearchField label="异常类型">
<Select v-model="balanceIssue" :options="balanceIssueOptions" optionLabel="label" optionValue="value" placeholder="请选择" class="w-full" />
</SearchField>
</SearchPanel>
<DataTable
:value="balanceAnomalies"
dataKey="user_id"
:loading="balanceLoading"
lazy
:paginator="true"
:rows="balanceRows"
:totalRecords="balanceTotalRecords"
:first="(balancePage - 1) * balanceRows"
:rowsPerPageOptions="[10, 20, 50, 100]"
sortMode="single"
:sortField="balanceSortField"
:sortOrder="balanceSortOrder"
@page="onBalancePage"
@sort="onBalanceSort"
currentPageReportTemplate="显示第 {first} - {last} 条,共 {totalRecords} 条"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
scrollable
scrollHeight="420px"
responsiveLayout="scroll"
>
<Column field="user_id" header="用户ID" sortable style="min-width: 8rem" />
<Column field="username" header="用户名" style="min-width: 12rem" />
<Column field="balance" header="可用余额" sortable style="min-width: 10rem">
<template #body="{ data }">
{{ formatCny(data?.balance) }}
</template>
</Column>
<Column field="balance_frozen" header="冻结余额" sortable style="min-width: 10rem">
<template #body="{ data }">
{{ formatCny(data?.balance_frozen) }}
</template>
</Column>
<Column field="issue_description" header="异常说明" style="min-width: 18rem" />
<Column field="created_at" header="创建时间" sortable style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data?.created_at) }}
</template>
</Column>
</DataTable>
</div>
<div class="flex flex-col gap-4">
<div class="flex items-center justify-between">
<div class="flex flex-col">
<span class="font-medium">订单异常</span>
<span class="text-muted-color">充值/退款时间缺失</span>
</div>
<Button label="刷新" icon="pi pi-refresh" severity="secondary" @click="loadOrderAnomalies" :disabled="orderAnomalyLoading" />
</div>
<SearchPanel :loading="orderAnomalyLoading" @search="onOrderAnomalySearch" @reset="onOrderAnomalyReset">
<SearchField label="OrderID">
<InputNumber v-model="orderAnomalyID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="TenantID">
<InputNumber v-model="orderAnomalyTenantID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="Tenant Code">
<InputText v-model="orderAnomalyTenantCode" placeholder="模糊匹配" class="w-full" @keyup.enter="onOrderAnomalySearch" />
</SearchField>
<SearchField label="Tenant Name">
<InputText v-model="orderAnomalyTenantName" placeholder="模糊匹配" class="w-full" @keyup.enter="onOrderAnomalySearch" />
</SearchField>
<SearchField label="UserID">
<InputNumber v-model="orderAnomalyUserID" :min="1" placeholder="精确匹配" class="w-full" />
</SearchField>
<SearchField label="用户名">
<InputText v-model="orderAnomalyUsername" placeholder="模糊匹配" class="w-full" @keyup.enter="onOrderAnomalySearch" />
</SearchField>
<SearchField label="订单类型">
<Select v-model="orderAnomalyType" :options="orderTypeOptions" optionLabel="label" optionValue="value" placeholder="请选择" class="w-full" />
</SearchField>
<SearchField label="异常类型">
<Select v-model="orderAnomalyIssue" :options="orderIssueOptions" optionLabel="label" optionValue="value" placeholder="请选择" class="w-full" />
</SearchField>
<SearchField label="创建时间 From">
<DatePicker v-model="orderAnomalyCreatedAtFrom" showIcon showButtonBar placeholder="开始时间" class="w-full" />
</SearchField>
<SearchField label="创建时间 To">
<DatePicker v-model="orderAnomalyCreatedAtTo" showIcon showButtonBar placeholder="结束时间" class="w-full" />
</SearchField>
</SearchPanel>
<DataTable
:value="orderAnomalies"
dataKey="order_id"
:loading="orderAnomalyLoading"
lazy
:paginator="true"
:rows="orderAnomalyRows"
:totalRecords="orderAnomalyTotalRecords"
:first="(orderAnomalyPage - 1) * orderAnomalyRows"
:rowsPerPageOptions="[10, 20, 50, 100]"
sortMode="single"
:sortField="orderAnomalySortField"
:sortOrder="orderAnomalySortOrder"
@page="onOrderAnomalyPage"
@sort="onOrderAnomalySort"
currentPageReportTemplate="显示第 {first} - {last} 条,共 {totalRecords} 条"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
scrollable
scrollHeight="420px"
responsiveLayout="scroll"
>
<Column field="order_id" header="订单ID" sortable style="min-width: 8rem" />
<Column field="type" header="类型" style="min-width: 10rem">
<template #body="{ data }">
{{ formatOrderType(data?.type) }}
</template>
</Column>
<Column field="status" header="状态" style="min-width: 10rem">
<template #body="{ data }">
<Tag :value="formatOrderStatus(data?.status)" :severity="getStatusSeverity(data?.status)" />
</template>
</Column>
<Column field="issue_description" header="异常说明" style="min-width: 16rem" />
<Column header="租户" style="min-width: 16rem">
<template #body="{ data }">
<div class="flex flex-col">
<span class="font-medium">{{ data?.tenant_name || '-' }}</span>
<span class="text-xs text-muted-color">Code: {{ data?.tenant_code || '-' }} / ID: {{ data?.tenant_id ?? '-' }}</span>
</div>
</template>
</Column>
<Column header="用户" style="min-width: 14rem">
<template #body="{ data }">
<div class="flex flex-col">
<span class="font-medium">{{ data?.username || '-' }}</span>
<span class="text-xs text-muted-color">ID: {{ data?.user_id ?? '-' }}</span>
</div>
</template>
</Column>
<Column field="amount_paid" header="金额" sortable style="min-width: 10rem">
<template #body="{ data }">
{{ formatCny(data?.amount_paid) }}
</template>
</Column>
<Column field="created_at" header="创建时间" sortable style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data?.created_at) }}
</template>
</Column>
<Column field="paid_at" header="支付时间" style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data?.paid_at) }}
</template>
</Column>
<Column field="refunded_at" header="退款时间" style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data?.refunded_at) }}
</template>
</Column>
</DataTable>
</div>
</div>
<span v-else class="text-muted-color">-</span>
</template>
</Column>
<Column field="amount_paid" header="金额" sortable style="min-width: 10rem">
<template #body="{ data }">
{{ formatCny(data.amount_paid) }}
</template>
</Column>
<Column field="status" header="状态" style="min-width: 10rem">
<template #body="{ data }">
<Tag :value="data.status_description || data.status || '-'" :severity="getStatusSeverity(data.status)" />
</template>
</Column>
<Column field="created_at" header="创建时间" sortable style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data.created_at) }}
</template>
</Column>
<Column field="paid_at" header="支付时间" sortable style="min-width: 14rem">
<template #body="{ data }">
{{ formatDate(data.paid_at) }}
</template>
</Column>
<Column header="操作" style="min-width: 12rem">
<template #body="{ data }">
<div class="flex items-center gap-2">
<Button label="通过" icon="pi pi-check" size="small" severity="success" :disabled="data.status !== 'created'" @click="openApproveDialog(data)" />
<Button label="驳回" icon="pi pi-times" size="small" severity="danger" :disabled="data.status !== 'created'" @click="openRejectDialog(data)" />
</div>
</template>
</Column>
</DataTable>
</TabPanel>
</TabPanels>
</Tabs>
</div>
<Dialog v-model:visible="approveDialogVisible" :modal="true" :style="{ width: '420px' }">