模板管理中的指标自动合并bug修复
This commit is contained in:
@ -377,31 +377,29 @@ const EvaluateTemplateTable: React.FC<EvaluateTemplateTableProps> = ({
|
||||
|
||||
// 特殊处理baseIndicator字段,确保唯一性
|
||||
if (field === 'baseIndicator') {
|
||||
// 如果之前为空,现在有值,则视为新的一级指标
|
||||
if (!item.baseIndicator && val) {
|
||||
// 检查是否有重复的baseIndicator
|
||||
// 检查是否有重复的baseIndicator(无论是新建还是修改都检查)
|
||||
if (val) {
|
||||
// 只要新值不为空
|
||||
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(
|
||||
intl.formatMessage({
|
||||
id: 'supplierTemplateManage.evaluateTable.message.duplicateName',
|
||||
}),
|
||||
);
|
||||
// 禁止合并,直接返回,不做任何数据更改
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新同组内所有行的一级指标信息
|
||||
if (item.baseIndicator) {
|
||||
const oldName = item.baseIndicator;
|
||||
newData.forEach((row, i) => {
|
||||
if (row.baseIndicator === oldName) {
|
||||
newData[i] = { ...row, baseIndicator: val };
|
||||
}
|
||||
});
|
||||
} else {
|
||||
newData[index] = { ...item, [field]: val };
|
||||
}
|
||||
// 原有逻辑:同步更新同组内所有行的一级指标信息
|
||||
// 现在只允许单独修改当前行的baseIndicator,不再自动合并
|
||||
newData[index] = { ...item, [field]: val };
|
||||
}
|
||||
// 处理其他一级指标字段,需要同步到同组的所有行
|
||||
else if (['descIndicator', 'stScore', 'indicatorType'].includes(field)) {
|
||||
@ -664,7 +662,8 @@ const EvaluateTemplateTable: React.FC<EvaluateTemplateTableProps> = ({
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const compShowDelBtnByRecord = useCallback((record: TableRowItem) => {
|
||||
const compShowDelBtnByRecord = useCallback(
|
||||
(record: TableRowItem) => {
|
||||
// isFirstDisabled 是否禁用 true false;
|
||||
// record.indicatorStEditST 是否可编辑 0是 1否
|
||||
// record.id 是否是新增的 有id是新增的 没有id是新增的
|
||||
@ -676,7 +675,9 @@ const EvaluateTemplateTable: React.FC<EvaluateTemplateTableProps> = ({
|
||||
// return false;
|
||||
// }
|
||||
return true;
|
||||
}, [isFirstDisabled]);
|
||||
},
|
||||
[isFirstDisabled],
|
||||
);
|
||||
const columns = [
|
||||
{
|
||||
title: intl.formatMessage({ id: 'supplierTemplateManage.evaluateTable.levelOne' }),
|
||||
|
@ -27,6 +27,7 @@ interface SupplierSelectorProps {
|
||||
* @property {string} [deptId] - 部门ID
|
||||
* @property {string} [deptName] - 部门名称
|
||||
* @property {string} [companyName] - 公司名称
|
||||
* @property {string} [unifiedCode] - 统一社会信用代码
|
||||
* @property {string} [categoryName] - 所属品类
|
||||
* @property {string} [levelName] - 最新评价等级
|
||||
* @property {Date} [admissionTime] - 准入时间
|
||||
@ -247,12 +248,12 @@ const SupplierSelector: React.FC<SupplierSelectorProps> = ({
|
||||
},
|
||||
{
|
||||
title: intl.formatMessage({ id: 'supplierTaskManage.column.socialCreditCode' }),
|
||||
dataIndex: 'socialCreditCode',
|
||||
dataIndex: 'unifiedCode',
|
||||
width: 120,
|
||||
ellipsis: true,
|
||||
render: (socialCreditCode: string) => (
|
||||
<Tooltip placement="topLeft" title={socialCreditCode}>
|
||||
{socialCreditCode || '-'}
|
||||
render: (unifiedCode: string) => (
|
||||
<Tooltip placement="topLeft" title={unifiedCode}>
|
||||
{unifiedCode || '-'}
|
||||
</Tooltip>
|
||||
),
|
||||
},
|
||||
|
@ -4,15 +4,24 @@ import { useState } from "react";
|
||||
export const useUser = () => {
|
||||
const [user, setUser] = useState<any>({
|
||||
role: 'admin1', // 模拟用户权限
|
||||
userId: '1234567890',
|
||||
});
|
||||
const getUserInfo = ()=>{
|
||||
return user;
|
||||
const userInfo = localStorage.getItem('currentUser');
|
||||
if(userInfo){
|
||||
setUser(JSON.parse(userInfo));
|
||||
}
|
||||
return userInfo || user;
|
||||
}
|
||||
const setUserInfo = (user: any) => {
|
||||
setUser(user);
|
||||
const getUserId = ()=>{
|
||||
const userId = sessionStorage.getItem('userId');
|
||||
return userId || user.userId;
|
||||
}
|
||||
const setUserInfo = (userInfo: any) => {
|
||||
setUser(userInfo);
|
||||
}
|
||||
const getUserRole = ()=>{
|
||||
return user.role;
|
||||
}
|
||||
return { user, getUserInfo, setUserInfo, getUserRole };
|
||||
};
|
||||
return { user, getUserInfo, setUserInfo, getUserRole, getUserId };
|
||||
};
|
||||
|
@ -243,8 +243,8 @@ const SupplierEvaluateResultScoreByList: React.FC = () => {
|
||||
},
|
||||
{
|
||||
title: intl.formatMessage({ id: 'supplierEvaluateResult.column.evaluatorName' }),
|
||||
dataIndex: 'evaluatorName',
|
||||
key: 'evaluatorName',
|
||||
dataIndex: 'userName',
|
||||
key: 'userName',
|
||||
width: 120,
|
||||
ellipsis: {
|
||||
showTitle: false,
|
||||
|
@ -16,7 +16,7 @@ import { ArrowLeftOutlined, SaveOutlined, ExclamationCircleOutlined } from '@ant
|
||||
import { getIndicator, saveEvaluateScore } from '@/servers/api/supplierEvaluate';
|
||||
import ScoreEvaluationTable from '@/components/ScoreEvaluationTable';
|
||||
import styles from './supplierEvaluateScore.less';
|
||||
|
||||
import { useUser } from '@/hooks/useUser';
|
||||
const { Title } = Typography;
|
||||
const { confirm } = Modal;
|
||||
|
||||
@ -34,7 +34,7 @@ const SupplierEvaluateScoreDetail: React.FC = () => {
|
||||
const [record, setRecord] = useState<any>(null);
|
||||
const [mode, setMode] = useState<'view' | 'score'>('view'); // 默认为查看模式
|
||||
const [recordType, setRecordType] = useState<'supplier' | 'task'>('supplier'); // 默认为供应商类型
|
||||
|
||||
const { getUserId } = useUser();
|
||||
// 从路由获取传递的记录
|
||||
useEffect(() => {
|
||||
if (location.state?.record) {
|
||||
@ -173,6 +173,7 @@ const SupplierEvaluateScoreDetail: React.FC = () => {
|
||||
// 构建提交数据
|
||||
const submitData: SupplierEvaluateScore.ScoreSaveRequest = {
|
||||
id: record.id,
|
||||
userId: getUserId(),
|
||||
scoreVoList: scoreData.flatMap((item) => {
|
||||
return item.indicatorNdList.map((subItem: any) => ({
|
||||
id: subItem.id,
|
||||
|
@ -11,6 +11,7 @@ declare namespace SupplierEvaluateScore {
|
||||
|
||||
interface ScoreSaveRequest {
|
||||
id: string;
|
||||
userId: string;
|
||||
scoreVoList: {
|
||||
id: string;
|
||||
score: number;
|
||||
|
Reference in New Issue
Block a user