mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-19 12:34:22 +08:00
feat: 积分页支持一键选择全班
This commit is contained in:
@@ -88,6 +88,7 @@ export const ScoreManager: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
||||
const [submitLoading, setSubmitLoading] = useState(false)
|
||||
const [form] = Form.useForm()
|
||||
const [messageApi, contextHolder] = message.useMessage()
|
||||
const selectedStudentNames = Form.useWatch("student_name", form) as string[] | undefined
|
||||
|
||||
const emitDataUpdated = (category: "events" | "students" | "reasons" | "all") => {
|
||||
window.dispatchEvent(new CustomEvent("ss:data-updated", { detail: { category } }))
|
||||
@@ -202,6 +203,17 @@ export const ScoreManager: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleSelectAllStudents = () => {
|
||||
form.setFieldValue(
|
||||
"student_name",
|
||||
students.map((s) => s.name)
|
||||
)
|
||||
}
|
||||
|
||||
const handleClearSelectedStudents = () => {
|
||||
form.setFieldValue("student_name", [])
|
||||
}
|
||||
|
||||
const handleUndo = async (uuid: string) => {
|
||||
if (!(window as any).api) return
|
||||
if (!canEdit) {
|
||||
@@ -265,13 +277,37 @@ export const ScoreManager: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
||||
<Form form={form} layout="vertical" initialValues={{ type: "add" }}>
|
||||
<div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "24px" }}>
|
||||
<Form.Item label={t("score.student")} name="student_name">
|
||||
<Select
|
||||
mode="multiple"
|
||||
showSearch
|
||||
placeholder={t("score.pleaseSelectStudent")}
|
||||
filterOption={(input, option) => matchStudentName(getOptionLabel(option), input)}
|
||||
options={students.map((s) => ({ label: s.name, value: s.name }))}
|
||||
/>
|
||||
<Space direction="vertical" size={8} style={{ width: "100%" }}>
|
||||
<Select
|
||||
mode="multiple"
|
||||
showSearch
|
||||
placeholder={t("score.pleaseSelectStudent")}
|
||||
filterOption={(input, option) => matchStudentName(getOptionLabel(option), input)}
|
||||
options={students.map((s) => ({ label: s.name, value: s.name }))}
|
||||
/>
|
||||
<Space size={8} wrap>
|
||||
<Button
|
||||
size="small"
|
||||
onClick={handleSelectAllStudents}
|
||||
disabled={students.length === 0 || !canEdit}
|
||||
>
|
||||
{t("score.selectAllStudents")}
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
onClick={handleClearSelectedStudents}
|
||||
disabled={!selectedStudentNames || selectedStudentNames.length === 0 || !canEdit}
|
||||
>
|
||||
{t("score.clearSelectedStudents")}
|
||||
</Button>
|
||||
<span style={{ color: "var(--ss-text-secondary)", fontSize: 12 }}>
|
||||
{t("score.selectedCount", {
|
||||
selected: selectedStudentNames?.length ?? 0,
|
||||
total: students.length,
|
||||
})}
|
||||
</span>
|
||||
</Space>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label={t("score.points")}>
|
||||
|
||||
@@ -468,6 +468,9 @@
|
||||
"undoFailed": "Undo failed",
|
||||
"recentRecords": "Recent Records",
|
||||
"pleaseSelectStudent": "Please select or search student",
|
||||
"selectAllStudents": "Whole Class",
|
||||
"clearSelectedStudents": "Clear",
|
||||
"selectedCount": "Selected {{selected}} / {{total}}",
|
||||
"points": "Points",
|
||||
"addPoints": "Add",
|
||||
"deductPoints": "Deduct",
|
||||
|
||||
@@ -468,6 +468,9 @@
|
||||
"undoFailed": "撤销失败",
|
||||
"recentRecords": "最近记录",
|
||||
"pleaseSelectStudent": "请选择或搜索学生",
|
||||
"selectAllStudents": "全班",
|
||||
"clearSelectedStudents": "清空",
|
||||
"selectedCount": "已选 {{selected}} / {{total}} 人",
|
||||
"points": "分数",
|
||||
"addPoints": "加分",
|
||||
"deductPoints": "扣分",
|
||||
|
||||
Reference in New Issue
Block a user