rht
This commit is contained in:
parent
02aea6ef8b
commit
077767d4e6
|
@ -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>
|
||||||
|
</>
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ export default function NavigationMenu() {
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
{ key: 'home', label: '首页', path: '/' },
|
{ key: 'home', label: '首页', path: '/' },
|
||||||
{ key: 'staff', label: '人员总览', path: '/staff' },
|
{ key: 'staff', label: '人员总览', path: '/staff' },
|
||||||
{ key: 'day', label: '日统计', path: '/day' },
|
{ key: 'day', label: '日统计', path: '/daily' },
|
||||||
{ key: 'month', label: '月统计', path: '/month' },
|
{ key: 'month', label: '月统计', path: '/month' },
|
||||||
{ key: 'year', label: '年度统计', path: '/year' }
|
{ key: 'year', label: '年度统计', path: '/year' }
|
||||||
];
|
];
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -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>
|
||||||
|
)
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
export default function DailyMsgDisplayLayout(){
|
||||||
|
return (
|
||||||
|
<div></div>
|
||||||
|
)
|
||||||
|
}
|
|
@ -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>
|
||||||
|
)
|
||||||
|
}
|
|
@ -9,6 +9,13 @@ interface StaffSelectProps {
|
||||||
multiple?: boolean;
|
multiple?: boolean;
|
||||||
domainId?: string;
|
domainId?: string;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
|
staffsMsg?: StaffsMsgProps[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StaffsMsgProps {
|
||||||
|
id: string;
|
||||||
|
showname: string;
|
||||||
|
username: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function StaffSelect({
|
export default function StaffSelect({
|
||||||
|
@ -18,6 +25,7 @@ export default function StaffSelect({
|
||||||
style,
|
style,
|
||||||
multiple,
|
multiple,
|
||||||
domainId,
|
domainId,
|
||||||
|
staffsMsg,
|
||||||
}: StaffSelectProps) {
|
}: StaffSelectProps) {
|
||||||
const [keyword, setQuery] = useState<string>("");
|
const [keyword, setQuery] = useState<string>("");
|
||||||
|
|
||||||
|
@ -50,7 +58,7 @@ export default function StaffSelect({
|
||||||
|
|
||||||
},
|
},
|
||||||
select: { id: true, showname: true, username: true },
|
select: { id: true, showname: true, username: true },
|
||||||
take: 30,
|
//take: 30,
|
||||||
orderBy: { order: "asc" }
|
orderBy: { order: "asc" }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -59,6 +67,13 @@ export default function StaffSelect({
|
||||||
};
|
};
|
||||||
|
|
||||||
const options: SelectProps["options"] =
|
const options: SelectProps["options"] =
|
||||||
|
staffsMsg ?
|
||||||
|
staffsMsg.map((staff)=>{
|
||||||
|
return {
|
||||||
|
value:staff.id,
|
||||||
|
label:staff.showname || staff.username
|
||||||
|
}
|
||||||
|
}) :
|
||||||
data?.map((staff: any) => ({
|
data?.map((staff: any) => ({
|
||||||
value: staff.id,
|
value: staff.id,
|
||||||
label: staff?.showname || staff?.username,
|
label: staff?.showname || staff?.username,
|
||||||
|
|
|
@ -10,6 +10,7 @@ import LoginPage from "../app/login";
|
||||||
import HomePage from "../app/main/home/page";
|
import HomePage from "../app/main/home/page";
|
||||||
import StaffMessage from "../app/main/staffpage/page";
|
import StaffMessage from "../app/main/staffpage/page";
|
||||||
import MainLayout from "../app/main/layout/MainLayout";
|
import MainLayout from "../app/main/layout/MainLayout";
|
||||||
|
import DailyPage from "../app/main/dailyPage/page";
|
||||||
interface CustomIndexRouteObject extends IndexRouteObject {
|
interface CustomIndexRouteObject extends IndexRouteObject {
|
||||||
name?: string;
|
name?: string;
|
||||||
breadcrumb?: string;
|
breadcrumb?: string;
|
||||||
|
@ -51,6 +52,10 @@ export const routes: CustomRouteObject[] = [
|
||||||
path: "/staff",
|
path: "/staff",
|
||||||
element: <StaffMessage></StaffMessage>,
|
element: <StaffMessage></StaffMessage>,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path:"/daily",
|
||||||
|
element:<DailyPage></DailyPage>
|
||||||
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue