Merge branch 'shiy' into awen
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';
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
import { apiRequest } from './client';
|
||||
import { FileType, Priority } from '~/types/enums';
|
||||
|
||||
/**
|
||||
* 将文件转换为二进制数据
|
||||
*/
|
||||
export async function uploadFileToBinary(file: File): Promise<ArrayBuffer> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
if (reader.result instanceof ArrayBuffer) {
|
||||
resolve(reader.result);
|
||||
} else {
|
||||
reject(new Error('文件读取失败'));
|
||||
}
|
||||
};
|
||||
reader.onerror = () => reject(new Error('文件读取失败'));
|
||||
reader.readAsArrayBuffer(file);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件到服务器
|
||||
*/
|
||||
export async function uploadFileToServer(
|
||||
binaryData: ArrayBuffer,
|
||||
fileName: string,
|
||||
fileType: string,
|
||||
documentType: FileType,
|
||||
priority: Priority
|
||||
): Promise<{ success: boolean; fileId?: string; message?: string; error?: string }> {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('file', new Blob([binaryData], { type: fileType }), fileName);
|
||||
formData.append('documentType', documentType);
|
||||
formData.append('priority', priority);
|
||||
|
||||
const response = await apiRequest<{ success: boolean; fileId?: string; message?: string }>(
|
||||
'/api/files/upload',
|
||||
{
|
||||
method: 'POST',
|
||||
body: formData
|
||||
}
|
||||
);
|
||||
|
||||
if (response.error) {
|
||||
return { success: false, error: response.error };
|
||||
}
|
||||
|
||||
return { success: true, fileId: response.data?.fileId, message: response.data?.message };
|
||||
} catch (error) {
|
||||
return { success: false, error: error instanceof Error ? error.message : '上传失败' };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件到文档审核系统
|
||||
*/
|
||||
export async function uploadDocumentToServer(
|
||||
binaryData: ArrayBuffer,
|
||||
fileName: string,
|
||||
fileType: string,
|
||||
typeId: string | number,
|
||||
priority: string,
|
||||
documentNumber?: string | null,
|
||||
remark?: string | null,
|
||||
isTestDocument: boolean = false
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
result?: {
|
||||
id: number;
|
||||
file_name: string;
|
||||
file_size: number;
|
||||
file_url: string;
|
||||
type_id: number;
|
||||
type_description: string;
|
||||
document_number: string | null;
|
||||
storage_type: string;
|
||||
is_test_document: boolean;
|
||||
remark: string | null;
|
||||
background_processing: boolean;
|
||||
evaluation_level: string;
|
||||
};
|
||||
error: string | null;
|
||||
}> {
|
||||
try {
|
||||
// 创建FormData对象
|
||||
const formData = new FormData();
|
||||
|
||||
// 将二进制数据转换为Blob并添加到FormData
|
||||
const blob = new Blob([binaryData], { type: fileType });
|
||||
formData.append('file', blob, fileName);
|
||||
|
||||
// 将信息添加到一个JSON对象中
|
||||
const uploadInfo = {
|
||||
type_id: Number(typeId),
|
||||
evaluation_level: priority,
|
||||
document_number: documentNumber || null,
|
||||
remark: remark || null,
|
||||
is_test_document: isTestDocument
|
||||
};
|
||||
|
||||
// 添加JSON字符串到FormData
|
||||
formData.append('upload_info', JSON.stringify(uploadInfo));
|
||||
|
||||
// 发送请求
|
||||
const response = await fetch('http://172.16.0.55:8000/admin/documents/upload', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-File-Name': encodeURIComponent(fileName)
|
||||
},
|
||||
body: formData
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
console.error(`上传失败 (${response.status}): ${errorText}`);
|
||||
return {
|
||||
success: false,
|
||||
error: `上传失败: ${response.status} ${response.statusText}`
|
||||
};
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('上传错误:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : '上传失败'
|
||||
};
|
||||
}
|
||||
}
|
||||
+45
-22
@@ -45,6 +45,8 @@ export interface DocumentSearchParams {
|
||||
documentNumber?: string;
|
||||
documentType?: string;
|
||||
status?: string;
|
||||
auditStatus?: string;
|
||||
fileStatus?: string;
|
||||
dateFrom?: string;
|
||||
dateTo?: string;
|
||||
page?: number;
|
||||
@@ -67,10 +69,16 @@ export interface Document {
|
||||
is_test_document: boolean;
|
||||
evaluation_level: string;
|
||||
status: 'pass' | 'warning' | 'waiting' | 'processing' | 'fail';
|
||||
ocr_result: unknown;
|
||||
extracted_results: unknown;
|
||||
summary: unknown;
|
||||
remark: string;
|
||||
file_status: 'Waiting' | 'Cutting' | 'Extractioning' | 'Evaluationing' | 'Processed';
|
||||
audit_status: number; // -1: 不通过, 0: 待审核, 1: 通过, 2: 警告, 3: 审核中
|
||||
ocr_result?: {
|
||||
__meta?: {
|
||||
page_count?: number;
|
||||
}
|
||||
};
|
||||
extracted_results?: unknown;
|
||||
summary?: unknown;
|
||||
remark?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
@@ -85,12 +93,15 @@ export interface DocumentUI {
|
||||
type: string;
|
||||
typeName: string;
|
||||
size: number;
|
||||
status: string;
|
||||
auditStatus: number; // -1: 不通过, 0: 待审核, 1: 通过, 2: 警告, 3: 审核中
|
||||
fileStatus: string; // Waiting, Cutting, Extractioning, Evaluationing, Processed
|
||||
issues: number | null;
|
||||
uploadTime: string;
|
||||
fileType: string;
|
||||
path: string;
|
||||
isTest: boolean;
|
||||
updatedAt?: string;
|
||||
pageCount?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,12 +130,15 @@ async function convertToUIDocument(doc: Document): Promise<DocumentUI> {
|
||||
type: doc.type_id.toString(),
|
||||
typeName: docType?.name || '未知类型',
|
||||
size: doc.file_size,
|
||||
status: doc.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
|
||||
};
|
||||
}
|
||||
|
||||
@@ -169,20 +183,36 @@ export async function getDocuments(searchParams: DocumentSearchParams = {}): Pro
|
||||
filter['type_id'] = `eq.${searchParams.documentType}`;
|
||||
}
|
||||
|
||||
if (searchParams.status) {
|
||||
filter['status'] = `eq.${searchParams.status}`;
|
||||
if (searchParams.auditStatus) {
|
||||
filter['audit_status'] = `eq.${searchParams.auditStatus}`;
|
||||
}
|
||||
|
||||
if (searchParams.fileStatus) {
|
||||
filter['status'] = `eq.${searchParams.fileStatus}`;
|
||||
}
|
||||
|
||||
// 处理日期范围
|
||||
if (searchParams.dateFrom) {
|
||||
filter['updated_at'] = `gte.${searchParams.dateFrom}`;
|
||||
// 添加当天开始时间 00:00:00
|
||||
filter['created_at'] = `gte.'${dayjs(`${searchParams.dateFrom} 00:00:00`).format()}'`;
|
||||
}
|
||||
|
||||
if (searchParams.dateTo) {
|
||||
const dateToKey = searchParams.dateFrom ? 'and.updated_at.lte' : 'updated_at';
|
||||
filter[dateToKey] = `lte.${searchParams.dateTo}`;
|
||||
// 如果有开始日期,使用and条件;否则直接设置结束日期
|
||||
const dateToKey = searchParams.dateFrom ? 'and' : 'created_at';
|
||||
const newDateFrom = dayjs(`${searchParams.dateFrom} 00:00:00`).format();
|
||||
const newDateTo = dayjs(`${searchParams.dateTo} 23:59:59`).format();
|
||||
// 添加当天结束时间 23:59:59
|
||||
if (dateToKey === 'and') {
|
||||
delete filter['created_at'];
|
||||
// 使用OR操作符连接两个条件
|
||||
filter[dateToKey] = `(created_at.gte.'${newDateFrom}',created_at.lte.'${newDateTo}')`;
|
||||
} else {
|
||||
filter['created_at'] = `lte.'${newDateTo}'`;
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('filter-----', filter);
|
||||
params.filter = filter;
|
||||
|
||||
// 发送请求
|
||||
@@ -200,7 +230,7 @@ export async function getDocuments(searchParams: DocumentSearchParams = {}): Pro
|
||||
|
||||
// 转换为UI格式
|
||||
const documents = await Promise.all(extractedData.map(convertToUIDocument));
|
||||
|
||||
// console.log('documentsItem',documents)
|
||||
// 获取总数
|
||||
let totalCount = 0;
|
||||
const responseWithHeaders = response as {
|
||||
@@ -332,13 +362,6 @@ export async function getFileDownloadUrl(filePath: string): Promise<{
|
||||
return { error: '文件路径不能为空', status: 400 };
|
||||
}
|
||||
|
||||
// 构建API请求参数
|
||||
const params: PostgrestParams = {
|
||||
filter: {
|
||||
'path': `eq.${filePath}`
|
||||
}
|
||||
};
|
||||
|
||||
// 这里应该调用获取文件下载链接的API
|
||||
// 假设后端有这样的端点:/api/files/generate-download-url?path=xxx
|
||||
// 实际项目中需要根据你的后端API调整
|
||||
@@ -387,8 +410,8 @@ export async function updateDocument(id: string, document: Partial<DocumentUI> &
|
||||
apiDocument.type_id = parseInt(document.type);
|
||||
}
|
||||
|
||||
if (document.status !== undefined) {
|
||||
apiDocument.status = document.status as 'pass' | 'warning' | 'waiting' | 'processing' | 'fail';
|
||||
if (document.auditStatus !== undefined) {
|
||||
apiDocument.audit_status = document.auditStatus;
|
||||
}
|
||||
|
||||
if (document.isTest !== undefined) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { postgrestGet, postgrestPut, postgrestPost, type PostgrestParams } from '../postgrest-client';
|
||||
import dayjs from 'dayjs';
|
||||
// import { API_BASE_URL } from '../client';
|
||||
|
||||
/**
|
||||
* 格式化日期
|
||||
@@ -39,10 +40,12 @@ function extractApiData<T>(responseData: unknown): T | null {
|
||||
|
||||
// 文档状态枚举
|
||||
export enum DocumentStatus {
|
||||
WAITING = "Waiting",
|
||||
CUTTING = "Cutting",
|
||||
EXTRACTIONING = "extractioning",
|
||||
REVIEWING = "reviewing",
|
||||
COMPLETED = "completed"
|
||||
EXTRACTIONING = "Extractioning",
|
||||
EVALUATIONING = "Evaluationing",
|
||||
FAILED = "Failed",
|
||||
PROCESSED = "Processed"
|
||||
}
|
||||
|
||||
// 文档类型接口
|
||||
@@ -80,6 +83,132 @@ export interface Document {
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
// 文件上传响应接口
|
||||
export interface FileUploadResponse {
|
||||
success: boolean;
|
||||
result?: {
|
||||
id: number;
|
||||
file_name: string;
|
||||
file_size: number;
|
||||
file_url: string;
|
||||
type_id: number;
|
||||
type_description: string;
|
||||
document_number: string | null;
|
||||
storage_type: string;
|
||||
is_test_document: boolean;
|
||||
remark: string | null;
|
||||
background_processing: boolean;
|
||||
evaluation_level: string;
|
||||
};
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将文件转换为二进制数据
|
||||
*/
|
||||
export async function uploadFileToBinary(file: File): Promise<ArrayBuffer> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
if (reader.result instanceof ArrayBuffer) {
|
||||
resolve(reader.result);
|
||||
} else {
|
||||
reject(new Error('文件读取失败'));
|
||||
}
|
||||
};
|
||||
reader.onerror = () => reject(new Error('文件读取失败'));
|
||||
reader.readAsArrayBuffer(file);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件到文档审核系统
|
||||
* @param binaryData 文件的二进制数据
|
||||
* @param fileName 文件名
|
||||
* @param fileType 文件类型
|
||||
* @param typeId 文档类型ID
|
||||
* @param priority 优先级
|
||||
* @param documentNumber 文档编号(可选)
|
||||
* @param remark 备注信息(可选)
|
||||
* @param isTestDocument 是否为测试文档
|
||||
* @returns 上传结果
|
||||
*/
|
||||
export async function uploadDocumentToServer(
|
||||
binaryData: ArrayBuffer,
|
||||
fileName: string,
|
||||
fileType: string,
|
||||
typeId: string | number,
|
||||
priority: string,
|
||||
documentNumber?: string | null,
|
||||
remark?: string | null,
|
||||
isTestDocument: boolean = false
|
||||
): Promise<{data: FileUploadResponse; error?: never} | {data?: never; error: string; status?: number}> {
|
||||
try {
|
||||
// 创建FormData对象
|
||||
const formData = new FormData();
|
||||
|
||||
// 将二进制数据转换为Blob并添加到FormData
|
||||
const blob = new Blob([binaryData], { type: fileType });
|
||||
formData.append('file', blob, fileName);
|
||||
|
||||
// 将信息添加到一个JSON对象中
|
||||
const uploadInfo = {
|
||||
type_id: Number(typeId),
|
||||
evaluation_level: priority,
|
||||
document_number: documentNumber || null,
|
||||
remark: remark || null,
|
||||
is_test_document: isTestDocument
|
||||
};
|
||||
|
||||
// 添加JSON字符串到FormData
|
||||
formData.append('upload_info', JSON.stringify(uploadInfo));
|
||||
|
||||
console.log('上传信息:', {
|
||||
fileName,
|
||||
fileType,
|
||||
typeId: Number(typeId),
|
||||
priority,
|
||||
documentNumber: documentNumber || null,
|
||||
remark: remark || null,
|
||||
isTestDocument
|
||||
});
|
||||
|
||||
// 发送请求
|
||||
// const response = await fetch(`${API_BASE_URL}/admin/documents/upload`, {
|
||||
const response = await fetch('http://172.16.0.55:8000/admin/documents/upload', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-File-Name': encodeURIComponent(fileName)
|
||||
},
|
||||
body: formData
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
console.error(`上传失败 (${response.status}): ${errorText}`);
|
||||
return {
|
||||
error: `上传失败: ${response.status} ${response.statusText}`,
|
||||
status: response.status
|
||||
};
|
||||
}
|
||||
|
||||
const responseData = await response.json();
|
||||
const extractedData = extractApiData<FileUploadResponse>(responseData);
|
||||
|
||||
if (!extractedData) {
|
||||
return { error: '处理上传响应失败', status: 500 };
|
||||
}
|
||||
|
||||
return { data: extractedData };
|
||||
} catch (error) {
|
||||
console.error('上传错误:', error);
|
||||
return {
|
||||
error: error instanceof Error ? error.message : '上传失败',
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当天的文档列表
|
||||
* @returns 文档列表
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
import { apiRequest, buildUrl, type PaginatedResponse } from './base';
|
||||
import type { File, DocumentType } from '~/models/file';
|
||||
|
||||
/**
|
||||
* 文件API服务
|
||||
*/
|
||||
|
||||
interface FileFilterParams {
|
||||
documentTypeId?: string;
|
||||
status?: string;
|
||||
reviewStatus?: string;
|
||||
keyword?: string;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
}
|
||||
|
||||
// 获取文件列表
|
||||
export async function getFiles(params?: FileFilterParams): Promise<PaginatedResponse<File>> {
|
||||
const url = buildUrl('/api/files', params);
|
||||
return apiRequest<PaginatedResponse<File>>(url);
|
||||
}
|
||||
|
||||
// 获取单个文件
|
||||
export async function getFile(id: string): Promise<File> {
|
||||
const url = buildUrl(`/api/files/${id}`);
|
||||
return apiRequest<File>(url);
|
||||
}
|
||||
|
||||
// 上传文件
|
||||
export async function uploadFile(formData: FormData): Promise<File> {
|
||||
const url = buildUrl('/api/files/upload');
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
throw new Error(error.message || '文件上传失败');
|
||||
}
|
||||
|
||||
return response.json().then(data => data.data);
|
||||
}
|
||||
|
||||
// 删除文件
|
||||
export async function deleteFile(id: string): Promise<void> {
|
||||
const url = buildUrl(`/api/files/${id}`);
|
||||
return apiRequest<void>(url, 'DELETE');
|
||||
}
|
||||
|
||||
// 获取文档类型列表
|
||||
export async function getDocumentTypes(): Promise<DocumentType[]> {
|
||||
const url = buildUrl('/api/document-types');
|
||||
return apiRequest<DocumentType[]>(url);
|
||||
}
|
||||
|
||||
// 获取单个文档类型
|
||||
export async function getDocumentType(id: string): Promise<DocumentType> {
|
||||
const url = buildUrl(`/api/document-types/${id}`);
|
||||
return apiRequest<DocumentType>(url);
|
||||
}
|
||||
|
||||
// 创建文档类型
|
||||
// 请使用 ~/api/document-types/document-types.ts 中的实现
|
||||
/*
|
||||
export async function createDocumentType(documentType: Omit<DocumentType, 'id' | 'createdAt' | 'updatedAt'>): Promise<DocumentType> {
|
||||
const url = buildUrl('/api/document-types');
|
||||
return apiRequest<DocumentType>(url, 'POST', documentType);
|
||||
}
|
||||
*/
|
||||
|
||||
// 更新文档类型
|
||||
// 请使用 ~/api/document-types/document-types.ts 中的实现
|
||||
/*
|
||||
export async function updateDocumentType(id: string, documentType: Partial<Omit<DocumentType, 'id' | 'createdAt' | 'updatedAt'>>): Promise<DocumentType> {
|
||||
const url = buildUrl(`/api/document-types/${id}`);
|
||||
return apiRequest<DocumentType>(url, 'PUT', documentType);
|
||||
}
|
||||
*/
|
||||
|
||||
// 删除文档类型
|
||||
export async function deleteDocumentType(id: string): Promise<void> {
|
||||
const url = buildUrl(`/api/document-types/${id}`);
|
||||
return apiRequest<void>(url, 'DELETE');
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
import { apiRequest, buildUrl, type PaginatedResponse } from './base';
|
||||
import type { Rule, RuleGroup } from '~/models/rule';
|
||||
|
||||
/**
|
||||
* 评查规则API服务
|
||||
*/
|
||||
|
||||
interface RuleFilterParams {
|
||||
ruleType?: string;
|
||||
groupId?: string;
|
||||
isActive?: boolean;
|
||||
keyword?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
}
|
||||
|
||||
// 获取评查点列表
|
||||
export async function getRules(params?: RuleFilterParams): Promise<PaginatedResponse<Rule>> {
|
||||
const url = buildUrl('/api/rules', params);
|
||||
return apiRequest<PaginatedResponse<Rule>>(url);
|
||||
}
|
||||
|
||||
// 获取单个评查点
|
||||
export async function getRule(id: string): Promise<Rule> {
|
||||
const url = buildUrl(`/api/rules/${id}`);
|
||||
return apiRequest<Rule>(url);
|
||||
}
|
||||
|
||||
// 创建评查点
|
||||
export async function createRule(rule: Omit<Rule, 'id' | 'createdAt' | 'updatedAt'>): Promise<Rule> {
|
||||
const url = buildUrl('/api/rules');
|
||||
return apiRequest<Rule>(url, 'POST', rule);
|
||||
}
|
||||
|
||||
// 更新评查点
|
||||
export async function updateRule(id: string, rule: Partial<Omit<Rule, 'id' | 'createdAt' | 'updatedAt'>>): Promise<Rule> {
|
||||
const url = buildUrl(`/api/rules/${id}`);
|
||||
return apiRequest<Rule>(url, 'PUT', rule);
|
||||
}
|
||||
|
||||
// 删除评查点
|
||||
export async function deleteRule(id: string): Promise<void> {
|
||||
const url = buildUrl(`/api/rules/${id}`);
|
||||
return apiRequest<void>(url, 'DELETE');
|
||||
}
|
||||
|
||||
// 获取评查点分组列表
|
||||
export async function getRuleGroups(): Promise<RuleGroup[]> {
|
||||
const url = buildUrl('/api/rule-groups');
|
||||
return apiRequest<RuleGroup[]>(url);
|
||||
}
|
||||
|
||||
// 获取单个评查点分组
|
||||
export async function getRuleGroup(id: string): Promise<RuleGroup> {
|
||||
const url = buildUrl(`/api/rule-groups/${id}`);
|
||||
return apiRequest<RuleGroup>(url);
|
||||
}
|
||||
|
||||
// 创建评查点分组
|
||||
export async function createRuleGroup(group: Omit<RuleGroup, 'id' | 'createdAt' | 'updatedAt'>): Promise<RuleGroup> {
|
||||
const url = buildUrl('/api/rule-groups');
|
||||
return apiRequest<RuleGroup>(url, 'POST', group);
|
||||
}
|
||||
|
||||
// 更新评查点分组
|
||||
export async function updateRuleGroup(id: string, group: Partial<Omit<RuleGroup, 'id' | 'createdAt' | 'updatedAt'>>): Promise<RuleGroup> {
|
||||
const url = buildUrl(`/api/rule-groups/${id}`);
|
||||
return apiRequest<RuleGroup>(url, 'PUT', group);
|
||||
}
|
||||
|
||||
// 删除评查点分组
|
||||
export async function deleteRuleGroup(id: string): Promise<void> {
|
||||
const url = buildUrl(`/api/rule-groups/${id}`);
|
||||
return apiRequest<void>(url, 'DELETE');
|
||||
}
|
||||
@@ -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>
|
||||
))}
|
||||
|
||||
+171
-76
@@ -5,12 +5,11 @@ import { Card } from "~/components/ui/Card";
|
||||
import { Button } from "~/components/ui/Button";
|
||||
import { Table } from "~/components/ui/Table";
|
||||
import { Pagination } from "~/components/ui/Pagination";
|
||||
import { StatusBadge } from "~/components/ui/StatusBadge";
|
||||
import { FileTypeTag } from "~/components/ui/FileTypeTag";
|
||||
import { FileTag } from "~/components/ui/FileTag";
|
||||
import { FilterPanel, FilterSelect, SearchFilter, DateRangeFilter } from "~/components/ui/FilterPanel";
|
||||
import documentsIndexStyles from "~/styles/pages/documents_index.css?url";
|
||||
import { getDocuments, deleteDocument, type DocumentUI, getFileDownloadUrl } from "~/api/files/documents";
|
||||
import { getDocuments, deleteDocument, type DocumentUI } from "~/api/files/documents";
|
||||
import { getDocumentTypes } from "~/api/document-types/document-types";
|
||||
|
||||
// 导入样式
|
||||
@@ -34,8 +33,9 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
||||
const url = new URL(request.url);
|
||||
const search = url.searchParams.get("search") || "";
|
||||
const documentType = url.searchParams.get("documentType") || "";
|
||||
const status = url.searchParams.get("status") || "";
|
||||
const auditStatus = url.searchParams.get("auditStatus") || "";
|
||||
const documentNumber = url.searchParams.get("documentNumber") || "";
|
||||
const fileStatus = url.searchParams.get("fileStatus") || "";
|
||||
const dateFrom = url.searchParams.get("dateFrom") || "";
|
||||
const dateTo = url.searchParams.get("dateTo") || "";
|
||||
const page = parseInt(url.searchParams.get("page") || "1", 10);
|
||||
@@ -46,7 +46,8 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
||||
name: search || undefined,
|
||||
documentNumber: documentNumber || undefined,
|
||||
documentType: documentType || undefined,
|
||||
status: status || undefined,
|
||||
auditStatus: auditStatus || undefined,
|
||||
fileStatus: fileStatus || undefined,
|
||||
dateFrom: dateFrom || undefined,
|
||||
dateTo: dateTo || undefined,
|
||||
page,
|
||||
@@ -59,8 +60,9 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
||||
throw new Error(documentsResponse.error);
|
||||
}
|
||||
|
||||
// 获取文档类型列表,用于筛选条件
|
||||
const typesResponse = await getDocumentTypes();
|
||||
// 获取文档类型列表,用于筛选条件,设置较大的pageSize确保获取所有数据
|
||||
const typesResponse = await getDocumentTypes({ pageSize: 500 });
|
||||
// console.log('typesResponse-----',typesResponse);
|
||||
const documentTypes = typesResponse.data?.types || [];
|
||||
const documentTypeOptions = documentTypes.map(type => ({
|
||||
value: type.id,
|
||||
@@ -113,15 +115,44 @@ export const action = async ({ request }: ActionFunctionArgs) => {
|
||||
return Response.json({ success: false, message: "未知操作" }, { status: 400 });
|
||||
};
|
||||
|
||||
// 文档状态选项
|
||||
const documentStatusOptions = [
|
||||
{ value: "waiting", label: "待审核" },
|
||||
{ value: "processing", label: "审核中" },
|
||||
{ value: "pass", label: "通过" },
|
||||
{ value: "warning", label: "警告" },
|
||||
{ value: "fail", label: "不通过" },
|
||||
// 审核状态筛选选项
|
||||
const auditStatusOptions = [
|
||||
// { value: "", label: "全部" },
|
||||
{ value: "-1", label: "不通过" },
|
||||
{ value: "0", label: "待审核" },
|
||||
{ value: "1", label: "通过" },
|
||||
{ value: "2", label: "警告" },
|
||||
{ value: "3", label: "审核中" },
|
||||
];
|
||||
|
||||
// 文件处理状态选项
|
||||
const fileProcessingStatusOptions = [
|
||||
{ value: "Waiting", label: "上传中", icon: "ri-loader-line", color: "blue" },
|
||||
{ value: "Cutting", label: "切分中", icon: "ri-loader-line", color: "purple" },
|
||||
{ value: "Extractioning", label: "抽取中", icon: "ri-loader-line", color: "cyan" },
|
||||
{ value: "Evaluationing", label: "评查中", icon: "ri-loader-line", color: "teal" },
|
||||
{ value: "Processed", label: "已完成", icon: "ri-check-line", color: "green" },
|
||||
];
|
||||
|
||||
// 文件状态筛选选项
|
||||
const fileStatusOptions = [
|
||||
// { value: "", label: "全部" },
|
||||
{ value: "Waiting", label: "上传中" },
|
||||
{ value: "Cutting", label: "切分中" },
|
||||
{ value: "Extractioning", label: "抽取中" },
|
||||
{ value: "Evaluationing", label: "评查中" },
|
||||
{ value: "Processed", label: "已完成" },
|
||||
];
|
||||
|
||||
// 审核状态选项及样式
|
||||
const auditStatusMapping: Record<string, { label: string; color: string; icon: string }> = {
|
||||
"-1": { label: "不通过", color: "red", icon: "ri-close-line" },
|
||||
"0": { label: "待审核", color: "blue", icon: "ri-time-line" },
|
||||
"1": { label: "通过", color: "green", icon: "ri-check-line" },
|
||||
"2": { label: "警告", color: "yellow", icon: "ri-alert-line" },
|
||||
"3": { label: "审核中", color: "purple", icon: "ri-search-line" },
|
||||
};
|
||||
|
||||
// 格式化文件大小
|
||||
const formatFileSize = (bytes: number) => {
|
||||
if (bytes === 0) return "0 Bytes";
|
||||
@@ -154,8 +185,9 @@ export default function DocumentsIndex() {
|
||||
// 从URL获取当前筛选条件
|
||||
const search = searchParams.get("search") || "";
|
||||
const documentType = searchParams.get("documentType") || "";
|
||||
const status = searchParams.get("status") || "";
|
||||
const auditStatus = searchParams.get("auditStatus") || "";
|
||||
const documentNumber = searchParams.get("documentNumber") || "";
|
||||
const fileStatus = searchParams.get("fileStatus") || "";
|
||||
const dateFrom = searchParams.get("dateFrom") || "";
|
||||
const dateTo = searchParams.get("dateTo") || "";
|
||||
const currentPage = parseInt(searchParams.get("page") || "1", 10);
|
||||
@@ -217,9 +249,9 @@ export default function DocumentsIndex() {
|
||||
const handleStatusChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
const params = new URLSearchParams(searchParams);
|
||||
if (e.target.value) {
|
||||
params.set("status", e.target.value);
|
||||
params.set("auditStatus", e.target.value);
|
||||
} else {
|
||||
params.delete("status");
|
||||
params.delete("auditStatus");
|
||||
}
|
||||
params.set("page", "1"); // 重置页码
|
||||
setSearchParams(params);
|
||||
@@ -315,7 +347,11 @@ export default function DocumentsIndex() {
|
||||
};
|
||||
|
||||
// 删除文档
|
||||
const handleDelete = (id: string, name: string) => {
|
||||
const handleDelete = (id: string, name: string, fileStatus: string) => {
|
||||
if (fileStatus !== 'Processed') {
|
||||
alert('文档正在处理中,不能删除');
|
||||
return;
|
||||
}
|
||||
if (window.confirm(`确认删除文档 "${name}"?`)) {
|
||||
// 使用fetcher提交表单
|
||||
const formData = new FormData();
|
||||
@@ -336,6 +372,16 @@ export default function DocumentsIndex() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否有正在处理中的文件
|
||||
const hasProcessingFiles = documents.some((doc: DocumentUI) =>
|
||||
selectedRowKeys.includes(doc.id.toString()) && doc.fileStatus !== 'Processed'
|
||||
);
|
||||
|
||||
if (hasProcessingFiles) {
|
||||
alert('存在服务器未处理完成的文件,请重新选择需要删除的文件');
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.confirm(`确认删除选中的 ${selectedRowKeys.length} 个文档?`)) {
|
||||
// 使用fetcher提交表单
|
||||
const formData = new FormData();
|
||||
@@ -353,6 +399,18 @@ export default function DocumentsIndex() {
|
||||
}
|
||||
};
|
||||
|
||||
// 处理文件状态变更
|
||||
const handleFileStatusChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
const params = new URLSearchParams(searchParams);
|
||||
if (e.target.value) {
|
||||
params.set("fileStatus", e.target.value);
|
||||
} else {
|
||||
params.delete("fileStatus");
|
||||
}
|
||||
params.set("page", "1"); // 重置页码
|
||||
setSearchParams(params);
|
||||
};
|
||||
|
||||
// 表格列定义
|
||||
const columns = [
|
||||
{
|
||||
@@ -376,6 +434,7 @@ export default function DocumentsIndex() {
|
||||
{
|
||||
title: "文档名称",
|
||||
key: "name",
|
||||
width:'25%',
|
||||
render: (_: unknown, record: DocumentUI) => (
|
||||
<div className="flex items-center m-1">
|
||||
<FileTag
|
||||
@@ -384,10 +443,10 @@ export default function DocumentsIndex() {
|
||||
showText={false}
|
||||
showBackground={false}
|
||||
size="lg"
|
||||
className="mr-2"
|
||||
className="mr-2 flex-shrink-0"
|
||||
/>
|
||||
<div>
|
||||
<span className="file-name" title={record.name}>{record.name}</span>
|
||||
<div className="overflow-hidden">
|
||||
<span className="file-name break-words block" title={record.name}>{record.name}</span>
|
||||
<div className="mt-2 flex inline-block">
|
||||
<FileTypeTag
|
||||
type={record.type}
|
||||
@@ -407,6 +466,7 @@ export default function DocumentsIndex() {
|
||||
{
|
||||
title: "文档编号",
|
||||
key: "documentNumber",
|
||||
width:'10%',
|
||||
render: (_: unknown, record: DocumentUI) => (
|
||||
<span className="document-number">{record.documentNumber}</span>
|
||||
)
|
||||
@@ -414,20 +474,49 @@ export default function DocumentsIndex() {
|
||||
{
|
||||
title: "文件大小",
|
||||
key: "size",
|
||||
width: "100px",
|
||||
width: "10%",
|
||||
render: (_: unknown, record: DocumentUI) => formatFileSize(record.size)
|
||||
},
|
||||
{
|
||||
title: "文件状态",
|
||||
key: "fileStatus",
|
||||
width:'10%',
|
||||
render: (_: unknown, record: DocumentUI) => {
|
||||
// 处理fileStatus为null或undefined的情况
|
||||
// console.log('fileStatus',record.fileStatus)
|
||||
const fileStatus = record.fileStatus || "Processed";
|
||||
const status = fileProcessingStatusOptions.find(s => s.value === fileStatus) ||
|
||||
fileProcessingStatusOptions[0];
|
||||
const isSpinning = fileStatus !== "Processed";
|
||||
return (
|
||||
<div className={`inline-flex items-center px-2 py-1 rounded-full text-xs bg-${status.color}-100 text-${status.color}-800`}>
|
||||
<i className={`${status.icon} ${isSpinning ? "animate-spin" : ""} mr-1`}></i>
|
||||
<span>{status.label}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "审核状态",
|
||||
key: "status",
|
||||
render: (_: unknown, record: DocumentUI) => (
|
||||
<StatusBadge status={record.status} showIcon={false} />
|
||||
)
|
||||
key: "auditStatus",
|
||||
width:"10%",
|
||||
render: (_: unknown, record: DocumentUI) => {
|
||||
// 处理auditStatus为null或undefined的情况,默认为0(待审核)
|
||||
const auditStatus = record.auditStatus != null ? record.auditStatus : 0;
|
||||
const statusKey = auditStatus.toString();
|
||||
const statusInfo = auditStatusMapping[statusKey] || auditStatusMapping["0"];
|
||||
return (
|
||||
<div className={`inline-flex items-center px-2 py-1 rounded-full text-xs bg-${statusInfo.color}-100 text-${statusInfo.color}-800`}>
|
||||
<i className={`${statusInfo.icon} mr-1`}></i>
|
||||
<span>{statusInfo.label}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "问题数量",
|
||||
key: "issues",
|
||||
width:"60px",
|
||||
width:"5%",
|
||||
render: (_: unknown, record: DocumentUI) => (
|
||||
record.issues === null ? "-" : record.issues
|
||||
)
|
||||
@@ -435,23 +524,24 @@ export default function DocumentsIndex() {
|
||||
{
|
||||
title: "上传时间",
|
||||
key: "uploadTime",
|
||||
width:"10%",
|
||||
render: (_: unknown, record: DocumentUI) => record.uploadTime
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
key: "actions",
|
||||
width: "280px",
|
||||
width: "20%",
|
||||
render: (_: unknown, record: DocumentUI) => (
|
||||
<div className="operations-cell">
|
||||
{record.status === "waiting" ? (
|
||||
{(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>
|
||||
开始审核
|
||||
</Link>
|
||||
) : record.status === "processing" ? (
|
||||
) : record.auditStatus === 3 ? (
|
||||
<Link
|
||||
to={`/documents/${record.id}/progress`}
|
||||
className="mr-1 hover:underline"
|
||||
@@ -486,7 +576,7 @@ export default function DocumentsIndex() {
|
||||
<button
|
||||
type="button"
|
||||
className="text-error hover:underline hover:text-red-700"
|
||||
onClick={() => handleDelete(record.id.toString(), record.name)}
|
||||
onClick={() => handleDelete(record.id.toString(), record.name, record.fileStatus)}
|
||||
>
|
||||
<i className="ri-delete-bin-line"></i>
|
||||
删除
|
||||
@@ -505,7 +595,7 @@ export default function DocumentsIndex() {
|
||||
<Button
|
||||
type="primary"
|
||||
icon="ri-upload-line"
|
||||
to="/documents/upload"
|
||||
to="/files/upload"
|
||||
className="hover:text-white"
|
||||
>
|
||||
上传文档
|
||||
@@ -539,51 +629,56 @@ export default function DocumentsIndex() {
|
||||
}
|
||||
noActionDivider={true}
|
||||
>
|
||||
<SearchFilter
|
||||
label="文档名称"
|
||||
placeholder="请输入文档名称"
|
||||
value={search}
|
||||
onSearch={handleNameSearch}
|
||||
instantSearch={true}
|
||||
className="mr-2 w-50"
|
||||
/>
|
||||
<div className="grid grid-cols-2 md:grid-cols-3 gap-4 w-full">
|
||||
<SearchFilter
|
||||
label="文档名称"
|
||||
placeholder="请输入文档名称"
|
||||
value={search}
|
||||
onSearch={handleNameSearch}
|
||||
instantSearch={true}
|
||||
/>
|
||||
|
||||
<SearchFilter
|
||||
label="文档编号"
|
||||
placeholder="请输入文档编号"
|
||||
value={documentNumber}
|
||||
onSearch={handleDocumentNumberChange}
|
||||
instantSearch={true}
|
||||
className="mr-2 w-50"
|
||||
/>
|
||||
|
||||
<FilterSelect
|
||||
label="文档类型"
|
||||
name="documentType"
|
||||
value={documentType}
|
||||
options={documentTypeOptions}
|
||||
onChange={handleDocumentTypeChange}
|
||||
className="mr-2 w-30"
|
||||
/>
|
||||
|
||||
<FilterSelect
|
||||
label="审核状态"
|
||||
name="status"
|
||||
value={status}
|
||||
options={documentStatusOptions}
|
||||
onChange={handleStatusChange}
|
||||
className="mr-2 w-50"
|
||||
/>
|
||||
|
||||
<DateRangeFilter
|
||||
label="上传时间"
|
||||
startDate={dateFrom}
|
||||
endDate={dateTo}
|
||||
onStartDateChange={(value) => handleDateChange('dateFrom', value)}
|
||||
onEndDateChange={(value) => handleDateChange('dateTo', value)}
|
||||
className="flex-1"
|
||||
simple={true}
|
||||
/>
|
||||
<SearchFilter
|
||||
label="文档编号"
|
||||
placeholder="请输入文档编号"
|
||||
value={documentNumber}
|
||||
onSearch={handleDocumentNumberChange}
|
||||
instantSearch={true}
|
||||
/>
|
||||
|
||||
<FilterSelect
|
||||
label="文档类型"
|
||||
name="documentType"
|
||||
value={documentType}
|
||||
options={documentTypeOptions}
|
||||
onChange={handleDocumentTypeChange}
|
||||
/>
|
||||
|
||||
<FilterSelect
|
||||
label="文件状态"
|
||||
name="fileStatus"
|
||||
value={fileStatus}
|
||||
options={fileStatusOptions}
|
||||
onChange={handleFileStatusChange}
|
||||
/>
|
||||
|
||||
<FilterSelect
|
||||
label="审核状态"
|
||||
name="auditStatus"
|
||||
value={auditStatus}
|
||||
options={auditStatusOptions}
|
||||
onChange={handleStatusChange}
|
||||
/>
|
||||
|
||||
<DateRangeFilter
|
||||
label="上传时间"
|
||||
startDate={dateFrom}
|
||||
endDate={dateTo}
|
||||
onStartDateChange={(value) => handleDateChange('dateFrom', value)}
|
||||
onEndDateChange={(value) => handleDateChange('dateTo', value)}
|
||||
simple={true}
|
||||
/>
|
||||
</div>
|
||||
</FilterPanel>
|
||||
|
||||
|
||||
|
||||
@@ -19,22 +19,31 @@ export const meta: MetaFunction = () => {
|
||||
];
|
||||
};
|
||||
|
||||
// 文档状态定义
|
||||
enum DocumentStatus {
|
||||
WAITING = "waiting",
|
||||
PROCESSING = "processing",
|
||||
PASS = "pass",
|
||||
WARNING = "warning",
|
||||
FAIL = "fail"
|
||||
// 文档审核状态定义
|
||||
enum DocumentAuditStatus {
|
||||
FAIL = -1,
|
||||
WAITING = 0,
|
||||
PASS = 1,
|
||||
WARNING = 2,
|
||||
PROCESSING = 3
|
||||
}
|
||||
|
||||
// 文档状态对应的中文标签
|
||||
const STATUS_LABELS: Record<DocumentStatus, string> = {
|
||||
[DocumentStatus.WAITING]: "待审核",
|
||||
[DocumentStatus.PROCESSING]: "审核中",
|
||||
[DocumentStatus.PASS]: "通过",
|
||||
[DocumentStatus.WARNING]: "警告",
|
||||
[DocumentStatus.FAIL]: "不通过"
|
||||
const STATUS_LABELS: Record<DocumentAuditStatus, string> = {
|
||||
[DocumentAuditStatus.FAIL]: "不通过",
|
||||
[DocumentAuditStatus.WAITING]: "待审核",
|
||||
[DocumentAuditStatus.PASS]: "通过",
|
||||
[DocumentAuditStatus.WARNING]: "警告",
|
||||
[DocumentAuditStatus.PROCESSING]: "审核中"
|
||||
};
|
||||
|
||||
// 文档状态样式配置
|
||||
const STATUS_STYLES: Record<number, { color: string; icon: string }> = {
|
||||
[-1]: { color: "red", icon: "ri-close-line" },
|
||||
[0]: { color: "blue", icon: "ri-time-line" },
|
||||
[1]: { color: "green", icon: "ri-check-line" },
|
||||
[2]: { color: "yellow", icon: "ri-alert-line" },
|
||||
[3]: { color: "purple", icon: "ri-search-line" }
|
||||
};
|
||||
|
||||
// 格式化文件大小
|
||||
@@ -62,7 +71,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
// 并行获取文档详情和文档类型列表
|
||||
const [documentResponse, documentTypesResponse] = await Promise.all([
|
||||
getDocument(id),
|
||||
getDocumentTypes()
|
||||
getDocumentTypes({ pageSize: 500 })
|
||||
]);
|
||||
|
||||
if (documentResponse.error) {
|
||||
@@ -99,31 +108,31 @@ export async function action({ request }: ActionFunctionArgs) {
|
||||
// 从表单数据中提取字段
|
||||
const type = formData.get("type_id") as string;
|
||||
const documentNumber = formData.get("document_number") as string;
|
||||
const status = formData.get("status") as DocumentStatus;
|
||||
const auditStatus = parseInt(formData.get("audit_status") as string);
|
||||
const isTest = formData.get("is_test_document") === "on";
|
||||
const remark = formData.get("remark") as string;
|
||||
|
||||
// 验证必填字段
|
||||
if (!type || !status) {
|
||||
if (!type || auditStatus === undefined || isNaN(auditStatus)) {
|
||||
return Response.json(
|
||||
{
|
||||
error: "缺少必填字段",
|
||||
fieldErrors: {
|
||||
type_id: !type ? "文档类型不能为空" : null,
|
||||
status: !status ? "状态不能为空" : null
|
||||
audit_status: (auditStatus === undefined || isNaN(auditStatus)) ? "审核状态不能为空" : null
|
||||
}
|
||||
},
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
console.log('提交更新:', { type, documentNumber, status, isTest, remark });
|
||||
console.log('提交更新:', { type, documentNumber, auditStatus, isTest, remark });
|
||||
|
||||
// 更新文档
|
||||
const updateResponse = await updateDocument(id, {
|
||||
type,
|
||||
documentNumber,
|
||||
status,
|
||||
auditStatus,
|
||||
isTest,
|
||||
remark
|
||||
});
|
||||
@@ -160,43 +169,40 @@ export default function DocumentEdit() {
|
||||
}
|
||||
|
||||
// 状态
|
||||
const [localStatus, setLocalStatus] = useState<DocumentStatus>(document.status as DocumentStatus);
|
||||
const [localStatus, setLocalStatus] = useState<number>(document.auditStatus);
|
||||
|
||||
// 处理状态变更
|
||||
const handleStatusChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
setLocalStatus(e.target.value as DocumentStatus);
|
||||
setLocalStatus(parseInt(e.target.value));
|
||||
};
|
||||
|
||||
// 获取文档类型名称
|
||||
const getDocumentTypeName = (typeId: string): string => {
|
||||
const docType = documentTypes.find((type) => (type as any).id.toString() === typeId);
|
||||
return docType ? (docType as any).name : "未知类型";
|
||||
const docType = documentTypes.find((type: DocType) => type.id.toString() === typeId);
|
||||
return docType ? docType.name : "未知类型";
|
||||
};
|
||||
|
||||
// 渲染状态徽章
|
||||
const renderStatusBadge = (status: string) => {
|
||||
const statusClasses: Record<string, string> = {
|
||||
"waiting": "status-badge status-pending",
|
||||
"processing": "status-badge status-processing",
|
||||
"pass": "status-badge status-pass",
|
||||
"warning": "status-badge status-warning",
|
||||
"fail": "status-badge status-fail"
|
||||
};
|
||||
|
||||
const statusLabel: Record<string, string> = {
|
||||
"waiting": "待审核",
|
||||
"processing": "审核中",
|
||||
"pass": "通过",
|
||||
"warning": "警告",
|
||||
"fail": "不通过"
|
||||
};
|
||||
const renderStatusBadge = (status: number) => {
|
||||
const style = STATUS_STYLES[status] || STATUS_STYLES[0];
|
||||
const label = STATUS_LABELS[status as DocumentAuditStatus] || STATUS_LABELS[DocumentAuditStatus.WAITING];
|
||||
|
||||
return (
|
||||
<span className={statusClasses[status] || "status-badge"}>
|
||||
{statusLabel[status] || status}
|
||||
<span className={`status-badge bg-${style.color}-100 text-${style.color}-800`}>
|
||||
<i className={`${style.icon} mr-1`}></i>
|
||||
{label}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
// 在新窗口打开文档预览
|
||||
const openPreview = () => {
|
||||
// 假设有一个预览URL的格式,比如 /preview?path=xxx
|
||||
console.log('documentstest', document);
|
||||
|
||||
const previewUrl = `/preview?path=${encodeURIComponent(document.path)}&name=${encodeURIComponent(document.name)}`;
|
||||
window.open(previewUrl, '_blank');
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="document-edit-page">
|
||||
@@ -250,7 +256,7 @@ export default function DocumentEdit() {
|
||||
<span>{formatFileSize(document.size)}</span>
|
||||
</div>
|
||||
<div className="meta-item">
|
||||
{renderStatusBadge(document.status)}
|
||||
{renderStatusBadge(document.auditStatus)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -264,14 +270,15 @@ export default function DocumentEdit() {
|
||||
<div className="grid grid-cols-2 gap-6">
|
||||
<div className="form-group">
|
||||
<label htmlFor="type-id" className="form-label">文档类型 <span className="text-red-500">*</span></label>
|
||||
<select
|
||||
<select
|
||||
id="type-id"
|
||||
name="type_id"
|
||||
className="form-select"
|
||||
defaultValue={document.type}
|
||||
disabled={document.fileStatus !== 'Processed'}
|
||||
required
|
||||
>
|
||||
{documentTypes.map(type => (
|
||||
{documentTypes.map((type: DocType) => (
|
||||
<option key={type.id} value={type.id}>{type.name}</option>
|
||||
))}
|
||||
</select>
|
||||
@@ -295,24 +302,24 @@ export default function DocumentEdit() {
|
||||
</div>
|
||||
|
||||
<div className="form-group">
|
||||
<label htmlFor="status" className="form-label">状态 <span className="text-red-500">*</span></label>
|
||||
<label htmlFor="audit-status" className="form-label">审核状态 <span className="text-red-500">*</span></label>
|
||||
<select
|
||||
id="status"
|
||||
name="status"
|
||||
id="audit-status"
|
||||
name="audit_status"
|
||||
className="form-select"
|
||||
value={localStatus}
|
||||
onChange={handleStatusChange}
|
||||
required
|
||||
>
|
||||
<option value={DocumentStatus.WAITING}>{STATUS_LABELS[DocumentStatus.WAITING]}</option>
|
||||
<option value={DocumentStatus.PROCESSING}>{STATUS_LABELS[DocumentStatus.PROCESSING]}</option>
|
||||
<option value={DocumentStatus.PASS}>{STATUS_LABELS[DocumentStatus.PASS]}</option>
|
||||
<option value={DocumentStatus.WARNING}>{STATUS_LABELS[DocumentStatus.WARNING]}</option>
|
||||
<option value={DocumentStatus.FAIL}>{STATUS_LABELS[DocumentStatus.FAIL]}</option>
|
||||
<option value={DocumentAuditStatus.WAITING}>{STATUS_LABELS[DocumentAuditStatus.WAITING]}</option>
|
||||
<option value={DocumentAuditStatus.PROCESSING}>{STATUS_LABELS[DocumentAuditStatus.PROCESSING]}</option>
|
||||
<option value={DocumentAuditStatus.PASS}>{STATUS_LABELS[DocumentAuditStatus.PASS]}</option>
|
||||
<option value={DocumentAuditStatus.WARNING}>{STATUS_LABELS[DocumentAuditStatus.WARNING]}</option>
|
||||
<option value={DocumentAuditStatus.FAIL}>{STATUS_LABELS[DocumentAuditStatus.FAIL]}</option>
|
||||
</select>
|
||||
<div className="text-sm text-secondary mt-1">更改状态可能会影响此文档在列表中的显示和排序</div>
|
||||
{actionData?.fieldErrors?.status && (
|
||||
<div className="text-red-500 text-sm mt-1">{actionData.fieldErrors.status}</div>
|
||||
{actionData?.fieldErrors?.audit_status && (
|
||||
<div className="text-red-500 text-sm mt-1">{actionData.fieldErrors.audit_status}</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -356,7 +363,7 @@ export default function DocumentEdit() {
|
||||
<div className="document-preview">
|
||||
<div className="preview-toolbar">
|
||||
<div className="flex items-center">
|
||||
<i className="ri-file-pdf-line text-red-500 mr-1"></i>
|
||||
<i className={`ri-file-${document.fileType}-line text-${document.fileType === 'pdf' ? 'red' : 'blue'}-500 mr-1`}></i>
|
||||
<span>{document.name}</span>
|
||||
</div>
|
||||
<div>
|
||||
@@ -364,21 +371,31 @@ export default function DocumentEdit() {
|
||||
type="default"
|
||||
size="small"
|
||||
icon="ri-download-line"
|
||||
className="mr-2"
|
||||
>
|
||||
下载
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
size="small"
|
||||
icon="ri-external-link-line"
|
||||
onClick={openPreview}
|
||||
>
|
||||
在新窗口打开
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="preview-content">
|
||||
<div className="preview-placeholder">
|
||||
<i className="ri-file-pdf-line"></i>
|
||||
<i className={`ri-file-${document.fileType}-line`}></i>
|
||||
<p>预览功能暂不可用</p>
|
||||
<p className="text-xs mt-2">PDF文件需要外部查看器支持</p>
|
||||
<p className="text-xs mt-2">点击"在新窗口打开"查看完整文档</p>
|
||||
<Button
|
||||
type="primary"
|
||||
size="small"
|
||||
icon="ri-external-link-line"
|
||||
className="mt-4"
|
||||
onClick={openPreview}
|
||||
>
|
||||
在新窗口打开
|
||||
</Button>
|
||||
@@ -388,7 +405,7 @@ export default function DocumentEdit() {
|
||||
</Card>
|
||||
|
||||
{/* 修改历史 */}
|
||||
<Card title="修改历史">
|
||||
<Card title="修改历史" className="hidden">
|
||||
<div className="history-timeline">
|
||||
{[
|
||||
{
|
||||
|
||||
+148
-62
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect, useRef } from "react";
|
||||
import { MetaFunction, ActionFunctionArgs, json } 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";
|
||||
@@ -8,8 +8,17 @@ import { UploadArea, UploadAreaRef } from "~/components/ui/UploadArea";
|
||||
import { FileProgress} from "~/components/ui/FileProgress";
|
||||
import { ProcessingSteps, Step } from "~/components/ui/ProcessingSteps";
|
||||
import uploadStyles from "~/styles/pages/files_upload.css?url";
|
||||
import { getTodayDocuments, getDocumentTypes, getDocumentsStatus, type Document, type DocumentType, DocumentStatus } from "~/api/files/files-upload";
|
||||
import { uploadFileToBinary, uploadDocumentToServer } from "~/api/files";
|
||||
import {
|
||||
getTodayDocuments,
|
||||
getDocumentTypes,
|
||||
getDocumentsStatus,
|
||||
uploadFileToBinary,
|
||||
uploadDocumentToServer,
|
||||
type Document,
|
||||
type DocumentType,
|
||||
type FileUploadResponse,
|
||||
DocumentStatus
|
||||
} from "~/api/files/files-upload";
|
||||
|
||||
export function links() {
|
||||
return [
|
||||
@@ -17,6 +26,13 @@ export function links() {
|
||||
];
|
||||
}
|
||||
|
||||
// 面包屑导航
|
||||
export const handle = {
|
||||
breadcrumb: () => {
|
||||
return '上传文件'
|
||||
}
|
||||
}
|
||||
|
||||
export const meta: MetaFunction = () => {
|
||||
return [
|
||||
{ title: "待审核文件上传 - 中国烟草AI合同及卷宗审核系统" },
|
||||
@@ -58,21 +74,21 @@ const PRIORITY_TO_CHINESE: Record<Priority, string> = {
|
||||
[Priority.URGENT]: "紧急"
|
||||
};
|
||||
|
||||
// 处理状态定义
|
||||
export enum ProcessingStatus {
|
||||
WAITING = "waiting",
|
||||
PROCESSING = "processing",
|
||||
SUCCESS = "success",
|
||||
ERROR = "error"
|
||||
}
|
||||
|
||||
// 处理步骤状态定义
|
||||
export enum StepStatus {
|
||||
CUTTING = "Cutting",
|
||||
EXTRACTIONING = "extractioning",
|
||||
REVIEWING = "reviewing",
|
||||
COMPLETED = "completed"
|
||||
}
|
||||
|
||||
// 模拟API支持的存储类型
|
||||
const STORAGE_TYPES = [
|
||||
{ id: "minio", name: "MinIO对象存储" },
|
||||
{ id: "local", name: "本地文件系统" },
|
||||
{ id: "s3", name: "Amazon S3" }
|
||||
];
|
||||
|
||||
// 文件上传完成后的操作选项
|
||||
const AFTER_UPLOAD_OPTIONS = [
|
||||
{ id: "list", name: "返回文档列表" },
|
||||
{ id: "stay", name: "留在当前页面" },
|
||||
{ id: "audit", name: "立即开始审核" }
|
||||
];
|
||||
|
||||
// 上传的文件信息接口
|
||||
export interface UploadedFile {
|
||||
@@ -82,7 +98,7 @@ export interface UploadedFile {
|
||||
type: string;
|
||||
fileType: FileType;
|
||||
priority: Priority;
|
||||
status: ProcessingStatus;
|
||||
status: DocumentStatus;
|
||||
uploadTime: string;
|
||||
processingInfo?: {
|
||||
progress: number;
|
||||
@@ -90,26 +106,6 @@ export interface UploadedFile {
|
||||
};
|
||||
}
|
||||
|
||||
// 文件上传响应接口
|
||||
interface FileUploadResponse {
|
||||
success: boolean;
|
||||
result?: {
|
||||
id: number;
|
||||
file_name: string;
|
||||
file_size: number;
|
||||
file_url: string;
|
||||
type_id: number;
|
||||
type_description: string;
|
||||
document_number: string | null;
|
||||
storage_type: string;
|
||||
is_test_document: boolean;
|
||||
remark: string | null;
|
||||
background_processing: boolean;
|
||||
evaluation_level: string;
|
||||
};
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
// 模拟上传文件到服务器的API
|
||||
async function uploadFileToServer(
|
||||
binaryData: ArrayBuffer,
|
||||
@@ -122,7 +118,7 @@ async function uploadFileToServer(
|
||||
isTestDocument: boolean
|
||||
): Promise<FileUploadResponse> {
|
||||
// 在实际应用中,这里会使用fetch或axios发送请求到后端API
|
||||
console.log(`[模拟API] 上传文件: ${fileName}, 大小: ${binaryData.byteLength} 字节`);
|
||||
console.log(`[API] 上传文件: ${fileName}, 大小: ${binaryData.byteLength} 字节`);
|
||||
|
||||
try {
|
||||
// 使用封装的上传函数
|
||||
@@ -137,9 +133,26 @@ async function uploadFileToServer(
|
||||
isTestDocument
|
||||
);
|
||||
|
||||
return response;
|
||||
if (response.error) {
|
||||
console.error('[API] 上传错误:', response.error);
|
||||
return {
|
||||
success: false,
|
||||
error: response.error
|
||||
};
|
||||
}
|
||||
|
||||
// 确保返回有效的FileUploadResponse对象
|
||||
if (response.data) {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
// 如果没有数据,则返回错误
|
||||
return {
|
||||
success: false,
|
||||
error: '上传失败,未获取到响应数据'
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('[模拟API] 上传错误:', error);
|
||||
console.error('[API] 上传错误:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : '上传失败'
|
||||
@@ -183,7 +196,7 @@ export async function action({ request }: ActionFunctionArgs) {
|
||||
|
||||
// 如果有错误,返回错误信息
|
||||
if (Object.keys(errors).length > 0) {
|
||||
return json({ errors });
|
||||
return Response.json({ errors });
|
||||
}
|
||||
|
||||
// 获取文件信息
|
||||
@@ -195,7 +208,7 @@ export async function action({ request }: ActionFunctionArgs) {
|
||||
// 这里的代码仅用于模拟。在前端组件中,我们将实现实际的文件处理逻辑。
|
||||
|
||||
// 模拟文件上传成功响应
|
||||
return json({
|
||||
return Response.json({
|
||||
success: true,
|
||||
message: "文件上传请求已接收",
|
||||
fileId: `file_${Date.now()}`,
|
||||
@@ -204,7 +217,7 @@ export async function action({ request }: ActionFunctionArgs) {
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("文件上传失败:", error);
|
||||
return json(
|
||||
return Response.json(
|
||||
{ success: false, error: "文件上传失败,请重试" },
|
||||
{ status: 500 }
|
||||
);
|
||||
@@ -215,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(),
|
||||
@@ -236,6 +251,7 @@ export async function loader() {
|
||||
}
|
||||
|
||||
return Response.json({
|
||||
mode,
|
||||
documents: documentsResponse.data || [],
|
||||
documentTypes: typesResponse.data || []
|
||||
});
|
||||
@@ -254,6 +270,8 @@ export default function FilesUpload() {
|
||||
const { documents, documentTypes } = useLoaderData<LoaderData>();
|
||||
|
||||
// 状态管理
|
||||
// 高级上传设置
|
||||
const [showAdvancedOptions, setShowAdvancedOptions] = useState(false);
|
||||
const [isTestDocument, setIsTestDocument] = useState(false);
|
||||
const [fileType, setFileType] = useState<FileType | "">("");
|
||||
const [priority, setPriority] = useState<Priority>(Priority.NORMAL);
|
||||
@@ -262,7 +280,7 @@ export default function FilesUpload() {
|
||||
const [currentFiles, setCurrentFiles] = useState<File[]>([]);
|
||||
const [uploadProgress, setUploadProgress] = useState(0);
|
||||
const [uploadSpeed, setUploadSpeed] = useState("0KB/s");
|
||||
const [uploadStage, setUploadStage] = useState<"idle" | "uploading" | "processing" | "completed">("idle");
|
||||
const [uploadStage, setUploadStage] = useState<"idle" | "uploading" | "processing" | "completed" | "hadden">("idle");
|
||||
const [processingSteps, setProcessingSteps] = useState<Step[]>([
|
||||
{ title: "文件上传", description: "等待上传文件到服务器...", status: "waiting" },
|
||||
{ title: "文档转换拆分", description: "转换文档格式,拆分文档内容", status: "waiting" },
|
||||
@@ -310,7 +328,8 @@ export default function FilesUpload() {
|
||||
useEffect(() => {
|
||||
console.log('设置上传队列状态检查定时器');
|
||||
|
||||
// 设置定时器检查队列中文件的状态
|
||||
// 设置定时器检查队列中文件的状态,初始先加载一次查询
|
||||
checkQueueStatus();
|
||||
statusCheckIntervalRef.current = setInterval(checkQueueStatus, 10000);
|
||||
|
||||
// 只在组件卸载时清除
|
||||
@@ -330,7 +349,7 @@ export default function FilesUpload() {
|
||||
|
||||
// 获取所有未完成的文档ID
|
||||
const incompleteIds = queueFiles
|
||||
.filter(file => file.status !== DocumentStatus.COMPLETED && file.id)
|
||||
.filter(file => file.status !== DocumentStatus.PROCESSED && file.id)
|
||||
.map(file => file.id);
|
||||
|
||||
console.log('未完成的文档ID:', incompleteIds);
|
||||
@@ -466,7 +485,7 @@ export default function FilesUpload() {
|
||||
type: file.type,
|
||||
fileType: fileType as FileType,
|
||||
priority,
|
||||
status: ProcessingStatus.PROCESSING,
|
||||
status: DocumentStatus.WAITING,
|
||||
uploadTime: getCurrentTime(),
|
||||
processingInfo: {
|
||||
progress: 0,
|
||||
@@ -587,7 +606,7 @@ export default function FilesUpload() {
|
||||
}
|
||||
|
||||
// 检查是否所有文件都已完成处理
|
||||
const allCompleted = response.data.every(doc => doc.status === DocumentStatus.COMPLETED);
|
||||
const allCompleted = response.data.every(doc => doc.status === DocumentStatus.PROCESSED);
|
||||
|
||||
// 更新步骤状态
|
||||
if (allCompleted) {
|
||||
@@ -656,7 +675,7 @@ export default function FilesUpload() {
|
||||
updatedSteps[2].description = "正在抽取评查点...";
|
||||
break;
|
||||
|
||||
case DocumentStatus.REVIEWING:
|
||||
case DocumentStatus.EVALUATIONING:
|
||||
updatedSteps[1].status = "done";
|
||||
updatedSteps[1].description = "文档格式转换完成,内容已拆分";
|
||||
updatedSteps[2].status = "done";
|
||||
@@ -665,7 +684,7 @@ export default function FilesUpload() {
|
||||
updatedSteps[3].description = "正在评查文档...";
|
||||
break;
|
||||
|
||||
case DocumentStatus.COMPLETED:
|
||||
case DocumentStatus.PROCESSED:
|
||||
updatedSteps[1].status = "done";
|
||||
updatedSteps[1].description = "文档格式转换完成,内容已拆分";
|
||||
updatedSteps[2].status = "done";
|
||||
@@ -745,7 +764,6 @@ export default function FilesUpload() {
|
||||
};
|
||||
|
||||
|
||||
|
||||
// 格式化文件大小显示
|
||||
const formatFileSize = (bytes: number) => {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
@@ -805,22 +823,32 @@ export default function FilesUpload() {
|
||||
let statusText = "";
|
||||
|
||||
switch(record.status) {
|
||||
case DocumentStatus.WAITING:
|
||||
statusClass = "status-processing";
|
||||
statusIcon = "ri-loader-4-line";
|
||||
statusText = "等待中";
|
||||
break;
|
||||
case DocumentStatus.CUTTING:
|
||||
statusClass = "status-processing";
|
||||
statusIcon = "ri-loader-4-line";
|
||||
statusText = "转换中";
|
||||
statusText = "切分中";
|
||||
break;
|
||||
case DocumentStatus.EXTRACTIONING:
|
||||
statusClass = "status-processing";
|
||||
statusIcon = "ri-loader-4-line";
|
||||
statusText = "抽取中";
|
||||
break;
|
||||
case DocumentStatus.REVIEWING:
|
||||
case DocumentStatus.EVALUATIONING:
|
||||
statusClass = "status-processing";
|
||||
statusIcon = "ri-loader-4-line";
|
||||
statusText = "审核中";
|
||||
statusText = "评查中";
|
||||
break;
|
||||
case DocumentStatus.COMPLETED:
|
||||
case DocumentStatus.FAILED:
|
||||
statusClass = "status-error";
|
||||
statusIcon = "ri-close-circle-line";
|
||||
statusText = "抽取异常";
|
||||
break;
|
||||
case DocumentStatus.PROCESSED:
|
||||
statusClass = "status-success";
|
||||
statusIcon = "ri-checkbox-circle-line";
|
||||
statusText = "已完成";
|
||||
@@ -843,7 +871,7 @@ export default function FilesUpload() {
|
||||
<Button
|
||||
type="default"
|
||||
size="small"
|
||||
disabled={record.status !== DocumentStatus.COMPLETED}
|
||||
disabled={record.status !== DocumentStatus.PROCESSED}
|
||||
icon="ri-eye-line"
|
||||
onClick={() => alert(`查看文件详情: ${record.name}`)}
|
||||
>
|
||||
@@ -950,7 +978,9 @@ export default function FilesUpload() {
|
||||
tipText="支持单个或批量上传,文件格式:PDF、Word、Excel、图片"
|
||||
shouldPreventFileSelect={!fileType}
|
||||
/>
|
||||
<div className="switch-container">
|
||||
|
||||
{/* 测试文档标记 */}
|
||||
<div className="switch-container mb-4">
|
||||
<label className="switch" aria-label="标记为测试文档">
|
||||
<input
|
||||
type="checkbox"
|
||||
@@ -961,6 +991,61 @@ export default function FilesUpload() {
|
||||
</label>
|
||||
<span>标记为测试文档(不计入正式统计)</span>
|
||||
</div>
|
||||
|
||||
{/* 高级上传设置 */}
|
||||
{ showAdvancedOptions && (
|
||||
<div className="advanced-options">
|
||||
<div
|
||||
className={`advanced-options-toggle ${showAdvancedOptions ? 'open' : ''}`}
|
||||
onClick={() => setShowAdvancedOptions(!showAdvancedOptions)}
|
||||
>
|
||||
<span>高级上传设置</span>
|
||||
<i className="ri-arrow-down-s-line"></i>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="advanced-options-content"
|
||||
style={{ display: showAdvancedOptions ? 'block' : 'none' }}
|
||||
>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="form-group">
|
||||
<label className="form-label" htmlFor="storageType">存储方式</label>
|
||||
<select
|
||||
id="storageType"
|
||||
name="storageType"
|
||||
className="form-select w-full"
|
||||
defaultValue="minio"
|
||||
>
|
||||
{STORAGE_TYPES.map(type => (
|
||||
<option key={type.id} value={type.id}>
|
||||
{type.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="form-tip">选择文档的存储位置</div>
|
||||
</div>
|
||||
|
||||
<div className="form-group">
|
||||
<label className="form-label" htmlFor="afterUpload">上传后操作</label>
|
||||
<select
|
||||
id="afterUpload"
|
||||
name="afterUpload"
|
||||
className="form-select w-full"
|
||||
defaultValue="list"
|
||||
>
|
||||
{AFTER_UPLOAD_OPTIONS.map(option => (
|
||||
<option key={option.id} value={option.id}>
|
||||
{option.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="form-tip">上传完成后自动执行的操作</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -982,7 +1067,8 @@ export default function FilesUpload() {
|
||||
)}
|
||||
|
||||
{/* 文件信息显示 - 上传完成后显示 */}
|
||||
{uploadStage !== "idle" && completedFiles.length > 0 && (
|
||||
{/* {uploadStage !== "idle" && completedFiles.length > 0 && ( */}
|
||||
{uploadStage === "hadden" && completedFiles.length > 0 && (
|
||||
<div className="file-info-grid">
|
||||
<div>
|
||||
<h4 className="font-medium mb-3">文件信息</h4>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -58,6 +58,28 @@
|
||||
@apply transform translate-x-5;
|
||||
}
|
||||
|
||||
/* 高级上传设置 */
|
||||
/* 高级选项区域 */
|
||||
.file-upload-page .advanced-options {
|
||||
@apply mt-4;
|
||||
}
|
||||
|
||||
.file-upload-page .advanced-options-toggle {
|
||||
@apply text-[var(--primary-color)] cursor-pointer inline-flex items-center text-sm;
|
||||
}
|
||||
|
||||
.file-upload-page .advanced-options-toggle i {
|
||||
@apply ml-1 transition-transform duration-200;
|
||||
}
|
||||
|
||||
.file-upload-page .advanced-options-toggle.open i {
|
||||
@apply rotate-180;
|
||||
}
|
||||
|
||||
.file-upload-page .advanced-options-content {
|
||||
@apply mt-3 p-3 bg-gray-50 border border-gray-200 rounded-md hidden;
|
||||
}
|
||||
|
||||
.file-upload-page .form-label {
|
||||
@apply block text-sm font-medium text-gray-700 mb-2;
|
||||
}
|
||||
|
||||
@@ -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