feat: 合同付款预警迁移到agent页面
This commit is contained in:
1 parent
ef6bc42c20
commit
4ce2defef0
49 files changed
+1052
-423
No files matched your search
@@ -0,0 +1,202 @@
|
||||
<!--
|
||||
features/contract-payment/components/ContractPaymentChatPanel.vue
|
||||
用途:合同付款预警 Chat 主区:管理员按钮、三 Tab、当前 Tab 内详情下钻。
|
||||
依赖:contract-payment 三页与详情、useContractPaymentAdminActions、vue-router query。
|
||||
逻辑:由 ChatViewContent 在 agent_code=contract_payment 时替换消息列表与输入框;
|
||||
view / contractId 写入 /chat/:agentId 查询参数,旧工作台地址重定向后仍可深链打开。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { CalendarClock, RefreshCw, Send } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { listContractPaymentContracts } from '../api/contract-payment.api';
|
||||
import { useContractPaymentAdminActions } from '../composables/useContractPaymentAdminActions';
|
||||
import type { ContractPaymentView } from '../constants';
|
||||
import {
|
||||
buildContractPaymentChatQuery,
|
||||
parseContractPaymentChatQuery,
|
||||
} from '../utils/contractPaymentChat.utils';
|
||||
import ContractPaymentPage from '../views/ContractPaymentPage.vue';
|
||||
import ContractPaymentReviewPage from '../views/ContractPaymentReviewPage.vue';
|
||||
import ContractPaymentWeeklyBatchesPage from '../views/ContractPaymentWeeklyBatchesPage.vue';
|
||||
import ContractPaymentDetailPage from '../views/ContractPaymentDetailPage.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const parsedQuery = computed(() => parseContractPaymentChatQuery(route.query.view, route.query.contractId));
|
||||
const activeView = computed<ContractPaymentView>(() => parsedQuery.value.view);
|
||||
const detailId = computed(() => parsedQuery.value.contractId);
|
||||
const reviewCount = ref(0);
|
||||
|
||||
const {
|
||||
isAdmin,
|
||||
actionLoading,
|
||||
showForceSyncConfirm,
|
||||
showReparseExistingConfirm,
|
||||
run,
|
||||
confirmForceSync,
|
||||
confirmReparseExisting,
|
||||
} = useContractPaymentAdminActions();
|
||||
|
||||
const tabs = computed(() => ([
|
||||
{ key: 'ledger' as const, label: t('admin.contractPayment.ledger') },
|
||||
{ key: 'review' as const, label: t('admin.contractPaymentReview.title'), count: reviewCount.value },
|
||||
{ key: 'batches' as const, label: t('admin.contractPayment.weeklyBatchesTitle') },
|
||||
]));
|
||||
|
||||
/**
|
||||
* 把当前 Tab / 详情写入 Chat 路由,保持刷新与旧地址重定向可用。
|
||||
* 核心逻辑:replace 避免 Tab 切换堆积历史;切 Tab 时清掉 contractId。
|
||||
*/
|
||||
async function syncQuery(view: ContractPaymentView, contractId: number | null): Promise<void> {
|
||||
const nextQuery = buildContractPaymentChatQuery(view, contractId);
|
||||
const currentView = String(route.query.view || '');
|
||||
const currentContractId = String(route.query.contractId || '');
|
||||
if (currentView === nextQuery.view && currentContractId === (nextQuery.contractId || '')) return;
|
||||
const query = { ...route.query, ...nextQuery };
|
||||
if (!contractId) delete query.contractId;
|
||||
await router.replace({ params: { ...route.params }, query });
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换主 Tab;详情下钻随 Tab 关闭,避免第四个隐形页。
|
||||
*/
|
||||
function selectView(view: ContractPaymentView): void {
|
||||
void syncQuery(view, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在当前 Tab 内打开合同详情。
|
||||
*/
|
||||
function openDetail(contractId: number): void {
|
||||
void syncQuery(activeView.value, contractId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从详情返回当前 Tab 列表。
|
||||
*/
|
||||
function closeDetail(): void {
|
||||
void syncQuery(activeView.value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取待确认合同数量,供 Tab 角标展示。
|
||||
* 核心逻辑:只取 total,不拉列表正文,失败时角标归零不打断主区。
|
||||
*/
|
||||
async function loadReviewCount(): Promise<void> {
|
||||
try {
|
||||
const result = await listContractPaymentContracts({
|
||||
reviewOnly: true,
|
||||
page: 1,
|
||||
pageSize: 1,
|
||||
});
|
||||
reviewCount.value = result.total || 0;
|
||||
} catch {
|
||||
reviewCount.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadReviewCount();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => route.query.view,
|
||||
(rawView) => {
|
||||
if (rawView) return;
|
||||
void syncQuery(activeView.value, detailId.value);
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-[var(--surface-muted,#f4f7fb)]">
|
||||
<div class="flex flex-wrap items-start justify-between gap-3 px-5 pt-5">
|
||||
<div class="min-w-0">
|
||||
<h1 class="text-xl font-bold text-primary">{{ t('admin.contractPayment.title') }}</h1>
|
||||
<p class="mt-1 text-sm text-muted">{{ t('admin.contractPayment.subtitle') }}</p>
|
||||
</div>
|
||||
<div v-if="isAdmin" class="flex flex-wrap gap-2">
|
||||
<button class="btn-secondary-ds" type="button" :disabled="actionLoading" @click="run('sync')">
|
||||
<RefreshCw class="h-4 w-4" />{{ t('admin.contractPayment.sync') }}
|
||||
</button>
|
||||
<button class="btn-secondary-ds" type="button" :disabled="actionLoading" @click="run('force-sync')">
|
||||
<RefreshCw class="h-4 w-4" />{{ t('admin.contractPayment.forceSync') }}
|
||||
</button>
|
||||
<button class="btn-secondary-ds" type="button" :disabled="actionLoading" @click="run('reparse-existing')">
|
||||
<RefreshCw class="h-4 w-4" />{{ t('admin.contractPayment.reparseExisting') }}
|
||||
</button>
|
||||
<button class="btn-secondary-ds" type="button" :disabled="actionLoading" @click="run('scan')">
|
||||
<CalendarClock class="h-4 w-4" />{{ t('admin.contractPayment.scanAlerts') }}
|
||||
</button>
|
||||
<button class="btn-primary" type="button" :disabled="actionLoading" @click="run('weekly')">
|
||||
<Send class="h-4 w-4" />{{ t('admin.contractPayment.weeklySend') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex gap-0 border-b border-default px-5">
|
||||
<button
|
||||
v-for="tab in tabs"
|
||||
:key="tab.key"
|
||||
type="button"
|
||||
class="mb-[-1px] border-b-2 px-4 py-2.5 text-sm font-bold"
|
||||
:class="activeView === tab.key
|
||||
? 'border-brand-500 text-brand-600'
|
||||
: 'border-transparent text-muted hover:text-secondary'"
|
||||
@click="selectView(tab.key)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<span
|
||||
v-if="tab.key === 'review' && tab.count"
|
||||
class="ml-1 inline-grid h-[18px] min-w-[18px] place-items-center rounded-full bg-amber-50 px-1.5 text-[11px] text-amber-700"
|
||||
>{{ tab.count }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="min-h-0 flex-1 overflow-auto px-5 py-4">
|
||||
<ContractPaymentDetailPage
|
||||
v-if="detailId"
|
||||
:contract-id="detailId"
|
||||
embedded
|
||||
@close="closeDetail"
|
||||
/>
|
||||
<ContractPaymentPage
|
||||
v-else-if="activeView === 'ledger'"
|
||||
embedded
|
||||
@open-detail="openDetail"
|
||||
/>
|
||||
<ContractPaymentReviewPage
|
||||
v-else-if="activeView === 'review'"
|
||||
embedded
|
||||
@open-detail="openDetail"
|
||||
/>
|
||||
<ContractPaymentWeeklyBatchesPage
|
||||
v-else
|
||||
embedded
|
||||
/>
|
||||
</div>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-if="isAdmin"
|
||||
v-model="showForceSyncConfirm"
|
||||
:title="t('admin.contractPayment.forceSync')"
|
||||
:message="t('admin.contractPayment.forceSyncConfirm')"
|
||||
confirm-tone="primary"
|
||||
@confirm="confirmForceSync"
|
||||
/>
|
||||
<DeleteConfirmDialog
|
||||
v-if="isAdmin"
|
||||
v-model="showReparseExistingConfirm"
|
||||
:title="t('admin.contractPayment.reparseExisting')"
|
||||
:message="t('admin.contractPayment.reparseExistingConfirm')"
|
||||
confirm-tone="primary"
|
||||
@confirm="confirmReparseExisting"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
Reference in new issue
Block a user