feat: align frontend document and rule management flows
This commit is contained in:
+563
-440
File diff suppressed because it is too large
Load Diff
@@ -105,6 +105,7 @@ export function BasicInfo({
|
||||
const [attributeTypeOptions, setAttributeTypeOptions] = useState<AttributeTypeOption[]>([]);
|
||||
const [attributeTypesLoading, setAttributeTypesLoading] = useState(false);
|
||||
const [isCustomAttributeType, setIsCustomAttributeType] = useState(false); // 是否为自定义输入模式
|
||||
const hasScopedGroupSource = filteredRuleTypes.length > 0 || evaluationPointGroups.length > 0;
|
||||
|
||||
// 从 Session Storage 获取 documentTypeIds 并调用 API 获取评查点类型
|
||||
useEffect(() => {
|
||||
@@ -199,7 +200,7 @@ export function BasicInfo({
|
||||
);
|
||||
}
|
||||
|
||||
// 如果 API 返回了数据,使用 API 数据
|
||||
// 优先使用接口按当前文档类型范围返回的一级分组
|
||||
if (filteredRuleTypes.length > 0) {
|
||||
return (
|
||||
<>
|
||||
@@ -213,11 +214,11 @@ export function BasicInfo({
|
||||
);
|
||||
}
|
||||
|
||||
// 兜底:如果 API 没有返回数据,使用 evaluationPointGroups 中的一级分组
|
||||
// 兜底仅限当前页面已加载的 scoped 分组数据,禁止回退到“全库分组”
|
||||
if (!evaluationPointGroups || evaluationPointGroups.length === 0) {
|
||||
return (
|
||||
<>
|
||||
<option value="">请选择评查点类型</option>
|
||||
<option value="">{ruleTypesLoading ? '加载中...' : '当前入口未绑定评查点类型'}</option>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -261,11 +262,13 @@ export function BasicInfo({
|
||||
// 清除错误信息
|
||||
setCodeError('');
|
||||
// 设置新的验证定时器(500ms后触发验证)
|
||||
const timer = setTimeout(async () => {
|
||||
const error = await validateCodeUnique(value);
|
||||
setCodeError(error);
|
||||
}, 500);
|
||||
setCodeValidationTimer(timer);
|
||||
{
|
||||
const timer = setTimeout(async () => {
|
||||
const error = await validateCodeUnique(value);
|
||||
setCodeError(error);
|
||||
}, 500);
|
||||
setCodeValidationTimer(timer);
|
||||
}
|
||||
break;
|
||||
case 'risk-level':
|
||||
newData.risk = value;
|
||||
@@ -294,6 +297,7 @@ export function BasicInfo({
|
||||
case 'checkpoint-type':
|
||||
// 处理评查点类型选择
|
||||
if (value) {
|
||||
newData.evaluation_point_groups_id = null;
|
||||
// 优先从 API 返回的 filteredRuleTypes 中查找
|
||||
const selectedFromApi = filteredRuleTypes.find(ruleType => ruleType.code === value);
|
||||
if (selectedFromApi) {
|
||||
@@ -494,7 +498,8 @@ export function BasicInfo({
|
||||
disabled={!formData.evaluation_point_groups_pid || filteredRuleGroups.length === 0}
|
||||
>
|
||||
<option value="">
|
||||
{!formData.evaluation_point_groups_pid ? "请先选择评查点类型" :
|
||||
{!hasScopedGroupSource ? "当前入口未绑定规则组" :
|
||||
!formData.evaluation_point_groups_pid ? "请先选择评查点类型" :
|
||||
filteredRuleGroups.length === 0 ? "该类型下暂无可用规则组" :
|
||||
"请选择规则组"}
|
||||
</option>
|
||||
@@ -505,7 +510,8 @@ export function BasicInfo({
|
||||
))}
|
||||
</select>
|
||||
<div className="form-tip">
|
||||
{!formData.evaluation_point_groups_pid ? "请先选择评查点类型" :
|
||||
{!hasScopedGroupSource ? "请先到系统设置为当前入口模块绑定文档类型与评查点分组" :
|
||||
!formData.evaluation_point_groups_pid ? "请先选择评查点类型" :
|
||||
filteredRuleGroups.length === 0 ? "该类型下暂无可用规则组" :
|
||||
"选择评查点所属的规则组"}
|
||||
</div>
|
||||
@@ -703,4 +709,4 @@ export function BasicInfo({
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user