rht
This commit is contained in:
parent
c6fc7d8f24
commit
622aa0358a
|
@ -1,7 +1,7 @@
|
||||||
import { api } from "@nice/client";
|
import { api } from "@nice/client";
|
||||||
import { useAuth } from "@web/src/providers/auth-provider";
|
import { useAuth } from "@web/src/providers/auth-provider";
|
||||||
import { UserProfile } from "@nice/common";
|
import { UserProfile } from "@nice/common";
|
||||||
import { createContext, ReactNode, useContext, useEffect } from "react";
|
import { createContext, ReactNode, useContext, useEffect, useState } from "react";
|
||||||
|
|
||||||
interface DailyContextProviderProps{
|
interface DailyContextProviderProps{
|
||||||
staffsMsg:{
|
staffsMsg:{
|
||||||
|
@ -9,7 +9,9 @@ interface DailyContextProviderProps{
|
||||||
showname:string,
|
showname:string,
|
||||||
username:string
|
username:string
|
||||||
}[],
|
}[],
|
||||||
staffsLoading:boolean
|
staffsLoading:boolean,
|
||||||
|
selectedUserMsg:UserProfile,
|
||||||
|
setSelectedUserMsg:(userMsg:UserProfile)=>void
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DailyContextProps{
|
interface DailyContextProps{
|
||||||
|
@ -20,6 +22,7 @@ const DailyContextProvider = createContext<DailyContextProviderProps>(null)
|
||||||
|
|
||||||
export default function DailyContext({children}:DailyContextProps){
|
export default function DailyContext({children}:DailyContextProps){
|
||||||
const {user} = useAuth()
|
const {user} = useAuth()
|
||||||
|
const [selectedUserMsg,setSelectedUserMsg] = useState(null)
|
||||||
// 获取当前员工的单位下的所有staff的记录
|
// 获取当前员工的单位下的所有staff的记录
|
||||||
const {data:staffs,isLoading:staffsLoading} = api.staff.findByDept.useQuery({
|
const {data:staffs,isLoading:staffsLoading} = api.staff.findByDept.useQuery({
|
||||||
deptId:user.deptId
|
deptId:user.deptId
|
||||||
|
@ -31,9 +34,13 @@ export default function DailyContext({children}:DailyContextProps){
|
||||||
username:staff.username
|
username:staff.username
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
return <DailyContextProvider.Provider value={{
|
return <DailyContextProvider.Provider value={{
|
||||||
staffsMsg,
|
staffsMsg,
|
||||||
staffsLoading,
|
staffsLoading,
|
||||||
|
selectedUserMsg,
|
||||||
|
setSelectedUserMsg
|
||||||
}}>
|
}}>
|
||||||
{children}
|
{children}
|
||||||
</DailyContextProvider.Provider>
|
</DailyContextProvider.Provider>
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
|
import DailyPersonMsg from "../dailyMsgForm/DailyPersonMsg";
|
||||||
|
import DailyTrainMsg from "../dailyMsgForm/DailyTrainMsg";
|
||||||
|
import { useDaily } from "../DailyContext";
|
||||||
export default function DailyMsgDisplayLayout(){
|
export default function DailyMsgDisplayLayout(){
|
||||||
|
const {selectedUserMsg} = useDaily()
|
||||||
return (
|
return (
|
||||||
<div></div>
|
<div>
|
||||||
|
<DailyPersonMsg selectedUserMsg={selectedUserMsg} />
|
||||||
|
<DailyTrainMsg selectedUserMsg={selectedUserMsg} />
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -4,14 +4,11 @@ import { useDaily } from "../DailyContext";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { staffDetailSelect, UserProfile } from "@nice/common";
|
import { staffDetailSelect, UserProfile } from "@nice/common";
|
||||||
import { api } from "@nice/client";
|
import { api } from "@nice/client";
|
||||||
import DailyPersonMsg from "./DailyPersonMsg";
|
|
||||||
import { MonitorOutlined } from "@ant-design/icons";
|
import { MonitorOutlined } from "@ant-design/icons";
|
||||||
import DailyTrainMsg from "./DailyTrainMsg";
|
|
||||||
|
|
||||||
export function DailyMsgFormLayout() {
|
export function DailyMsgFormLayout() {
|
||||||
const [form] = Form.useForm()
|
const [form] = Form.useForm()
|
||||||
const { staffsMsg } = useDaily()
|
const { staffsMsg ,selectedUserMsg,setSelectedUserMsg} = useDaily()
|
||||||
const [selectedUserMsg, setSelectedUserMsg] = useState(null)
|
|
||||||
const [selectedUserId, setSelectedUserId] = useState<string | null>(null);
|
const [selectedUserId, setSelectedUserId] = useState<string | null>(null);
|
||||||
const { data: selectedUserData } = api.staff.findUnique.useQuery(
|
const { data: selectedUserData } = api.staff.findUnique.useQuery(
|
||||||
{
|
{
|
||||||
|
@ -35,7 +32,7 @@ export function DailyMsgFormLayout() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedUserData) {
|
if (selectedUserData) {
|
||||||
console.log(selectedUserData)
|
console.log(selectedUserData)
|
||||||
setSelectedUserMsg(selectedUserData);
|
setSelectedUserMsg(selectedUserData as any as UserProfile);
|
||||||
}
|
}
|
||||||
}, [selectedUserData]);
|
}, [selectedUserData]);
|
||||||
|
|
||||||
|
@ -53,8 +50,6 @@ export function DailyMsgFormLayout() {
|
||||||
></StaffSelect>
|
></StaffSelect>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
<DailyPersonMsg selectedUserMsg={selectedUserMsg} />
|
|
||||||
<DailyTrainMsg />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
export default function DailyTrainMsg() {
|
export default function DailyTrainMsg({selectedUserMsg}) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<span>每日培训消息</span>
|
<span>每日培训消息</span>
|
||||||
|
|
Loading…
Reference in New Issue