This commit is contained in:
Rao 2025-03-12 10:02:41 +08:00
parent 02aea6ef8b
commit 077767d4e6
8 changed files with 117 additions and 2 deletions

View File

@ -0,0 +1,10 @@
import DailyContext from "@web/src/components/models/daily/DailyContext";
import DailyLayout from "@web/src/components/models/daily/DailyLayout";
export default function DailyPage(){
return <>
<DailyContext>
<DailyLayout></DailyLayout>
</DailyContext>
</>
}

View File

@ -7,7 +7,7 @@ export default function NavigationMenu() {
const menuItems = [
{ key: 'home', label: '首页', path: '/' },
{ key: 'staff', label: '人员总览', path: '/staff' },
{ key: 'day', label: '日统计', path: '/day' },
{ key: 'day', label: '日统计', path: '/daily' },
{ key: 'month', label: '月统计', path: '/month' },
{ key: 'year', label: '年度统计', path: '/year' }
];

View File

@ -0,0 +1,46 @@
import { api } from "@nice/client";
import { createContext, ReactNode, useContext, useEffect } from "react";
interface DailyContextProviderProps{
staffsMsg:{
id:string,
showname:string,
username:string
}[],
staffsLoading:boolean
}
interface DailyContextProps{
children:ReactNode
}
const DailyContextProvider = createContext<DailyContextProviderProps>(null)
export default function DailyContext({children}:DailyContextProps){
// 获取当前单位下的所有staff的记录
const {data:staffs,isLoading:staffsLoading} = api.staff.findByDept.useQuery({
deptId:"cm84jt1gv000do5gqsxx68iko"
})
const staffsMsg = staffs?.map((staff)=>{
return {
id:staff.id,
showname:staff.showname,
username:staff.username
}
})
useEffect(()=>{
console.log(staffs)
},[staffs])
return <DailyContextProvider.Provider value={{
staffsMsg,
staffsLoading
}}>
{children}
</DailyContextProvider.Provider>
}
export function useDaily(){
const daily = useContext(DailyContextProvider)
if(!daily) {throw new Error("useParams must be used within a ParamsProvider");}
return daily
}

View File

@ -0,0 +1,11 @@
import DailyMsgDisplayLayout from "./dailyMsgDisplay/DailyMsgDisplayLayout";
import { DailyMsgFormLayout } from "./dailyMsgForm/DailyMsgFormLayout";
export default function DailyLayout(){
return (
<div className="w-full h-full bg-slate-400">
<DailyMsgFormLayout></DailyMsgFormLayout>
<DailyMsgDisplayLayout></DailyMsgDisplayLayout>
</div>
)
}

View File

@ -0,0 +1,5 @@
export default function DailyMsgDisplayLayout(){
return (
<div></div>
)
}

View File

@ -0,0 +1,23 @@
import { Form, QRCode, Select } from "antd";
import StaffSelect from "../../staff/staff-select";
import { useDaily } from "../DailyContext";
export function DailyMsgFormLayout() {
const [form] = Form.useForm()
const { staffsMsg } = useDaily()
const handleChange = (value: string | string[]) => {
console.log(value)
}
return (
<div className="w-full h-[260px] bg-white">
<Form
form={form}
>
<StaffSelect
staffsMsg={staffsMsg}
onChange={(value)=>handleChange(value)}
></StaffSelect>
</Form>
</div>
)
}

View File

@ -9,6 +9,13 @@ interface StaffSelectProps {
multiple?: boolean;
domainId?: string;
placeholder?: string;
staffsMsg?: StaffsMsgProps[];
}
interface StaffsMsgProps {
id: string;
showname: string;
username: string;
}
export default function StaffSelect({
@ -18,6 +25,7 @@ export default function StaffSelect({
style,
multiple,
domainId,
staffsMsg,
}: StaffSelectProps) {
const [keyword, setQuery] = useState<string>("");
@ -50,7 +58,7 @@ export default function StaffSelect({
},
select: { id: true, showname: true, username: true },
take: 30,
//take: 30,
orderBy: { order: "asc" }
});
@ -59,6 +67,13 @@ export default function StaffSelect({
};
const options: SelectProps["options"] =
staffsMsg ?
staffsMsg.map((staff)=>{
return {
value:staff.id,
label:staff.showname || staff.username
}
}) :
data?.map((staff: any) => ({
value: staff.id,
label: staff?.showname || staff?.username,

View File

@ -10,6 +10,7 @@ import LoginPage from "../app/login";
import HomePage from "../app/main/home/page";
import StaffMessage from "../app/main/staffpage/page";
import MainLayout from "../app/main/layout/MainLayout";
import DailyPage from "../app/main/dailyPage/page";
interface CustomIndexRouteObject extends IndexRouteObject {
name?: string;
breadcrumb?: string;
@ -51,6 +52,10 @@ export const routes: CustomRouteObject[] = [
path: "/staff",
element: <StaffMessage></StaffMessage>,
},
{
path:"/daily",
element:<DailyPage></DailyPage>
}
],
},