|
|
|
@ -90,61 +90,95 @@ const ExamListPage = ({ history }: { history: any }) => { |
|
|
|
|
// 批量删除
|
|
|
|
|
const handleDeleteSelected = async () => { |
|
|
|
|
const ids = selectedRows.map((value) => { return String(value) }); |
|
|
|
|
const res = await doDelete(ids); |
|
|
|
|
if (!res) { |
|
|
|
|
if (ids ===null || ids.length === 0) { |
|
|
|
|
message.warning('请选择要删除的考试'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
research(); |
|
|
|
|
Modal.confirm({ |
|
|
|
|
title: '确认删除', |
|
|
|
|
content: '你确定要删除这些选中的考试吗?', |
|
|
|
|
onOk: () => { |
|
|
|
|
const res = doDelete(ids); |
|
|
|
|
if (!res) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
research(); |
|
|
|
|
}, |
|
|
|
|
onCancel: () => { |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 批量撤回
|
|
|
|
|
const handleWithdrawSelected = async () => { |
|
|
|
|
const selectedExams = currentPageExamList.filter(exam => selectedRows.includes(exam.examId)); |
|
|
|
|
const hasWithdrawn = selectedExams.some(exam => exam.publishStatus === 0 || exam.publishStatus === 2); |
|
|
|
|
|
|
|
|
|
if (hasWithdrawn) { |
|
|
|
|
const confirm = window.confirm('选中数据当中有无法撤回的数据,是否继续'); |
|
|
|
|
if (!confirm) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (selectedExams ===null || selectedExams.length === 0) { |
|
|
|
|
message.warning('请选择要撤回的考试'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
Modal.confirm({ |
|
|
|
|
title: '确认撤回', |
|
|
|
|
content: '你确定要撤回这些选中的考试吗?', |
|
|
|
|
onOk: () => { |
|
|
|
|
const hasWithdrawn = selectedExams.some(exam => exam.publishStatus === 0 || exam.publishStatus === 2); |
|
|
|
|
if (hasWithdrawn) { |
|
|
|
|
const confirm = window.confirm('选中数据当中有无法撤回的数据,是否继续'); |
|
|
|
|
if (!confirm) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 筛选出可以撤回的数据
|
|
|
|
|
const validExams = selectedExams.filter(exam => exam.publishStatus === 1); |
|
|
|
|
const validIds = validExams.map(exam => String(exam.examId)); |
|
|
|
|
// 筛选出可以撤回的数据
|
|
|
|
|
const validExams = selectedExams.filter(exam => exam.publishStatus === 1); |
|
|
|
|
const validIds = validExams.map(exam => String(exam.examId)); |
|
|
|
|
|
|
|
|
|
if (validIds.length > 0) { |
|
|
|
|
const res = await doCancel(validIds); |
|
|
|
|
if (!res) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
research(); |
|
|
|
|
} |
|
|
|
|
if (validIds.length > 0) { |
|
|
|
|
const res = doCancel(validIds); |
|
|
|
|
if (!res) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
research(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
onCancel: () => { |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 批量发布
|
|
|
|
|
const handlePublishSelected = async () => { |
|
|
|
|
const selectedExams = currentPageExamList.filter(exam => selectedRows.includes(exam.examId)); |
|
|
|
|
const hasPublishedOrWithdrawn = selectedExams.some(exam => exam.publishStatus === 1 || exam.publishStatus === 2); |
|
|
|
|
|
|
|
|
|
if (hasPublishedOrWithdrawn) { |
|
|
|
|
const confirm = window.confirm('选中数据当中有无法发布的数据,是否继续'); |
|
|
|
|
if (!confirm) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (selectedExams ===null || selectedExams.length === 0) { |
|
|
|
|
message.warning('请选择要发布的考试'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
Modal.confirm({ |
|
|
|
|
title: '确认发布', |
|
|
|
|
content: '你确定要发布这些选中的考试吗?', |
|
|
|
|
onOk: () => { |
|
|
|
|
const hasPublishedOrWithdrawn = selectedExams.some(exam => exam.publishStatus === 1 || exam.publishStatus === 2); |
|
|
|
|
if (hasPublishedOrWithdrawn) { |
|
|
|
|
const confirm = window.confirm('选中数据当中有无法发布的数据,是否继续'); |
|
|
|
|
if (!confirm) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 筛选出可以发布的数据
|
|
|
|
|
const validExams = selectedExams.filter(exam => exam.publishStatus === 0); |
|
|
|
|
const validIds = validExams.map(exam => String(exam.examId)); |
|
|
|
|
// 筛选出可以发布的数据
|
|
|
|
|
const validExams = selectedExams.filter(exam => exam.publishStatus === 0); |
|
|
|
|
const validIds = validExams.map(exam => String(exam.examId)); |
|
|
|
|
|
|
|
|
|
if (validIds.length > 0) { |
|
|
|
|
const res = await doPublish(validIds); |
|
|
|
|
if (!res) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
research(); |
|
|
|
|
} |
|
|
|
|
if (validIds.length > 0) { |
|
|
|
|
const res = doPublish(validIds); |
|
|
|
|
if (!res) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
research(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
onCancel: () => { |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 新增考试
|
|
|
|
@ -179,32 +213,56 @@ const ExamListPage = ({ history }: { history: any }) => { |
|
|
|
|
|
|
|
|
|
// 发布
|
|
|
|
|
const handlePublishSingle = async (examId: number) => { |
|
|
|
|
const ids = [String(examId)]; |
|
|
|
|
const res = await doPublish(ids); |
|
|
|
|
if (!res) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
research(); |
|
|
|
|
Modal.confirm({ |
|
|
|
|
title: '确认发布', |
|
|
|
|
content: '你确定要发布这个考试吗?', |
|
|
|
|
onOk: () => { |
|
|
|
|
const ids = [String(examId)]; |
|
|
|
|
const res = doPublish(ids); |
|
|
|
|
if (!res) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
research(); |
|
|
|
|
}, |
|
|
|
|
onCancel: () => { |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 撤回
|
|
|
|
|
const handleWithdrawSingle = async (examId: number) => { |
|
|
|
|
const ids = [String(examId)]; |
|
|
|
|
const res = await doCancel(ids); |
|
|
|
|
if (!res) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
research(); |
|
|
|
|
Modal.confirm({ |
|
|
|
|
title: '确认撤回', |
|
|
|
|
content: '你确定要撤回这个考试吗?', |
|
|
|
|
onOk: () => { |
|
|
|
|
const ids = [String(examId)]; |
|
|
|
|
const res = doCancel(ids); |
|
|
|
|
if (!res) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
research(); |
|
|
|
|
}, |
|
|
|
|
onCancel: () => { |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 删除
|
|
|
|
|
const handleDeleteSingle = async (examId: number) => { |
|
|
|
|
const ids = [String(examId)]; |
|
|
|
|
const res = await doDelete(ids); |
|
|
|
|
if (!res) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
research(); |
|
|
|
|
Modal.confirm({ |
|
|
|
|
title: '确认删除', |
|
|
|
|
content: '你确定要删除这个考试吗?', |
|
|
|
|
onOk: () => { |
|
|
|
|
const ids = [String(examId)]; |
|
|
|
|
const res = doDelete(ids); |
|
|
|
|
if (!res) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
research(); |
|
|
|
|
}, |
|
|
|
|
onCancel: () => { |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 页面重新查询
|
|
|
|
|