fix:修复前端路由权限校验。修复交叉评查与普通评查结果的ai建议的替换效果不一致。
This commit is contained in:
@@ -449,7 +449,9 @@ export function ReviewPointsList({
|
||||
scoringProposals = [],
|
||||
jwtToken,
|
||||
userInfo,
|
||||
onOpinionSubmitted
|
||||
onOpinionSubmitted,
|
||||
fileFormat,
|
||||
onAiSuggestionReplace
|
||||
}: ReviewPointsListProps) {
|
||||
// 状态管理
|
||||
const [searchText, setSearchText] = useState(''); // 搜索文本
|
||||
@@ -1971,10 +1973,15 @@ export function ReviewPointsList({
|
||||
|
||||
// 渲染AI建议(ai_suggestion)
|
||||
if (config.ai_suggestion?.suggestions && Object.keys(config.ai_suggestion.suggestions).length > 0) {
|
||||
// 判断是否为PDF文档(禁用替换按钮)
|
||||
fileFormat = fileFormat?.replace(/\./g,'')
|
||||
const isPDF = fileFormat?.toUpperCase() === 'PDF';
|
||||
|
||||
// 遍历suggestions对象的key-value对
|
||||
Object.entries(config.ai_suggestion.suggestions).forEach(([key, suggestionValue], index) => {
|
||||
// 检查建议值是否存在(null 或有值都要渲染)
|
||||
const hasSuggestedValue = suggestionValue.suggested_value !== null && suggestionValue.suggested_value.trim() !== '';
|
||||
const isReplaceDisabled = !hasSuggestedValue || isPDF;
|
||||
|
||||
fieldElements.push(
|
||||
<div key={`ai-suggestion-${index}`} className="mb-3">
|
||||
@@ -1986,7 +1993,7 @@ export function ReviewPointsList({
|
||||
|
||||
{/* 原因说明 */}
|
||||
<div className="mb-2 p-2 bg-amber-50 rounded border border-amber-200 text-xs text-gray-700">
|
||||
<div className="flex items-start">
|
||||
<div className="flex items-center">
|
||||
<i className="ri-information-line text-amber-600 mr-1 mt-0.5"></i>
|
||||
<div>
|
||||
<span>{suggestionValue.reason}</span>
|
||||
@@ -1999,14 +2006,14 @@ export function ReviewPointsList({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 建议内容显示 */}
|
||||
{/* 建议内容和替换按钮 */}
|
||||
<div className="flex gap-2 items-center">
|
||||
{/* 文本输入框 */}
|
||||
<textarea
|
||||
value={suggestionValue.suggested_value || ''}
|
||||
readOnly
|
||||
disabled={!hasSuggestedValue}
|
||||
className={`flex-1 p-2 border rounded text-xs resize-none overflow-y-auto ${
|
||||
className={`flex-1 p-2 border rounded text-xs resize-none overflow-y-auto focus:outline-none ${
|
||||
hasSuggestedValue
|
||||
? 'border-gray-200 bg-gray-50 text-gray-700 cursor-not-allowed'
|
||||
: 'border-gray-200 bg-gray-100 text-gray-400 cursor-not-allowed'
|
||||
@@ -2014,6 +2021,46 @@ export function ReviewPointsList({
|
||||
aria-label={`${key}的AI建议内容`}
|
||||
placeholder={!hasSuggestedValue ? '暂无建议值' : ''}
|
||||
/>
|
||||
|
||||
{/* 意见替换按钮 */}
|
||||
{ !isPDF &&
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
if (!isReplaceDisabled && onAiSuggestionReplace && config.fields) {
|
||||
// 从 config.fields[key] 中获取对应的字段信息
|
||||
const fieldData = config.fields[key];
|
||||
if (fieldData) {
|
||||
// 调用回调函数,传递搜索文本(原文)、替换文本(AI建议)和页码
|
||||
onAiSuggestionReplace(
|
||||
fieldData.value || '', // 搜索文本(使用 suggestions 的 key对应的config中的key的value值)
|
||||
suggestionValue.suggested_value || '', // 替换文本(AI建议的 suggested_value)
|
||||
Number(fieldData.page) || 1 // 页码
|
||||
);
|
||||
} else {
|
||||
toastService.error(`未找到字段 ${key} 的原始数据`);
|
||||
}
|
||||
}
|
||||
}}
|
||||
disabled={isReplaceDisabled}
|
||||
className={`px-3 py-2 text-xs rounded whitespace-nowrap transition-colors
|
||||
${isReplaceDisabled
|
||||
? 'bg-gray-200 text-gray-400 cursor-not-allowed'
|
||||
: 'bg-primary text-white hover:bg-primary-hover active:bg-primary'
|
||||
}`}
|
||||
title={
|
||||
isPDF
|
||||
? 'PDF文档不支持替换'
|
||||
: !hasSuggestedValue
|
||||
? '暂无建议值,无法替换'
|
||||
: '点击执行一键替换'
|
||||
}
|
||||
aria-label={`替换${key}的内容`}
|
||||
>
|
||||
<i className="ri-exchange-line mr-1"></i>
|
||||
替换
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -2545,7 +2592,7 @@ export function ReviewPointsList({
|
||||
tabIndex={0}
|
||||
style={{ userSelect: 'text' }}
|
||||
onClick={() => {
|
||||
console.log('reviewPoint', reviewPoint);
|
||||
// console.log('reviewPoint', reviewPoint);
|
||||
handleReviewPointClick(reviewPoint.id);
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
|
||||
Reference in New Issue
Block a user