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