From 8a231c784d2b5af47c26fdb1fbdc23709eaa5bff Mon Sep 17 00:00:00 2001 From: CoderOJ Date: Sun, 25 May 2025 20:57:02 +0800 Subject: [PATCH 1/2] feat(Admin): add spare set assignee --- src/pages/Admin.tsx | 99 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-) diff --git a/src/pages/Admin.tsx b/src/pages/Admin.tsx index 9adb5ac..8313fcb 100644 --- a/src/pages/Admin.tsx +++ b/src/pages/Admin.tsx @@ -4,10 +4,11 @@ import { LinkButton, ResourceLoader, SubmitField, SubmitStatus } from "../lib/co import { ColumnDef, createSolidTable, flexRender, getCoreRowModel, getPaginationRowModel, Table } from "@tanstack/solid-table" import { api, Role, Room, Spare, SpareInitRequest, UserFulls, UserSetResponse } from "../api" import { WeekSelect } from "../lib/WeekSelect" -import { addDays, addWeeks, format, formatISODuration, intervalToDuration, parse } from "date-fns" +import { addDays, addWeeks, format, formatDate, formatISODuration, intervalToDuration, parse } from "date-fns" import { match } from "ts-pattern" -import { Signal } from "../util" +import { Signal, spare_end_time, spare_start_time } from "../util" import { Calendar, SpareDefaultTd } from "../component/Calendar" +import { zhCN } from "date-fns/locale" const TanstackTableContent = (props: { table: Table }) => <> @@ -372,6 +373,96 @@ const SpareManage: Component = () => { ) } +const SpareListManage = () => { + const week = new Signal(new Date()) + const [data] = createResource(week.get, async (week) => ({ + spares: (await api.spare_list({ + type: "Week", + content: format(week, "RRRR-'W'ww"), + })).spares, + users: (await api.users_list({})).users, + })) + + + + const render = ({ spares, users }: { spares: Spare[], users: UserFulls }) => { + const columns: ColumnDef[] = [ + { + header: "琴房号", + cell: ({ row }) => ( + row.original.room + ), + }, + { + header: "日期", + cell: ({ row }) => ( + formatDate(spare_start_time(row.original), "LLLdo EEEE", { locale: zhCN }) + ), + }, + { + header: "开始时间", + cell: ({ row }) => ( + format(spare_start_time(row.original), "H:mm", { locale: zhCN }) + ), + }, + { + header: "结束时间", + cell: ({ row }) => ( + format(spare_end_time(row.original), "H:mm", { locale: zhCN }) + ), + }, + { + header: "预约人", + cell: ({ row }) => ( + + ), + }, + ] + const table = createSolidTable({ + get data() { + return spares + }, + columns, + getCoreRowModel: getCoreRowModel(), + }) + + return ( +
+ + +
+
+ ) + } + + return ( +
+
+ + +
+ +
+ ) +} + export const Admin: Component = () => { return MenuViewer([ { @@ -382,5 +473,9 @@ export const Admin: Component = () => { name: "琴房管理", component: SpareManage, }, + { + name: "琴表管理", + component: SpareListManage, + } ]) } \ No newline at end of file From a01fd78bf369c7f96f9f0265735249caa1425767 Mon Sep 17 00:00:00 2001 From: Early Date: Sun, 25 May 2025 22:11:01 +0800 Subject: [PATCH 2/2] fix(admin): query iso week --- src/pages/Admin.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/Admin.tsx b/src/pages/Admin.tsx index 8313fcb..7ba8498 100644 --- a/src/pages/Admin.tsx +++ b/src/pages/Admin.tsx @@ -378,7 +378,7 @@ const SpareListManage = () => { const [data] = createResource(week.get, async (week) => ({ spares: (await api.spare_list({ type: "Week", - content: format(week, "RRRR-'W'ww"), + content: format(week, "RRRR-'W'II"), })).spares, users: (await api.users_list({})).users, })) @@ -478,4 +478,4 @@ export const Admin: Component = () => { component: SpareListManage, } ]) -} \ No newline at end of file +}