feat: 1. 完善评查点分组的删除逻辑,会涉及文档类型绑定的一级分组,分组绑定的评查点规则。新增一个评查点分组换绑的。
2. 修复交叉评查的任务中的文档列表的历史文档的查看跳转路径。 3. 修复评查点新增中评查点类型只能显示当前文档类型绑定的这几个一级分组。评查点类型=一级分组。 4. 修复文档列表关于pdf的下载失败的问题。
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import type { EvaluationPoint } from '~/models/evaluation_points';
|
||||
import type { EvaluationPointGroup } from '~/models/evaluation_point_groups';
|
||||
import { getRulesList } from '~/api/evaluation_points/rules';
|
||||
import { getRulesList, getRuleTypes, type RuleType } from '~/api/evaluation_points/rules';
|
||||
|
||||
interface BasicInfoProps {
|
||||
onChange?: (data: Record<string, unknown>) => void;
|
||||
@@ -77,8 +77,15 @@ export function BasicInfo({
|
||||
const getCheckpointTypeCode = () => {
|
||||
if (!formData.evaluation_point_groups_pid) return "";
|
||||
|
||||
// 优先从 API 返回的 filteredRuleTypes 中查找
|
||||
const fromApi = filteredRuleTypes.find(
|
||||
ruleType => Number(ruleType.id) === formData.evaluation_point_groups_pid
|
||||
);
|
||||
if (fromApi?.code) return fromApi.code;
|
||||
|
||||
// 兜底:从 evaluationPointGroups 中查找
|
||||
const typeGroup = evaluationPointGroups.find(
|
||||
group => group.id === formData.evaluation_point_groups_pid && (!group.pid || group.pid === 0) // 🆕 NULL或0都表示顶级分组
|
||||
group => group.id === formData.evaluation_point_groups_pid && (!group.pid || group.pid === 0)
|
||||
);
|
||||
|
||||
return typeGroup?.code || "";
|
||||
@@ -86,10 +93,53 @@ export function BasicInfo({
|
||||
|
||||
// 评查点描述与法律依据 展开状态
|
||||
const [isDescExpanded, setIsDescExpanded] = useState(false);
|
||||
|
||||
|
||||
// 条款号临时输入字符串(不会触发自动分割)
|
||||
const [lawArticlesText, setLawArticlesText] = useState('');
|
||||
|
||||
// 从 API 获取的评查点类型列表(根据 documentTypeIds 过滤)
|
||||
const [filteredRuleTypes, setFilteredRuleTypes] = useState<RuleType[]>([]);
|
||||
const [ruleTypesLoading, setRuleTypesLoading] = useState(false);
|
||||
|
||||
// 从 Session Storage 获取 documentTypeIds 并调用 API 获取评查点类型
|
||||
useEffect(() => {
|
||||
const fetchRuleTypes = async () => {
|
||||
try {
|
||||
const storedIds = sessionStorage.getItem('documentTypeIds');
|
||||
if (!storedIds) {
|
||||
setFilteredRuleTypes([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const parsedIds = JSON.parse(storedIds);
|
||||
if (!Array.isArray(parsedIds) || parsedIds.length === 0) {
|
||||
setFilteredRuleTypes([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const documentTypeIds = parsedIds.map(id => Number(id));
|
||||
setRuleTypesLoading(true);
|
||||
|
||||
// 调用 getRuleTypes API 获取过滤后的评查点类型
|
||||
const response = await getRuleTypes(documentTypeIds, frontendJWT);
|
||||
|
||||
if (response.data) {
|
||||
setFilteredRuleTypes(response.data);
|
||||
} else {
|
||||
console.error('获取评查点类型失败:', response.error);
|
||||
setFilteredRuleTypes([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取评查点类型失败:', error);
|
||||
setFilteredRuleTypes([]);
|
||||
} finally {
|
||||
setRuleTypesLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchRuleTypes();
|
||||
}, [frontendJWT]);
|
||||
|
||||
// 根据选择的评查点类型筛选可用的规则组
|
||||
const filteredRuleGroups = evaluationPointGroups.filter(group =>
|
||||
formData.evaluation_point_groups_pid &&
|
||||
@@ -97,8 +147,31 @@ export function BasicInfo({
|
||||
group.is_enabled
|
||||
);
|
||||
|
||||
// 🆕 获取评查点类型选项(pid为NULL或0的数据)
|
||||
// 🆕 获取评查点类型选项(使用 API 返回的过滤后数据)
|
||||
const getCheckpointTypeOptions = () => {
|
||||
if (ruleTypesLoading) {
|
||||
return (
|
||||
<>
|
||||
<option value="">加载中...</option>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// 如果 API 返回了数据,使用 API 数据
|
||||
if (filteredRuleTypes.length > 0) {
|
||||
return (
|
||||
<>
|
||||
<option value="">请选择评查点类型</option>
|
||||
{filteredRuleTypes.map(ruleType => (
|
||||
<option key={ruleType.id} value={ruleType.code}>
|
||||
{ruleType.name}
|
||||
</option>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// 兜底:如果 API 没有返回数据,使用 evaluationPointGroups 中的一级分组
|
||||
if (!evaluationPointGroups || evaluationPointGroups.length === 0) {
|
||||
return (
|
||||
<>
|
||||
@@ -107,7 +180,9 @@ export function BasicInfo({
|
||||
);
|
||||
}
|
||||
|
||||
const typeGroups = evaluationPointGroups.filter(group => (!group.pid || group.pid === 0) && group.is_enabled);
|
||||
const typeGroups = evaluationPointGroups.filter(group =>
|
||||
(!group.pid || group.pid === 0) && group.is_enabled
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -177,10 +252,16 @@ export function BasicInfo({
|
||||
case 'checkpoint-type':
|
||||
// 处理评查点类型选择
|
||||
if (value) {
|
||||
// 🆕 找到选中的类型组(pid为NULL或0表示顶级分组)
|
||||
const selectedType = evaluationPointGroups.find(group => group.code === value && (!group.pid || group.pid === 0));
|
||||
if (selectedType) {
|
||||
newData.evaluation_point_groups_pid = selectedType.id;
|
||||
// 优先从 API 返回的 filteredRuleTypes 中查找
|
||||
const selectedFromApi = filteredRuleTypes.find(ruleType => ruleType.code === value);
|
||||
if (selectedFromApi) {
|
||||
newData.evaluation_point_groups_pid = Number(selectedFromApi.id);
|
||||
} else {
|
||||
// 兜底:从 evaluationPointGroups 中查找(pid为NULL或0表示顶级分组)
|
||||
const selectedType = evaluationPointGroups.find(group => group.code === value && (!group.pid || group.pid === 0));
|
||||
if (selectedType) {
|
||||
newData.evaluation_point_groups_pid = selectedType.id;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newData.evaluation_point_groups_pid = null;
|
||||
|
||||
Reference in New Issue
Block a user