完成智慧法务前端调整20250522,还有登录和主页需要完善

This commit is contained in:
2025-05-27 23:48:28 +08:00
parent 742a789244
commit 690d369f57
30 changed files with 1557 additions and 292 deletions
+166 -79
View File
@@ -55,6 +55,16 @@ export interface ReviewPoint {
};
postAction?: string;
actionContent?: string;
evaluationConfig?: {
rules?: Array<{
type: string;
config?: {
fields?: string[];
pairs?: Array<{ sourceField?: string; targetField?: string }>;
logic?: string;
};
}>;
};
}
// 统计数据类型
@@ -444,84 +454,160 @@ export function ReviewPointsList({
* @returns 评查点主要内容组件
*/
const renderContent = (reviewPoint: ReviewPoint, result?: boolean) => {
// 获取evaluationConfig中type为consistency的规则 评查点一致性规则组的规则
const consistencyRules = reviewPoint.evaluationConfig?.rules?.filter(rule => rule.type === 'consistency') || [];
// 获取所有consistency规则中的fields
const allConsistencyFields: string[][] = [];
consistencyRules.forEach(rule => {
if (rule.config?.fields) {
allConsistencyFields.push(rule.config.fields);
}else if (rule.config?.pairs) {
// 处理pairs情况,提取sourceField和targetField
const fields: string[] = [];
rule.config.pairs.forEach(pair => {
if (pair.sourceField) fields.push(pair.sourceField);
if (pair.targetField) fields.push(pair.targetField);
});
if (fields.length > 0) {
allConsistencyFields.push(fields);
}
}
});
// 对content进行排序
const contentEntries = Object.entries(reviewPoint.content);
// 按照consistency规则分组
const groupedContent: Record<string, Array<[string, { page?: number | string, value?: object }]>> = {
'default': [] // 默认组,存放不属于任何consistency规则的项
};
// 为每个consistency规则创建分组
allConsistencyFields.forEach((fields, index) => {
groupedContent[`consistency_${index}`] = [];
});
// 将content按照规则分组
contentEntries.forEach(entry => {
const [key, value] = entry;
// 检查是否属于某个consistency规则
let assigned = false;
allConsistencyFields.forEach((fields, index) => {
if (fields.includes(key)) {
groupedContent[`consistency_${index}`].push(entry);
assigned = true;
}
});
// 如果不属于任何规则,放入默认组
if (!assigned) {
groupedContent['default'].push(entry);
}
});
return (
<>
{/* 修改评查结果的结构之后,显示新的结构 */}
{Object.entries(reviewPoint.content).map(([key, value], index) => !(result && value.value?.toString().trim() == '') && (
<div
key={index}
className="mb-2 pb-2 border-b border-gray-100 last:border-b-0 last:mb-0 last:pb-0 cursor-pointer hover:bg-gray-100 transition-colors duration-200 rounded p-1 group"
onClick={(e) => {
e.stopPropagation();
console.log(`单独点击${key}----`, reviewPoint);
const valuePage = parseInt(value.page as string);
const contentPage = parseInt(reviewPoint.contentPage?.[key] as string);
// 检查value中的page属性是否存在,优先取value中的page
if (valuePage > 0) {
console.log(`存在page且不为空:单独点击${key}---------->evaluated_results内的页码:`, valuePage);
onReviewPointSelect(reviewPoint.id, valuePage);
{/* 渲染各个分组 */}
{Object.entries(groupedContent).map(([groupKey, entries], groupIndex) => {
if (entries.length === 0) return null;
// 非默认组添加边框
const isDefaultGroup = groupKey === 'default';
return (
<div
key={groupKey}
className={`mb-1 ${!isDefaultGroup ? `border border-${result ? 'green' : 'red'}-200 rounded-md` : ''}`}
>
{/* 分组标题,只有非默认组显示 */}
{/* {!isDefaultGroup && (
<div className="text-xs font-medium text-red-500 mb-2">
规则组 {groupIndex}
</div>
)} */}
{/* 渲染组内内容 */}
{entries.map(([key, value], index) =>
!(result && value.value?.toString().trim() == '') && (
<div
key={`${groupKey}_${index}`}
className="mb-2 pb-2 border-b border-gray-100 last:border-b-0 last:mb-0 cursor-pointer hover:bg-gray-100 transition-colors duration-200 rounded p-1 group"
onClick={(e) => {
e.stopPropagation();
console.log(`单独点击${key}----`, reviewPoint);
const valuePage = parseInt(value.page as string);
const contentPage = parseInt(reviewPoint.contentPage?.[key] as string);
// 检查value中的page属性是否存在,优先取value中的page
if (valuePage > 0) {
console.log(`存在page且不为空:单独点击${key}---------->evaluated_results内的页码:`, valuePage);
onReviewPointSelect(reviewPoint.id, valuePage);
} else if(contentPage && contentPage > 0) {
console.log(`存在page且为空:单独点击${key}---------->ocr_result内的页码:`, contentPage);
onReviewPointSelect(reviewPoint.id, contentPage);
}else {
toastService.error(`无法找到"${key}"对应的索引内容`);
console.log(`单独点击${key}--------没有对应页码`);
}
}}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
const valuePage = parseInt(value.page as string);
const contentPage = parseInt(reviewPoint.contentPage?.[key] as string);
// 检查value中的page属性是否存在,优先取value中的page
if (valuePage > 0) {
onReviewPointSelect(reviewPoint.id, valuePage);
} else if(contentPage && contentPage > 0) {
onReviewPointSelect(reviewPoint.id, contentPage);
} else {
toastService.error(`无法找到"${key}"对应的索引内容`);
console.log(`单独点击${key}--------没有对应页码`);
}
}
}}
role="button"
tabIndex={0}
aria-label={`查看${key}内容详情`}
onMouseLeave={(e) => {
// 获取容器内的滚动区域元素
const scrollContainer = e.currentTarget.querySelector('.text-container');
if (scrollContainer) {
// 在文本缩回之前重置滚动位置
scrollContainer.scrollTop = 0;
}
}}
>
{/* <div className="flex justify-between items-center mb-1"> */}
<div className="flex items-center mb-1">
<span className="text-xs pr-5">
{key}
</span>
<span className={`flex-shrink-0 text-xs w-15 ${value.value?.toString().trim() ? 'text-error' : 'text-warning'}`}>
{parseInt(value.page as string)>0 || parseInt(reviewPoint.contentPage?.[key] as string)>0 ? '' : <i title="无法找到索引内容" className="ri-alert-line text-red-500 mr-2"></i>}
{value.value?.toString().trim() ? '' : '缺失'}
</span>
</div>
} else if(contentPage && contentPage > 0) {
console.log(`存在page且为空:单独点击${key}---------->ocr_result内的页码:`, contentPage);
onReviewPointSelect(reviewPoint.id, contentPage);
}else {
toastService.error(`无法找到"${key}"对应的索引内容`);
console.log(`单独点击${key}--------没有对应页码`);
}
}}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
const valuePage = parseInt(value.page as string);
const contentPage = parseInt(reviewPoint.contentPage?.[key] as string);
// 检查value中的page属性是否存在,优先取value中的page
if (valuePage > 0) {
onReviewPointSelect(reviewPoint.id, valuePage);
} else if(contentPage && contentPage > 0) {
onReviewPointSelect(reviewPoint.id, contentPage);
} else {
toastService.error(`无法找到"${key}"对应的索引内容`);
console.log(`单独点击${key}--------没有对应页码`);
}
}
}}
role="button"
tabIndex={0}
aria-label={`查看${key}内容详情`}
onMouseLeave={(e) => {
// 获取容器内的滚动区域元素
const scrollContainer = e.currentTarget.querySelector('.text-container');
if (scrollContainer) {
// 在文本缩回之前重置滚动位置
scrollContainer.scrollTop = 0;
}
}}
>
{/* <div className="flex justify-between items-center mb-1"> */}
<div className="flex items-center mb-1">
<span className="text-xs pr-5">
{key}
</span>
<span className={`flex-shrink-0 text-xs w-15 ${value.value?.toString().trim() ? 'text-error' : 'text-warning'}`}>
{parseInt(value.page as string)>0 || parseInt(reviewPoint.contentPage?.[key] as string)>0 ? '' : <i title="无法找到索引内容" className="ri-alert-line text-red-500 mr-2"></i>}
{value.value?.toString().trim() ? '' : '缺失'}
</span>
</div>
<div className="relative text-container max-h-96 group-hover:overflow-auto overflow-hidden">
<p
className="text-xs text-left select-text block overflow-hidden !line-clamp-2
group-hover:!line-clamp-none group-hover:bg-white group-hover:shadow-md group-hover:z-10 group-hover:relative px-1 rounded transition-all duration-300 ease-in-out cursor-text"
// title={value.value?.toString() || ''}
// style={{ userSelect: 'all' }}
>
{(value.value?.toString().trim() === '')
? ""
: value.value?.toString() || ''}
</p>
<div className="relative text-container max-h-96 group-hover:overflow-auto overflow-hidden">
<p
className="text-xs text-left select-text block overflow-hidden !line-clamp-2
group-hover:!line-clamp-none group-hover:bg-white group-hover:shadow-md group-hover:z-10 group-hover:relative px-1 rounded transition-all duration-300 ease-in-out cursor-text"
// title={value.value?.toString() || ''}
// style={{ userSelect: 'all' }}
>
{(value.value?.toString().trim() === '')
? ""
: value.value?.toString() || ''}
</p>
</div>
</div>
))}
</div>
</div>
))}
);
})}
</>
);
};
@@ -533,7 +619,7 @@ export function ReviewPointsList({
* @returns 评查点内容与建议组件
*/
const renderReviewPointContent = (reviewPoint: ReviewPoint) => {
const handleManualReviewNotesChange = (reviewPointId: string, text: string) => {
setManualReviewNotes(prev => ({
...prev,
@@ -541,8 +627,9 @@ export function ReviewPointsList({
}));
};
// 如果当前评查点不处于编辑状态,只显示简单信息
// 如果当前评查点不处于编辑状态 TODO delete
if (editingReviewPoint !== reviewPoint.id) {
// 根据result和status决定渲染哪种样式
if (reviewPoint.result === true) {
// 已通过的评查点只显示基本信息和人工审核注释
@@ -893,11 +980,11 @@ export function ReviewPointsList({
>
{/* 评查点标题和状态 */}
{/* 评查点名称 pointName*/}
<div className="review-point-title flex-1 text-left text-blue-500">{'评查点名称:' + reviewPoint.pointName}</div>
<div className="review-point-title flex-1 text-left text-blue-500">{reviewPoint.pointName}</div>
<div className="review-point-header flex justify-between items-start">
<div className="review-point-title flex-1 text-left min-w-[25%]">{reviewPoint.title}</div>
<div className="flex-1 text-left min-w-[25%] font-medium text-[13px]">{reviewPoint.title}</div>
{/* 评查点所属分组 */}
<div className="review-point-location max-w-[40%] flex items-center">
{/* <div className="review-point-location max-w-[40%] flex items-center">
<i className="ri-file-list-line mr-1 flex-shrink-0"></i>
<span
className="truncate block whitespace-nowrap overflow-hidden
@@ -907,7 +994,7 @@ export function ReviewPointsList({
>
{reviewPoint.groupName}
</span>
</div>
</div> */}
<div className="flex flex-col items-center ml-2 flex-shrink-0 max-w-[15%]">
{renderStatusBadge(reviewPoint.status, reviewPoint.result)}
{renderHumanReviewBadge(reviewPoint)}