模板管理中的指标自动合并bug修复

This commit is contained in:
linxd
2025-07-15 16:02:34 +08:00
parent 7870f5289e
commit 8debe46863
6 changed files with 43 additions and 30 deletions

View File

@ -377,31 +377,29 @@ const EvaluateTemplateTable: React.FC<EvaluateTemplateTableProps> = ({
// 特殊处理baseIndicator字段确保唯一性 // 特殊处理baseIndicator字段确保唯一性
if (field === 'baseIndicator') { if (field === 'baseIndicator') {
// 如果之前为空,现在有值,则视为新的一级指标 // 检查是否有重复的baseIndicator无论是新建还是修改都检查
if (!item.baseIndicator && val) { if (val) {
// 检查是否有重复的baseIndicator // 只要新值不为空
const existingNames = newData.map((d) => d.baseIndicator).filter(Boolean); const existingNames = newData.map((d) => d.baseIndicator).filter(Boolean);
if (existingNames.includes(val)) { const sameNameItems = existingNames.filter((name) => name === val);
// 排除当前项自己
const isDuplicate =
sameNameItems.length > 0 && (item.baseIndicator !== val || sameNameItems.length > 1);
if (isDuplicate) {
// 只做提示,不做自动合并
message.warning( message.warning(
intl.formatMessage({ intl.formatMessage({
id: 'supplierTemplateManage.evaluateTable.message.duplicateName', id: 'supplierTemplateManage.evaluateTable.message.duplicateName',
}), }),
); );
// 禁止合并,直接返回,不做任何数据更改
return; return;
} }
} }
// 更新同组内所有行的一级指标信息 // 原有逻辑:同步更新同组内所有行的一级指标信息
if (item.baseIndicator) { // 现在只允许单独修改当前行的baseIndicator,不再自动合并
const oldName = item.baseIndicator; newData[index] = { ...item, [field]: val };
newData.forEach((row, i) => {
if (row.baseIndicator === oldName) {
newData[i] = { ...row, baseIndicator: val };
}
});
} else {
newData[index] = { ...item, [field]: val };
}
} }
// 处理其他一级指标字段,需要同步到同组的所有行 // 处理其他一级指标字段,需要同步到同组的所有行
else if (['descIndicator', 'stScore', 'indicatorType'].includes(field)) { else if (['descIndicator', 'stScore', 'indicatorType'].includes(field)) {
@ -664,7 +662,8 @@ const EvaluateTemplateTable: React.FC<EvaluateTemplateTableProps> = ({
} }
return false; return false;
}; };
const compShowDelBtnByRecord = useCallback((record: TableRowItem) => { const compShowDelBtnByRecord = useCallback(
(record: TableRowItem) => {
// isFirstDisabled 是否禁用 true false; // isFirstDisabled 是否禁用 true false;
// record.indicatorStEditST 是否可编辑 0是 1否 // record.indicatorStEditST 是否可编辑 0是 1否
// record.id 是否是新增的 有id是新增的 没有id是新增的 // record.id 是否是新增的 有id是新增的 没有id是新增的
@ -676,7 +675,9 @@ const EvaluateTemplateTable: React.FC<EvaluateTemplateTableProps> = ({
// return false; // return false;
// } // }
return true; return true;
}, [isFirstDisabled]); },
[isFirstDisabled],
);
const columns = [ const columns = [
{ {
title: intl.formatMessage({ id: 'supplierTemplateManage.evaluateTable.levelOne' }), title: intl.formatMessage({ id: 'supplierTemplateManage.evaluateTable.levelOne' }),

View File

@ -27,6 +27,7 @@ interface SupplierSelectorProps {
* @property {string} [deptId] - 部门ID * @property {string} [deptId] - 部门ID
* @property {string} [deptName] - 部门名称 * @property {string} [deptName] - 部门名称
* @property {string} [companyName] - 公司名称 * @property {string} [companyName] - 公司名称
* @property {string} [unifiedCode] - 统一社会信用代码
* @property {string} [categoryName] - 所属品类 * @property {string} [categoryName] - 所属品类
* @property {string} [levelName] - 最新评价等级 * @property {string} [levelName] - 最新评价等级
* @property {Date} [admissionTime] - 准入时间 * @property {Date} [admissionTime] - 准入时间
@ -247,12 +248,12 @@ const SupplierSelector: React.FC<SupplierSelectorProps> = ({
}, },
{ {
title: intl.formatMessage({ id: 'supplierTaskManage.column.socialCreditCode' }), title: intl.formatMessage({ id: 'supplierTaskManage.column.socialCreditCode' }),
dataIndex: 'socialCreditCode', dataIndex: 'unifiedCode',
width: 120, width: 120,
ellipsis: true, ellipsis: true,
render: (socialCreditCode: string) => ( render: (unifiedCode: string) => (
<Tooltip placement="topLeft" title={socialCreditCode}> <Tooltip placement="topLeft" title={unifiedCode}>
{socialCreditCode || '-'} {unifiedCode || '-'}
</Tooltip> </Tooltip>
), ),
}, },

View File

@ -4,15 +4,24 @@ import { useState } from "react";
export const useUser = () => { export const useUser = () => {
const [user, setUser] = useState<any>({ const [user, setUser] = useState<any>({
role: 'admin1', // 模拟用户权限 role: 'admin1', // 模拟用户权限
userId: '1234567890',
}); });
const getUserInfo = ()=>{ const getUserInfo = ()=>{
return user; const userInfo = localStorage.getItem('currentUser');
if(userInfo){
setUser(JSON.parse(userInfo));
}
return userInfo || user;
} }
const setUserInfo = (user: any) => { const getUserId = ()=>{
setUser(user); const userId = sessionStorage.getItem('userId');
return userId || user.userId;
}
const setUserInfo = (userInfo: any) => {
setUser(userInfo);
} }
const getUserRole = ()=>{ const getUserRole = ()=>{
return user.role; return user.role;
} }
return { user, getUserInfo, setUserInfo, getUserRole }; return { user, getUserInfo, setUserInfo, getUserRole, getUserId };
}; };

View File

@ -243,8 +243,8 @@ const SupplierEvaluateResultScoreByList: React.FC = () => {
}, },
{ {
title: intl.formatMessage({ id: 'supplierEvaluateResult.column.evaluatorName' }), title: intl.formatMessage({ id: 'supplierEvaluateResult.column.evaluatorName' }),
dataIndex: 'evaluatorName', dataIndex: 'userName',
key: 'evaluatorName', key: 'userName',
width: 120, width: 120,
ellipsis: { ellipsis: {
showTitle: false, showTitle: false,

View File

@ -16,7 +16,7 @@ import { ArrowLeftOutlined, SaveOutlined, ExclamationCircleOutlined } from '@ant
import { getIndicator, saveEvaluateScore } from '@/servers/api/supplierEvaluate'; import { getIndicator, saveEvaluateScore } from '@/servers/api/supplierEvaluate';
import ScoreEvaluationTable from '@/components/ScoreEvaluationTable'; import ScoreEvaluationTable from '@/components/ScoreEvaluationTable';
import styles from './supplierEvaluateScore.less'; import styles from './supplierEvaluateScore.less';
import { useUser } from '@/hooks/useUser';
const { Title } = Typography; const { Title } = Typography;
const { confirm } = Modal; const { confirm } = Modal;
@ -34,7 +34,7 @@ const SupplierEvaluateScoreDetail: React.FC = () => {
const [record, setRecord] = useState<any>(null); const [record, setRecord] = useState<any>(null);
const [mode, setMode] = useState<'view' | 'score'>('view'); // 默认为查看模式 const [mode, setMode] = useState<'view' | 'score'>('view'); // 默认为查看模式
const [recordType, setRecordType] = useState<'supplier' | 'task'>('supplier'); // 默认为供应商类型 const [recordType, setRecordType] = useState<'supplier' | 'task'>('supplier'); // 默认为供应商类型
const { getUserId } = useUser();
// 从路由获取传递的记录 // 从路由获取传递的记录
useEffect(() => { useEffect(() => {
if (location.state?.record) { if (location.state?.record) {
@ -173,6 +173,7 @@ const SupplierEvaluateScoreDetail: React.FC = () => {
// 构建提交数据 // 构建提交数据
const submitData: SupplierEvaluateScore.ScoreSaveRequest = { const submitData: SupplierEvaluateScore.ScoreSaveRequest = {
id: record.id, id: record.id,
userId: getUserId(),
scoreVoList: scoreData.flatMap((item) => { scoreVoList: scoreData.flatMap((item) => {
return item.indicatorNdList.map((subItem: any) => ({ return item.indicatorNdList.map((subItem: any) => ({
id: subItem.id, id: subItem.id,

View File

@ -11,6 +11,7 @@ declare namespace SupplierEvaluateScore {
interface ScoreSaveRequest { interface ScoreSaveRequest {
id: string; id: string;
userId: string;
scoreVoList: { scoreVoList: {
id: string; id: string;
score: number; score: number;