169 lines
7.3 KiB
Vue
169 lines
7.3 KiB
Vue
<!--
|
||
features/contract-payment/views/ContractPaymentReviewPage.vue
|
||
用途:集中展示关键解析事实缺失或冲突的合同,供管理员下载原文并人工确认。
|
||
依赖:contract-payment.api、PaginationBar、统一消息提示。
|
||
逻辑:后端以 review_only 过滤 needs_review 合同;关键词可搜合同号、采购单号、供应商和申请人;Chat 父级通过 open-detail 下钻详情。
|
||
嵌入布局为搜索栏与底部分页固定,仅表格区域滚动,表头 sticky。
|
||
-->
|
||
<script setup lang="ts">
|
||
import { onMounted, ref } from 'vue';
|
||
import { useI18n } from 'vue-i18n';
|
||
import { Search } from 'lucide-vue-next';
|
||
import { BusinessError } from '@/shared/api/client';
|
||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||
import { useMessage } from '@/shared/composables/useMessage';
|
||
import { listContractPaymentContracts, type ContractPaymentContract } from '../api/contract-payment.api';
|
||
|
||
const props = withDefaults(defineProps<{
|
||
embedded?: boolean;
|
||
}>(), { embedded: false });
|
||
|
||
const emit = defineEmits<{
|
||
'open-detail': [contractId: number];
|
||
}>();
|
||
const { t } = useI18n();
|
||
const msg = useMessage();
|
||
const keyword = ref('');
|
||
const loading = ref(false);
|
||
const contracts = ref<ContractPaymentContract[]>([]);
|
||
const page = ref(1);
|
||
const pageSize = ref(20);
|
||
const total = ref(0);
|
||
const pages = ref(1);
|
||
|
||
/**
|
||
* 读取需要人工确认的合同列表。
|
||
* 核心逻辑:明确传入 reviewOnly,避免前端仅按显示状态过滤而遗漏后端新产生的待确认合同;关键词同样匹配供应商和申请人。
|
||
* @param resetPage - 为 true 时重置到第一页,供关键词查询使用。
|
||
* @returns 请求完成后更新分页数据;失败时保留已有列表并提示原因。
|
||
*/
|
||
async function load(resetPage = false): Promise<void> {
|
||
if (resetPage) page.value = 1;
|
||
loading.value = true;
|
||
try {
|
||
const result = await listContractPaymentContracts({
|
||
keyword: keyword.value.trim(), reviewOnly: true, page: page.value, pageSize: pageSize.value,
|
||
});
|
||
contracts.value = result.items || [];
|
||
total.value = result.total || 0;
|
||
pages.value = result.pages || 1;
|
||
page.value = result.page || 1;
|
||
} catch (error) {
|
||
msg.error(error instanceof BusinessError ? error.message : t('admin.contractPaymentReview.loadFailed'));
|
||
} finally {
|
||
loading.value = false;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 打开待确认合同详情,以便查看解析问题并下载原文人工核验。
|
||
* 核心逻辑:仍复用现有合同详情页,避免新页面复制附件权限与下载逻辑。
|
||
* @param contractId - 合同付款台账主键。
|
||
* @returns 路由跳转完成。
|
||
*/
|
||
function openContractDetail(contractId: number): void {
|
||
emit('open-detail', contractId);
|
||
}
|
||
|
||
onMounted(() => void load());
|
||
</script>
|
||
|
||
<template>
|
||
<section class="flex h-full min-h-0 flex-1 flex-col gap-3 animate-fade-in-up">
|
||
<div v-if="!props.embedded" class="shrink-0">
|
||
<h2 class="text-2xl font-bold text-primary">{{ t('admin.contractPaymentReview.title') }}</h2>
|
||
<p class="mt-1 text-sm text-muted">{{ t('admin.contractPaymentReview.subtitle') }}</p>
|
||
</div>
|
||
<div class="contract-filter-bar shrink-0">
|
||
<div class="contract-filter-search">
|
||
<Search class="contract-filter-icon" />
|
||
<input
|
||
v-model="keyword"
|
||
class="contract-filter-input"
|
||
:placeholder="t('admin.contractPaymentReview.searchPlaceholder')"
|
||
@keyup.enter="load(true)"
|
||
/>
|
||
</div>
|
||
<button type="button" class="contract-filter-submit" @click="load(true)">{{ t('admin.contractPayment.search') }}</button>
|
||
</div>
|
||
<div class="surface-panel contract-scroll-panel min-h-0 flex-1 rounded-2xl">
|
||
<table class="review-table text-sm"><thead><tr><th>{{ t('admin.contractPaymentReview.contractWorkflow') }}</th><th>{{ t('admin.contractPayment.purchaseOrder') }}</th><th>{{ t('admin.contractPayment.supplier') }}</th><th>{{ t('admin.contractPayment.amount') }}</th><th>{{ t('admin.contractPaymentReview.reason') }}</th></tr></thead>
|
||
<tbody><tr v-for="item in contracts" :key="item.id" class="cursor-pointer hover:bg-surface-soft" @click="openContractDetail(item.id)"><td><strong>{{ item.contract_no || t('admin.contractPayment.contractNoPending') }}</strong><span>{{ item.workflow_no || '—' }}</span></td><td>{{ item.purchase_order_no || '—' }}</td><td>{{ item.supplier_name || '—' }}</td><td>{{ item.total_amount || '—' }}</td><td><ul><li v-for="issue in item.parse_issues || [t('admin.contractPaymentReview.fallbackIssue')]" :key="issue">{{ issue }}</li></ul></td></tr><tr v-if="!loading && !contracts.length"><td colspan="5" class="py-9 text-center text-muted">{{ t('admin.contractPaymentReview.empty') }}</td></tr></tbody>
|
||
</table>
|
||
</div>
|
||
<PaginationBar class="shrink-0" v-model:page="page" v-model:page-size="pageSize" :total="total" :pages="pages" :visible="total > 0 || !!keyword.trim()" @update:page="() => load()" @update:page-size="() => load()" />
|
||
</section>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.contract-filter-bar {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: center;
|
||
gap: 8px;
|
||
padding: 10px 14px;
|
||
border: 1px solid #d7e1ef;
|
||
border-radius: 12px;
|
||
background: #fff;
|
||
}
|
||
.contract-filter-search { position: relative; width: min(100%, 320px); }
|
||
.contract-filter-icon {
|
||
position: absolute;
|
||
left: 10px;
|
||
top: 50%;
|
||
width: 14px;
|
||
height: 14px;
|
||
color: #8aa0bd;
|
||
transform: translateY(-50%);
|
||
pointer-events: none;
|
||
}
|
||
.contract-filter-input {
|
||
box-sizing: border-box;
|
||
width: 100%;
|
||
height: 36px;
|
||
padding: 0 12px 0 30px;
|
||
border: 1px solid #d7e1ef;
|
||
border-radius: 8px;
|
||
background: #f7faff;
|
||
color: #183c72;
|
||
font-size: 14px;
|
||
line-height: 36px;
|
||
outline: none;
|
||
}
|
||
.contract-filter-input::placeholder { color: #8aa0bd; font-size: 14px; }
|
||
.contract-filter-input:focus { border-color: #93c5fd; box-shadow: 0 0 0 2px rgba(59, 130, 246, .12); }
|
||
.contract-filter-submit {
|
||
height: 36px;
|
||
padding: 0 14px;
|
||
border: 1px solid #d7e1ef;
|
||
border-radius: 8px;
|
||
background: #fff;
|
||
color: #426493;
|
||
font-size: 14px;
|
||
font-weight: 600;
|
||
}
|
||
.contract-filter-submit:hover { background: #f7faff; color: #183c72; }
|
||
.contract-scroll-panel {
|
||
min-height: 0;
|
||
flex: 1 1 auto;
|
||
overflow: auto;
|
||
overscroll-behavior: contain;
|
||
scrollbar-gutter: stable;
|
||
scrollbar-width: thin;
|
||
scrollbar-color: #9eb1c9 #e8eef6;
|
||
}
|
||
.contract-scroll-panel::-webkit-scrollbar { width: 10px; height: 10px; }
|
||
.contract-scroll-panel::-webkit-scrollbar-track { background: #e8eef6; border-radius: 8px; }
|
||
.contract-scroll-panel::-webkit-scrollbar-thumb { background: #9eb1c9; border-radius: 8px; border: 2px solid #e8eef6; }
|
||
.contract-scroll-panel::-webkit-scrollbar-thumb:hover { background: #7c93b0; }
|
||
.review-table { width: 100%; min-width: 980px; border-collapse: separate; border-spacing: 0; color: #183c72; }
|
||
.review-table th { position: sticky; top: 0; z-index: 2; padding: 13px 14px; border-bottom: 1px solid #d7e1ef; background: #f7faff; color: #426493; text-align: left; }
|
||
.review-table td { padding: 13px 14px; border-bottom: 1px solid #d7e1ef; vertical-align: top; }
|
||
.review-table tbody tr:last-child td { border-bottom: 0; }
|
||
.review-table strong, .review-table span { display: block; }
|
||
.review-table strong { color: #102d59; }
|
||
.review-table span, .review-table li { color: #9a3412; }
|
||
.review-table ul { margin: 0; padding-left: 18px; }
|
||
.review-table li + li { margin-top: 3px; }
|
||
</style>
|