feat: 合同付款预警迁移到agent页面

This commit is contained in:
sophie committed 2026-09-16 09:36:18 +08:00
1 parent ef6bc42c20
commit 4ce2defef0
49 files changed
+1052 -423

No files matched your search

@@ -1,31 +1,30 @@
<!--
features/contract-payment/views/ContractPaymentWeeklyBatchesPage.vue
用途:独立展示合同付款预警的周汇总批次及其企业微信发送审计摘要,并下载 Excel 明细。
依赖:contract-payment.api、useAuthStore、统一消息提示;由工作台“合同付款预警 > 周汇总批次”路由加载。
逻辑:后端扫描产生的批次在此集中查看;Excel 经受控接口下载;手动发送仅管理员可见并提交异步任务。
依赖:contract-payment.api、统一消息提示。
逻辑:后端扫描产生的批次在此集中查看;Excel 经受控接口下载;Chat 顶栏共用发送入口,本页 embedded 时隐藏页头与发送按钮。
-->
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
import { CalendarClock, Download, Send } from 'lucide-vue-next';
import { onMounted, ref } from 'vue';
import { CalendarClock, Download } from 'lucide-vue-next';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import { formatLocalDateTime } from '@/shared/utils/dateTime';
import { useMessage } from '@/shared/composables/useMessage';
import { useAuthStore } from '@/features/auth/stores/auth.store';
import {
downloadContractPaymentAlertBatchExcel,
enqueueContractPaymentWeeklyAlert,
listContractPaymentAlertBatches,
type AlertBatch,
} from '../api/contract-payment.api';
const props = withDefaults(defineProps<{
embedded?: boolean;
}>(), { embedded: false });
const { t, te } = useI18n();
const auth = useAuthStore();
const isAdmin = computed(() => auth.isAdmin);
const msg = useMessage();
const batches = ref<AlertBatch[]>([]);
const loading = ref(false);
const actionLoading = ref(false);
const downloadingId = ref<number | null>(null);
/**
@@ -45,25 +44,6 @@ async function load(): Promise<void> {
}
}
/**
* 手动提交本周汇总发送任务。
* 核心逻辑:仅管理员可调用异步入队接口,避免浏览器等待企业微信发送和 Excel 文件生成完成。
* @returns 提交结果通过统一消息提示反馈,成功后刷新批次列表。
*/
async function runWeeklyAlert(): Promise<void> {
if (!isAdmin.value) return;
actionLoading.value = true;
try {
await enqueueContractPaymentWeeklyAlert();
msg.success(t('admin.contractPayment.weeklyBatchSubmitted'));
await load();
} catch (error) {
msg.error(error instanceof BusinessError ? error.message : t('admin.contractPayment.actionFailed'));
} finally {
actionLoading.value = false;
}
}
/**
* 判断批次是否已归档 Excel,供下载按钮启用。
* 核心逻辑:文件名或大小任一存在即视为可下载;真正有无字节由下载接口校验。
@@ -127,16 +107,9 @@ onMounted(() => void load());
<template>
<section class="section-gap animate-fade-in-up">
<div class="flex flex-wrap items-start justify-between gap-4">
<div>
<h2 class="text-2xl font-bold text-primary">{{ t('admin.contractPayment.weeklyBatchesTitle') }}</h2>
<p class="mt-1 text-sm text-muted">{{ t('admin.contractPayment.weeklyBatchesSubtitle') }}</p>
</div>
<div v-if="isAdmin" class="flex gap-2">
<button class="btn-primary" :disabled="actionLoading" @click="runWeeklyAlert">
<Send class="h-4 w-4" />{{ t('admin.contractPayment.weeklySend') }}
</button>
</div>
<div v-if="!props.embedded">
<h2 class="text-2xl font-bold text-primary">{{ t('admin.contractPayment.weeklyBatchesTitle') }}</h2>
<p class="mt-1 text-sm text-muted">{{ t('admin.contractPayment.weeklyBatchesSubtitle') }}</p>
</div>
<div class="surface-panel mt-5 overflow-x-auto rounded-2xl">