fixed
This commit is contained in:
+3
-3
@@ -14,9 +14,9 @@ export type ApiResponse<T> = {
|
||||
export type QueryParams = Record<string, string | number | boolean | undefined>;
|
||||
|
||||
// 获取 API 基础 URL
|
||||
// const API_BASE_URL = '172.18.0.100:3000';
|
||||
// const API_BASE_URL = '172.16.0.119:9000/admin';
|
||||
export const API_BASE_URL = 'http://nas.7bm.co:3000';
|
||||
const API_BASE_URL = 'http://172.18.0.100:3000';
|
||||
// const API_BASE_URL = 'http://172.16.0.119:9000/admin';
|
||||
// export const API_BASE_URL = 'http://nas.7bm.co:3000';
|
||||
|
||||
// 是否使用模拟数据(开发环境使用)
|
||||
const USE_MOCK_DATA = false; // 设置为true使用模拟数据,避免API连接问题
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
import { postgrestGet, type PostgrestParams } from "../postgrest-client";
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
/**
|
||||
* 格式化日期
|
||||
* @param dateString 日期字符串
|
||||
* @returns 格式化后的日期字符串
|
||||
*/
|
||||
function formatDate(dateString: string): string {
|
||||
if (!dateString) return '';
|
||||
try {
|
||||
return dayjs(dateString).format('YYYY-MM-DD HH:mm:ss');
|
||||
} catch (error) {
|
||||
console.error('日期格式化失败:', error);
|
||||
return dateString;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从不同格式的 API 响应中提取数据
|
||||
* @param responseData API 响应数据
|
||||
* @returns 提取后的数据或 null
|
||||
*/
|
||||
function extractApiData<T>(responseData: unknown): T | null {
|
||||
if (!responseData) return null;
|
||||
|
||||
// 格式1: { code: number, msg: string, data: T }
|
||||
if (typeof responseData === 'object' && responseData !== null &&
|
||||
'code' in responseData &&
|
||||
'data' in responseData &&
|
||||
(responseData as { data: unknown }).data) {
|
||||
return (responseData as { data: T }).data;
|
||||
}
|
||||
|
||||
// 格式2: 直接是数据对象
|
||||
return responseData as T;
|
||||
}
|
||||
|
||||
// 定义评查结果类型
|
||||
interface EvaluationResult {
|
||||
id: string | number;
|
||||
document_id: string | number;
|
||||
evaluation_point_id: string | number;
|
||||
evaluated_results?: {
|
||||
result?: boolean;
|
||||
message?: string;
|
||||
data?: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
// 定义评查点类型
|
||||
interface EvaluationPoint {
|
||||
id: string | number;
|
||||
evaluation_point_groups_id: string | number;
|
||||
suggestion_message_type?: string;
|
||||
suggestion_message?: string;
|
||||
score?: number;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
// 定义评查点组类型
|
||||
interface EvaluationPointGroup {
|
||||
id: string | number;
|
||||
name?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
// 定义前端使用的评查点结果类型
|
||||
interface ReviewPointResult {
|
||||
id: string | number;
|
||||
title: string;
|
||||
groupName: string;
|
||||
status: string;
|
||||
content: string;
|
||||
suggestion: string;
|
||||
result?: boolean;
|
||||
score: number;
|
||||
}
|
||||
|
||||
// 定义统计数据类型
|
||||
interface StatsData {
|
||||
total: number;
|
||||
success: number;
|
||||
warning: number;
|
||||
error: number;
|
||||
score: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前评查文件的所有评查点结果
|
||||
* @param fileId 评查文件ID
|
||||
* @returns 评查点结果列表和统计数据
|
||||
*/
|
||||
export async function getReviewPoints(fileId: string) {
|
||||
// 步骤1:根据fileId查询evaluation_results表
|
||||
const evaluationResultsParams: PostgrestParams = {
|
||||
select: '*',
|
||||
filter: {
|
||||
'document_id': `eq.${fileId}`
|
||||
}
|
||||
};
|
||||
const evaluationResultsResponse = await postgrestGet('evaluation_results', evaluationResultsParams);
|
||||
|
||||
if (evaluationResultsResponse.error) {
|
||||
return { error: evaluationResultsResponse.error, status: evaluationResultsResponse.status };
|
||||
}
|
||||
|
||||
const evaluationResultsData = extractApiData<EvaluationResult[]>(evaluationResultsResponse.data);
|
||||
|
||||
if (!evaluationResultsData || !Array.isArray(evaluationResultsData)) {
|
||||
return { data: [], stats: { total: 0, success: 0, warning: 0, error: 0, score: 0 } };
|
||||
}
|
||||
|
||||
// 收集所有评查点ID,用于查询评查点详情
|
||||
const evaluationPointIds = evaluationResultsData.map(item => item.evaluation_point_id).filter(Boolean);
|
||||
|
||||
if (evaluationPointIds.length === 0) {
|
||||
return { data: [], stats: { total: 0, success: 0, warning: 0, error: 0, score: 0 } };
|
||||
}
|
||||
|
||||
// 步骤2:根据evaluation_point_id查询evaluation_points表
|
||||
const evaluationPointsParams: PostgrestParams = {
|
||||
select: '*',
|
||||
filter: {
|
||||
'id': `in.(${evaluationPointIds.join(',')})`
|
||||
}
|
||||
};
|
||||
const evaluationPointsResponse = await postgrestGet('evaluation_points', evaluationPointsParams);
|
||||
|
||||
if (evaluationPointsResponse.error) {
|
||||
return { error: evaluationPointsResponse.error, status: evaluationPointsResponse.status };
|
||||
}
|
||||
|
||||
const evaluationPointsData = extractApiData<EvaluationPoint[]>(evaluationPointsResponse.data);
|
||||
|
||||
if (!evaluationPointsData || !Array.isArray(evaluationPointsData)) {
|
||||
return { data: [], stats: { total: 0, success: 0, warning: 0, error: 0, score: 0 } };
|
||||
}
|
||||
|
||||
// 收集所有评查点组ID,用于查询评查点组详情
|
||||
const groupIds = evaluationPointsData.map(item => item.evaluation_point_groups_id).filter(Boolean);
|
||||
|
||||
if (groupIds.length === 0) {
|
||||
return { data: [], stats: { total: 0, success: 0, warning: 0, error: 0, score: 0 } };
|
||||
}
|
||||
|
||||
// 查询评查点组
|
||||
const groupsParams: PostgrestParams = {
|
||||
select: '*',
|
||||
filter: {
|
||||
'id': `in.(${groupIds.join(',')})`
|
||||
}
|
||||
};
|
||||
const groupsResponse = await postgrestGet('evaluation_point_groups', groupsParams);
|
||||
|
||||
if (groupsResponse.error) {
|
||||
return { error: groupsResponse.error, status: groupsResponse.status };
|
||||
}
|
||||
|
||||
const groupsData = extractApiData<EvaluationPointGroup[]>(groupsResponse.data);
|
||||
|
||||
if (!groupsData || !Array.isArray(groupsData)) {
|
||||
return { data: [], stats: { total: 0, success: 0, warning: 0, error: 0, score: 0 } };
|
||||
}
|
||||
|
||||
// 创建映射关系以便快速查找
|
||||
const pointsMap = new Map<string | number, EvaluationPoint>();
|
||||
evaluationPointsData.forEach(point => {
|
||||
pointsMap.set(point.id, point);
|
||||
});
|
||||
|
||||
// console.log('pointsMap-------', pointsMap);
|
||||
|
||||
const groupsMap = new Map<string | number, EvaluationPointGroup>();
|
||||
groupsData.forEach(group => {
|
||||
groupsMap.set(group.id, group);
|
||||
});
|
||||
|
||||
// console.log('groupsMap-------', groupsMap);
|
||||
|
||||
// 构建前端所需的数据格式
|
||||
const resultData: ReviewPointResult[] = evaluationResultsData.map(result => {
|
||||
const point = pointsMap.get(result.evaluation_point_id) || {} as EvaluationPoint;
|
||||
const group = groupsMap.get(point.evaluation_point_groups_id || 0) || {} as EvaluationPointGroup;
|
||||
|
||||
// 从 evaluated_results 中提取数据
|
||||
let message = '';
|
||||
let data = '';
|
||||
|
||||
if (result.evaluated_results && typeof result.evaluated_results === 'object') {
|
||||
message = result.evaluated_results.message || '';
|
||||
data = result.evaluated_results.data || '';
|
||||
}
|
||||
|
||||
return {
|
||||
id: result.id,
|
||||
title: message,
|
||||
groupName: group.name || '',
|
||||
status: point.suggestion_message_type || '',
|
||||
content: data,
|
||||
suggestion: point.suggestion_message || '',
|
||||
result: result.evaluated_results?.result, // 记录评查结果,用于统计
|
||||
score: point.score || 0
|
||||
};
|
||||
});
|
||||
|
||||
// 统计数据
|
||||
const stats: StatsData = {
|
||||
total: evaluationResultsData.length,
|
||||
success: 0,
|
||||
warning: 0,
|
||||
error: 0,
|
||||
score: 0
|
||||
};
|
||||
|
||||
// 计算统计数据
|
||||
resultData.forEach(item => {
|
||||
// 成功数量统计
|
||||
if (item.result === true) {
|
||||
stats.success += 1;
|
||||
} else if (item.result === false) {
|
||||
// 警告和错误数量统计
|
||||
if (item.status === 'warning') {
|
||||
stats.warning += 1;
|
||||
} else if (item.status === 'error') {
|
||||
stats.error += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// 分数统计
|
||||
stats.score += item.score || 0;
|
||||
});
|
||||
|
||||
return { data: resultData, stats };
|
||||
}
|
||||
@@ -0,0 +1,371 @@
|
||||
import { postgrestGet, postgrestPut, type PostgrestParams } from '../postgrest-client';
|
||||
import dayjs from 'dayjs';
|
||||
import { getDocumentTypes } from '../document-types/document-types';
|
||||
import type { DocumentTypeUI } from '../document-types/document-types';
|
||||
import weekday from 'dayjs/plugin/weekday';
|
||||
import updateLocale from 'dayjs/plugin/updateLocale';
|
||||
|
||||
// 配置 dayjs
|
||||
dayjs.extend(weekday);
|
||||
dayjs.extend(updateLocale);
|
||||
// 设置一周的第一天为周一
|
||||
dayjs.updateLocale('en', {
|
||||
weekStart: 1
|
||||
});
|
||||
|
||||
// 文档数据库表接口
|
||||
export interface Document {
|
||||
id: number;
|
||||
user_id: number | null;
|
||||
type_id: number;
|
||||
name: string;
|
||||
document_number: string;
|
||||
path: string;
|
||||
storage_type: string;
|
||||
file_size: number;
|
||||
upload_time: string;
|
||||
is_test_document: boolean;
|
||||
evaluation_level: string;
|
||||
status: string;
|
||||
ocr_result: Record<string, unknown>;
|
||||
extracted_results: Record<string, unknown> | null;
|
||||
sumary: string | null;
|
||||
remark: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
evaluations_status: number | null;
|
||||
audit_status: number | null;
|
||||
}
|
||||
|
||||
// 文档类型接口
|
||||
export interface DocumentType {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string | null;
|
||||
status: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
// 评查文件UI接口
|
||||
export interface ReviewFileUI {
|
||||
id: string;
|
||||
fileName: string;
|
||||
fileCode: string;
|
||||
fileType: string;
|
||||
fileTypeId: number;
|
||||
fileSize: number;
|
||||
uploadTime: string;
|
||||
reviewStatus: string;
|
||||
reviewStatusCode: number;
|
||||
issueCount: number;
|
||||
issues: Array<{
|
||||
severity: 'info' | 'warning' | 'error' | 'critical';
|
||||
message: string;
|
||||
}>;
|
||||
createdBy: string;
|
||||
}
|
||||
|
||||
// 文件列表搜索参数
|
||||
export interface DocumentSearchParams {
|
||||
fileType?: string; // 文件类型ID
|
||||
reviewStatus?: string; // 评查状态
|
||||
dateRange?: string; // 日期范围
|
||||
keyword?: string; // 搜索关键字
|
||||
sortOrder?: string; // 排序方式
|
||||
page?: number; // 当前页码
|
||||
pageSize?: number; // 每页条数
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化日期
|
||||
* @param dateString 日期字符串
|
||||
* @returns 格式化后的日期字符串
|
||||
*/
|
||||
function formatDate(dateString: string): string {
|
||||
if (!dateString) return '';
|
||||
try {
|
||||
return dayjs(dateString).format('YYYY-MM-DD HH:mm:ss');
|
||||
} catch (error) {
|
||||
console.error('日期格式化失败:', error);
|
||||
return dateString;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从不同格式的 API 响应中提取数据
|
||||
* @param responseData API 响应数据
|
||||
* @returns 提取后的数据或 null
|
||||
*/
|
||||
function extractApiData<T>(responseData: unknown): T | null {
|
||||
if (!responseData) return null;
|
||||
|
||||
// 格式1: { code: number, msg: string, data: T }
|
||||
if (typeof responseData === 'object' && responseData !== null &&
|
||||
'code' in responseData &&
|
||||
'data' in responseData &&
|
||||
(responseData as { data: unknown }).data) {
|
||||
return (responseData as { data: T }).data;
|
||||
}
|
||||
|
||||
// 格式2: 直接是数据对象
|
||||
return responseData as T;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将评查状态代码映射到UI状态
|
||||
* @param status 评查状态代码
|
||||
* @returns UI状态
|
||||
*/
|
||||
export function mapReviewStatusToUI(status: number | null): string {
|
||||
switch(status) {
|
||||
case 1: return 'pass';
|
||||
case 2: return 'warning';
|
||||
case -1: return 'fail';
|
||||
case 0: return 'pending';
|
||||
default: return 'pending';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将UI状态映射到评查状态代码
|
||||
* @param status UI状态
|
||||
* @returns 评查状态代码
|
||||
*/
|
||||
export function mapUIToReviewStatus(status: string): number {
|
||||
switch(status) {
|
||||
case 'pass': return 1;
|
||||
case 'warning': return 2;
|
||||
case 'fail': return -1;
|
||||
case 'pending': return 0;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件扩展名
|
||||
* @param fileName 文件名
|
||||
* @returns 文件扩展名
|
||||
*/
|
||||
export function getFileExtension(fileName: string): string {
|
||||
return fileName.split('.').pop()?.toLowerCase() || '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 将数据库文档转换为UI文件对象
|
||||
* @param document 数据库文档
|
||||
* @param documentTypeName 文档类型名称
|
||||
* @returns UI文件对象
|
||||
*/
|
||||
export function convertToReviewFileUI(document: Document, documentTypeName: string): ReviewFileUI {
|
||||
const reviewStatus = mapReviewStatusToUI(document.evaluations_status);
|
||||
|
||||
const reviewFileUI: ReviewFileUI = {
|
||||
id: document.id.toString(),
|
||||
fileName: document.name,
|
||||
fileCode: document.document_number,
|
||||
fileType: documentTypeName,
|
||||
fileTypeId: document.type_id,
|
||||
fileSize: document.file_size,
|
||||
uploadTime: formatDate(document.created_at),
|
||||
reviewStatus: reviewStatus,
|
||||
reviewStatusCode: document.evaluations_status || 0,
|
||||
issueCount: 0,
|
||||
issues: [],
|
||||
createdBy: document.user_id?.toString() || '系统'
|
||||
};
|
||||
|
||||
// console.log('reviewFileUI-----',reviewFileUI);
|
||||
|
||||
return reviewFileUI;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取评查文件列表
|
||||
* @param searchParams 搜索参数
|
||||
* @returns 评查文件列表和总数
|
||||
*/
|
||||
export async function getReviewFiles(searchParams: DocumentSearchParams = {}): Promise<{
|
||||
data?: { files: ReviewFileUI[], total: number };
|
||||
error?: string;
|
||||
status?: number;
|
||||
}> {
|
||||
try {
|
||||
const page = searchParams.page || 1;
|
||||
const pageSize = searchParams.pageSize || 10;
|
||||
|
||||
// 构建查询参数
|
||||
const params: PostgrestParams = {
|
||||
select: '*',
|
||||
order: 'created_at.desc',
|
||||
headers: {
|
||||
'Prefer': 'count=exact'
|
||||
},
|
||||
limit: pageSize,
|
||||
offset: (page - 1) * pageSize,
|
||||
filter: {} as Record<string, string>
|
||||
};
|
||||
|
||||
// 根据排序方式设置排序
|
||||
if (searchParams.sortOrder) {
|
||||
switch (searchParams.sortOrder) {
|
||||
case 'upload_time_desc':
|
||||
params.order = 'created_at.desc';
|
||||
break;
|
||||
case 'upload_time_asc':
|
||||
params.order = 'created_at.asc';
|
||||
break;
|
||||
// 其他排序方式可以在这里添加
|
||||
}
|
||||
}
|
||||
|
||||
// 添加筛选条件
|
||||
const filter: Record<string, string> = {};
|
||||
|
||||
if (searchParams.fileType) {
|
||||
filter['type_id'] = `eq.${searchParams.fileType}`;
|
||||
}
|
||||
|
||||
if (searchParams.reviewStatus) {
|
||||
const statusValue = mapUIToReviewStatus(searchParams.reviewStatus);
|
||||
filter['evaluations_status'] = `eq.${statusValue}`;
|
||||
}
|
||||
|
||||
if (searchParams.keyword) {
|
||||
filter['or'] = `(name.ilike.%${searchParams.keyword}%,document_number.ilike.%${searchParams.keyword}%)`;
|
||||
}
|
||||
|
||||
// 处理日期范围筛选
|
||||
if (searchParams.dateRange) {
|
||||
const now = dayjs();
|
||||
const today = now.startOf('day').format('YYYY-MM-DD HH:mm:ss');
|
||||
switch (searchParams.dateRange) {
|
||||
case 'today':
|
||||
filter['created_at'] = `gte.${today}`;
|
||||
break;
|
||||
case 'week': {
|
||||
const weekStart = now.startOf('week').format('YYYY-MM-DD HH:mm:ss');
|
||||
filter['created_at'] = `gte.${weekStart}`;
|
||||
break;
|
||||
}
|
||||
case 'month': {
|
||||
const monthStart = now.startOf('month').format('YYYY-MM-DD HH:mm:ss');
|
||||
filter['created_at'] = `gte.${monthStart}`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('filter-----',filter);
|
||||
params.filter = filter;
|
||||
|
||||
// 发送API请求获取文档列表
|
||||
const response = await postgrestGet<Document[]>('documents', params);
|
||||
|
||||
if (response.error) {
|
||||
return { error: response.error, status: response.status };
|
||||
}
|
||||
|
||||
// 提取API返回的数据
|
||||
const extractedDocuments = extractApiData<Document[]>(response.data);
|
||||
|
||||
if (!extractedDocuments) {
|
||||
return { error: '获取评查文件数据失败', status: 500 };
|
||||
}
|
||||
|
||||
// 从响应头中获取总数
|
||||
let totalCount = 0;
|
||||
const responseWithHeaders = response as { data: Document[]; headers: Record<string, string> };
|
||||
if(responseWithHeaders.headers){
|
||||
const rangeHeader = responseWithHeaders.headers['content-range'];
|
||||
if(rangeHeader){
|
||||
const total = rangeHeader.split('/')[1];
|
||||
if(total !== '*'){
|
||||
totalCount = parseInt(total, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取文档类型数据,用于查找文档类型名称
|
||||
const documentTypesResponse = await getDocumentTypes({pageSize: 500});
|
||||
const documentTypes = documentTypesResponse.data?.types || [];
|
||||
|
||||
// 创建文档类型ID到名称的映射
|
||||
const typeNameMap: Record<number, string> = {};
|
||||
documentTypes.forEach((type: DocumentTypeUI) => {
|
||||
typeNameMap[type.id] = type.name;
|
||||
});
|
||||
|
||||
// 将文档数据转换为UI文件对象
|
||||
const reviewFiles = extractedDocuments.map(doc => {
|
||||
const typeName = typeNameMap[doc.type_id] || '未知类型';
|
||||
return convertToReviewFileUI(doc, typeName);
|
||||
});
|
||||
|
||||
return {
|
||||
data: {
|
||||
files: reviewFiles,
|
||||
total: totalCount
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取评查文件列表失败:', error);
|
||||
return {
|
||||
error: error instanceof Error ? error.message : '获取评查文件列表失败',
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新文件的评查状态
|
||||
* @param id 文件ID
|
||||
* @param status 评查状态
|
||||
* @returns 更新后的文件信息
|
||||
*/
|
||||
export async function updateReviewStatus(id: string, status: string): Promise<{
|
||||
data?: ReviewFileUI;
|
||||
error?: string;
|
||||
status?: number;
|
||||
}> {
|
||||
try {
|
||||
if (!id) {
|
||||
return { error: '文件ID不能为空', status: 400 };
|
||||
}
|
||||
|
||||
const statusValue = mapUIToReviewStatus(status);
|
||||
|
||||
const response = await postgrestPut<Document, Partial<Document>>(
|
||||
'documents',
|
||||
{ evaluations_status: statusValue },
|
||||
{ id: parseInt(id) }
|
||||
);
|
||||
|
||||
if (response.error) {
|
||||
return { error: response.error, status: response.status };
|
||||
}
|
||||
|
||||
const extractedData = extractApiData<Document>(response.data);
|
||||
|
||||
if (!extractedData) {
|
||||
return { error: '更新评查状态失败', status: 500 };
|
||||
}
|
||||
|
||||
// 获取文档类型,用于查找文档类型名称
|
||||
const documentTypesResponse = await getDocumentTypes({pageSize: 500});
|
||||
const documentTypes = documentTypesResponse.data?.types || [];
|
||||
|
||||
// 查找文档类型名称
|
||||
const docType = documentTypes.find((type: DocumentTypeUI) => type.id === extractedData.type_id);
|
||||
const typeName = docType ? docType.name : '未知类型';
|
||||
|
||||
return { data: convertToReviewFileUI(extractedData, typeName) };
|
||||
} catch (error) {
|
||||
console.error('更新评查状态失败:', error);
|
||||
return {
|
||||
error: error instanceof Error ? error.message : '更新评查状态失败',
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,10 +71,14 @@ export interface Document {
|
||||
status: 'pass' | 'warning' | 'waiting' | 'processing' | 'fail';
|
||||
file_status: 'Waiting' | 'Cutting' | 'Extractioning' | 'Evaluationing' | 'Processed';
|
||||
audit_status: number; // -1: 不通过, 0: 待审核, 1: 通过, 2: 警告, 3: 审核中
|
||||
ocr_result: unknown;
|
||||
extracted_results: unknown;
|
||||
summary: unknown;
|
||||
remark: string;
|
||||
ocr_result?: {
|
||||
__meta?: {
|
||||
page_count?: number;
|
||||
}
|
||||
};
|
||||
extracted_results?: unknown;
|
||||
summary?: unknown;
|
||||
remark?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
@@ -96,6 +100,8 @@ export interface DocumentUI {
|
||||
fileType: string;
|
||||
path: string;
|
||||
isTest: boolean;
|
||||
updatedAt?: string;
|
||||
pageCount?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,13 +130,15 @@ async function convertToUIDocument(doc: Document): Promise<DocumentUI> {
|
||||
type: doc.type_id.toString(),
|
||||
typeName: docType?.name || '未知类型',
|
||||
size: doc.file_size,
|
||||
auditStatus: doc.audit_status,
|
||||
auditStatus: doc.audit_status || 0,
|
||||
fileStatus: doc.status || '', // 默认为''
|
||||
issues: 0, // 固定为0
|
||||
uploadTime: formatDate(doc.updated_at),
|
||||
fileType: getFileExtension(doc.name),
|
||||
path: doc.path,
|
||||
isTest: doc.is_test_document
|
||||
isTest: doc.is_test_document,
|
||||
updatedAt: formatDate(doc.updated_at),
|
||||
pageCount: doc.ocr_result?.__meta?.page_count || 0
|
||||
};
|
||||
}
|
||||
|
||||
@@ -204,7 +212,7 @@ export async function getDocuments(searchParams: DocumentSearchParams = {}): Pro
|
||||
}
|
||||
}
|
||||
|
||||
console.log('filter-----', filter);
|
||||
// console.log('filter-----', filter);
|
||||
params.filter = filter;
|
||||
|
||||
// 发送请求
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
/**
|
||||
* 文件信息组件
|
||||
* 显示文件名称、状态信息以及操作按钮(下载原文件、导出评查报告、确认评查结果)
|
||||
*/
|
||||
|
||||
interface FileInfoProps {
|
||||
fileInfo: {
|
||||
fileName: string;
|
||||
contractNumber: string;
|
||||
fileSize?: string;
|
||||
fileSize?: string;
|
||||
fileFormat?: string;
|
||||
pageCount?: number;
|
||||
uploadTime?: string;
|
||||
uploadUser?: string;
|
||||
auditStatus?: number;
|
||||
};
|
||||
onConfirmResults: () => void;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,34 @@
|
||||
/**
|
||||
* 评查点列表组件
|
||||
* 显示评查结果统计和所有评查点列表
|
||||
*
|
||||
* 功能概述:
|
||||
* - 展示评查结果统计信息(总计、通过、警告、错误数量)
|
||||
* - 提供评查点过滤功能(按状态和搜索文本)
|
||||
* - 显示评查点详细信息(标题、状态、内容、建议修改等)
|
||||
* - 支持评查点操作(一键替换、人工审核等)
|
||||
*
|
||||
* 组件结构:
|
||||
* - 统计区域: 显示评查点数量统计
|
||||
* - 搜索区域: 提供文本搜索功能
|
||||
* - 评查点列表: 展示所有评查点
|
||||
* - 评查点卡片: 展示单个评查点详情
|
||||
* - 评查点头部: 显示标题和状态
|
||||
* - 评查点内容: 显示当前内容和问题
|
||||
* - 建议修改区域: 显示建议的修改内容
|
||||
* - 操作按钮: 提供一键替换和人工审核功能
|
||||
*/
|
||||
import { useState } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
// 评查点类型定义
|
||||
interface ReviewPoint {
|
||||
/**
|
||||
* 评查点类型定义
|
||||
* 用于展示单个评查结果
|
||||
*/
|
||||
export interface ReviewPoint {
|
||||
id: string;
|
||||
title: string;
|
||||
location: string;
|
||||
groupName: string;
|
||||
status: string;
|
||||
content: string;
|
||||
content: string | Record<string, string>;
|
||||
suggestion: string;
|
||||
needsHumanReview?: boolean;
|
||||
humanReviewNote?: string;
|
||||
@@ -20,6 +38,7 @@ interface ReviewPoint {
|
||||
section: string;
|
||||
index: number;
|
||||
};
|
||||
result?: boolean;
|
||||
}
|
||||
|
||||
// 统计数据类型
|
||||
@@ -41,29 +60,75 @@ interface ReviewPointsListProps {
|
||||
|
||||
export function ReviewPointsList({
|
||||
reviewPoints,
|
||||
statistics,
|
||||
statistics,
|
||||
activeReviewPointId,
|
||||
onReviewPointSelect,
|
||||
onStatusChange
|
||||
}: ReviewPointsListProps) {
|
||||
const [editingReviewPoint, setEditingReviewPoint] = useState<string | null>(null);
|
||||
const [userInputText, setUserInputText] = useState('');
|
||||
const [searchText, setSearchText] = useState('');
|
||||
const [statusFilter, setStatusFilter] = useState<string | null>(null);
|
||||
// 状态管理
|
||||
const [editingReviewPoint, setEditingReviewPoint] = useState<string | null>(null); // 当前正在编辑的评查点ID
|
||||
const [userInputText, setUserInputText] = useState(''); // 用户输入的审核意见文本
|
||||
const [searchText, setSearchText] = useState(''); // 搜索文本
|
||||
const [statusFilter, setStatusFilter] = useState<string | null>(null); // 状态过滤
|
||||
const [suggestionTexts, setSuggestionTexts] = useState<Record<string, string>>({}); // 存储每个评查点的建议文本
|
||||
|
||||
// 过滤评查点
|
||||
// 初始化建议文本
|
||||
useEffect(() => {
|
||||
// 将所有评查点的建议文本存储到状态中
|
||||
const suggestions: Record<string, string> = {};
|
||||
reviewPoints.forEach(point => {
|
||||
suggestions[point.id] = point.suggestion || '';
|
||||
});
|
||||
setSuggestionTexts(suggestions);
|
||||
}, [reviewPoints]);
|
||||
|
||||
// 处理建议文本变更
|
||||
const handleSuggestionChange = (reviewPointId: string, text: string) => {
|
||||
setSuggestionTexts(prev => ({
|
||||
...prev,
|
||||
[reviewPointId]: text
|
||||
}));
|
||||
};
|
||||
|
||||
/**
|
||||
* 过滤评查点
|
||||
* 根据搜索文本和状态过滤条件筛选评查点
|
||||
*/
|
||||
const filteredReviewPoints = reviewPoints.filter(point => {
|
||||
// 匹配搜索文本
|
||||
const matchesSearch = searchText === '' ||
|
||||
point.title.toLowerCase().includes(searchText.toLowerCase()) ||
|
||||
point.location.toLowerCase().includes(searchText.toLowerCase()) ||
|
||||
point.content.toLowerCase().includes(searchText.toLowerCase());
|
||||
point.groupName.toLowerCase().includes(searchText.toLowerCase()) ||
|
||||
(typeof point.content === 'string' && point.content.toLowerCase().includes(searchText.toLowerCase())) ||
|
||||
(typeof point.content === 'object' && point.content !== null &&
|
||||
Object.values(point.content).some(value =>
|
||||
typeof value === 'string' && value.toLowerCase().includes(searchText.toLowerCase())
|
||||
));
|
||||
|
||||
const matchesStatus = statusFilter === null || point.status === statusFilter;
|
||||
// 处理状态过滤
|
||||
let matchesStatus = false;
|
||||
|
||||
if (statusFilter === null) {
|
||||
// 未选择过滤条件时显示所有
|
||||
matchesStatus = true;
|
||||
} else if (statusFilter === 'success') {
|
||||
// 过滤"通过"状态
|
||||
matchesStatus = point.result === true || (point.result === undefined && point.status === 'success');
|
||||
} else if (statusFilter === 'warning') {
|
||||
// 过滤"警告"状态
|
||||
matchesStatus = point.result === false && point.status === 'warning';
|
||||
} else if (statusFilter === 'error') {
|
||||
// 过滤"错误"状态
|
||||
matchesStatus = point.result === false && point.status === 'error';
|
||||
}
|
||||
|
||||
return matchesSearch && matchesStatus;
|
||||
});
|
||||
|
||||
// 处理点击"一键替换"按钮
|
||||
/**
|
||||
* 处理一键替换操作
|
||||
* @param reviewPointId 评查点ID
|
||||
*/
|
||||
const handleReplace = (reviewPointId: string) => {
|
||||
// 在实际应用中,这里应该调用API进行内容替换
|
||||
// 模拟替换操作
|
||||
@@ -73,7 +138,11 @@ export function ReviewPointsList({
|
||||
onStatusChange(reviewPointId, 'success');
|
||||
};
|
||||
|
||||
// 处理评查点审核操作
|
||||
/**
|
||||
* 处理评查点审核操作
|
||||
* @param reviewPointId 评查点ID
|
||||
* @param action 操作类型: 'approve' 通过 / 'reject' 不通过
|
||||
*/
|
||||
const handleReviewAction = (reviewPointId: string, action: 'approve' | 'reject') => {
|
||||
// 更新评查点状态
|
||||
onStatusChange(reviewPointId, action === 'approve' ? 'success' : 'error');
|
||||
@@ -85,7 +154,10 @@ export function ReviewPointsList({
|
||||
alert(`${action === 'approve' ? '通过' : '不通过'}了评查点 ${reviewPointId}`);
|
||||
};
|
||||
|
||||
// 显示评查点详情编辑界面
|
||||
/**
|
||||
* 显示评查点详情编辑界面
|
||||
* @param reviewPointId 评查点ID
|
||||
*/
|
||||
const handleEditReviewPoint = (reviewPointId: string) => {
|
||||
setEditingReviewPoint(reviewPointId);
|
||||
|
||||
@@ -96,18 +168,51 @@ export function ReviewPointsList({
|
||||
}
|
||||
};
|
||||
|
||||
// 渲染评查统计信息
|
||||
/**
|
||||
* 渲染评查统计信息
|
||||
* 显示总计、通过、警告、错误数量
|
||||
*/
|
||||
const renderStatistics = () => {
|
||||
// 确保传入的statistics存在,否则使用计算值
|
||||
const statsToUse = statistics || {
|
||||
total: reviewPoints.length,
|
||||
success: 0,
|
||||
warning: 0,
|
||||
error: 0,
|
||||
score: 0
|
||||
};
|
||||
|
||||
// 计算各个状态的评查点数量
|
||||
const successCount = reviewPoints.filter(
|
||||
point => point.result === true || (point.result === undefined && point.status === 'success')
|
||||
).length;
|
||||
|
||||
const warningCount = reviewPoints.filter(
|
||||
point => point.result === false && point.status === 'warning'
|
||||
).length;
|
||||
|
||||
const errorCount = reviewPoints.filter(
|
||||
point => point.result === false && point.status === 'error'
|
||||
).length;
|
||||
|
||||
// 如果没有计算值,则使用传入的统计值
|
||||
const totalToShow = statsToUse.total === 0 ? reviewPoints.length : statsToUse.total;
|
||||
const successToShow = successCount || statsToUse.success;
|
||||
const warningToShow = warningCount || statsToUse.warning;
|
||||
const errorToShow = errorCount || statsToUse.error;
|
||||
|
||||
return (
|
||||
<div className="review-statistics bg-white border-b border-gray-100 py-3 px-4">
|
||||
<div className="flex justify-between items-center">
|
||||
{/* 总计数量 */}
|
||||
<div className="flex items-center">
|
||||
<div className="w-7 h-7 bg-gray-100 rounded-md flex items-center justify-center">
|
||||
<span className="text-sm font-semibold text-gray-600">{statistics.total}</span>
|
||||
<span className="text-sm font-semibold text-gray-600">{totalToShow}</span>
|
||||
</div>
|
||||
<span className="text-xs text-gray-500 ml-1">总计</span>
|
||||
</div>
|
||||
<div className="h-8 border-r border-gray-200"></div>
|
||||
{/* 通过数量 */}
|
||||
<div className="flex items-center">
|
||||
<button
|
||||
className={`w-7 h-7 bg-green-50 rounded-md flex items-center justify-center cursor-pointer ${statusFilter === 'success' ? 'ring-2 ring-success' : ''}`}
|
||||
@@ -115,11 +220,12 @@ export function ReviewPointsList({
|
||||
aria-label={`过滤通过项 ${statusFilter === 'success' ? '(已选中)' : ''}`}
|
||||
type="button"
|
||||
>
|
||||
<span className="text-sm font-semibold text-success">{statistics.success}</span>
|
||||
<span className="text-sm font-semibold text-success">{successToShow}</span>
|
||||
</button>
|
||||
<span className="text-xs text-gray-500 ml-1">通过</span>
|
||||
</div>
|
||||
<div className="h-8 border-r border-gray-200"></div>
|
||||
{/* 警告数量 */}
|
||||
<div className="flex items-center">
|
||||
<button
|
||||
className={`w-7 h-7 bg-yellow-50 rounded-md flex items-center justify-center cursor-pointer ${statusFilter === 'warning' ? 'ring-2 ring-warning' : ''}`}
|
||||
@@ -127,11 +233,12 @@ export function ReviewPointsList({
|
||||
aria-label={`过滤警告项 ${statusFilter === 'warning' ? '(已选中)' : ''}`}
|
||||
type="button"
|
||||
>
|
||||
<span className="text-sm font-semibold text-warning">{statistics.warning}</span>
|
||||
<span className="text-sm font-semibold text-warning">{warningToShow}</span>
|
||||
</button>
|
||||
<span className="text-xs text-gray-500 ml-1">警告</span>
|
||||
</div>
|
||||
<div className="h-8 border-r border-gray-200"></div>
|
||||
{/* 错误数量 */}
|
||||
<div className="flex items-center">
|
||||
<button
|
||||
className={`w-7 h-7 bg-red-50 rounded-md flex items-center justify-center cursor-pointer ${statusFilter === 'error' ? 'ring-2 ring-error' : ''}`}
|
||||
@@ -139,7 +246,7 @@ export function ReviewPointsList({
|
||||
aria-label={`过滤错误项 ${statusFilter === 'error' ? '(已选中)' : ''}`}
|
||||
type="button"
|
||||
>
|
||||
<span className="text-sm font-semibold text-error">{statistics.error}</span>
|
||||
<span className="text-sm font-semibold text-error">{errorToShow}</span>
|
||||
</button>
|
||||
<span className="text-xs text-gray-500 ml-1">错误</span>
|
||||
</div>
|
||||
@@ -148,7 +255,10 @@ export function ReviewPointsList({
|
||||
);
|
||||
};
|
||||
|
||||
// 渲染搜索框
|
||||
/**
|
||||
* 渲染搜索框
|
||||
* 用于按文本搜索评查点
|
||||
*/
|
||||
const renderSearchBar = () => {
|
||||
return (
|
||||
<div className="py-2 px-3 border-b border-gray-100">
|
||||
@@ -174,8 +284,40 @@ export function ReviewPointsList({
|
||||
);
|
||||
};
|
||||
|
||||
// 渲染评查点状态标签
|
||||
const renderStatusBadge = (status: string) => {
|
||||
/**
|
||||
* 渲染评查点状态标签
|
||||
* @param status 状态文本
|
||||
* @param result 评查结果
|
||||
* @returns 状态标签组件
|
||||
*/
|
||||
const renderStatusBadge = (status: string, result?: boolean) => {
|
||||
// 优先根据result判断是否通过
|
||||
if (result === true) {
|
||||
return (
|
||||
<span className="status-badge status-success">
|
||||
<i className="ri-checkbox-circle-line mr-1"></i>通过
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
// 当result为false时,根据status决定显示警告还是错误
|
||||
if (result === false) {
|
||||
if (status === 'warning') {
|
||||
return (
|
||||
<span className="status-badge status-warning">
|
||||
<i className="ri-alert-line mr-1"></i>警告
|
||||
</span>
|
||||
);
|
||||
} else if (status === 'error') {
|
||||
return (
|
||||
<span className="status-badge status-error">
|
||||
<i className="ri-close-circle-line mr-1"></i>不通过
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 兼容旧版逻辑,当没有result时,仍按status判断
|
||||
switch (status) {
|
||||
case 'success':
|
||||
return (
|
||||
@@ -210,7 +352,11 @@ export function ReviewPointsList({
|
||||
}
|
||||
};
|
||||
|
||||
// 渲染人工审核标记
|
||||
/**
|
||||
* 渲染人工审核标记
|
||||
* @param reviewPoint 评查点
|
||||
* @returns 人工审核标记组件
|
||||
*/
|
||||
const renderHumanReviewBadge = (reviewPoint: ReviewPoint) => {
|
||||
if (reviewPoint.needsHumanReview) {
|
||||
return (
|
||||
@@ -222,7 +368,11 @@ export function ReviewPointsList({
|
||||
return null;
|
||||
};
|
||||
|
||||
// 渲染人工审核注释
|
||||
/**
|
||||
* 渲染人工审核注释
|
||||
* @param reviewPoint 评查点
|
||||
* @returns 人工审核注释组件
|
||||
*/
|
||||
const renderHumanReviewNote = (reviewPoint: ReviewPoint) => {
|
||||
if (reviewPoint.needsHumanReview && reviewPoint.humanReviewNote) {
|
||||
return (
|
||||
@@ -239,11 +389,16 @@ export function ReviewPointsList({
|
||||
return null;
|
||||
};
|
||||
|
||||
// 渲染评查点内容与建议
|
||||
/**
|
||||
* 渲染评查点内容与建议
|
||||
* @param reviewPoint 评查点
|
||||
* @returns 评查点内容组件
|
||||
*/
|
||||
const renderReviewPointContent = (reviewPoint: ReviewPoint) => {
|
||||
// 如果当前评查点不处于编辑状态,只显示简单信息
|
||||
if (editingReviewPoint !== reviewPoint.id) {
|
||||
if (reviewPoint.status === 'success') {
|
||||
// 根据result和status决定渲染哪种样式
|
||||
if (reviewPoint.result === true || (reviewPoint.result === undefined && reviewPoint.status === 'success')) {
|
||||
// 已通过的评查点只显示基本信息和人工审核注释
|
||||
if (reviewPoint.needsHumanReview && reviewPoint.humanReviewNote) {
|
||||
return (
|
||||
@@ -262,39 +417,62 @@ export function ReviewPointsList({
|
||||
return null;
|
||||
}
|
||||
|
||||
// 非通过状态,显示内容和修改建议
|
||||
const isErrorStatus = reviewPoint.result === false && reviewPoint.status === 'error';
|
||||
|
||||
return (
|
||||
<div className="mt-2">
|
||||
<div className="p-2 bg-white rounded border border-gray-200 text-xs">
|
||||
<div className="flex justify-between items-center mb-1">
|
||||
<span className="text-xs">当前值</span>
|
||||
<span className={`text-xs ${reviewPoint.status === 'error' ? 'text-error' : 'text-warning'}`}>
|
||||
{reviewPoint.status === 'error' ? '不符合规范' : '需优化'}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs text-left">{reviewPoint.content || '(内容为空)'}</p>
|
||||
|
||||
{reviewPoint.suggestion && (
|
||||
<div className="mt-2 pt-2 border-t border-gray-100">
|
||||
{/* 内容显示区域 */}
|
||||
<div className="p-2 bg-white rounded border border-gray-200 text-xs mb-3">
|
||||
{/* 移除顶部的"当前值"标题,在每个内容项中显示 */}
|
||||
{typeof reviewPoint.content === 'object' && reviewPoint.content !== null ? (
|
||||
// 当 content 是对象时的渲染方式
|
||||
<div>
|
||||
{Object.entries(reviewPoint.content).map(([key, value], index) => (
|
||||
<div key={index} className="mb-2 pb-2 border-b border-gray-100 last:border-b-0 last:mb-0 last:pb-0">
|
||||
{/* 使用flex布局使key和状态标签左右对齐 */}
|
||||
<div className="flex justify-between items-center mb-1">
|
||||
<span className="text-xs">{key}</span>
|
||||
<span className={`text-xs ${isErrorStatus ? 'text-error' : 'text-warning'}`}>
|
||||
{isErrorStatus ? '不符合规范' : '需优化'}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs text-left">{value || '(内容为空)'}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
// 当 content 是字符串时的渲染方式
|
||||
<>
|
||||
{/* 为字符串内容也添加标题和状态 */}
|
||||
<div className="flex justify-between items-center mb-1">
|
||||
<span className="text-xs">建议修改为</span>
|
||||
<span className='text-xs text-green-500'>
|
||||
符合规范
|
||||
<span className="text-xs">当前值</span>
|
||||
<span className={`text-xs ${isErrorStatus ? 'text-error' : 'text-warning'}`}>
|
||||
{isErrorStatus ? '不符合规范' : '需优化'}
|
||||
</span>
|
||||
</div>
|
||||
<textarea
|
||||
className="text-xs w-full border border-gray-200 rounded p-2"
|
||||
rows={4}
|
||||
value={reviewPoint.suggestion}
|
||||
onChange={(e) => setUserInputText(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<p className="text-xs text-left">{reviewPoint.content || '(内容为空)'}</p>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 建议修改区域 */}
|
||||
<div className="mb-2">
|
||||
<div className="flex justify-between items-center mb-2">
|
||||
<span className="text-gray-700">建议修改为:</span>
|
||||
<span className="text-green-500">符合规范</span>
|
||||
</div>
|
||||
<textarea
|
||||
value={suggestionTexts[reviewPoint.id] || ''}
|
||||
onChange={(e) => handleSuggestionChange(reviewPoint.id, e.target.value)}
|
||||
className="w-full p-2 border rounded bg-gray-50 min-h-[100px] focus:outline-none focus:border-[#00684a] focus:shadow-[0_0_0_2px_rgba(0,104,74,0.2)]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 操作按钮区域 */}
|
||||
<div className="flex space-x-2 mt-2">
|
||||
{/* 一键替换按钮 - 只有非人工审核的点或未通过的人工审核点才显示 */}
|
||||
{(!reviewPoint.needsHumanReview || reviewPoint.status !== 'success') && (
|
||||
{(!reviewPoint.needsHumanReview || (!reviewPoint.result && reviewPoint.status !== 'success')) && (
|
||||
<button
|
||||
className="replace-action flex-1 justify-center"
|
||||
onClick={() => handleReplace(reviewPoint.id)}
|
||||
@@ -304,7 +482,7 @@ export function ReviewPointsList({
|
||||
)}
|
||||
|
||||
{/* 人工审核按钮 */}
|
||||
{reviewPoint.needsHumanReview && reviewPoint.status !== 'success' && (
|
||||
{reviewPoint.needsHumanReview && !reviewPoint.result && reviewPoint.status !== 'success' && (
|
||||
<button
|
||||
className="replace-action flex-1 justify-center human-review-request"
|
||||
onClick={() => handleEditReviewPoint(reviewPoint.id)}
|
||||
@@ -318,27 +496,59 @@ export function ReviewPointsList({
|
||||
}
|
||||
|
||||
// 处于编辑状态时显示编辑界面
|
||||
// 根据result和status决定显示不同的标记
|
||||
const isErrorStatus = reviewPoint.result === false && reviewPoint.status === 'error';
|
||||
|
||||
return (
|
||||
<div className="mt-2">
|
||||
<div className="p-2 bg-white rounded border border-gray-200 text-xs mb-2">
|
||||
<div className="flex justify-between items-center mb-1">
|
||||
<span className="text-xs">当前值</span>
|
||||
<span className={`text-xs ${reviewPoint.status === 'error' ? 'text-error' : 'text-warning'}`}>
|
||||
{reviewPoint.status === 'error' ? '不符合规范' : '需优化'}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs">{reviewPoint.content || '(内容为空)'}</p>
|
||||
|
||||
{reviewPoint.suggestion && (
|
||||
<div className="mt-2 pt-2 border-t border-gray-100">
|
||||
<div className="flex justify-between items-center mb-1">
|
||||
<span className="text-xs text-primary">建议修改为</span>
|
||||
</div>
|
||||
<p className="text-xs">{reviewPoint.suggestion}</p>
|
||||
{/* 内容显示区域 */}
|
||||
<div className="p-2 bg-white rounded border border-gray-200 text-xs mb-3">
|
||||
{/* 隐藏顶部的"当前值"标题,在每个内容项中显示 */}
|
||||
{typeof reviewPoint.content === 'object' && reviewPoint.content !== null ? (
|
||||
// 当 content 是对象时的渲染方式
|
||||
<div>
|
||||
{Object.entries(reviewPoint.content).map(([key, value], index) => (
|
||||
<div key={index} className="mb-2 pb-2 border-b border-gray-100 last:border-b-0 last:mb-0 last:pb-0">
|
||||
{/* 使用flex布局使key和状态标签左右对齐 */}
|
||||
<div className="flex justify-between items-center mb-1">
|
||||
<span className="text-xs">{key}</span>
|
||||
<span className={`text-xs ${isErrorStatus ? 'text-error' : 'text-warning'}`}>
|
||||
{isErrorStatus ? '不符合规范' : '需优化'}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs text-left">{value || '(内容为空)'}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
// 当 content 是字符串时的渲染方式
|
||||
<>
|
||||
{/* 为字符串内容也添加标题和状态 */}
|
||||
<div className="flex justify-between items-center mb-1">
|
||||
<span className="text-xs">当前值</span>
|
||||
<span className={`text-xs ${isErrorStatus ? 'text-error' : 'text-warning'}`}>
|
||||
{isErrorStatus ? '不符合规范' : '需优化'}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs">{reviewPoint.content || '(内容为空)'}</p>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 建议修改区域 */}
|
||||
<div className="mb-2">
|
||||
<div className="flex justify-between items-center mb-2">
|
||||
<span className="text-gray-700">建议修改为:</span>
|
||||
<span className="text-green-500">符合规范</span>
|
||||
</div>
|
||||
<textarea
|
||||
value={suggestionTexts[reviewPoint.id] || ''}
|
||||
onChange={(e) => handleSuggestionChange(reviewPoint.id, e.target.value)}
|
||||
className="w-full p-2 border rounded bg-gray-50 min-h-[100px] focus:outline-none focus:border-[#00684a] focus:shadow-[0_0_0_2px_rgba(0,104,74,0.2)]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 审核意见区域 */}
|
||||
<div className="bg-gray-50 rounded border border-gray-200 p-2">
|
||||
<label htmlFor="reviewNote" className="block text-xs text-gray-700 mb-1">审核意见</label>
|
||||
<textarea
|
||||
@@ -368,7 +578,10 @@ export function ReviewPointsList({
|
||||
);
|
||||
};
|
||||
|
||||
// 渲染无匹配结果提示
|
||||
/**
|
||||
* 渲染无匹配结果提示
|
||||
* 当过滤后没有评查点时显示
|
||||
*/
|
||||
const renderEmptyState = () => {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center py-8 px-4 text-center text-gray-500">
|
||||
@@ -390,8 +603,10 @@ export function ReviewPointsList({
|
||||
);
|
||||
};
|
||||
|
||||
// 组件主渲染函数
|
||||
return (
|
||||
<div className="review-points-panel">
|
||||
{/* 面板头部 */}
|
||||
<div className="review-panel-header py-2 px-4 flex items-center">
|
||||
<i className="ri-file-list-check-line text-primary mr-2"></i>
|
||||
<span className="font-medium text-primary">评查结果</span>
|
||||
@@ -413,16 +628,19 @@ export function ReviewPointsList({
|
||||
onClick={() => onReviewPointSelect(reviewPoint.id)}
|
||||
type="button"
|
||||
>
|
||||
<div className="review-point-header">
|
||||
<div className="review-point-title">{reviewPoint.title}</div>
|
||||
<div className="flex items-center">
|
||||
{renderStatusBadge(reviewPoint.status)}
|
||||
{/* 评查点标题和状态 */}
|
||||
<div className="review-point-header flex justify-between items-start">
|
||||
<div className="review-point-title flex-1 text-left">{reviewPoint.title}</div>
|
||||
<div className="flex items-center ml-2 flex-shrink-0">
|
||||
{renderStatusBadge(reviewPoint.status, reviewPoint.result)}
|
||||
{renderHumanReviewBadge(reviewPoint)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 评查点所属分组 */}
|
||||
<div className="review-point-location">
|
||||
<i className="ri-file-list-line mr-1"></i>
|
||||
<span>{reviewPoint.location}</span>
|
||||
<span>{reviewPoint.groupName}</span>
|
||||
</div>
|
||||
|
||||
{/* 人工审核注释 */}
|
||||
|
||||
@@ -6,5 +6,6 @@ export { FileInfo } from './FileInfo';
|
||||
export { ReviewTabs } from './ReviewTabs';
|
||||
export { FilePreview } from './FilePreview';
|
||||
export { ReviewPointsList } from './ReviewPointsList';
|
||||
export type { ReviewPoint } from './ReviewPointsList';
|
||||
export { AIAnalysis } from './AIAnalysis';
|
||||
export { FileDetails } from './FileDetails';
|
||||
+31
-79
@@ -5,14 +5,14 @@ import { Card } from "~/components/ui/Card";
|
||||
import { Button } from "~/components/ui/Button";
|
||||
import { StatusBadge, links as statusBadgeLinks } from "~/components/ui/StatusBadge";
|
||||
import { FileTag, links as fileTagLinks } from "~/components/ui/FileTag";
|
||||
import { FileTypeTag, links as fileTypeTagLinks } from "~/components/ui/FileTypeTag";
|
||||
// import { FileTypeTag, links as fileTypeTagLinks } from "~/components/ui/FileTypeTag";
|
||||
import { Tag } from "~/components/ui/Tag";
|
||||
import homeStyles from "~/styles/pages/home.css?url";
|
||||
|
||||
import { getDocuments, type DocumentUI } from "~/api/files/documents";
|
||||
export const links = () => [
|
||||
{ rel: "stylesheet", href: homeStyles },
|
||||
...statusBadgeLinks(),
|
||||
...fileTagLinks(),
|
||||
...fileTypeTagLinks()
|
||||
...fileTagLinks()
|
||||
];
|
||||
|
||||
export const meta: MetaFunction = () => {
|
||||
@@ -30,13 +30,6 @@ interface StatsData {
|
||||
passRate: number;
|
||||
}
|
||||
|
||||
interface RecentFile {
|
||||
id: string;
|
||||
name: string;
|
||||
type: string;
|
||||
reviewStatus: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// interface LoaderData {
|
||||
// stats: StatsData;
|
||||
@@ -47,13 +40,22 @@ interface RecentFile {
|
||||
// 模拟数据,实际项目中应该从API获取
|
||||
export async function loader() {
|
||||
try {
|
||||
// 实际项目中这里应该是 API 调用
|
||||
// const response = await fetch('/api/dashboard/stats');
|
||||
// const stats: StatsData = await response.json();
|
||||
|
||||
// const filesResponse = await fetch('/api/files/recent');
|
||||
// const recentFiles: RecentFile[] = await filesResponse.json();
|
||||
|
||||
const documentSearchParams = {
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
order: 'updated_at.desc'
|
||||
};
|
||||
|
||||
// 获取最近文档数据
|
||||
const responseDocuments = await getDocuments(documentSearchParams);
|
||||
if (responseDocuments.error) {
|
||||
console.error('获取最近文档数据失败', responseDocuments.error);
|
||||
return Response.json({ error: responseDocuments.error }, { status: responseDocuments.status || 500 });
|
||||
}
|
||||
const recentFiles = responseDocuments.data?.documents || [];
|
||||
console.log("recentFiles-------",recentFiles);
|
||||
|
||||
|
||||
// 模拟数据
|
||||
const stats = {
|
||||
totalFiles: 156,
|
||||
@@ -62,43 +64,7 @@ export async function loader() {
|
||||
passRate: 92.5
|
||||
} as StatsData;
|
||||
|
||||
const recentFiles = [
|
||||
{
|
||||
id: "1",
|
||||
name: "2023年度烟草专卖零售许可证.pdf",
|
||||
type: "专卖许可证",
|
||||
reviewStatus: "pass",
|
||||
updatedAt: "2023-12-24 14:30"
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
name: "烟草制品购销合同(2023-12).docx",
|
||||
type: "合同文档",
|
||||
reviewStatus: "warning",
|
||||
updatedAt: "2023-12-23 09:15"
|
||||
},
|
||||
{
|
||||
id: "3",
|
||||
name: "专卖管理处罚决定书(2023-145).pdf",
|
||||
type: "行政处罚决定书",
|
||||
reviewStatus: "fail",
|
||||
updatedAt: "2023-12-22 16:45"
|
||||
},
|
||||
{
|
||||
id: "4",
|
||||
name: "2023年第四季度采购合同.docx",
|
||||
type: "合同文档",
|
||||
reviewStatus: "pass",
|
||||
updatedAt: "2023-12-20 11:20"
|
||||
},
|
||||
{
|
||||
id: "5",
|
||||
name: "广告宣传协议书.pdf",
|
||||
type: "合同文档",
|
||||
reviewStatus: "pass",
|
||||
updatedAt: "2023-12-18 15:30"
|
||||
}
|
||||
] as RecentFile[];
|
||||
|
||||
|
||||
return Response.json({ stats, recentFiles });
|
||||
} catch (error) {
|
||||
@@ -117,14 +83,6 @@ export default function Index() {
|
||||
return (
|
||||
<div className="dashboard-container">
|
||||
{/* 页面标识 */}
|
||||
<div className="mb-4 p-3 bg-yellow-100 border border-yellow-300 rounded text-yellow-800">
|
||||
<h3 className="font-bold text-lg">当前页面: 首页 (_index.tsx)</h3>
|
||||
<p>如果你看到这个提示,说明你正在浏览首页,而不是评查点列表页面。</p>
|
||||
<div className="mt-2">
|
||||
<a href="/debug" className="text-blue-600 hover:underline">查看路由诊断页面</a> |
|
||||
<a href="/rules" className="ml-2 text-blue-600 hover:underline">通过原生链接访问评查点列表</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 统计卡片区域 */}
|
||||
<Card title="统计信息" icon="ri-bar-chart-line" className="mt-6 transition-all duration-200 hover:shadow-[0_4px_15px_rgba(0,0,0,0.1)]">
|
||||
@@ -158,13 +116,13 @@ export default function Index() {
|
||||
{/* 快捷访问区域 */}
|
||||
<Card title="快捷访问" icon="ri-speed-line" className="mt-6 transition-all duration-200 hover:shadow-[0_4px_15px_rgba(0,0,0,0.1)]">
|
||||
<div className="shortcut-grid">
|
||||
<ShortcutItem icon="ri-upload-cloud-line" label="上传文件" to="/files/new" />
|
||||
<ShortcutItem icon="ri-file-list-3-line" label="文件列表" to="/files" />
|
||||
<ShortcutItem icon="ri-upload-cloud-line" label="上传文件" to="/files/upload" />
|
||||
<ShortcutItem icon="ri-file-list-3-line" label="文件列表" to="/documents" />
|
||||
<ShortcutItem icon="ri-list-check-2" label="评查点管理" to="/rules" />
|
||||
<ShortcutItem icon="ri-folder-open-line" label="评查点分组" to="/rule-groups" />
|
||||
<ShortcutItem icon="ri-file-chart-line" label="评查详情" to="/reviews" />
|
||||
<ShortcutItem icon="ri-file-list-line" label="文档类型" to="/doc-types" />
|
||||
<ShortcutItem icon="ri-settings-3-line" label="系统设置" to="/settings" />
|
||||
<ShortcutItem icon="ri-file-list-line" label="文档类型" to="/document-types" />
|
||||
{/* <ShortcutItem icon="ri-settings-3-line" label="系统设置" to="/settings" /> */}
|
||||
<ShortcutItem icon="ri-chat-1-line" label="提示词管理" to="/prompts" />
|
||||
</div>
|
||||
</Card>
|
||||
@@ -173,11 +131,11 @@ export default function Index() {
|
||||
<Card
|
||||
title="最近文档"
|
||||
icon="ri-file-list-3-line"
|
||||
extra={<Button to="/files" size="small">查看全部</Button>}
|
||||
extra={<Button to="/documents" size="small">查看全部</Button>}
|
||||
className="mt-6"
|
||||
>
|
||||
<div className="doc-list">
|
||||
{recentFiles.map((file: RecentFile) => (
|
||||
{recentFiles.map((file: DocumentUI) => (
|
||||
<div key={file.id} className="doc-item">
|
||||
<div className="doc-info">
|
||||
<FileTag
|
||||
@@ -191,22 +149,16 @@ export default function Index() {
|
||||
<div>
|
||||
<div className="doc-name">{file.name}</div>
|
||||
<div className="doc-meta">
|
||||
<FileTypeTag
|
||||
type={file.type === "合同文档" ? "sales-contract" :
|
||||
file.type === "专卖许可证" ? "license" :
|
||||
file.type === "行政处罚决定书" ? "punishment" : "agreement"}
|
||||
text={file.type}
|
||||
size="sm"
|
||||
showIcon={false}
|
||||
className="mr-2"
|
||||
/>
|
||||
<Tag size="sm" className="mr-2">
|
||||
{file.typeName}
|
||||
</Tag>
|
||||
<span className="text-gray-500">·</span>
|
||||
<span className="ml-2 text-gray-500">{file.updatedAt}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="doc-status">
|
||||
<StatusBadge status={file.reviewStatus} />
|
||||
<StatusBadge status={file.fileStatus} />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -62,6 +62,7 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
||||
|
||||
// 获取文档类型列表,用于筛选条件,设置较大的pageSize确保获取所有数据
|
||||
const typesResponse = await getDocumentTypes({ pageSize: 500 });
|
||||
// console.log('typesResponse-----',typesResponse);
|
||||
const documentTypes = typesResponse.data?.types || [];
|
||||
const documentTypeOptions = documentTypes.map(type => ({
|
||||
value: type.id,
|
||||
@@ -433,7 +434,7 @@ export default function DocumentsIndex() {
|
||||
{
|
||||
title: "文档名称",
|
||||
key: "name",
|
||||
width:'20%',
|
||||
width:'25%',
|
||||
render: (_: unknown, record: DocumentUI) => (
|
||||
<div className="flex items-center m-1">
|
||||
<FileTag
|
||||
@@ -445,7 +446,7 @@ export default function DocumentsIndex() {
|
||||
className="mr-2 flex-shrink-0"
|
||||
/>
|
||||
<div className="overflow-hidden">
|
||||
<span className="file-name truncate block" title={record.name}>{record.name}</span>
|
||||
<span className="file-name break-words block" title={record.name}>{record.name}</span>
|
||||
<div className="mt-2 flex inline-block">
|
||||
<FileTypeTag
|
||||
type={record.type}
|
||||
@@ -515,7 +516,7 @@ export default function DocumentsIndex() {
|
||||
{
|
||||
title: "问题数量",
|
||||
key: "issues",
|
||||
width:"10%",
|
||||
width:"5%",
|
||||
render: (_: unknown, record: DocumentUI) => (
|
||||
record.issues === null ? "-" : record.issues
|
||||
)
|
||||
@@ -534,7 +535,7 @@ export default function DocumentsIndex() {
|
||||
<div className="operations-cell">
|
||||
{(record.auditStatus === 0 || record.auditStatus == null) ? (
|
||||
<Link
|
||||
to={`/documents/${record.id}/review`}
|
||||
to={`/reviews?id=${record.id}`}
|
||||
className="mr-1 hover:underline"
|
||||
>
|
||||
<i className="ri-play-circle-line"></i>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect, useRef } from "react";
|
||||
import { MetaFunction, ActionFunctionArgs } from "@remix-run/node";
|
||||
import { MetaFunction, ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
|
||||
import { Form, useActionData, useLoaderData } from "@remix-run/react";
|
||||
import { Card } from "~/components/ui/Card";
|
||||
import { Button } from "~/components/ui/Button";
|
||||
@@ -26,6 +26,13 @@ export function links() {
|
||||
];
|
||||
}
|
||||
|
||||
// 面包屑导航
|
||||
export const handle = {
|
||||
breadcrumb: () => {
|
||||
return '上传文件'
|
||||
}
|
||||
}
|
||||
|
||||
export const meta: MetaFunction = () => {
|
||||
return [
|
||||
{ title: "待审核文件上传 - 中国烟草AI合同及卷宗审核系统" },
|
||||
@@ -221,13 +228,15 @@ export async function action({ request }: ActionFunctionArgs) {
|
||||
type LoaderData = {
|
||||
documents: Document[];
|
||||
documentTypes: DocumentType[];
|
||||
mode: string;
|
||||
};
|
||||
|
||||
// 添加 loader 函数
|
||||
export async function loader() {
|
||||
export async function loader({ request }: LoaderFunctionArgs) {
|
||||
try {
|
||||
console.log('loader: 开始加载数据...');
|
||||
|
||||
// console.log('loader: 开始加载数据...');
|
||||
const url = new URL(request.url);
|
||||
const mode = url.searchParams.get("mode") || "create";
|
||||
// 并行加载文档和文档类型
|
||||
const [documentsResponse, typesResponse] = await Promise.all([
|
||||
getTodayDocuments(),
|
||||
@@ -242,6 +251,7 @@ export async function loader() {
|
||||
}
|
||||
|
||||
return Response.json({
|
||||
mode,
|
||||
documents: documentsResponse.data || [],
|
||||
documentTypes: typesResponse.data || []
|
||||
});
|
||||
|
||||
@@ -67,7 +67,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
|
||||
if (result.error) {
|
||||
console.error('获取提示词模板失败:', result.error);
|
||||
return json<LoaderData>(
|
||||
return Response.json(
|
||||
{
|
||||
templates: [],
|
||||
total: 0,
|
||||
@@ -81,7 +81,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
|
||||
console.log(`成功加载${result.data?.templates.length || 0}条提示词模板数据`);
|
||||
|
||||
return json<LoaderData>({
|
||||
return Response.json({
|
||||
templates: result.data?.templates || [],
|
||||
total: result.data?.total || 0,
|
||||
pageSize,
|
||||
@@ -89,7 +89,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("加载提示词模板失败:", error);
|
||||
return json<LoaderData>(
|
||||
return Response.json(
|
||||
{
|
||||
templates: [],
|
||||
total: 0,
|
||||
@@ -262,7 +262,7 @@ export default function PromptsIndex() {
|
||||
title: "描述",
|
||||
key: "description",
|
||||
render: (_: unknown, record: PromptTemplateUI) => (
|
||||
<div className="text-secondary text-sm truncate max-w-xs" title={record.description}>
|
||||
<div className="text-secondary text-sm max-w-xs text-wrap" title={record.description}>
|
||||
{record.description}
|
||||
</div>
|
||||
)
|
||||
@@ -276,7 +276,7 @@ export default function PromptsIndex() {
|
||||
{
|
||||
title: "状态",
|
||||
key: "status",
|
||||
width: "80px",
|
||||
width: "100px",
|
||||
render: (_: unknown, record: PromptTemplateUI) => {
|
||||
let statusText = '';
|
||||
let statusClass = '';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { MetaFunction, LoaderFunctionArgs, ActionFunctionArgs, json, redirect } from "@remix-run/node";
|
||||
import { MetaFunction, LoaderFunctionArgs, ActionFunctionArgs, redirect } from "@remix-run/node";
|
||||
import { Link, useLoaderData, useNavigation, useActionData, Form } from "@remix-run/react";
|
||||
import { Button } from "~/components/ui/Button";
|
||||
import newStyles from "~/styles/pages/prompts_new.css?url";
|
||||
@@ -86,17 +86,16 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
}
|
||||
}
|
||||
|
||||
return json<LoaderData>({
|
||||
return Response.json({
|
||||
template,
|
||||
mode
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("加载提示词模板失败:", error);
|
||||
return json<LoaderData>(
|
||||
{
|
||||
template: null,
|
||||
mode: "create",
|
||||
error: error instanceof Error ? error.message : "加载提示词模板失败"
|
||||
return Response.json({
|
||||
template: null,
|
||||
mode: "create",
|
||||
error: error instanceof Error ? error.message : "加载提示词模板失败"
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
@@ -131,7 +130,7 @@ export async function action({ request }: ActionFunctionArgs) {
|
||||
}
|
||||
|
||||
if (Object.keys(errors).length > 0) {
|
||||
return json({ errors });
|
||||
return Response.json({ errors });
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -166,7 +165,7 @@ export async function action({ request }: ActionFunctionArgs) {
|
||||
}
|
||||
|
||||
if (result.error) {
|
||||
return json({
|
||||
return Response.json({
|
||||
errors: { general: result.error },
|
||||
formData: {
|
||||
template_name,
|
||||
@@ -183,7 +182,7 @@ export async function action({ request }: ActionFunctionArgs) {
|
||||
return redirect("/prompts");
|
||||
} catch (error) {
|
||||
console.error("保存提示词模板失败:", error);
|
||||
return json({
|
||||
return Response.json({
|
||||
errors: {
|
||||
general: error instanceof Error ? error.message : "保存提示词模板失败"
|
||||
},
|
||||
|
||||
+102
-45
@@ -25,10 +25,12 @@
|
||||
* @author 中国烟草AI合同及卷宗审核系统开发团队
|
||||
*/
|
||||
|
||||
import { type MetaFunction } from "@remix-run/node";
|
||||
import { type MetaFunction, type LoaderFunctionArgs } from "@remix-run/node";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useNavigate } from "@remix-run/react";
|
||||
import { useNavigate, useLoaderData } from "@remix-run/react";
|
||||
import {getDocument} from "~/api/files/documents";
|
||||
import reviewsStyles from "~/styles/reviews.css?url";
|
||||
import { getReviewPoints } from "~/api/evaluation_points/reviews";
|
||||
|
||||
// 导入评查详情页面组件
|
||||
import {
|
||||
@@ -40,23 +42,21 @@ import {
|
||||
FileDetails
|
||||
} from "~/components/reviews";
|
||||
|
||||
// 定义评查点类型
|
||||
interface ReviewPoint {
|
||||
id: string;
|
||||
title: string;
|
||||
location: string;
|
||||
status: string;
|
||||
content: string;
|
||||
suggestion: string;
|
||||
needsHumanReview?: boolean;
|
||||
humanReviewNote?: string;
|
||||
humanReviewBy?: string;
|
||||
humanReviewTime?: string;
|
||||
position?: {
|
||||
section: string;
|
||||
index: number;
|
||||
};
|
||||
}
|
||||
// 从ReviewPointsList组件中导入ReviewPoint类型
|
||||
import { type ReviewPoint } from '~/components/reviews';
|
||||
|
||||
/**
|
||||
* 文件信息组件
|
||||
* 显示文件名称、状态信息以及操作按钮(下载原文件、导出评查报告、确认评查结果)
|
||||
*/
|
||||
// 格式化文件大小
|
||||
const formatFileSize = (bytes: number) => {
|
||||
if (bytes === 0) return "0 Bytes";
|
||||
const k = 1024;
|
||||
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
|
||||
};
|
||||
|
||||
// 定义统计数据类型
|
||||
interface Statistics {
|
||||
@@ -76,6 +76,7 @@ interface FileInfo {
|
||||
pageCount: number;
|
||||
uploadTime: string;
|
||||
uploadUser: string;
|
||||
auditStatus: number;
|
||||
}
|
||||
|
||||
// 定义合同信息类型
|
||||
@@ -166,30 +167,79 @@ export const handle = {
|
||||
breadcrumb: "评查详情"
|
||||
};
|
||||
|
||||
export async function loader({ request }: LoaderFunctionArgs) {
|
||||
try {
|
||||
const url = new URL(request.url);
|
||||
const id = url.searchParams.get('id') || undefined;
|
||||
// console.log("id-------",id);
|
||||
if (!id) {
|
||||
return Response.json({ error: '评查ID不能为空' }, { status: 400 });
|
||||
}
|
||||
|
||||
const documentData = await getDocument(id);
|
||||
if (documentData.error) {
|
||||
console.error("获取文档数据错误:", documentData.error);
|
||||
return Response.json({ error: documentData.error }, { status: documentData.status || 500 });
|
||||
}
|
||||
const reviewData = await getReviewPoints(id);
|
||||
|
||||
console.log("reviewData-------",reviewData);
|
||||
if (reviewData.error) {
|
||||
console.error("获取评查点数据错误:", reviewData.error);
|
||||
return Response.json({ error: reviewData.error }, { status: reviewData.status || 500 });
|
||||
}
|
||||
|
||||
return Response.json({
|
||||
document: documentData.data,
|
||||
reviewPoints: reviewData.data,
|
||||
statistics: reviewData.stats
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('获取评查数据失败:', error);
|
||||
return Response.json({ error: '获取评查数据失败' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
export default function ReviewDetails() {
|
||||
const navigate = useNavigate();
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const { document, reviewPoints, statistics } = useLoaderData<typeof loader>();
|
||||
const [isLoading, setIsLoading] = useState(false); // 已经通过loader加载了数据,不需要再显示加载状态
|
||||
const [activeTab, setActiveTab] = useState<string>('preview'); // 'preview', 'analysis', 'fileinfo'
|
||||
const [reviewData, setReviewData] = useState<ReviewData | null>(null);
|
||||
const [activeReviewPointId, setActiveReviewPointId] = useState<string | null>(null);
|
||||
|
||||
// 模拟获取评查数据
|
||||
useEffect(() => {
|
||||
// 模拟API请求延迟
|
||||
const timer = setTimeout(() => {
|
||||
// 模拟评查数据
|
||||
const mockData = getMockReviewData();
|
||||
setReviewData(mockData);
|
||||
setIsLoading(false);
|
||||
|
||||
// 默认选中第一个评查点
|
||||
if (mockData.reviewPoints.length > 0) {
|
||||
setActiveReviewPointId(mockData.reviewPoints[0].id);
|
||||
}
|
||||
}, 800);
|
||||
if (!document) return;
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
// 构建文件信息对象
|
||||
const fileInfo = {
|
||||
fileName: document.name || "未知文件名",
|
||||
contractNumber: document.documentNumber || "未知编号",
|
||||
fileSize: document.size ? formatFileSize(document.size) : "未知大小",
|
||||
fileFormat: document.fileType ? document.fileType.toUpperCase() : "未知格式",
|
||||
pageCount: document.pageCount || 0,
|
||||
uploadTime: document.uploadTime || "未知时间",
|
||||
uploadUser: document.uploadUser || "未知用户",
|
||||
auditStatus: document.auditStatus || 0,
|
||||
};
|
||||
|
||||
// 创建包含真实文档数据的评查数据对象
|
||||
const reviewDataObj: ReviewData = {
|
||||
// 使用真实文件信息
|
||||
fileInfo: fileInfo,
|
||||
// 其他字段暂时使用默认值
|
||||
contractInfo: getMockReviewData().contractInfo,
|
||||
reviewInfo: getMockReviewData().reviewInfo,
|
||||
statistics: statistics,
|
||||
fileContent: getMockReviewData().fileContent,
|
||||
reviewPoints: reviewPoints,
|
||||
aiAnalysis: getMockReviewData().aiAnalysis,
|
||||
};
|
||||
|
||||
setReviewData(reviewDataObj);
|
||||
setIsLoading(false);
|
||||
}, [document, reviewPoints, statistics]);
|
||||
|
||||
const handleTabChange = (tabKey: string) => {
|
||||
setActiveTab(tabKey);
|
||||
@@ -317,7 +367,8 @@ function getMockReviewData(): ReviewData {
|
||||
fileFormat: "DOCX",
|
||||
pageCount: 5,
|
||||
uploadTime: "2023-10-25 14:30:45",
|
||||
uploadUser: "张三"
|
||||
uploadUser: "张三",
|
||||
auditStatus: 0
|
||||
},
|
||||
contractInfo: {
|
||||
contractType: "销售合同",
|
||||
@@ -383,36 +434,40 @@ function getMockReviewData(): ReviewData {
|
||||
{
|
||||
id: "1",
|
||||
title: "付款条件描述不明确",
|
||||
location: "付款条款清晰性",
|
||||
groupName: "付款条款清晰性",
|
||||
// location: "交货与付款条款",
|
||||
status: "error",
|
||||
content: "乙方应在收到货物之日起5个工作日内支付合同款项,甲方应在收到乙方全部付款后开具增值税专用发票,乙方应在收到发票后支付剩余款项。",
|
||||
suggestion: "乙方应在收到货物验收合格之日起5个工作日内支付合同总额的70%,甲方收到该部分款项后3个工作日内向乙方开具等额增值税专用发票;乙方应在收到发票之日起5个工作日内支付剩余30%款项。",
|
||||
position: { section: "交货与付款", index: 2 }
|
||||
position: { section: "交货与付款", index: 2 },
|
||||
result: false
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
title: "违约责任条款缺失",
|
||||
location: "合同权利义务对等性",
|
||||
groupName: "合同权利义务对等性",
|
||||
status: "warning",
|
||||
content: "如合同发生纠纷,双方应协商解决。",
|
||||
suggestion: "如合同发生纠纷,双方应友好协商解决;协商不成的,任何一方均有权向甲方所在地人民法院提起诉讼。任何一方未能履行本合同约定义务,应向守约方支付合同总金额的10%作为违约金;给对方造成损失的,还应赔偿由此产生的全部损失。",
|
||||
position: { section: "争议解决", index: 0 }
|
||||
position: { section: "争议解决", index: 0 },
|
||||
result: false
|
||||
},
|
||||
{
|
||||
id: "3",
|
||||
title: "签章不完整",
|
||||
location: "合同签署规范性",
|
||||
groupName: "合同签署规范性",
|
||||
status: "warning",
|
||||
content: "乙方(盖章):YY贸易有限公司\n代表人签字:李YY\n日期:2023年10月20日",
|
||||
suggestion: "需要联系甲方补充公章",
|
||||
needsHumanReview: true,
|
||||
humanReviewNote: "需要联系甲方补充公章",
|
||||
position: { section: "签章", index: 0 }
|
||||
position: { section: "签章", index: 0 },
|
||||
result: false
|
||||
},
|
||||
{
|
||||
id: "9",
|
||||
title: "交货方式描述模糊",
|
||||
location: "履行条款明确性",
|
||||
groupName: "履行条款明确性",
|
||||
status: "success",
|
||||
content: "3.4 运输方式:陆运,运费由甲方承担。",
|
||||
suggestion: "建议补充具体的运输方式和时间",
|
||||
@@ -420,16 +475,18 @@ function getMockReviewData(): ReviewData {
|
||||
humanReviewNote: "经核实,该交货方式虽然描述不够详细,但符合行业惯例且双方已经多次合作,不会造成实际履行障碍。",
|
||||
humanReviewBy: "王法务",
|
||||
humanReviewTime: "2023-11-05 14:30:22",
|
||||
position: { section: "交货与付款", index: 4 }
|
||||
position: { section: "交货与付款", index: 4 },
|
||||
result: true
|
||||
},
|
||||
{
|
||||
id: "10",
|
||||
title: "法律适用条款缺失",
|
||||
location: "争议解决条款完整性",
|
||||
groupName: "争议解决条款完整性",
|
||||
status: "error",
|
||||
content: "",
|
||||
suggestion: "第十三条 法律适用\n本合同的订立、效力、解释、履行及争议的解决均适用中华人民共和国法律。因本合同引起的或与本合同有关的任何争议,双方应友好协商解决。协商不成的,提交甲方所在地人民法院诉讼解决。",
|
||||
position: { section: "缺失", index: 0 }
|
||||
position: { section: "缺失", index: 0 },
|
||||
result: false
|
||||
}
|
||||
],
|
||||
aiAnalysis: {
|
||||
|
||||
+110
-258
@@ -1,4 +1,4 @@
|
||||
import { json, type MetaFunction, type LoaderFunctionArgs } from "@remix-run/node";
|
||||
import { type MetaFunction, type LoaderFunctionArgs } from "@remix-run/node";
|
||||
import { useLoaderData, useSearchParams } from "@remix-run/react";
|
||||
import { Button } from "~/components/ui/Button";
|
||||
import { Card } from "~/components/ui/Card";
|
||||
@@ -6,15 +6,20 @@ import { FileIcon } from "~/components/ui/FileIcon";
|
||||
import { FilterPanel, FilterSelect, SearchFilter } from "~/components/ui/FilterPanel";
|
||||
import { Pagination } from "~/components/ui/Pagination";
|
||||
import { Table } from "~/components/ui/Table";
|
||||
import { FileTypeTag } from "~/components/ui/FileTypeTag";
|
||||
import { Tag } from "~/components/ui/Tag";
|
||||
import { StatusBadge } from "~/components/ui/StatusBadge";
|
||||
import rulesFilesStyles from "~/styles/pages/rules-files.css?url";
|
||||
import {
|
||||
getReviewFiles,
|
||||
updateReviewStatus,
|
||||
type ReviewFileUI
|
||||
} from "~/api/evaluation_points/rules-files";
|
||||
import { getDocumentTypes } from "~/api/document-types/document-types";
|
||||
|
||||
export const links = () => [
|
||||
{ rel: "stylesheet", href: rulesFilesStyles }
|
||||
];
|
||||
|
||||
|
||||
export const handle = {
|
||||
breadcrumb: "评查文件列表"
|
||||
};
|
||||
@@ -27,23 +32,6 @@ export const meta: MetaFunction = () => {
|
||||
];
|
||||
};
|
||||
|
||||
// 评查文件类型枚举
|
||||
export enum FileType {
|
||||
CONTRACT = 'contract',
|
||||
LICENSE = 'license',
|
||||
PUNISHMENT = 'punishment',
|
||||
REPORT = 'report',
|
||||
OTHER = 'other'
|
||||
}
|
||||
|
||||
// 评查状态枚举
|
||||
export enum ReviewStatus {
|
||||
PASS = 'pass',
|
||||
WARNING = 'warning',
|
||||
FAIL = 'fail',
|
||||
PENDING = 'pending'
|
||||
}
|
||||
|
||||
// 日期范围枚举
|
||||
export enum DateRange {
|
||||
ALL = 'all',
|
||||
@@ -53,47 +41,14 @@ export enum DateRange {
|
||||
CUSTOM = 'custom'
|
||||
}
|
||||
|
||||
// 文件类型标签映射
|
||||
export const FILE_TYPE_LABELS: Record<FileType, string> = {
|
||||
[FileType.CONTRACT]: '合同文档',
|
||||
[FileType.LICENSE]: '专卖许可证',
|
||||
[FileType.PUNISHMENT]: '行政处罚',
|
||||
[FileType.REPORT]: '报表文档',
|
||||
[FileType.OTHER]: '其他文档'
|
||||
};
|
||||
|
||||
// 评查状态标签映射
|
||||
export const REVIEW_STATUS_LABELS: Record<ReviewStatus, string> = {
|
||||
[ReviewStatus.PASS]: '通过',
|
||||
[ReviewStatus.WARNING]: '警告',
|
||||
[ReviewStatus.FAIL]: '不通过',
|
||||
[ReviewStatus.PENDING]: '待人工确认'
|
||||
export const REVIEW_STATUS_LABELS: Record<string, string> = {
|
||||
'pass': '通过',
|
||||
'warning': '警告',
|
||||
'fail': '不通过',
|
||||
'pending': '待人工确认'
|
||||
};
|
||||
|
||||
// 评查文件模型
|
||||
interface ReviewFile {
|
||||
id: string;
|
||||
fileName: string;
|
||||
fileCode: string; // 文件编号
|
||||
fileType: FileType;
|
||||
fileSize: number;
|
||||
uploadTime: string;
|
||||
reviewStatus: ReviewStatus;
|
||||
issueCount: number;
|
||||
issues: Array<{
|
||||
severity: 'info' | 'warning' | 'error' | 'critical';
|
||||
message: string;
|
||||
}>;
|
||||
createdBy: string;
|
||||
}
|
||||
|
||||
interface LoaderData {
|
||||
files: ReviewFile[];
|
||||
totalCount: number;
|
||||
currentPage: number;
|
||||
pageSize: number;
|
||||
totalPages: number;
|
||||
}
|
||||
|
||||
export async function loader({ request }: LoaderFunctionArgs) {
|
||||
const url = new URL(request.url);
|
||||
@@ -106,164 +61,38 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
const pageSize = parseInt(url.searchParams.get("pageSize") || "10", 10);
|
||||
|
||||
try {
|
||||
// 模拟数据,实际项目中应从API获取
|
||||
const mockFiles: ReviewFile[] = [
|
||||
{
|
||||
id: "1",
|
||||
fileName: "烟草产品销售合同(2023版).pdf",
|
||||
fileCode: "XS-2023-1025-001",
|
||||
fileType: FileType.CONTRACT,
|
||||
fileSize: 1024 * 1024 * 2.5, // 2.5MB
|
||||
uploadTime: "2023-10-25 14:30:45",
|
||||
reviewStatus: ReviewStatus.WARNING,
|
||||
issueCount: 3,
|
||||
issues: [
|
||||
{ severity: "warning", message: "付款条件描述不明确" },
|
||||
{ severity: "warning", message: "违约责任条款缺失" },
|
||||
{ severity: "warning", message: "签章不完整" }
|
||||
],
|
||||
createdBy: "张三"
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
fileName: "2023年度烟草专卖零售许可证.pdf",
|
||||
fileCode: "LS-2023-0058",
|
||||
fileType: FileType.LICENSE,
|
||||
fileSize: 1024 * 1024 * 1.2, // 1.2MB
|
||||
uploadTime: "2023-10-24 10:15:22",
|
||||
reviewStatus: ReviewStatus.PASS,
|
||||
issueCount: 0,
|
||||
issues: [],
|
||||
createdBy: "李四"
|
||||
},
|
||||
{
|
||||
id: "3",
|
||||
fileName: "XX公司违规处罚决定书.pdf",
|
||||
fileCode: "处罚[2023]42号",
|
||||
fileType: FileType.PUNISHMENT,
|
||||
fileSize: 1024 * 1024 * 3.1, // 3.1MB
|
||||
uploadTime: "2023-10-23 16:45:30",
|
||||
reviewStatus: ReviewStatus.FAIL,
|
||||
issueCount: 2,
|
||||
issues: [
|
||||
{ severity: "error", message: "处罚依据条款引用错误" },
|
||||
{ severity: "error", message: "处罚金额超出规定范围" }
|
||||
],
|
||||
createdBy: "王五"
|
||||
},
|
||||
{
|
||||
id: "4",
|
||||
fileName: "烟草设备采购协议.docx",
|
||||
fileCode: "CG-2023-0089",
|
||||
fileType: FileType.CONTRACT,
|
||||
fileSize: 1024 * 1024 * 0.8, // 0.8MB
|
||||
uploadTime: "2023-10-22 09:22:15",
|
||||
reviewStatus: ReviewStatus.PENDING,
|
||||
issueCount: 1,
|
||||
issues: [
|
||||
{ severity: "warning", message: "交付日期条款存在歧义,需人工确认" }
|
||||
],
|
||||
createdBy: "赵六"
|
||||
},
|
||||
{
|
||||
id: "5",
|
||||
fileName: "2023年度销售额报表.xlsx",
|
||||
fileCode: "BB-2023-Q3",
|
||||
fileType: FileType.REPORT,
|
||||
fileSize: 1024 * 1024 * 0.5, // 0.5MB
|
||||
uploadTime: "2023-10-20 14:05:38",
|
||||
reviewStatus: ReviewStatus.PASS,
|
||||
issueCount: 0,
|
||||
issues: [],
|
||||
createdBy: "钱七"
|
||||
}
|
||||
];
|
||||
// 获取文档类型列表
|
||||
const typesResponse = await getDocumentTypes({pageSize:500});
|
||||
const documentTypes = typesResponse.data?.types || [];
|
||||
|
||||
// 过滤数据
|
||||
let filteredFiles = [...mockFiles];
|
||||
// 获取文件列表
|
||||
const searchParams = {
|
||||
fileType,
|
||||
reviewStatus,
|
||||
dateRange,
|
||||
keyword,
|
||||
sortOrder,
|
||||
page: currentPage,
|
||||
pageSize,
|
||||
};
|
||||
|
||||
if (fileType) {
|
||||
filteredFiles = filteredFiles.filter(file => file.fileType === fileType);
|
||||
console.log('rules-filessearchParams-----',searchParams);
|
||||
|
||||
const filesResponse = await getReviewFiles(searchParams);
|
||||
if (filesResponse.error) {
|
||||
console.error('获取评查文件列表失败:', filesResponse.error);
|
||||
throw new Response('获取评查文件列表失败', { status: filesResponse.status || 500 });
|
||||
}
|
||||
|
||||
if (reviewStatus) {
|
||||
filteredFiles = filteredFiles.filter(file => file.reviewStatus === reviewStatus);
|
||||
}
|
||||
const files = filesResponse.data?.files || [];
|
||||
const totalCount = filesResponse.data?.total || 0;
|
||||
|
||||
if (dateRange) {
|
||||
const now = new Date();
|
||||
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
|
||||
switch (dateRange) {
|
||||
case DateRange.TODAY:
|
||||
filteredFiles = filteredFiles.filter(file => {
|
||||
const fileDate = new Date(file.uploadTime.split(' ')[0]);
|
||||
return fileDate >= today;
|
||||
});
|
||||
break;
|
||||
case DateRange.WEEK: {
|
||||
const weekStart = new Date(today);
|
||||
weekStart.setDate(today.getDate() - today.getDay());
|
||||
filteredFiles = filteredFiles.filter(file => {
|
||||
const fileDate = new Date(file.uploadTime.split(' ')[0]);
|
||||
return fileDate >= weekStart;
|
||||
});
|
||||
break;
|
||||
}
|
||||
case DateRange.MONTH: {
|
||||
const monthStart = new Date(today.getFullYear(), today.getMonth(), 1);
|
||||
filteredFiles = filteredFiles.filter(file => {
|
||||
const fileDate = new Date(file.uploadTime.split(' ')[0]);
|
||||
return fileDate >= monthStart;
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (keyword) {
|
||||
const lowerKeyword = keyword.toLowerCase();
|
||||
filteredFiles = filteredFiles.filter(file =>
|
||||
file.fileName.toLowerCase().includes(lowerKeyword) ||
|
||||
file.fileCode.toLowerCase().includes(lowerKeyword)
|
||||
);
|
||||
}
|
||||
|
||||
// 排序
|
||||
switch (sortOrder) {
|
||||
case "upload_time_desc":
|
||||
filteredFiles.sort((a, b) => new Date(b.uploadTime).getTime() - new Date(a.uploadTime).getTime());
|
||||
break;
|
||||
case "upload_time_asc":
|
||||
filteredFiles.sort((a, b) => new Date(a.uploadTime).getTime() - new Date(b.uploadTime).getTime());
|
||||
break;
|
||||
case "issue_count_desc":
|
||||
filteredFiles.sort((a, b) => b.issueCount - a.issueCount);
|
||||
break;
|
||||
case "issue_count_asc":
|
||||
filteredFiles.sort((a, b) => a.issueCount - b.issueCount);
|
||||
break;
|
||||
}
|
||||
|
||||
// 计算分页信息
|
||||
const totalCount = filteredFiles.length;
|
||||
const totalPages = Math.ceil(totalCount / pageSize);
|
||||
|
||||
// 分页截取
|
||||
const startIndex = (currentPage - 1) * pageSize;
|
||||
const endIndex = startIndex + pageSize;
|
||||
const paginatedFiles = filteredFiles.slice(startIndex, endIndex);
|
||||
|
||||
return json<LoaderData>({
|
||||
files: paginatedFiles,
|
||||
return Response.json({
|
||||
files,
|
||||
documentTypes,
|
||||
totalCount,
|
||||
currentPage,
|
||||
pageSize,
|
||||
totalPages
|
||||
}, {
|
||||
headers: {
|
||||
"Cache-Control": "max-age=60, s-maxage=180"
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('加载评查文件列表失败:', error);
|
||||
@@ -284,9 +113,10 @@ export function ErrorBoundary() {
|
||||
|
||||
// 在文件中定义一个与路由文件名匹配的命名函数组件
|
||||
export default function RulesFiles() {
|
||||
const { files, totalCount, currentPage, pageSize } = useLoaderData<typeof loader>();
|
||||
const { files, documentTypes, totalCount, currentPage, pageSize } = useLoaderData<typeof loader>();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
|
||||
// 处理筛选条件变更
|
||||
const handleFilterChange = (e: React.ChangeEvent<HTMLSelectElement | HTMLInputElement>) => {
|
||||
const { name, value } = e.target;
|
||||
const newParams = new URLSearchParams(searchParams);
|
||||
@@ -303,6 +133,7 @@ export default function RulesFiles() {
|
||||
setSearchParams(newParams);
|
||||
};
|
||||
|
||||
// 处理搜索操作
|
||||
const handleSearch = (keyword: string) => {
|
||||
const newParams = new URLSearchParams(searchParams);
|
||||
if (keyword) {
|
||||
@@ -317,13 +148,14 @@ export default function RulesFiles() {
|
||||
setSearchParams(newParams);
|
||||
};
|
||||
|
||||
// 处理页码变更
|
||||
const handlePageChange = (page: number) => {
|
||||
const newParams = new URLSearchParams(searchParams);
|
||||
newParams.set('page', page.toString());
|
||||
setSearchParams(newParams);
|
||||
};
|
||||
|
||||
// 添加页码大小变更处理函数
|
||||
// 处理每页条数变更
|
||||
const handlePageSizeChange = (size: number) => {
|
||||
const newParams = new URLSearchParams(searchParams);
|
||||
newParams.set('pageSize', size.toString());
|
||||
@@ -331,9 +163,23 @@ export default function RulesFiles() {
|
||||
setSearchParams(newParams);
|
||||
};
|
||||
|
||||
// 处理确认评查状态
|
||||
const handleConfirmStatus = async (id: string, status: string) => {
|
||||
try {
|
||||
await updateReviewStatus(id, status);
|
||||
// 刷新页面获取最新数据
|
||||
const newParams = new URLSearchParams(searchParams);
|
||||
setSearchParams(newParams);
|
||||
} catch (error) {
|
||||
console.error('更新评查状态失败:', error);
|
||||
// 可以在这里添加错误提示
|
||||
}
|
||||
};
|
||||
|
||||
// 渲染问题摘要
|
||||
const renderIssues = (issues: ReviewFile['issues']) => {
|
||||
if (issues.length === 0) {
|
||||
const renderIssues = (file: ReviewFileUI) => {
|
||||
// 如果评查状态为通过,显示"所有评查点均通过"
|
||||
if (file.reviewStatus === 'pass') {
|
||||
return (
|
||||
<div className="text-sm text-success">
|
||||
<i className="ri-check-double-line mr-1"></i>所有评查点均通过
|
||||
@@ -341,29 +187,23 @@ export default function RulesFiles() {
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="text-sm">
|
||||
{issues.slice(0, 3).map((issue, index) => (
|
||||
<div key={index} className={`mb-1 ${index === issues.length - 1 ? 'last:mb-0' : ''}`}>
|
||||
<span className={`severity-indicator severity-${issue.severity}`}></span>
|
||||
{issue.message}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
// 其他状态显示占位符
|
||||
return <div className="text-sm text-secondary">-</div>;
|
||||
};
|
||||
|
||||
// 文件类型选项
|
||||
const fileTypeOptions = Object.keys(FILE_TYPE_LABELS).map(type => ({
|
||||
value: type,
|
||||
label: FILE_TYPE_LABELS[type as FileType]
|
||||
const fileTypeOptions = documentTypes.map((type: {id: number, name: string}) => ({
|
||||
value: type.id.toString(),
|
||||
label: type.name
|
||||
}));
|
||||
|
||||
// 评查状态选项
|
||||
const reviewStatusOptions = Object.keys(REVIEW_STATUS_LABELS).map(status => ({
|
||||
value: status,
|
||||
label: REVIEW_STATUS_LABELS[status as ReviewStatus]
|
||||
}));
|
||||
const reviewStatusOptions = [
|
||||
{ value: 'pass', label: '通过' },
|
||||
{ value: 'warning', label: '警告' },
|
||||
{ value: 'fail', label: '不通过' },
|
||||
{ value: 'pending', label: '待人工确认' }
|
||||
];
|
||||
|
||||
// 时间范围选项
|
||||
const dateRangeOptions = [
|
||||
@@ -379,17 +219,13 @@ export default function RulesFiles() {
|
||||
title: "文件名称",
|
||||
key: "fileName",
|
||||
width: "30%",
|
||||
render: (_: unknown, file: ReviewFile) => (
|
||||
render: (_: unknown, file: ReviewFileUI) => (
|
||||
<div className="flex items-center">
|
||||
<FileIcon fileName={file.fileName} className="mr-2 text-lg" />
|
||||
<FileIcon fileName={file.fileName} className="mr-2 text-lg flex-shrink-0 w-10 h-10" />
|
||||
<div>
|
||||
<div className="font-normal text-base">{file.fileName}</div>
|
||||
<div className="font-normal text-base break-words" title={file.fileName}>{file.fileName}</div>
|
||||
<div className="text-xs text-secondary mt-1">
|
||||
{file.fileType === FileType.CONTRACT && "合同编号:"}
|
||||
{file.fileType === FileType.LICENSE && "许可证号:"}
|
||||
{file.fileType === FileType.PUNISHMENT && "文号:"}
|
||||
{file.fileType === FileType.REPORT && "报表编号:"}
|
||||
{file.fileCode}
|
||||
文件编号:{file.fileCode}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -399,34 +235,38 @@ export default function RulesFiles() {
|
||||
title: "文件类型",
|
||||
key: "fileType",
|
||||
width: "12%",
|
||||
render: (_: unknown, file: ReviewFile) => (
|
||||
<FileTypeTag
|
||||
type={file.fileType}
|
||||
text={FILE_TYPE_LABELS[file.fileType]}
|
||||
showIcon={true}
|
||||
/>
|
||||
render: (_: unknown, file: ReviewFileUI) => (
|
||||
<Tag
|
||||
color="blue"
|
||||
size="sm"
|
||||
>
|
||||
{file.fileType}
|
||||
</Tag>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: "上传时间",
|
||||
key: "uploadTime",
|
||||
width: "12%",
|
||||
render: (_: unknown, file: ReviewFile) => (
|
||||
<div>
|
||||
<span className="text-base">{file.uploadTime.split(' ')[0]}</span>
|
||||
<br />
|
||||
<span className="text-xs text-secondary">{file.uploadTime.split(' ')[1]}</span>
|
||||
</div>
|
||||
)
|
||||
render: (_: unknown, file: ReviewFileUI) => {
|
||||
const [date, time] = file.uploadTime.split(' ');
|
||||
return (
|
||||
<div>
|
||||
<span className="text-base">{date}</span>
|
||||
<br />
|
||||
<span className="text-xs text-secondary">{time}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "评查状态",
|
||||
key: "reviewStatus",
|
||||
width: "12%",
|
||||
render: (_: unknown, file: ReviewFile) => (
|
||||
render: (_: unknown, file: ReviewFileUI) => (
|
||||
<StatusBadge
|
||||
status={file.reviewStatus}
|
||||
text={file.issueCount > 0 ? `${REVIEW_STATUS_LABELS[file.reviewStatus]} (${file.issueCount})` : REVIEW_STATUS_LABELS[file.reviewStatus]}
|
||||
text={REVIEW_STATUS_LABELS[file.reviewStatus]}
|
||||
showIcon={true}
|
||||
/>
|
||||
)
|
||||
@@ -435,20 +275,32 @@ export default function RulesFiles() {
|
||||
title: "问题摘要",
|
||||
key: "issues",
|
||||
width: "20%",
|
||||
render: (_: unknown, file: ReviewFile) => renderIssues(file.issues)
|
||||
render: (_: unknown, file: ReviewFileUI) => renderIssues(file)
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
key: "operation",
|
||||
width: "14%",
|
||||
render: (_: unknown, file: ReviewFile) => (
|
||||
render: (_: unknown, file: ReviewFileUI) => (
|
||||
<>
|
||||
{file.reviewStatus === ReviewStatus.PENDING ? (
|
||||
<Button type="primary" size="small" icon="ri-check-double-line" className="mr-2">
|
||||
{file.reviewStatus === 'pending' ? (
|
||||
<Button
|
||||
type="primary"
|
||||
size="small"
|
||||
icon="ri-check-double-line"
|
||||
className="mr-2"
|
||||
onClick={() => handleConfirmStatus(file.id, 'pass')}
|
||||
>
|
||||
确认
|
||||
</Button>
|
||||
) : (
|
||||
<Button type="default" size="small" icon="ri-eye-line" to={`/files/${file.id}`} className="mr-2">
|
||||
<Button
|
||||
type="default"
|
||||
size="small"
|
||||
icon="ri-eye-line"
|
||||
to={`/files/${file.id}`}
|
||||
className="mr-2"
|
||||
>
|
||||
查看
|
||||
</Button>
|
||||
)}
|
||||
@@ -472,7 +324,7 @@ export default function RulesFiles() {
|
||||
<span className="text-base font-normal text-primary ml-1">{totalCount}</span>
|
||||
</div>
|
||||
</div>
|
||||
<Button type="primary" icon="ri-file-upload-line" to="/files/new">
|
||||
<Button type="primary" icon="ri-file-upload-line" to="/files/upload">
|
||||
上传新文件
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -415,7 +415,7 @@ export default function RulesIndex() {
|
||||
title: "优先级",
|
||||
key: "priority",
|
||||
align: "left" as const,
|
||||
width: "5%",
|
||||
width: "8%",
|
||||
render: (_: unknown, record: Rule) => {
|
||||
const priorityColor = RULE_PRIORITY_COLORS[record.priority] as TagColor;
|
||||
return (
|
||||
@@ -467,7 +467,7 @@ export default function RulesIndex() {
|
||||
{/* 页面头部 */}
|
||||
<div className="flex justify-between items-center mb-4">
|
||||
<h2 className="text-xl font-medium">评查点管理</h2>
|
||||
<Button type="primary" icon="ri-add-line" to="/rules/new" className="btn-add-rule">
|
||||
<Button type="primary" icon="ri-add-line" to="/rules-new" className="btn-add-rule">
|
||||
新增评查点
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
/* 表格内容 */
|
||||
.ant-table tbody td {
|
||||
@apply py-3 px-4 border-b border-gray-100 align-middle;
|
||||
@apply py-3 border-b border-gray-100 align-middle pl-4;
|
||||
}
|
||||
|
||||
/* 表格行 */
|
||||
|
||||
@@ -22,10 +22,9 @@
|
||||
}
|
||||
|
||||
.file-name {
|
||||
max-width: 240px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 100%;
|
||||
word-wrap: break-word;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.document-number {
|
||||
|
||||
@@ -210,7 +210,16 @@
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.text-error {
|
||||
color: #f5222d;
|
||||
}
|
||||
|
||||
.text-warning {
|
||||
color: #faad14;
|
||||
}
|
||||
|
||||
.review-point-title {
|
||||
text-align: left;
|
||||
font-weight: 500;
|
||||
font-size: 13px;
|
||||
line-height: 1.3;
|
||||
|
||||
Reference in New Issue
Block a user