优化文档列表
This commit is contained in:
@@ -45,6 +45,8 @@ export interface DocumentSearchParams {
|
|||||||
documentNumber?: string;
|
documentNumber?: string;
|
||||||
documentType?: string;
|
documentType?: string;
|
||||||
status?: string;
|
status?: string;
|
||||||
|
auditStatus?: string;
|
||||||
|
fileStatus?: string;
|
||||||
dateFrom?: string;
|
dateFrom?: string;
|
||||||
dateTo?: string;
|
dateTo?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
@@ -123,7 +125,7 @@ async function convertToUIDocument(doc: Document): Promise<DocumentUI> {
|
|||||||
typeName: docType?.name || '未知类型',
|
typeName: docType?.name || '未知类型',
|
||||||
size: doc.file_size,
|
size: doc.file_size,
|
||||||
auditStatus: doc.audit_status,
|
auditStatus: doc.audit_status,
|
||||||
fileStatus: doc.file_status || 'Processed', // 默认为已处理
|
fileStatus: doc.status || '', // 默认为''
|
||||||
issues: 0, // 固定为0
|
issues: 0, // 固定为0
|
||||||
uploadTime: formatDate(doc.updated_at),
|
uploadTime: formatDate(doc.updated_at),
|
||||||
fileType: getFileExtension(doc.name),
|
fileType: getFileExtension(doc.name),
|
||||||
@@ -173,20 +175,35 @@ export async function getDocuments(searchParams: DocumentSearchParams = {}): Pro
|
|||||||
filter['type_id'] = `eq.${searchParams.documentType}`;
|
filter['type_id'] = `eq.${searchParams.documentType}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchParams.status) {
|
if (searchParams.auditStatus) {
|
||||||
filter['status'] = `eq.${searchParams.status}`;
|
filter['audit_status'] = `eq.${searchParams.auditStatus}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchParams.fileStatus) {
|
||||||
|
filter['status'] = `eq.${searchParams.fileStatus}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理日期范围
|
// 处理日期范围
|
||||||
if (searchParams.dateFrom) {
|
if (searchParams.dateFrom) {
|
||||||
filter['updated_at'] = `gte.${searchParams.dateFrom}`;
|
// 添加当天开始时间 00:00:00
|
||||||
|
filter['created_at'] = `gte.'${searchParams.dateFrom} 00:00:00'`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchParams.dateTo) {
|
if (searchParams.dateTo) {
|
||||||
const dateToKey = searchParams.dateFrom ? 'and.updated_at.lte' : 'updated_at';
|
// 如果有开始日期,使用and条件;否则直接设置结束日期
|
||||||
filter[dateToKey] = `lte.${searchParams.dateTo}`;
|
const dateToKey = searchParams.dateFrom ? 'and' : 'created_at';
|
||||||
|
|
||||||
|
// 添加当天结束时间 23:59:59
|
||||||
|
if (dateToKey === 'and') {
|
||||||
|
delete filter['created_at'];
|
||||||
|
// 使用OR操作符连接两个条件
|
||||||
|
filter[dateToKey] = `(created_at.gte.'${dayjs(searchParams.dateFrom).format()}',created_at.lte.'${dayjs(searchParams.dateTo).format()}')`;
|
||||||
|
} else {
|
||||||
|
filter['created_at'] = `lte.'${dayjs(searchParams.dateTo).format()}'`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('filter-----', filter);
|
||||||
params.filter = filter;
|
params.filter = filter;
|
||||||
|
|
||||||
// 发送请求
|
// 发送请求
|
||||||
@@ -204,7 +221,7 @@ export async function getDocuments(searchParams: DocumentSearchParams = {}): Pro
|
|||||||
|
|
||||||
// 转换为UI格式
|
// 转换为UI格式
|
||||||
const documents = await Promise.all(extractedData.map(convertToUIDocument));
|
const documents = await Promise.all(extractedData.map(convertToUIDocument));
|
||||||
|
// console.log('documentsItem',documents)
|
||||||
// 获取总数
|
// 获取总数
|
||||||
let totalCount = 0;
|
let totalCount = 0;
|
||||||
const responseWithHeaders = response as {
|
const responseWithHeaders = response as {
|
||||||
|
|||||||
@@ -40,11 +40,12 @@ function extractApiData<T>(responseData: unknown): T | null {
|
|||||||
|
|
||||||
// 文档状态枚举
|
// 文档状态枚举
|
||||||
export enum DocumentStatus {
|
export enum DocumentStatus {
|
||||||
WAITING = "waiting",
|
WAITING = "Waiting",
|
||||||
CUTTING = "Cutting",
|
CUTTING = "Cutting",
|
||||||
EXTRACTIONING = "extractioning",
|
EXTRACTIONING = "Extractioning",
|
||||||
REVIEWING = "reviewing",
|
EVALUATIONING = "Evaluationing",
|
||||||
COMPLETED = "completed"
|
FAILED = "Failed",
|
||||||
|
PROCESSED = "Processed"
|
||||||
}
|
}
|
||||||
|
|
||||||
// 文档类型接口
|
// 文档类型接口
|
||||||
|
|||||||
@@ -33,8 +33,9 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
|||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
const search = url.searchParams.get("search") || "";
|
const search = url.searchParams.get("search") || "";
|
||||||
const documentType = url.searchParams.get("documentType") || "";
|
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 documentNumber = url.searchParams.get("documentNumber") || "";
|
||||||
|
const fileStatus = url.searchParams.get("fileStatus") || "";
|
||||||
const dateFrom = url.searchParams.get("dateFrom") || "";
|
const dateFrom = url.searchParams.get("dateFrom") || "";
|
||||||
const dateTo = url.searchParams.get("dateTo") || "";
|
const dateTo = url.searchParams.get("dateTo") || "";
|
||||||
const page = parseInt(url.searchParams.get("page") || "1", 10);
|
const page = parseInt(url.searchParams.get("page") || "1", 10);
|
||||||
@@ -45,7 +46,8 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
|||||||
name: search || undefined,
|
name: search || undefined,
|
||||||
documentNumber: documentNumber || undefined,
|
documentNumber: documentNumber || undefined,
|
||||||
documentType: documentType || undefined,
|
documentType: documentType || undefined,
|
||||||
status: status || undefined,
|
auditStatus: auditStatus || undefined,
|
||||||
|
fileStatus: fileStatus || undefined,
|
||||||
dateFrom: dateFrom || undefined,
|
dateFrom: dateFrom || undefined,
|
||||||
dateTo: dateTo || undefined,
|
dateTo: dateTo || undefined,
|
||||||
page,
|
page,
|
||||||
@@ -58,8 +60,8 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
|||||||
throw new Error(documentsResponse.error);
|
throw new Error(documentsResponse.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取文档类型列表,用于筛选条件
|
// 获取文档类型列表,用于筛选条件,设置较大的pageSize确保获取所有数据
|
||||||
const typesResponse = await getDocumentTypes();
|
const typesResponse = await getDocumentTypes({ pageSize: 500 });
|
||||||
const documentTypes = typesResponse.data?.types || [];
|
const documentTypes = typesResponse.data?.types || [];
|
||||||
const documentTypeOptions = documentTypes.map(type => ({
|
const documentTypeOptions = documentTypes.map(type => ({
|
||||||
value: type.id,
|
value: type.id,
|
||||||
@@ -112,22 +114,33 @@ export const action = async ({ request }: ActionFunctionArgs) => {
|
|||||||
return Response.json({ success: false, message: "未知操作" }, { status: 400 });
|
return Response.json({ success: false, message: "未知操作" }, { status: 400 });
|
||||||
};
|
};
|
||||||
|
|
||||||
// 文档状态选项
|
// 审核状态筛选选项
|
||||||
const documentStatusOptions = [
|
const auditStatusOptions = [
|
||||||
{ value: "waiting", label: "待审核" },
|
// { value: "", label: "全部" },
|
||||||
{ value: "processing", label: "审核中" },
|
{ value: "-1", label: "不通过" },
|
||||||
{ value: "pass", label: "通过" },
|
{ value: "0", label: "待审核" },
|
||||||
{ value: "warning", label: "警告" },
|
{ value: "1", label: "通过" },
|
||||||
{ value: "fail", label: "不通过" },
|
{ value: "2", label: "警告" },
|
||||||
|
{ value: "3", label: "审核中" },
|
||||||
];
|
];
|
||||||
|
|
||||||
// 文件处理状态选项
|
// 文件处理状态选项
|
||||||
const fileProcessingStatusOptions = [
|
const fileProcessingStatusOptions = [
|
||||||
{ value: "Waiting", label: "上传中", icon: "ri-loader-line" },
|
{ value: "Waiting", label: "上传中", icon: "ri-loader-line", color: "blue" },
|
||||||
{ value: "Cutting", label: "切分中", icon: "ri-loader-line" },
|
{ value: "Cutting", label: "切分中", icon: "ri-loader-line", color: "purple" },
|
||||||
{ value: "Extractioning", label: "抽取中", icon: "ri-loader-line" },
|
{ value: "Extractioning", label: "抽取中", icon: "ri-loader-line", color: "cyan" },
|
||||||
{ value: "Evaluationing", label: "评查中", icon: "ri-loader-line" },
|
{ value: "Evaluationing", label: "评查中", icon: "ri-loader-line", color: "teal" },
|
||||||
{ value: "Processed", label: "已完成", icon: "ri-check-line" },
|
{ 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: "已完成" },
|
||||||
];
|
];
|
||||||
|
|
||||||
// 审核状态选项及样式
|
// 审核状态选项及样式
|
||||||
@@ -171,8 +184,9 @@ export default function DocumentsIndex() {
|
|||||||
// 从URL获取当前筛选条件
|
// 从URL获取当前筛选条件
|
||||||
const search = searchParams.get("search") || "";
|
const search = searchParams.get("search") || "";
|
||||||
const documentType = searchParams.get("documentType") || "";
|
const documentType = searchParams.get("documentType") || "";
|
||||||
const status = searchParams.get("status") || "";
|
const auditStatus = searchParams.get("auditStatus") || "";
|
||||||
const documentNumber = searchParams.get("documentNumber") || "";
|
const documentNumber = searchParams.get("documentNumber") || "";
|
||||||
|
const fileStatus = searchParams.get("fileStatus") || "";
|
||||||
const dateFrom = searchParams.get("dateFrom") || "";
|
const dateFrom = searchParams.get("dateFrom") || "";
|
||||||
const dateTo = searchParams.get("dateTo") || "";
|
const dateTo = searchParams.get("dateTo") || "";
|
||||||
const currentPage = parseInt(searchParams.get("page") || "1", 10);
|
const currentPage = parseInt(searchParams.get("page") || "1", 10);
|
||||||
@@ -234,9 +248,9 @@ export default function DocumentsIndex() {
|
|||||||
const handleStatusChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
const handleStatusChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
||||||
const params = new URLSearchParams(searchParams);
|
const params = new URLSearchParams(searchParams);
|
||||||
if (e.target.value) {
|
if (e.target.value) {
|
||||||
params.set("status", e.target.value);
|
params.set("auditStatus", e.target.value);
|
||||||
} else {
|
} else {
|
||||||
params.delete("status");
|
params.delete("auditStatus");
|
||||||
}
|
}
|
||||||
params.set("page", "1"); // 重置页码
|
params.set("page", "1"); // 重置页码
|
||||||
setSearchParams(params);
|
setSearchParams(params);
|
||||||
@@ -332,7 +346,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}"?`)) {
|
if (window.confirm(`确认删除文档 "${name}"?`)) {
|
||||||
// 使用fetcher提交表单
|
// 使用fetcher提交表单
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
@@ -353,6 +371,16 @@ export default function DocumentsIndex() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查是否有正在处理中的文件
|
||||||
|
const hasProcessingFiles = documents.some((doc: DocumentUI) =>
|
||||||
|
selectedRowKeys.includes(doc.id.toString()) && doc.fileStatus !== 'Processed'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hasProcessingFiles) {
|
||||||
|
alert('存在服务器未处理完成的文件,请重新选择需要删除的文件');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (window.confirm(`确认删除选中的 ${selectedRowKeys.length} 个文档?`)) {
|
if (window.confirm(`确认删除选中的 ${selectedRowKeys.length} 个文档?`)) {
|
||||||
// 使用fetcher提交表单
|
// 使用fetcher提交表单
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
@@ -370,6 +398,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 = [
|
const columns = [
|
||||||
{
|
{
|
||||||
@@ -393,6 +433,7 @@ export default function DocumentsIndex() {
|
|||||||
{
|
{
|
||||||
title: "文档名称",
|
title: "文档名称",
|
||||||
key: "name",
|
key: "name",
|
||||||
|
width:'20%',
|
||||||
render: (_: unknown, record: DocumentUI) => (
|
render: (_: unknown, record: DocumentUI) => (
|
||||||
<div className="flex items-center m-1">
|
<div className="flex items-center m-1">
|
||||||
<FileTag
|
<FileTag
|
||||||
@@ -401,10 +442,10 @@ export default function DocumentsIndex() {
|
|||||||
showText={false}
|
showText={false}
|
||||||
showBackground={false}
|
showBackground={false}
|
||||||
size="lg"
|
size="lg"
|
||||||
className="mr-2"
|
className="mr-2 flex-shrink-0"
|
||||||
/>
|
/>
|
||||||
<div>
|
<div className="overflow-hidden">
|
||||||
<span className="file-name" title={record.name}>{record.name}</span>
|
<span className="file-name truncate block" title={record.name}>{record.name}</span>
|
||||||
<div className="mt-2 flex inline-block">
|
<div className="mt-2 flex inline-block">
|
||||||
<FileTypeTag
|
<FileTypeTag
|
||||||
type={record.type}
|
type={record.type}
|
||||||
@@ -424,6 +465,7 @@ export default function DocumentsIndex() {
|
|||||||
{
|
{
|
||||||
title: "文档编号",
|
title: "文档编号",
|
||||||
key: "documentNumber",
|
key: "documentNumber",
|
||||||
|
width:'10%',
|
||||||
render: (_: unknown, record: DocumentUI) => (
|
render: (_: unknown, record: DocumentUI) => (
|
||||||
<span className="document-number">{record.documentNumber}</span>
|
<span className="document-number">{record.documentNumber}</span>
|
||||||
)
|
)
|
||||||
@@ -431,18 +473,22 @@ export default function DocumentsIndex() {
|
|||||||
{
|
{
|
||||||
title: "文件大小",
|
title: "文件大小",
|
||||||
key: "size",
|
key: "size",
|
||||||
width: "100px",
|
width: "10%",
|
||||||
render: (_: unknown, record: DocumentUI) => formatFileSize(record.size)
|
render: (_: unknown, record: DocumentUI) => formatFileSize(record.size)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "文件状态",
|
title: "文件状态",
|
||||||
key: "fileStatus",
|
key: "fileStatus",
|
||||||
|
width:'10%',
|
||||||
render: (_: unknown, record: DocumentUI) => {
|
render: (_: unknown, record: DocumentUI) => {
|
||||||
const status = fileProcessingStatusOptions.find(s => s.value === record.fileStatus) ||
|
// 处理fileStatus为null或undefined的情况
|
||||||
|
// console.log('fileStatus',record.fileStatus)
|
||||||
|
const fileStatus = record.fileStatus || "Processed";
|
||||||
|
const status = fileProcessingStatusOptions.find(s => s.value === fileStatus) ||
|
||||||
fileProcessingStatusOptions[0];
|
fileProcessingStatusOptions[0];
|
||||||
const isSpinning = record.fileStatus !== "Processed";
|
const isSpinning = fileStatus !== "Processed";
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center">
|
<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>
|
<i className={`${status.icon} ${isSpinning ? "animate-spin" : ""} mr-1`}></i>
|
||||||
<span>{status.label}</span>
|
<span>{status.label}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -452,8 +498,11 @@ export default function DocumentsIndex() {
|
|||||||
{
|
{
|
||||||
title: "审核状态",
|
title: "审核状态",
|
||||||
key: "auditStatus",
|
key: "auditStatus",
|
||||||
|
width:"10%",
|
||||||
render: (_: unknown, record: DocumentUI) => {
|
render: (_: unknown, record: DocumentUI) => {
|
||||||
const statusKey = record.auditStatus.toString();
|
// 处理auditStatus为null或undefined的情况,默认为0(待审核)
|
||||||
|
const auditStatus = record.auditStatus != null ? record.auditStatus : 0;
|
||||||
|
const statusKey = auditStatus.toString();
|
||||||
const statusInfo = auditStatusMapping[statusKey] || auditStatusMapping["0"];
|
const statusInfo = auditStatusMapping[statusKey] || auditStatusMapping["0"];
|
||||||
return (
|
return (
|
||||||
<div className={`inline-flex items-center px-2 py-1 rounded-full text-xs bg-${statusInfo.color}-100 text-${statusInfo.color}-800`}>
|
<div className={`inline-flex items-center px-2 py-1 rounded-full text-xs bg-${statusInfo.color}-100 text-${statusInfo.color}-800`}>
|
||||||
@@ -466,7 +515,7 @@ export default function DocumentsIndex() {
|
|||||||
{
|
{
|
||||||
title: "问题数量",
|
title: "问题数量",
|
||||||
key: "issues",
|
key: "issues",
|
||||||
width:"60px",
|
width:"10%",
|
||||||
render: (_: unknown, record: DocumentUI) => (
|
render: (_: unknown, record: DocumentUI) => (
|
||||||
record.issues === null ? "-" : record.issues
|
record.issues === null ? "-" : record.issues
|
||||||
)
|
)
|
||||||
@@ -474,15 +523,16 @@ export default function DocumentsIndex() {
|
|||||||
{
|
{
|
||||||
title: "上传时间",
|
title: "上传时间",
|
||||||
key: "uploadTime",
|
key: "uploadTime",
|
||||||
|
width:"10%",
|
||||||
render: (_: unknown, record: DocumentUI) => record.uploadTime
|
render: (_: unknown, record: DocumentUI) => record.uploadTime
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "操作",
|
title: "操作",
|
||||||
key: "actions",
|
key: "actions",
|
||||||
width: "280px",
|
width: "20%",
|
||||||
render: (_: unknown, record: DocumentUI) => (
|
render: (_: unknown, record: DocumentUI) => (
|
||||||
<div className="operations-cell">
|
<div className="operations-cell">
|
||||||
{record.auditStatus === 0 ? (
|
{(record.auditStatus === 0 || record.auditStatus == null) ? (
|
||||||
<Link
|
<Link
|
||||||
to={`/documents/${record.id}/review`}
|
to={`/documents/${record.id}/review`}
|
||||||
className="mr-1 hover:underline"
|
className="mr-1 hover:underline"
|
||||||
@@ -525,7 +575,7 @@ export default function DocumentsIndex() {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="text-error hover:underline hover:text-red-700"
|
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>
|
<i className="ri-delete-bin-line"></i>
|
||||||
删除
|
删除
|
||||||
@@ -578,13 +628,13 @@ export default function DocumentsIndex() {
|
|||||||
}
|
}
|
||||||
noActionDivider={true}
|
noActionDivider={true}
|
||||||
>
|
>
|
||||||
|
<div className="grid grid-cols-2 md:grid-cols-3 gap-4 w-full">
|
||||||
<SearchFilter
|
<SearchFilter
|
||||||
label="文档名称"
|
label="文档名称"
|
||||||
placeholder="请输入文档名称"
|
placeholder="请输入文档名称"
|
||||||
value={search}
|
value={search}
|
||||||
onSearch={handleNameSearch}
|
onSearch={handleNameSearch}
|
||||||
instantSearch={true}
|
instantSearch={true}
|
||||||
className="mr-2 w-50"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SearchFilter
|
<SearchFilter
|
||||||
@@ -593,7 +643,6 @@ export default function DocumentsIndex() {
|
|||||||
value={documentNumber}
|
value={documentNumber}
|
||||||
onSearch={handleDocumentNumberChange}
|
onSearch={handleDocumentNumberChange}
|
||||||
instantSearch={true}
|
instantSearch={true}
|
||||||
className="mr-2 w-50"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FilterSelect
|
<FilterSelect
|
||||||
@@ -602,16 +651,22 @@ export default function DocumentsIndex() {
|
|||||||
value={documentType}
|
value={documentType}
|
||||||
options={documentTypeOptions}
|
options={documentTypeOptions}
|
||||||
onChange={handleDocumentTypeChange}
|
onChange={handleDocumentTypeChange}
|
||||||
className="mr-2 w-30"
|
/>
|
||||||
|
|
||||||
|
<FilterSelect
|
||||||
|
label="文件状态"
|
||||||
|
name="fileStatus"
|
||||||
|
value={fileStatus}
|
||||||
|
options={fileStatusOptions}
|
||||||
|
onChange={handleFileStatusChange}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FilterSelect
|
<FilterSelect
|
||||||
label="审核状态"
|
label="审核状态"
|
||||||
name="status"
|
name="auditStatus"
|
||||||
value={status}
|
value={auditStatus}
|
||||||
options={documentStatusOptions}
|
options={auditStatusOptions}
|
||||||
onChange={handleStatusChange}
|
onChange={handleStatusChange}
|
||||||
className="mr-2 w-50"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DateRangeFilter
|
<DateRangeFilter
|
||||||
@@ -620,9 +675,9 @@ export default function DocumentsIndex() {
|
|||||||
endDate={dateTo}
|
endDate={dateTo}
|
||||||
onStartDateChange={(value) => handleDateChange('dateFrom', value)}
|
onStartDateChange={(value) => handleDateChange('dateFrom', value)}
|
||||||
onEndDateChange={(value) => handleDateChange('dateTo', value)}
|
onEndDateChange={(value) => handleDateChange('dateTo', value)}
|
||||||
className="flex-1"
|
|
||||||
simple={true}
|
simple={true}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</FilterPanel>
|
</FilterPanel>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
|||||||
// 并行获取文档详情和文档类型列表
|
// 并行获取文档详情和文档类型列表
|
||||||
const [documentResponse, documentTypesResponse] = await Promise.all([
|
const [documentResponse, documentTypesResponse] = await Promise.all([
|
||||||
getDocument(id),
|
getDocument(id),
|
||||||
getDocumentTypes()
|
getDocumentTypes({ pageSize: 500 })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (documentResponse.error) {
|
if (documentResponse.error) {
|
||||||
@@ -198,6 +198,8 @@ export default function DocumentEdit() {
|
|||||||
// 在新窗口打开文档预览
|
// 在新窗口打开文档预览
|
||||||
const openPreview = () => {
|
const openPreview = () => {
|
||||||
// 假设有一个预览URL的格式,比如 /preview?path=xxx
|
// 假设有一个预览URL的格式,比如 /preview?path=xxx
|
||||||
|
console.log('documentstest', document);
|
||||||
|
|
||||||
const previewUrl = `/preview?path=${encodeURIComponent(document.path)}&name=${encodeURIComponent(document.name)}`;
|
const previewUrl = `/preview?path=${encodeURIComponent(document.path)}&name=${encodeURIComponent(document.name)}`;
|
||||||
window.open(previewUrl, '_blank');
|
window.open(previewUrl, '_blank');
|
||||||
};
|
};
|
||||||
@@ -273,6 +275,7 @@ export default function DocumentEdit() {
|
|||||||
name="type_id"
|
name="type_id"
|
||||||
className="form-select"
|
className="form-select"
|
||||||
defaultValue={document.type}
|
defaultValue={document.type}
|
||||||
|
disabled={document.fileStatus !== 'Processed'}
|
||||||
required
|
required
|
||||||
>
|
>
|
||||||
{documentTypes.map((type: DocType) => (
|
{documentTypes.map((type: DocType) => (
|
||||||
|
|||||||
+16
-25
@@ -67,21 +67,7 @@ const PRIORITY_TO_CHINESE: Record<Priority, string> = {
|
|||||||
[Priority.URGENT]: "紧急"
|
[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支持的存储类型
|
// 模拟API支持的存储类型
|
||||||
const STORAGE_TYPES = [
|
const STORAGE_TYPES = [
|
||||||
@@ -105,7 +91,7 @@ export interface UploadedFile {
|
|||||||
type: string;
|
type: string;
|
||||||
fileType: FileType;
|
fileType: FileType;
|
||||||
priority: Priority;
|
priority: Priority;
|
||||||
status: ProcessingStatus;
|
status: DocumentStatus;
|
||||||
uploadTime: string;
|
uploadTime: string;
|
||||||
processingInfo?: {
|
processingInfo?: {
|
||||||
progress: number;
|
progress: number;
|
||||||
@@ -353,7 +339,7 @@ export default function FilesUpload() {
|
|||||||
|
|
||||||
// 获取所有未完成的文档ID
|
// 获取所有未完成的文档ID
|
||||||
const incompleteIds = queueFiles
|
const incompleteIds = queueFiles
|
||||||
.filter(file => file.status !== DocumentStatus.COMPLETED && file.id)
|
.filter(file => file.status !== DocumentStatus.PROCESSED && file.id)
|
||||||
.map(file => file.id);
|
.map(file => file.id);
|
||||||
|
|
||||||
console.log('未完成的文档ID:', incompleteIds);
|
console.log('未完成的文档ID:', incompleteIds);
|
||||||
@@ -489,7 +475,7 @@ export default function FilesUpload() {
|
|||||||
type: file.type,
|
type: file.type,
|
||||||
fileType: fileType as FileType,
|
fileType: fileType as FileType,
|
||||||
priority,
|
priority,
|
||||||
status: ProcessingStatus.PROCESSING,
|
status: DocumentStatus.WAITING,
|
||||||
uploadTime: getCurrentTime(),
|
uploadTime: getCurrentTime(),
|
||||||
processingInfo: {
|
processingInfo: {
|
||||||
progress: 0,
|
progress: 0,
|
||||||
@@ -610,7 +596,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) {
|
if (allCompleted) {
|
||||||
@@ -679,7 +665,7 @@ export default function FilesUpload() {
|
|||||||
updatedSteps[2].description = "正在抽取评查点...";
|
updatedSteps[2].description = "正在抽取评查点...";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DocumentStatus.REVIEWING:
|
case DocumentStatus.EVALUATIONING:
|
||||||
updatedSteps[1].status = "done";
|
updatedSteps[1].status = "done";
|
||||||
updatedSteps[1].description = "文档格式转换完成,内容已拆分";
|
updatedSteps[1].description = "文档格式转换完成,内容已拆分";
|
||||||
updatedSteps[2].status = "done";
|
updatedSteps[2].status = "done";
|
||||||
@@ -688,7 +674,7 @@ export default function FilesUpload() {
|
|||||||
updatedSteps[3].description = "正在评查文档...";
|
updatedSteps[3].description = "正在评查文档...";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DocumentStatus.COMPLETED:
|
case DocumentStatus.PROCESSED:
|
||||||
updatedSteps[1].status = "done";
|
updatedSteps[1].status = "done";
|
||||||
updatedSteps[1].description = "文档格式转换完成,内容已拆分";
|
updatedSteps[1].description = "文档格式转换完成,内容已拆分";
|
||||||
updatedSteps[2].status = "done";
|
updatedSteps[2].status = "done";
|
||||||
@@ -835,19 +821,24 @@ export default function FilesUpload() {
|
|||||||
case DocumentStatus.CUTTING:
|
case DocumentStatus.CUTTING:
|
||||||
statusClass = "status-processing";
|
statusClass = "status-processing";
|
||||||
statusIcon = "ri-loader-4-line";
|
statusIcon = "ri-loader-4-line";
|
||||||
statusText = "转换中";
|
statusText = "切分中";
|
||||||
break;
|
break;
|
||||||
case DocumentStatus.EXTRACTIONING:
|
case DocumentStatus.EXTRACTIONING:
|
||||||
statusClass = "status-processing";
|
statusClass = "status-processing";
|
||||||
statusIcon = "ri-loader-4-line";
|
statusIcon = "ri-loader-4-line";
|
||||||
statusText = "抽取中";
|
statusText = "抽取中";
|
||||||
break;
|
break;
|
||||||
case DocumentStatus.REVIEWING:
|
case DocumentStatus.EVALUATIONING:
|
||||||
statusClass = "status-processing";
|
statusClass = "status-processing";
|
||||||
statusIcon = "ri-loader-4-line";
|
statusIcon = "ri-loader-4-line";
|
||||||
statusText = "审核中";
|
statusText = "评查中";
|
||||||
break;
|
break;
|
||||||
case DocumentStatus.COMPLETED:
|
case DocumentStatus.FAILED:
|
||||||
|
statusClass = "status-error";
|
||||||
|
statusIcon = "ri-close-circle-line";
|
||||||
|
statusText = "抽取异常";
|
||||||
|
break;
|
||||||
|
case DocumentStatus.PROCESSED:
|
||||||
statusClass = "status-success";
|
statusClass = "status-success";
|
||||||
statusIcon = "ri-checkbox-circle-line";
|
statusIcon = "ri-checkbox-circle-line";
|
||||||
statusText = "已完成";
|
statusText = "已完成";
|
||||||
@@ -870,7 +861,7 @@ export default function FilesUpload() {
|
|||||||
<Button
|
<Button
|
||||||
type="default"
|
type="default"
|
||||||
size="small"
|
size="small"
|
||||||
disabled={record.status !== DocumentStatus.COMPLETED}
|
disabled={record.status !== DocumentStatus.PROCESSED}
|
||||||
icon="ri-eye-line"
|
icon="ri-eye-line"
|
||||||
onClick={() => alert(`查看文件详情: ${record.name}`)}
|
onClick={() => alert(`查看文件详情: ${record.name}`)}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user