1234 lines
43 KiB
Vue
1234 lines
43 KiB
Vue
/**
|
||
* features/admin/modules/procurement-contract/ProcurementContractPage.vue
|
||
* 用途:采购合同审查管理。一张卡片里放模板库、风险规则、审查历史三个页签。
|
||
* 依赖:AdminListPage、AdminListTabs、useElementProvider、element-plus、procurement-contract.api、
|
||
* contract-ocr-match-tokens、ContractRiskRulesPanel、useMessage、vue-i18n。
|
||
* 逻辑:Admin 路由挂载。页签用 AdminListTabs,筛选和表格走 AdminListPage。上传、区域配置、详情用对话框。
|
||
* 删除用 Element 确认框。下载和保存仍走原有接口,参数不变。
|
||
*/
|
||
<script setup lang="ts">
|
||
import { computed, onMounted, ref } from 'vue';
|
||
import { useI18n } from 'vue-i18n';
|
||
import { Plus, Upload } from '@element-plus/icons-vue';
|
||
import {
|
||
ElAlert,
|
||
ElButton,
|
||
ElCheckbox,
|
||
ElCheckboxGroup,
|
||
ElConfigProvider,
|
||
ElDescriptions,
|
||
ElDescriptionsItem,
|
||
ElDialog,
|
||
ElForm,
|
||
ElFormItem,
|
||
ElInput,
|
||
ElLoading,
|
||
ElMessageBox,
|
||
ElOption,
|
||
ElSelect,
|
||
ElTable,
|
||
ElTableColumn,
|
||
ElTag,
|
||
ElUpload,
|
||
type UploadFile,
|
||
} from 'element-plus';
|
||
import 'element-plus/dist/index.css';
|
||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||
import '@/features/admin/styles/element-trial.css';
|
||
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||
import AdminListTabs from '@/features/admin/components/AdminListTabs.vue';
|
||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||
import {
|
||
createAdminContractTemplate,
|
||
deleteAdminContractTemplate,
|
||
downloadAdminAnnotatedContract,
|
||
downloadAdminContractReviewContract,
|
||
downloadAdminContractReviewReport,
|
||
downloadAdminContractReviewTemplateFile,
|
||
downloadAdminContractTemplate,
|
||
getAdminContractReview,
|
||
listAdminContractReviews,
|
||
listAdminContractTemplates,
|
||
previewAdminContractTemplateRegions,
|
||
updateAdminContractTemplate,
|
||
type ContractComparisonRegionConfig,
|
||
type ContractComparisonRegionPreview,
|
||
type ContractMetadataField,
|
||
type ContractReviewRow,
|
||
type ContractTemplateRow,
|
||
} from '@/features/admin/api/procurement-contract.api';
|
||
import { V4_REGION_CONFIG } from './contract-ocr-match-tokens';
|
||
import ContractRiskRulesPanel from './components/ContractRiskRulesPanel.vue';
|
||
import { useMessage } from '@/shared/composables/useMessage';
|
||
|
||
const vLoading = ElLoading.directive;
|
||
|
||
const { t } = useI18n();
|
||
const msg = useMessage();
|
||
const { elementLocale } = useElementProvider();
|
||
|
||
type ContractTab = 'templates' | 'rules' | 'reviews';
|
||
type TagType = 'primary' | 'success' | 'warning' | 'info' | 'danger';
|
||
|
||
const tab = ref<ContractTab>('templates');
|
||
|
||
/** 三个页签交给公共页签条。名称用页签键,文字用现有文案。 */
|
||
const contractTabs = computed(() => [
|
||
{ name: 'templates', label: t('admin.procurementContract.tabTemplates') },
|
||
{ name: 'rules', label: t('admin.procurementContract.tabRules') },
|
||
{ name: 'reviews', label: t('admin.procurementContract.tabReviews') },
|
||
]);
|
||
const rulesPanelRef = ref<InstanceType<typeof ContractRiskRulesPanel> | null>(null);
|
||
const loading = ref(false);
|
||
const templates = ref<ContractTemplateRow[]>([]);
|
||
const reviews = ref<ContractReviewRow[]>([]);
|
||
const reviewTotal = ref(0);
|
||
|
||
const showUpload = ref(false);
|
||
const uploading = ref(false);
|
||
const editingTemplate = ref<ContractTemplateRow | null>(null);
|
||
const uploadName = ref(t('admin.procurementContract.defaultTemplateName'));
|
||
const uploadVersion = ref('V1.0');
|
||
const uploadStatus = ref<'enabled' | 'disabled'>('enabled');
|
||
const uploadDefault = ref(false);
|
||
const uploadRemark = ref('');
|
||
const uploadFile = ref<File | null>(null);
|
||
|
||
const isEditMode = computed(() => Boolean(editingTemplate.value));
|
||
const formModalTitle = computed(() =>
|
||
isEditMode.value
|
||
? t('admin.procurementContract.editModalTitle')
|
||
: t('admin.procurementContract.uploadModalTitle'),
|
||
);
|
||
|
||
const filterMode = ref('');
|
||
const filterSource = ref('');
|
||
const filterKeyword = ref('');
|
||
const filterRiskLevel = ref('');
|
||
const ruleStatusFilter = ref('');
|
||
const detail = ref<ContractReviewRow | null>(null);
|
||
const showDetail = ref(false);
|
||
const showRegionConfig = ref(false);
|
||
const regionTemplate = ref<ContractTemplateRow | null>(null);
|
||
const regionSaving = ref(false);
|
||
const regionPreviewing = ref(false);
|
||
const regionPreview = ref<ContractComparisonRegionPreview | null>(null);
|
||
const regionMetadataFields = ref<ContractMetadataField[]>([]);
|
||
const regionBodyStart = ref('');
|
||
const regionBodyEnd = ref('');
|
||
const regionSignatureTerms = ref('');
|
||
const regionAttachmentStart = ref('');
|
||
let reviewFilterTimer: ReturnType<typeof setTimeout> | undefined;
|
||
|
||
const metadataFieldOptions: ContractMetadataField[] = ['contract_no', 'buyer', 'seller', 'version'];
|
||
|
||
/**
|
||
* 加载模板列表。
|
||
*/
|
||
async function loadTemplates(): Promise<void> {
|
||
templates.value = await listAdminContractTemplates();
|
||
}
|
||
|
||
/**
|
||
* 加载审查历史。
|
||
* 核心逻辑:空筛选不传给接口,表示该条件不限制。
|
||
*/
|
||
async function loadReviews(): Promise<void> {
|
||
const data = await listAdminContractReviews({
|
||
review_mode: filterMode.value || undefined,
|
||
template_source: filterSource.value || undefined,
|
||
keyword: filterKeyword.value || undefined,
|
||
risk_level: filterRiskLevel.value || undefined,
|
||
});
|
||
reviews.value = data.items;
|
||
reviewTotal.value = data.total;
|
||
}
|
||
|
||
/**
|
||
* 审查编号输入防抖,避免每敲一个字就请求列表。
|
||
* @param immediate - 为 true 时取消等待并立刻刷新
|
||
*/
|
||
function filterReviews(immediate = false): void {
|
||
if (reviewFilterTimer) clearTimeout(reviewFilterTimer);
|
||
if (immediate) {
|
||
void loadReviews();
|
||
return;
|
||
}
|
||
reviewFilterTimer = setTimeout(() => {
|
||
void loadReviews();
|
||
}, 300);
|
||
}
|
||
|
||
/**
|
||
* 把审查历史下拉的空值写回空字符串,并立刻刷新。
|
||
* 核心逻辑:Element 清空得到 undefined,筛选状态仍用空字符串表示全部。
|
||
* @param value - 下拉当前值
|
||
* @param assign - 写回对应筛选字段
|
||
*/
|
||
function onReviewSelectChange(value: string | undefined, assign: (next: string) => void): void {
|
||
assign(value ?? '');
|
||
filterReviews(true);
|
||
}
|
||
|
||
/**
|
||
* 审查模式筛选变更。
|
||
* @param value - compare / solo;清空时为 undefined
|
||
*/
|
||
function onFilterModeChange(value: string | undefined): void {
|
||
onReviewSelectChange(value, (next) => {
|
||
filterMode.value = next;
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 模板来源筛选变更。
|
||
* @param value - library / user_upload / none;清空时为 undefined
|
||
*/
|
||
function onFilterSourceChange(value: string | undefined): void {
|
||
onReviewSelectChange(value, (next) => {
|
||
filterSource.value = next;
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 风险等级筛选变更。
|
||
* @param value - high / medium / low;清空时为 undefined
|
||
*/
|
||
function onFilterRiskChange(value: string | undefined): void {
|
||
onReviewSelectChange(value, (next) => {
|
||
filterRiskLevel.value = next;
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 把风险规则状态筛选项写回空字符串。列表刷新由面板监听该值完成。
|
||
* @param value - 下拉当前值;清空时为 undefined
|
||
*/
|
||
function onRuleStatusChange(value: string | undefined): void {
|
||
ruleStatusFilter.value = value ?? '';
|
||
}
|
||
|
||
/**
|
||
* 刷新当前页签的列表。遮罩只盖住表格,不盖住标题和页签。
|
||
* 风险规则由面板挂载时自己拉列表,这里不重复请求。
|
||
*/
|
||
async function refresh(): Promise<void> {
|
||
if (tab.value === 'rules') return;
|
||
loading.value = true;
|
||
try {
|
||
if (tab.value === 'templates') await loadTemplates();
|
||
else await loadReviews();
|
||
} catch (e) {
|
||
console.error(e);
|
||
msg.error(t('admin.procurementContract.loadFailed'));
|
||
} finally {
|
||
loading.value = false;
|
||
}
|
||
}
|
||
|
||
onMounted(() => {
|
||
void refresh();
|
||
});
|
||
|
||
/**
|
||
* 切换页签并加载对应列表。公共页签回传字符串,这里收成三个已知页签。
|
||
* @param name - AdminListTabs 当前 name
|
||
*/
|
||
async function onTabChange(name: string | number): Promise<void> {
|
||
const next = String(name);
|
||
if (next !== 'templates' && next !== 'rules' && next !== 'reviews') return;
|
||
if (next === tab.value) return;
|
||
tab.value = next;
|
||
await refresh();
|
||
}
|
||
|
||
/**
|
||
* 重置上传/编辑对话框表单。
|
||
*/
|
||
function resetUploadForm(): void {
|
||
editingTemplate.value = null;
|
||
uploadName.value = t('admin.procurementContract.defaultTemplateName');
|
||
uploadVersion.value = 'V1.0';
|
||
uploadStatus.value = 'enabled';
|
||
uploadDefault.value = false;
|
||
uploadRemark.value = '';
|
||
uploadFile.value = null;
|
||
}
|
||
|
||
/**
|
||
* 打开新建模板对话框。
|
||
*/
|
||
function openUploadModal(): void {
|
||
resetUploadForm();
|
||
showUpload.value = true;
|
||
}
|
||
|
||
/**
|
||
* 打开编辑模板对话框。当前只改元数据,不更换文件。
|
||
* @param row - 模板行
|
||
*/
|
||
function openEditModal(row: ContractTemplateRow): void {
|
||
editingTemplate.value = row;
|
||
uploadName.value = row.name;
|
||
uploadVersion.value = row.version;
|
||
uploadStatus.value = row.status === 'disabled' ? 'disabled' : 'enabled';
|
||
uploadDefault.value = Boolean(row.is_default);
|
||
uploadRemark.value = row.remark || '';
|
||
uploadFile.value = null;
|
||
showUpload.value = true;
|
||
}
|
||
|
||
/**
|
||
* 对话框关闭后清掉编辑状态和已选文件。
|
||
*/
|
||
function onUploadDialogClosed(): void {
|
||
editingTemplate.value = null;
|
||
uploadFile.value = null;
|
||
}
|
||
|
||
/**
|
||
* 记下用户选中的模板文件,提交时再放进 FormData。
|
||
* @param file - Element 上传组件给出的文件
|
||
*/
|
||
function onUploadFileChange(file: UploadFile): void {
|
||
if (!file.raw) return;
|
||
uploadFile.value = file.raw;
|
||
}
|
||
|
||
/**
|
||
* 是否默认模板的下拉写回布尔值。
|
||
* @param value - yes 或 no
|
||
*/
|
||
function onUploadDefaultChange(value: string | undefined): void {
|
||
uploadDefault.value = value === 'yes';
|
||
}
|
||
|
||
/**
|
||
* 提交新建或编辑模板。请求字段与原来的保存接口一致。
|
||
*/
|
||
async function submitUpload(): Promise<void> {
|
||
if (uploading.value) return;
|
||
if (!isEditMode.value && !uploadFile.value) {
|
||
msg.error(t('admin.procurementContract.fileRequired'));
|
||
return;
|
||
}
|
||
if (!uploadName.value.trim() || !uploadVersion.value.trim()) {
|
||
msg.error(t('admin.procurementContract.nameVersionRequired'));
|
||
return;
|
||
}
|
||
uploading.value = true;
|
||
try {
|
||
if (isEditMode.value && editingTemplate.value) {
|
||
await updateAdminContractTemplate(editingTemplate.value.id, {
|
||
name: uploadName.value.trim(),
|
||
version: uploadVersion.value.trim(),
|
||
status: uploadStatus.value,
|
||
is_default: uploadDefault.value,
|
||
remark: uploadRemark.value.trim() || null,
|
||
});
|
||
showUpload.value = false;
|
||
msg.success(t('admin.procurementContract.editOk'));
|
||
} else {
|
||
const fd = new FormData();
|
||
fd.append('file', uploadFile.value!);
|
||
fd.append('name', uploadName.value.trim());
|
||
fd.append('version', uploadVersion.value.trim());
|
||
fd.append('status', uploadStatus.value);
|
||
fd.append('is_default', uploadDefault.value ? 'true' : 'false');
|
||
if (uploadRemark.value.trim()) fd.append('remark', uploadRemark.value.trim());
|
||
await createAdminContractTemplate(fd);
|
||
showUpload.value = false;
|
||
msg.success(t('admin.procurementContract.uploadOk'));
|
||
}
|
||
await loadTemplates();
|
||
} catch (e: unknown) {
|
||
msg.error(
|
||
e instanceof Error
|
||
? e.message
|
||
: isEditMode.value
|
||
? t('admin.procurementContract.actionFailed')
|
||
: t('admin.procurementContract.uploadFailed'),
|
||
);
|
||
} finally {
|
||
uploading.value = false;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 设为默认模板。
|
||
* @param row - 模板行
|
||
*/
|
||
async function setDefault(row: ContractTemplateRow): Promise<void> {
|
||
try {
|
||
await updateAdminContractTemplate(row.id, { is_default: true });
|
||
msg.success(t('admin.procurementContract.setDefaultOk'));
|
||
await loadTemplates();
|
||
} catch (e: unknown) {
|
||
msg.error(e instanceof Error ? e.message : t('admin.procurementContract.actionFailed'));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 切换模板启停。
|
||
* @param row - 模板行
|
||
*/
|
||
async function toggleStatus(row: ContractTemplateRow): Promise<void> {
|
||
const next = row.status === 'enabled' ? 'disabled' : 'enabled';
|
||
try {
|
||
await updateAdminContractTemplate(row.id, { status: next });
|
||
await loadTemplates();
|
||
} catch (e: unknown) {
|
||
msg.error(e instanceof Error ? e.message : t('admin.procurementContract.actionFailed'));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 鉴权下载模板库文件。
|
||
*/
|
||
async function downloadTemplate(row: ContractTemplateRow): Promise<void> {
|
||
try {
|
||
await downloadAdminContractTemplate(row.id);
|
||
} catch (e: unknown) {
|
||
msg.error(e instanceof Error ? e.message : t('admin.procurementContract.downloadFailed'));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 鉴权下载审查报告(Word .docx)。
|
||
*/
|
||
async function downloadReport(row: ContractReviewRow): Promise<void> {
|
||
try {
|
||
await downloadAdminContractReviewReport(row.id, row.review_no, 'docx');
|
||
} catch (e: unknown) {
|
||
msg.error(e instanceof Error ? e.message : t('admin.procurementContract.downloadFailed'));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 鉴权下载待审合同原件。
|
||
*/
|
||
async function downloadContract(row: ContractReviewRow): Promise<void> {
|
||
try {
|
||
await downloadAdminContractReviewContract(row.id, row.contract_file_name);
|
||
} catch (e: unknown) {
|
||
msg.error(e instanceof Error ? e.message : t('admin.procurementContract.downloadFailed'));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 把多行锚点文本收成去重后的字符串数组。
|
||
* @param value - 文本框内容,支持换行和中英文逗号
|
||
*/
|
||
function parseRegionItems(value: string): string[] {
|
||
return [...new Set(value.split(/[\n,,]+/).map((item) => item.trim()).filter(Boolean))];
|
||
}
|
||
|
||
/**
|
||
* 用对话框里的字段组装区域配置。附件策略仍只按页数提示。
|
||
*/
|
||
function buildRegionConfig(): ContractComparisonRegionConfig {
|
||
return {
|
||
metadata_fields: [...regionMetadataFields.value],
|
||
body_start_anchors: parseRegionItems(regionBodyStart.value),
|
||
body_end_anchors: parseRegionItems(regionBodyEnd.value),
|
||
signature_terms: parseRegionItems(regionSignatureTerms.value),
|
||
attachment_start_anchors: parseRegionItems(regionAttachmentStart.value),
|
||
attachment_policy: 'page_count_only',
|
||
};
|
||
}
|
||
|
||
/**
|
||
* 用已有配置或 V4 默认值填区域对话框。
|
||
* @param config - 要比对的区域配置
|
||
*/
|
||
function applyRegionConfig(config: ContractComparisonRegionConfig): void {
|
||
regionMetadataFields.value = [...config.metadata_fields];
|
||
regionBodyStart.value = config.body_start_anchors.join('\n');
|
||
regionBodyEnd.value = config.body_end_anchors.join('\n');
|
||
regionSignatureTerms.value = config.signature_terms.join('\n');
|
||
regionAttachmentStart.value = config.attachment_start_anchors.join('\n');
|
||
regionPreview.value = null;
|
||
}
|
||
|
||
/**
|
||
* 打开某个模板的比对区域编辑。不改已保存的模板文件。
|
||
* @param row - 模板行
|
||
*/
|
||
function openRegionConfig(row: ContractTemplateRow): void {
|
||
regionTemplate.value = row;
|
||
applyRegionConfig(row.comparison_region_config || V4_REGION_CONFIG);
|
||
showRegionConfig.value = true;
|
||
}
|
||
|
||
/**
|
||
* 区域对话框关闭后清掉模板和预览。
|
||
*/
|
||
function onRegionDialogClosed(): void {
|
||
regionTemplate.value = null;
|
||
regionPreview.value = null;
|
||
}
|
||
|
||
/**
|
||
* 恢复固定的 V4 锚点,方便管理员撤销误改。
|
||
*/
|
||
function restoreV4RegionConfig(): void {
|
||
applyRegionConfig(V4_REGION_CONFIG);
|
||
}
|
||
|
||
/**
|
||
* 让后端按未保存的锚点识别当前模板。
|
||
*/
|
||
async function previewRegionConfig(): Promise<void> {
|
||
if (!regionTemplate.value || regionPreviewing.value) return;
|
||
regionPreviewing.value = true;
|
||
try {
|
||
regionPreview.value = await previewAdminContractTemplateRegions(
|
||
regionTemplate.value.id,
|
||
buildRegionConfig(),
|
||
);
|
||
} catch (error: unknown) {
|
||
msg.error(error instanceof Error ? error.message : t('admin.procurementContract.regionPreviewFailed'));
|
||
} finally {
|
||
regionPreviewing.value = false;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 校验并保存比对区域规则。请求体与原来的更新接口一致。
|
||
*/
|
||
async function saveRegionConfig(): Promise<void> {
|
||
if (!regionTemplate.value || regionSaving.value) return;
|
||
regionSaving.value = true;
|
||
try {
|
||
await updateAdminContractTemplate(regionTemplate.value.id, {
|
||
comparison_region_config: buildRegionConfig(),
|
||
});
|
||
msg.success(t('admin.procurementContract.regionSaved'));
|
||
showRegionConfig.value = false;
|
||
await loadTemplates();
|
||
} catch (error: unknown) {
|
||
msg.error(error instanceof Error ? error.message : t('admin.procurementContract.actionFailed'));
|
||
} finally {
|
||
regionSaving.value = false;
|
||
}
|
||
}
|
||
|
||
/** 鉴权下载带风险高亮批注的合同 PDF 副本。 */
|
||
async function downloadAnnotatedContract(row: ContractReviewRow): Promise<void> {
|
||
try {
|
||
await downloadAdminAnnotatedContract(row.id, row.review_no);
|
||
} catch (e: unknown) {
|
||
msg.error(e instanceof Error ? e.message : t('admin.procurementContract.downloadFailed'));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 鉴权下载本次审查所用模板文件。
|
||
*/
|
||
async function downloadReviewTemplate(row: ContractReviewRow): Promise<void> {
|
||
try {
|
||
await downloadAdminContractReviewTemplateFile(row.id);
|
||
} catch (e: unknown) {
|
||
msg.error(e instanceof Error ? e.message : t('admin.procurementContract.downloadFailed'));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 确认后删除模板。取消确认框时不请求接口。
|
||
* @param row - 待删除的模板
|
||
*/
|
||
async function deleteTemplate(row: ContractTemplateRow): Promise<void> {
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
t('admin.procurementContract.confirmDeleteNamed', { name: row.name, version: row.version }),
|
||
t('common.deleteDialog.defaultTitle'),
|
||
{
|
||
type: 'warning',
|
||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||
},
|
||
);
|
||
} catch {
|
||
return;
|
||
}
|
||
try {
|
||
await deleteAdminContractTemplate(row.id);
|
||
await loadTemplates();
|
||
} catch (e: unknown) {
|
||
msg.error(e instanceof Error ? e.message : t('admin.procurementContract.actionFailed'));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 打开审查详情。
|
||
* @param row - 审查历史行
|
||
*/
|
||
async function openDetail(row: ContractReviewRow): Promise<void> {
|
||
try {
|
||
detail.value = await getAdminContractReview(row.id);
|
||
showDetail.value = true;
|
||
} catch (e: unknown) {
|
||
msg.error(e instanceof Error ? e.message : t('admin.procurementContract.loadFailed'));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 点击审查历史行时打开详情。
|
||
* @param row - 表格行
|
||
*/
|
||
function onReviewRowClick(row: ContractReviewRow): void {
|
||
void openDetail(row);
|
||
}
|
||
|
||
/**
|
||
* 审查模式文案。
|
||
* @param mode - compare 或 solo
|
||
*/
|
||
function modeLabel(mode: string): string {
|
||
return mode === 'solo'
|
||
? t('admin.procurementContract.modeSolo')
|
||
: t('admin.procurementContract.modeCompare');
|
||
}
|
||
|
||
/**
|
||
* 审查模式标签色。
|
||
* @param mode - compare 或 solo
|
||
*/
|
||
function modeTagType(mode: string): TagType {
|
||
return mode === 'compare' ? 'primary' : 'info';
|
||
}
|
||
|
||
/**
|
||
* 模板来源文案。
|
||
* @param source - library / user_upload / none
|
||
*/
|
||
function sourceLabel(source: string): string {
|
||
if (source === 'library') return t('admin.procurementContract.sourceLibrary');
|
||
if (source === 'user_upload') return t('admin.procurementContract.sourceUpload');
|
||
return t('admin.procurementContract.sourceNone');
|
||
}
|
||
|
||
/**
|
||
* 模板来源标签色。
|
||
* @param source - library / user_upload / none
|
||
*/
|
||
function sourceTagType(source: string): TagType {
|
||
if (source === 'library') return 'primary';
|
||
if (source === 'user_upload') return 'warning';
|
||
return 'info';
|
||
}
|
||
|
||
/**
|
||
* 格式化审查完成时间。未完成或无法解析时用短横线或原值。
|
||
* @param value - 完成时间
|
||
*/
|
||
function reviewFinishedAt(value?: string | null): string {
|
||
if (!value) return '-';
|
||
const date = new Date(value);
|
||
if (Number.isNaN(date.getTime())) return value;
|
||
return new Intl.DateTimeFormat(undefined, {
|
||
year: 'numeric',
|
||
month: '2-digit',
|
||
day: '2-digit',
|
||
hour: '2-digit',
|
||
minute: '2-digit',
|
||
hour12: false,
|
||
}).format(date);
|
||
}
|
||
|
||
/**
|
||
* 返回历史列表中最高风险等级及其数量。失败或没有发现时不展示标签。
|
||
* @param row - 审查历史行
|
||
*/
|
||
function reviewRisk(row: ContractReviewRow): { level: 'high' | 'medium' | 'low'; count: number } | null {
|
||
if (row.status !== 'success') return null;
|
||
if (row.high_risk_count > 0) return { level: 'high', count: row.high_risk_count };
|
||
if (row.medium_risk_count > 0) return { level: 'medium', count: row.medium_risk_count };
|
||
if (row.low_risk_count > 0) return { level: 'low', count: row.low_risk_count };
|
||
return null;
|
||
}
|
||
|
||
/**
|
||
* 风险标签的文案和颜色。没有风险时返回空。
|
||
* @param row - 审查历史行
|
||
*/
|
||
function reviewRiskTag(row: ContractReviewRow): { type: TagType; text: string } | null {
|
||
const risk = reviewRisk(row);
|
||
if (!risk) return null;
|
||
const label = risk.level === 'high'
|
||
? t('admin.procurementContract.riskHigh')
|
||
: risk.level === 'medium'
|
||
? t('admin.procurementContract.riskMedium')
|
||
: t('admin.procurementContract.riskLow');
|
||
const type: TagType = risk.level === 'high' ? 'danger' : risk.level === 'medium' ? 'warning' : 'info';
|
||
return { type, text: `${label} ${risk.count}` };
|
||
}
|
||
|
||
/**
|
||
* 模板或审查状态文案。
|
||
* @param status - 状态编码
|
||
*/
|
||
function statusLabel(status: string): string {
|
||
if (status === 'enabled') return t('admin.procurementContract.enable');
|
||
if (status === 'disabled') return t('admin.procurementContract.disable');
|
||
if (status === 'success') return t('admin.procurementContract.statusSuccess');
|
||
if (status === 'failed') return t('admin.procurementContract.statusFailed');
|
||
if (status === 'running') return t('admin.procurementContract.statusRunning');
|
||
if (status === 'pending') return t('admin.procurementContract.statusPending');
|
||
return status;
|
||
}
|
||
|
||
/**
|
||
* 状态标签色。启用和成功为绿,失败为红,进行中和待处理为警告。
|
||
* @param status - 状态编码
|
||
*/
|
||
function statusTagType(status: string): TagType {
|
||
if (status === 'enabled' || status === 'success') return 'success';
|
||
if (status === 'failed') return 'danger';
|
||
if (status === 'running' || status === 'pending') return 'warning';
|
||
return 'info';
|
||
}
|
||
|
||
/**
|
||
* 是否默认模板的文案。
|
||
* @param isDefault - 是否默认
|
||
*/
|
||
function defaultLabel(isDefault: boolean): string {
|
||
return isDefault
|
||
? t('admin.procurementContract.defaultYesShort')
|
||
: t('admin.procurementContract.defaultNo');
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<ElConfigProvider :locale="elementLocale">
|
||
<AdminListPage>
|
||
<template #title>
|
||
<h2 class="section-title">{{ t('admin.procurementContract.title') }}</h2>
|
||
<p class="section-desc mt-1">{{ t('admin.procurementContract.subtitle') }}</p>
|
||
</template>
|
||
<template #actions>
|
||
<ElButton
|
||
v-if="tab === 'templates'"
|
||
type="primary"
|
||
:icon="Upload"
|
||
@click="openUploadModal"
|
||
>
|
||
{{ t('admin.procurementContract.uploadTemplate') }}
|
||
</ElButton>
|
||
<ElButton
|
||
v-else-if="tab === 'rules'"
|
||
type="primary"
|
||
:icon="Plus"
|
||
@click="rulesPanelRef?.openCreate()"
|
||
>
|
||
{{ t('admin.procurementContract.addRule') }}
|
||
</ElButton>
|
||
</template>
|
||
<template #tabs>
|
||
<AdminListTabs :model-value="tab" :items="contractTabs" @update:model-value="onTabChange" />
|
||
</template>
|
||
<template #filters>
|
||
<template v-if="tab === 'reviews'">
|
||
<ElInput
|
||
v-model="filterKeyword"
|
||
clearable
|
||
class="contract-filter-keyword"
|
||
:placeholder="t('admin.procurementContract.colReviewNo')"
|
||
@input="filterReviews()"
|
||
@keyup.enter="filterReviews(true)"
|
||
/>
|
||
<ElSelect
|
||
:model-value="filterMode || undefined"
|
||
class="contract-filter-select"
|
||
clearable
|
||
:placeholder="t('admin.procurementContract.all')"
|
||
@update:model-value="onFilterModeChange"
|
||
>
|
||
<ElOption :label="t('admin.procurementContract.modeCompare')" value="compare" />
|
||
<ElOption :label="t('admin.procurementContract.modeSolo')" value="solo" />
|
||
</ElSelect>
|
||
<ElSelect
|
||
:model-value="filterSource || undefined"
|
||
class="contract-filter-select"
|
||
clearable
|
||
:placeholder="t('admin.procurementContract.all')"
|
||
@update:model-value="onFilterSourceChange"
|
||
>
|
||
<ElOption :label="t('admin.procurementContract.sourceLibrary')" value="library" />
|
||
<ElOption :label="t('admin.procurementContract.sourceUpload')" value="user_upload" />
|
||
<ElOption :label="t('admin.procurementContract.sourceNone')" value="none" />
|
||
</ElSelect>
|
||
<ElSelect
|
||
:model-value="filterRiskLevel || undefined"
|
||
class="contract-filter-select"
|
||
clearable
|
||
:placeholder="t('admin.procurementContract.all')"
|
||
@update:model-value="onFilterRiskChange"
|
||
>
|
||
<ElOption :label="t('admin.procurementContract.riskHigh')" value="high" />
|
||
<ElOption :label="t('admin.procurementContract.riskMedium')" value="medium" />
|
||
<ElOption :label="t('admin.procurementContract.riskLow')" value="low" />
|
||
</ElSelect>
|
||
<span class="contract-filter-meta">{{ t('admin.procurementContract.total', { n: reviewTotal }) }}</span>
|
||
</template>
|
||
<template v-else-if="tab === 'rules'">
|
||
<ElSelect
|
||
:model-value="ruleStatusFilter || undefined"
|
||
class="contract-filter-select"
|
||
clearable
|
||
:placeholder="t('admin.procurementContract.all')"
|
||
@update:model-value="onRuleStatusChange"
|
||
>
|
||
<ElOption :label="t('admin.procurementContract.enable')" value="enabled" />
|
||
<ElOption :label="t('admin.procurementContract.disable')" value="disabled" />
|
||
</ElSelect>
|
||
<span class="contract-filter-meta">
|
||
{{ t('admin.procurementContract.ruleStatTotal') }} {{ rulesPanelRef?.ruleStats?.total ?? 0 }}
|
||
· {{ t('admin.procurementContract.ruleStatEnabled') }} {{ rulesPanelRef?.ruleStats?.enabled ?? 0 }}
|
||
· {{ t('admin.procurementContract.ruleStatHighRisk') }} {{ rulesPanelRef?.ruleStats?.highRisk ?? 0 }}
|
||
</span>
|
||
</template>
|
||
</template>
|
||
|
||
<ElTable
|
||
v-if="tab === 'templates'"
|
||
v-loading="loading"
|
||
class="hx-admin-table"
|
||
:data="templates"
|
||
row-key="id"
|
||
:empty-text="loading ? t('admin.procurementContract.loading') : t('admin.procurementContract.emptyTemplates')"
|
||
>
|
||
<ElTableColumn prop="name" :label="t('admin.procurementContract.colName')" min-width="180" show-overflow-tooltip />
|
||
<ElTableColumn prop="version" :label="t('admin.procurementContract.colVersion')" min-width="100" />
|
||
<ElTableColumn prop="file_name" :label="t('admin.procurementContract.colFile')" min-width="180" show-overflow-tooltip />
|
||
<ElTableColumn :label="t('admin.procurementContract.colStatus')" width="110">
|
||
<template #default="{ row }">
|
||
<ElTag :type="statusTagType(row.status)" effect="light">{{ statusLabel(row.status) }}</ElTag>
|
||
</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="t('admin.procurementContract.colDefault')" width="100">
|
||
<template #default="{ row }">
|
||
<ElTag :type="row.is_default ? 'primary' : 'info'" effect="light">
|
||
{{ defaultLabel(row.is_default) }}
|
||
</ElTag>
|
||
</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="t('admin.procurementContract.colActions')" width="440" align="right">
|
||
<template #default="{ row }">
|
||
<div class="contract-row-actions">
|
||
<ElButton link type="primary" @click="downloadTemplate(row as ContractTemplateRow)">
|
||
{{ t('admin.procurementContract.downloadFile') }}
|
||
</ElButton>
|
||
<ElButton link type="primary" @click="openEditModal(row as ContractTemplateRow)">
|
||
{{ t('admin.edit') }}
|
||
</ElButton>
|
||
<ElButton link type="primary" @click="openRegionConfig(row as ContractTemplateRow)">
|
||
{{ t('admin.procurementContract.regionConfigAction') }}
|
||
</ElButton>
|
||
<ElButton
|
||
link
|
||
type="primary"
|
||
:disabled="row.is_default || row.status !== 'enabled'"
|
||
@click="setDefault(row as ContractTemplateRow)"
|
||
>
|
||
{{ t('admin.procurementContract.setDefault') }}
|
||
</ElButton>
|
||
<ElButton link @click="toggleStatus(row as ContractTemplateRow)">
|
||
{{ row.status === 'enabled' ? t('admin.procurementContract.disable') : t('admin.procurementContract.enable') }}
|
||
</ElButton>
|
||
<ElButton link type="danger" @click="deleteTemplate(row as ContractTemplateRow)">
|
||
{{ t('admin.delete') }}
|
||
</ElButton>
|
||
</div>
|
||
</template>
|
||
</ElTableColumn>
|
||
</ElTable>
|
||
|
||
<ContractRiskRulesPanel
|
||
v-else-if="tab === 'rules'"
|
||
ref="rulesPanelRef"
|
||
:status-filter="ruleStatusFilter"
|
||
/>
|
||
|
||
<ElTable
|
||
v-else
|
||
v-loading="loading"
|
||
class="hx-admin-table"
|
||
:data="reviews"
|
||
row-key="id"
|
||
:empty-text="loading ? t('admin.procurementContract.loading') : t('admin.procurementContract.emptyReviews')"
|
||
@row-click="onReviewRowClick"
|
||
>
|
||
<ElTableColumn prop="review_no" :label="t('admin.procurementContract.colReviewNo')" min-width="150" show-overflow-tooltip />
|
||
<ElTableColumn :label="t('admin.procurementContract.colMode')" width="120">
|
||
<template #default="{ row }">
|
||
<ElTag :type="modeTagType(row.review_mode)" effect="light">{{ modeLabel(row.review_mode) }}</ElTag>
|
||
</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn prop="contract_file_name" :label="t('admin.procurementContract.colContract')" min-width="180" show-overflow-tooltip />
|
||
<ElTableColumn :label="t('admin.procurementContract.colContractNo')" min-width="140" show-overflow-tooltip>
|
||
<template #default="{ row }">{{ row.contract_no || '—' }}</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="t('admin.procurementContract.colSupplier')" min-width="140" show-overflow-tooltip>
|
||
<template #default="{ row }">{{ row.supplier_name || '—' }}</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="t('admin.procurementContract.colTemplate')" min-width="140" show-overflow-tooltip>
|
||
<template #default="{ row }">{{ row.template_name || '—' }}</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="t('admin.procurementContract.colSource')" width="120">
|
||
<template #default="{ row }">
|
||
<ElTag :type="sourceTagType(row.template_source)" effect="light">
|
||
{{ sourceLabel(row.template_source) }}
|
||
</ElTag>
|
||
</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="t('admin.procurementContract.colUser')" min-width="120" show-overflow-tooltip>
|
||
<template #default="{ row }">{{ row.user_name || row.user_id }}</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="t('admin.procurementContract.colFinishedAt')" min-width="160">
|
||
<template #default="{ row }">{{ reviewFinishedAt(row.finished_at) }}</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="t('admin.procurementContract.colStatus')" width="110">
|
||
<template #default="{ row }">
|
||
<ElTag :type="statusTagType(row.status)" effect="light">{{ statusLabel(row.status) }}</ElTag>
|
||
</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="t('admin.procurementContract.colRisk')" width="130">
|
||
<template #default="{ row }">
|
||
<ElTag
|
||
v-if="reviewRiskTag(row as ContractReviewRow)"
|
||
:type="reviewRiskTag(row as ContractReviewRow)?.type"
|
||
effect="light"
|
||
>
|
||
{{ reviewRiskTag(row as ContractReviewRow)?.text }}
|
||
</ElTag>
|
||
<span v-else>-</span>
|
||
</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="t('admin.procurementContract.colActions')" width="100" align="right">
|
||
<template #default="{ row }">
|
||
<ElButton link type="primary" @click.stop="openDetail(row as ContractReviewRow)">
|
||
{{ t('admin.procurementContract.detail') }}
|
||
</ElButton>
|
||
</template>
|
||
</ElTableColumn>
|
||
</ElTable>
|
||
</AdminListPage>
|
||
|
||
<ElDialog
|
||
v-model="showUpload"
|
||
:title="formModalTitle"
|
||
width="680px"
|
||
align-center
|
||
append-to-body
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
:close-on-press-escape="!uploading"
|
||
:show-close="!uploading"
|
||
@closed="onUploadDialogClosed"
|
||
>
|
||
<ElUpload
|
||
v-if="!isEditMode"
|
||
class="contract-upload"
|
||
drag
|
||
:auto-upload="false"
|
||
:show-file-list="false"
|
||
accept=".pdf,.doc,.docx,.txt,.md,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
||
@change="onUploadFileChange"
|
||
>
|
||
<div v-if="uploadFile">
|
||
<div>{{ uploadFile.name }}</div>
|
||
<p class="hx-element-hint">{{ t('admin.procurementContract.uploadZoneReplace') }}</p>
|
||
</div>
|
||
<div v-else>
|
||
<span>
|
||
{{ t('admin.procurementContract.uploadZonePrefix') }}
|
||
<strong>{{ t('admin.procurementContract.uploadZoneAction') }}</strong>
|
||
</span>
|
||
<p class="hx-element-hint">{{ t('admin.procurementContract.noFileSelected') }}</p>
|
||
</div>
|
||
</ElUpload>
|
||
<div v-else class="contract-file-hint">
|
||
<div>{{ editingTemplate?.file_name }}</div>
|
||
<p class="hx-element-hint">{{ t('admin.procurementContract.editFileHint') }}</p>
|
||
</div>
|
||
|
||
<ElForm label-position="top" @submit.prevent="submitUpload">
|
||
<div class="contract-form-grid">
|
||
<ElFormItem :label="t('admin.procurementContract.templateName')" required>
|
||
<ElInput v-model="uploadName" />
|
||
</ElFormItem>
|
||
<ElFormItem :label="t('admin.procurementContract.versionNo')" required>
|
||
<ElInput v-model="uploadVersion" />
|
||
</ElFormItem>
|
||
<ElFormItem :label="t('admin.procurementContract.colStatus')">
|
||
<ElSelect v-model="uploadStatus" class="contract-field">
|
||
<ElOption :label="t('admin.procurementContract.enable')" value="enabled" />
|
||
<ElOption :label="t('admin.procurementContract.disable')" value="disabled" />
|
||
</ElSelect>
|
||
</ElFormItem>
|
||
<ElFormItem :label="t('admin.procurementContract.setDefault')">
|
||
<ElSelect
|
||
class="contract-field"
|
||
:model-value="uploadDefault ? 'yes' : 'no'"
|
||
@update:model-value="onUploadDefaultChange"
|
||
>
|
||
<ElOption :label="t('admin.procurementContract.defaultNo')" value="no" />
|
||
<ElOption :label="t('admin.procurementContract.defaultYes')" value="yes" />
|
||
</ElSelect>
|
||
</ElFormItem>
|
||
<ElFormItem class="contract-form-span" :label="t('admin.procurementContract.remark')">
|
||
<ElInput
|
||
v-model="uploadRemark"
|
||
type="textarea"
|
||
:rows="4"
|
||
:placeholder="t('admin.procurementContract.remarkPlaceholder')"
|
||
/>
|
||
</ElFormItem>
|
||
</div>
|
||
</ElForm>
|
||
<ElAlert
|
||
v-if="!isEditMode"
|
||
type="info"
|
||
:closable="false"
|
||
:title="t('admin.procurementContract.uploadCallout')"
|
||
/>
|
||
<template #footer>
|
||
<ElButton :disabled="uploading" @click="showUpload = false">{{ t('admin.cancel') }}</ElButton>
|
||
<ElButton type="primary" :loading="uploading" @click="submitUpload">
|
||
{{ isEditMode ? t('admin.procurementContract.saveChanges') : t('admin.procurementContract.saveToLibrary') }}
|
||
</ElButton>
|
||
</template>
|
||
</ElDialog>
|
||
|
||
<ElDialog
|
||
v-model="showRegionConfig"
|
||
:title="t('admin.procurementContract.regionConfigTitle')"
|
||
width="680px"
|
||
align-center
|
||
append-to-body
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
:close-on-press-escape="!regionSaving && !regionPreviewing"
|
||
:show-close="!regionSaving"
|
||
@closed="onRegionDialogClosed"
|
||
>
|
||
<template v-if="regionTemplate">
|
||
<p class="section-desc">
|
||
{{ regionTemplate.name }} {{ regionTemplate.version }} · {{ t('admin.procurementContract.regionConfigHint') }}
|
||
</p>
|
||
<ElForm class="contract-region-form" label-position="top">
|
||
<div class="contract-form-grid">
|
||
<ElFormItem class="contract-form-span" :label="t('admin.procurementContract.regionMetadata')">
|
||
<ElCheckboxGroup v-model="regionMetadataFields" class="contract-check-group">
|
||
<ElCheckbox v-for="field in metadataFieldOptions" :key="field" :value="field">
|
||
{{ t(`admin.procurementContract.regionField_${field}`) }}
|
||
</ElCheckbox>
|
||
</ElCheckboxGroup>
|
||
</ElFormItem>
|
||
<ElFormItem :label="t('admin.procurementContract.regionBodyStart')">
|
||
<ElInput v-model="regionBodyStart" type="textarea" :rows="4" />
|
||
</ElFormItem>
|
||
<ElFormItem :label="t('admin.procurementContract.regionBodyEnd')">
|
||
<ElInput v-model="regionBodyEnd" type="textarea" :rows="4" />
|
||
</ElFormItem>
|
||
<ElFormItem :label="t('admin.procurementContract.regionSignatureTerms')">
|
||
<ElInput v-model="regionSignatureTerms" type="textarea" :rows="4" />
|
||
</ElFormItem>
|
||
<ElFormItem :label="t('admin.procurementContract.regionAttachmentStart')">
|
||
<ElInput v-model="regionAttachmentStart" type="textarea" :rows="4" />
|
||
</ElFormItem>
|
||
</div>
|
||
</ElForm>
|
||
<ElAlert
|
||
type="info"
|
||
:closable="false"
|
||
:title="`${t('admin.procurementContract.regionAttachmentPolicy')} · ${t('admin.procurementContract.regionPageCountOnly')}`"
|
||
/>
|
||
<ElAlert
|
||
v-if="regionPreview"
|
||
class="contract-preview-alert"
|
||
:type="regionPreview.status === 'recognized' ? 'success' : 'warning'"
|
||
:closable="false"
|
||
show-icon
|
||
:title="regionPreview.status === 'recognized'
|
||
? t('admin.procurementContract.regionPreviewRecognized')
|
||
: t('admin.procurementContract.regionPreviewIncomplete')"
|
||
>
|
||
<p>{{ t('admin.procurementContract.regionBodyStart') }}:{{ regionPreview.body_start_anchor || '—' }}</p>
|
||
<p>{{ t('admin.procurementContract.regionBodyEnd') }}:{{ regionPreview.body_end_anchor || '—' }}</p>
|
||
<p>{{ t('admin.procurementContract.regionSignatureTerms') }}:{{ regionPreview.signature_terms_found?.join(', ') || '—' }}</p>
|
||
<p>{{ t('admin.procurementContract.regionAttachmentStart') }}:{{ regionPreview.attachment_anchor || '—' }}</p>
|
||
</ElAlert>
|
||
</template>
|
||
<template #footer>
|
||
<ElButton :disabled="regionSaving || regionPreviewing" @click="restoreV4RegionConfig">
|
||
{{ t('admin.procurementContract.regionRestoreV4') }}
|
||
</ElButton>
|
||
<ElButton :loading="regionPreviewing" :disabled="regionSaving" @click="previewRegionConfig">
|
||
{{ t('admin.procurementContract.regionPreview') }}
|
||
</ElButton>
|
||
<ElButton :disabled="regionSaving || regionPreviewing" @click="showRegionConfig = false">
|
||
{{ t('admin.cancel') }}
|
||
</ElButton>
|
||
<ElButton type="primary" :loading="regionSaving" :disabled="regionPreviewing" @click="saveRegionConfig">
|
||
{{ t('admin.procurementContract.saveChanges') }}
|
||
</ElButton>
|
||
</template>
|
||
</ElDialog>
|
||
|
||
<ElDialog
|
||
v-model="showDetail"
|
||
:title="detail?.review_no || t('admin.procurementContract.detail')"
|
||
width="680px"
|
||
align-center
|
||
append-to-body
|
||
:close-on-click-modal="false"
|
||
>
|
||
<template v-if="detail">
|
||
<p class="section-desc">{{ modeLabel(detail.review_mode) }} · {{ statusLabel(detail.status) }}</p>
|
||
<ElDescriptions class="contract-detail" :column="1" border>
|
||
<ElDescriptionsItem :label="t('admin.procurementContract.colContract')">
|
||
{{ detail.contract_file_name }}
|
||
</ElDescriptionsItem>
|
||
<ElDescriptionsItem :label="t('admin.procurementContract.colContractNo')">
|
||
{{ detail.contract_no || '—' }}
|
||
</ElDescriptionsItem>
|
||
<ElDescriptionsItem :label="t('admin.procurementContract.colSupplier')">
|
||
{{ detail.supplier_name || '—' }}
|
||
</ElDescriptionsItem>
|
||
<ElDescriptionsItem :label="t('admin.procurementContract.colTemplate')">
|
||
{{ detail.template_name || '—' }}
|
||
</ElDescriptionsItem>
|
||
<ElDescriptionsItem :label="t('admin.procurementContract.colSource')">
|
||
{{ sourceLabel(detail.template_source) }}
|
||
</ElDescriptionsItem>
|
||
<ElDescriptionsItem :label="t('admin.procurementContract.colRisk')">
|
||
H{{ detail.high_risk_count }} / M{{ detail.medium_risk_count }} / L{{ detail.low_risk_count }}
|
||
</ElDescriptionsItem>
|
||
</ElDescriptions>
|
||
<pre class="contract-report">{{ detail.report_text || JSON.stringify(detail.summary_json, null, 2) }}</pre>
|
||
</template>
|
||
<template v-if="detail" #footer>
|
||
<div class="contract-detail-actions">
|
||
<ElButton @click="showDetail = false">{{ t('admin.close') }}</ElButton>
|
||
<ElButton @click="downloadContract(detail)">
|
||
{{ t('admin.procurementContract.downloadContract') }}
|
||
</ElButton>
|
||
<ElButton
|
||
v-if="detail.contract_file_name?.toLowerCase().endsWith('.pdf')
|
||
&& detail.clauses_json?.some((item) => item.anchor_status === 'anchored')"
|
||
@click="downloadAnnotatedContract(detail)"
|
||
>
|
||
{{ t('admin.procurementContract.downloadAnnotated') }}
|
||
</ElButton>
|
||
<ElButton
|
||
v-if="detail.template_source !== 'none'"
|
||
@click="downloadReviewTemplate(detail)"
|
||
>
|
||
{{ t('admin.procurementContract.downloadTemplateFile') }}
|
||
</ElButton>
|
||
<ElButton type="primary" @click="downloadReport(detail)">
|
||
{{ t('admin.procurementContract.downloadReport') }}
|
||
</ElButton>
|
||
</div>
|
||
</template>
|
||
</ElDialog>
|
||
</ElConfigProvider>
|
||
</template>
|
||
|
||
<style scoped>
|
||
:deep(.contract-filter-keyword) {
|
||
width: 16rem;
|
||
}
|
||
|
||
:deep(.contract-filter-select) {
|
||
width: 11rem;
|
||
}
|
||
|
||
.contract-filter-meta {
|
||
margin-left: auto;
|
||
color: var(--el-text-color-secondary);
|
||
font-size: var(--el-font-size-small);
|
||
}
|
||
|
||
:deep(.admin-list-page__filters:empty) {
|
||
display: none;
|
||
}
|
||
|
||
.contract-row-actions {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
justify-content: flex-end;
|
||
gap: 2px 8px;
|
||
}
|
||
|
||
.contract-upload {
|
||
width: 100%;
|
||
margin-bottom: 16px;
|
||
}
|
||
|
||
.contract-upload :deep(.el-upload),
|
||
.contract-upload :deep(.el-upload-dragger) {
|
||
width: 100%;
|
||
}
|
||
|
||
.contract-file-hint {
|
||
margin-bottom: 16px;
|
||
padding: 12px 16px;
|
||
border: 1px solid var(--el-border-color);
|
||
border-radius: var(--el-border-radius-base);
|
||
background: var(--el-fill-color-light);
|
||
}
|
||
|
||
.contract-form-grid {
|
||
display: grid;
|
||
grid-template-columns: 1fr 1fr;
|
||
column-gap: 16px;
|
||
}
|
||
|
||
.contract-form-span {
|
||
grid-column: 1 / -1;
|
||
}
|
||
|
||
.contract-field {
|
||
width: 100%;
|
||
}
|
||
|
||
.contract-region-form {
|
||
margin-top: 16px;
|
||
}
|
||
|
||
.contract-check-group {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 8px 16px;
|
||
}
|
||
|
||
.contract-preview-alert {
|
||
margin-top: 12px;
|
||
}
|
||
|
||
.contract-detail {
|
||
margin-top: 16px;
|
||
}
|
||
|
||
.contract-report {
|
||
white-space: pre-wrap;
|
||
max-height: 40vh;
|
||
overflow: auto;
|
||
margin-top: 16px;
|
||
padding: 12px;
|
||
border-radius: var(--el-border-radius-base);
|
||
background: var(--el-fill-color-light);
|
||
}
|
||
|
||
.contract-detail-actions {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
justify-content: flex-end;
|
||
gap: 8px;
|
||
}
|
||
</style>
|