评审结果提交增加防抖
This commit is contained in:
@ -50,11 +50,13 @@ const GroupLeaderModal: React.FC<GroupLeaderModalProps> = ({
|
||||
dispatch,
|
||||
}) => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [suppliers, setSuppliers] = useState<any[]>([]);
|
||||
const [items, setItems] = useState<any[]>([]);
|
||||
const [supplierReviewerMap, setSupplierReviewerMap] = useState<Record<string, string[]>>({});
|
||||
const [groupSummaryResult, setGroupSummaryResult] = useState<{ [k: string]: '0' | '1' | undefined }>({});
|
||||
const [suppliers, setSuppliers] = useState < any[] > ([]);
|
||||
const [items, setItems] = useState < any[] > ([]);
|
||||
const [supplierReviewerMap, setSupplierReviewerMap] = useState < Record < string, string[]>> ({});
|
||||
const [groupSummaryResult, setGroupSummaryResult] = useState < { [k: string]: '0' | '1' | undefined } > ({});
|
||||
const [remarkModal, setRemarkModal] = useState({ open: false, remark: '', file: undefined as any });
|
||||
//提交防抖
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
// 适配新结构
|
||||
useEffect(() => {
|
||||
@ -66,7 +68,7 @@ const GroupLeaderModal: React.FC<GroupLeaderModalProps> = ({
|
||||
setSuppliers(supplierList);
|
||||
|
||||
// ============ 1. 收集所有评审项(itemType==='item') ===========
|
||||
const allItemsSet = new Set<string>();
|
||||
const allItemsSet = new Set < string > ();
|
||||
const allItemsArr: any[] = [];
|
||||
supplierList.forEach((sup: any) => {
|
||||
(sup.coscoAccessUserItemList || []).forEach((u: any) => {
|
||||
@ -81,7 +83,7 @@ const GroupLeaderModal: React.FC<GroupLeaderModalProps> = ({
|
||||
// ============ 2. 组员收集 =============
|
||||
const tempReviewerMap: Record<string, string[]> = {};
|
||||
supplierList.forEach((sup: any) => {
|
||||
const reviewerSet = new Set<string>();
|
||||
const reviewerSet = new Set < string > ();
|
||||
(sup.coscoAccessUserItemList || []).forEach((u: any) => {
|
||||
if (u.itemType === 'item' && u.reviewBy) {
|
||||
reviewerSet.add(u.reviewBy);
|
||||
@ -136,12 +138,20 @@ const GroupLeaderModal: React.FC<GroupLeaderModalProps> = ({
|
||||
return
|
||||
}
|
||||
}
|
||||
update({ coscoAccessUserItemList: summaryParams, accessWorkId }).then((res: any) => {
|
||||
if (res.code === 200) {
|
||||
message.success('提交成功');
|
||||
onSubmit && onSubmit();
|
||||
}
|
||||
});
|
||||
if (submitting) return; // 防重复提交
|
||||
setSubmitting(true);
|
||||
try {
|
||||
update({ coscoAccessUserItemList: summaryParams, accessWorkId }).then((res: any) => {
|
||||
if (res.code === 200) {
|
||||
message.success('提交成功');
|
||||
onSubmit && onSubmit();
|
||||
}
|
||||
});
|
||||
}
|
||||
finally {
|
||||
setSubmitting(false); // 无论成功失败都解锁
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// 构造二级表头
|
||||
@ -270,7 +280,7 @@ const GroupLeaderModal: React.FC<GroupLeaderModalProps> = ({
|
||||
{view ? '关闭' : '取消'}
|
||||
</Button>,
|
||||
!view && (
|
||||
<Button key="submit" type="primary" onClick={handleSubmit}>
|
||||
<Button key="submit" type="primary" onClick={handleSubmit} disabled={submitting}>
|
||||
提交评审结果
|
||||
</Button>
|
||||
)
|
||||
|
@ -8,7 +8,7 @@ import { connect } from 'umi';
|
||||
interface ResultModalProps {
|
||||
visible: boolean;
|
||||
view: boolean;
|
||||
record?: { id?: string; [key: string]: any } | null;
|
||||
record?: { id?: string;[key: string]: any } | null;
|
||||
onCancel: () => void;
|
||||
onSubmit: () => void;
|
||||
dispatch: any;
|
||||
@ -61,19 +61,20 @@ const ResultModal: React.FC<ResultModalProps> = ({
|
||||
onSubmit,
|
||||
dispatch,
|
||||
}) => {
|
||||
const [suppliers, setSuppliers] = useState<any[]>([]);
|
||||
const [items, setItems] = useState<any[]>([]);
|
||||
const [userItemMatrix, setUserItemMatrix] = useState<any[][]>([]);
|
||||
const [cellData, setCellData] = useState<{ [userItemId: string]: CellValue }>({});
|
||||
const [suppliers, setSuppliers] = useState < any[] > ([]);
|
||||
const [items, setItems] = useState < any[] > ([]);
|
||||
const [userItemMatrix, setUserItemMatrix] = useState < any[][] > ([]);
|
||||
const [cellData, setCellData] = useState < { [userItemId: string]: CellValue } > ({});
|
||||
const [loading, setLoading] = useState(false);
|
||||
// 查看备注弹窗
|
||||
const [remarkModal, setRemarkModal] = useState({ open: false, remark: '', file: undefined as any });
|
||||
// 备注弹窗
|
||||
const [remarksModalVisible, setRemarksModalVisible] = useState(false);
|
||||
const [remarks, setRemarks] = useState('');
|
||||
const [fileList, setFileList] = useState<any[]>([]);
|
||||
const [currentUserItemId, setCurrentUserItemId] = useState<string | null>(null);
|
||||
|
||||
const [fileList, setFileList] = useState < any[] > ([]);
|
||||
const [currentUserItemId, setCurrentUserItemId] = useState < string | null > (null);
|
||||
//提交防抖
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
// 拉取并整理表格数据
|
||||
useEffect(() => {
|
||||
if (visible && record?.id) {
|
||||
@ -147,14 +148,14 @@ const ResultModal: React.FC<ResultModalProps> = ({
|
||||
setFileList(
|
||||
cell.file
|
||||
? [
|
||||
{
|
||||
uid: '-1',
|
||||
name: cell.file.fileName,
|
||||
status: 'done',
|
||||
url: cell.file.fileUrl,
|
||||
response: cell.file
|
||||
}
|
||||
]
|
||||
{
|
||||
uid: '-1',
|
||||
name: cell.file.fileName,
|
||||
status: 'done',
|
||||
url: cell.file.fileUrl,
|
||||
response: cell.file
|
||||
}
|
||||
]
|
||||
: []
|
||||
);
|
||||
setRemarksModalVisible(true);
|
||||
@ -207,33 +208,41 @@ const ResultModal: React.FC<ResultModalProps> = ({
|
||||
reviewResult: cellData[userItem.id]?.reviewResult,
|
||||
remark: cellData[userItem.id]?.remark || '',
|
||||
coscoAccessTtemAttachments: cellData[userItem.id]?.file
|
||||
? {
|
||||
? {
|
||||
...cellData[userItem.id]?.file,
|
||||
accessWorkId: userItem.accessWorkId // 补充
|
||||
}
|
||||
: undefined
|
||||
: undefined
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
let accessWorkId = ''
|
||||
if(record?.id) {
|
||||
if (record?.id) {
|
||||
accessWorkId = record?.id
|
||||
}
|
||||
|
||||
for (let index = 0; index < result.length; index++) {
|
||||
if(result[index].reviewResult === null || result[index].reviewResult === undefined) {
|
||||
if (result[index].reviewResult === null || result[index].reviewResult === undefined) {
|
||||
message.warning('有未评审项');
|
||||
return
|
||||
}
|
||||
}
|
||||
// 提交审核
|
||||
update( {coscoAccessUserItemList: result, accessWorkId }).then((res) => {
|
||||
if(res.code == 200) {
|
||||
message.success('提交成功');
|
||||
onSubmit()
|
||||
}
|
||||
})
|
||||
if (submitting) return; // 防重复提交
|
||||
setSubmitting(true);
|
||||
try {
|
||||
// 提交审核
|
||||
update({ coscoAccessUserItemList: result, accessWorkId }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
message.success('提交成功');
|
||||
onSubmit()
|
||||
}
|
||||
})
|
||||
}
|
||||
finally {
|
||||
setSubmitting(false); // 无论成功失败都解锁
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// 组装表头
|
||||
@ -273,21 +282,21 @@ const ResultModal: React.FC<ResultModalProps> = ({
|
||||
<>
|
||||
{view && (
|
||||
<>
|
||||
<span style={{color: v.reviewResult === '0'? '#52c41a': '#f5222d' }}> {v.reviewResult === '0'? '合格': '不合格'}</span>
|
||||
<span style={{ color: v.reviewResult === '0' ? '#52c41a' : '#f5222d' }}> {v.reviewResult === '0' ? '合格' : '不合格'}</span>
|
||||
<Button type="link" size="small" onClick={() =>
|
||||
setRemarkModal({ open: true, remark: v.remark || '', file: v.file })
|
||||
}>查看备注</Button>
|
||||
</>
|
||||
)}
|
||||
{ !view && (
|
||||
{!view && (
|
||||
<div>
|
||||
<Radio.Group
|
||||
value={
|
||||
v.reviewResult === '0'
|
||||
? '合格'
|
||||
: v.reviewResult === '1'
|
||||
? '不合格'
|
||||
: undefined
|
||||
? '不合格'
|
||||
: undefined
|
||||
}
|
||||
onChange={e => handleRadioChange(userItem.id, e.target.value)}
|
||||
>
|
||||
@ -330,7 +339,7 @@ const ResultModal: React.FC<ResultModalProps> = ({
|
||||
{view ? '关闭' : '取消'}
|
||||
</Button>,
|
||||
!view && (
|
||||
<Button key="submit" type="primary" onClick={handleSubmit}>
|
||||
<Button key="submit" type="primary" onClick={handleSubmit} disabled={submitting}>
|
||||
提交评审结果
|
||||
</Button>
|
||||
)
|
||||
|
Reference in New Issue
Block a user