Merge branch 'main' of http://113.45.157.195:3003/raohaotian/train-data
This commit is contained in:
commit
1cdefc79d4
|
@ -1,7 +1,12 @@
|
|||
import { Injectable } from "@nestjs/common";
|
||||
import { TrpcService } from "@server/trpc/trpc.service";
|
||||
import { TrainContentService } from "./trainContent.service";
|
||||
import { z, ZodType } from "zod";
|
||||
import { Prisma } from "@nice/common";
|
||||
|
||||
const TrainContentArgsSchema:ZodType<Prisma.TrainContentCreateArgs> = z.any()
|
||||
const TrainContentUpdateArgsSchema:ZodType<Prisma.TrainContentUpdateArgs> = z.any()
|
||||
const TrainContentFindManyArgsSchema:ZodType<Prisma.TrainContentFindManyArgs> = z.any()
|
||||
@Injectable()
|
||||
export class TrainContentRouter {
|
||||
constructor(
|
||||
|
@ -10,7 +15,18 @@ export class TrainContentRouter {
|
|||
) { }
|
||||
|
||||
router = this.trpc.router({
|
||||
|
||||
create:this.trpc.procedure.input(TrainContentArgsSchema)
|
||||
.mutation(async ({input})=>{
|
||||
return this.trainContentService.create(input)
|
||||
}),
|
||||
update:this.trpc.procedure.input(TrainContentUpdateArgsSchema)
|
||||
.mutation(async ({input})=>{
|
||||
return this.trainContentService.update(input)
|
||||
}),
|
||||
findMany:this.trpc.procedure.input(TrainContentFindManyArgsSchema)
|
||||
.query(async ({input})=>{
|
||||
return this.trainContentService.findMany(input)
|
||||
})
|
||||
})
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import DailyContext from "@web/src/components/models/daily/DailyContext";
|
||||
import DailyLayout from "@web/src/components/models/daily/DailyLayout";
|
||||
import DailyContext from "@web/src/components/models/trainPlan/TrainPlanContext";
|
||||
import DailyLayout from "@web/src/components/models/trainPlan/TrainPlanLayout";
|
||||
|
||||
export default function DailyPage(){
|
||||
return <>
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
import DailyMsgDisplayLayout from "./dailyMsgDisplay/DailyMsgDisplayLayout";
|
||||
import { DailyMsgFormLayout } from "./dailyMsgForm/DailyMsgFormLayout";
|
||||
|
||||
export default function DailyLayout(){
|
||||
return (
|
||||
<div className="w-full h-[calc(100vh-100px)]">
|
||||
<DailyMsgFormLayout></DailyMsgFormLayout>
|
||||
<DailyMsgDisplayLayout></DailyMsgDisplayLayout>
|
||||
</div>
|
||||
)
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
import { Form } from "antd";
|
||||
import StaffSelect from "../../staff/staff-select";
|
||||
import { useDaily } from "../DailyContext";
|
||||
import { useEffect, useState } from "react";
|
||||
import { staffDetailSelect, UserProfile } from "@nice/common";
|
||||
import { api } from "@nice/client";
|
||||
import { MonitorOutlined } from "@ant-design/icons";
|
||||
|
||||
export function DailyMsgFormLayout() {
|
||||
const [form] = Form.useForm()
|
||||
const { staffsMsg ,selectedUserMsg,setSelectedUserMsg} = useDaily()
|
||||
const [selectedUserId, setSelectedUserId] = useState<string | null>(null);
|
||||
const { data: selectedUserData } = api.staff.findUnique.useQuery(
|
||||
{
|
||||
where: {
|
||||
id: selectedUserId,
|
||||
},
|
||||
select: staffDetailSelect
|
||||
},
|
||||
{
|
||||
enabled: !!selectedUserId, // 只有当selectedUserId存在时才执行查询
|
||||
}
|
||||
);
|
||||
const handleChange = (value: string | string[]) => {
|
||||
if (!value) {
|
||||
setSelectedUserId(null);
|
||||
setSelectedUserMsg(null);
|
||||
return;
|
||||
}
|
||||
setSelectedUserId(Array.isArray(value) ? value[0] : value);
|
||||
}
|
||||
useEffect(() => {
|
||||
if (selectedUserData) {
|
||||
console.log(selectedUserData)
|
||||
setSelectedUserMsg(selectedUserData as any as UserProfile);
|
||||
}
|
||||
}, [selectedUserData]);
|
||||
|
||||
return (
|
||||
<div className="w-full h-[260px] bg-white flex flex-col items-center">
|
||||
<Form
|
||||
form={form}
|
||||
>
|
||||
<div className="flex items-center m-8">
|
||||
<MonitorOutlined className="mr-2" />
|
||||
<StaffSelect
|
||||
staffsMsg={staffsMsg}
|
||||
placeholder="请搜索或选择人员"
|
||||
onChange={(value) => handleChange(value)}
|
||||
></StaffSelect>
|
||||
</div>
|
||||
</Form>
|
||||
</div>
|
||||
)
|
||||
}
|
|
@ -1,17 +1,13 @@
|
|||
import { api } from "@nice/client";
|
||||
import { useAuth } from "@web/src/providers/auth-provider";
|
||||
import { UserProfile } from "@nice/common";
|
||||
import { Department, UserProfile } from "@nice/common";
|
||||
import { createContext, ReactNode, useContext, useEffect, useState } from "react";
|
||||
|
||||
interface DailyContextProviderProps{
|
||||
staffsMsg:{
|
||||
id:string,
|
||||
showname:string,
|
||||
username:string
|
||||
}[],
|
||||
staffs:UserProfile[],
|
||||
staffsLoading:boolean,
|
||||
selectedUserMsg:UserProfile,
|
||||
setSelectedUserMsg:(userMsg:UserProfile)=>void
|
||||
depts:Department[],
|
||||
deptsLoading:boolean
|
||||
}
|
||||
|
||||
interface DailyContextProps{
|
||||
|
@ -21,26 +17,24 @@ interface DailyContextProps{
|
|||
const DailyContextProvider = createContext<DailyContextProviderProps>(null)
|
||||
|
||||
export default function DailyContext({children}:DailyContextProps){
|
||||
const {user} = useAuth()
|
||||
const [selectedUserMsg,setSelectedUserMsg] = useState(null)
|
||||
const {user,isAuthenticated} = useAuth()
|
||||
// 获取当前员工的单位下的所有staff的记录
|
||||
const {data:staffs,isLoading:staffsLoading} = api.staff.findByDept.useQuery({
|
||||
const {data:staffs,isLoading:staffsLoading} = isAuthenticated?api.staff.findByDept.useQuery({
|
||||
deptId:user.deptId
|
||||
})
|
||||
const staffsMsg = staffs?.map((staff)=>{
|
||||
return {
|
||||
id:staff.id,
|
||||
showname:staff.showname,
|
||||
username:staff.username
|
||||
}
|
||||
})
|
||||
}):{data:null,isLoading:false}
|
||||
|
||||
const {data:depts,isLoading:deptsLoading} = isAuthenticated?api.department.getChildSimpleTree.useQuery({
|
||||
rootId:user.deptId
|
||||
}):{data:null,isLoading:false}
|
||||
|
||||
useEffect(()=>{
|
||||
console.log(user)
|
||||
},[user])
|
||||
return <DailyContextProvider.Provider value={{
|
||||
staffsMsg,
|
||||
staffs:staffs as any as UserProfile[],
|
||||
staffsLoading,
|
||||
selectedUserMsg,
|
||||
setSelectedUserMsg
|
||||
depts:depts as any as Department[],
|
||||
deptsLoading
|
||||
}}>
|
||||
{children}
|
||||
</DailyContextProvider.Provider>
|
|
@ -1,10 +1,12 @@
|
|||
import { Button, DatePicker, Form, Modal, TimePicker, TreeSelect } from "antd";
|
||||
import { Button, DatePicker, Form, Modal, Select, TimePicker, TreeSelect } from "antd";
|
||||
import TextArea from "antd/es/input/TextArea";
|
||||
import dayjs from "dayjs";
|
||||
import { useState } from "react";
|
||||
export default function DailyMsgDisplayLayout() {
|
||||
import { useState,useEffect } from "react";
|
||||
import { useDaily } from "./TrainPlanContext";
|
||||
export default function TrainPlanCreateForm() {
|
||||
const [form] = Form.useForm()
|
||||
const [open, setOpen] = useState(true)
|
||||
const {depts,deptsLoading} = useDaily()
|
||||
const treeData = [
|
||||
{
|
||||
title: 'Node1',
|
||||
|
@ -25,6 +27,11 @@ export default function DailyMsgDisplayLayout() {
|
|||
value: '0-1',
|
||||
},
|
||||
];
|
||||
useEffect(()=>{
|
||||
if(depts){
|
||||
console.log(depts)
|
||||
}
|
||||
},[depts])
|
||||
const handleSave = () => {
|
||||
//console.log(form.getFieldsValue())
|
||||
const { trainDate, trainTime, trainType, trainContent } = form.getFieldsValue()
|
||||
|
@ -51,6 +58,13 @@ export default function DailyMsgDisplayLayout() {
|
|||
<Form.Item name="trainTime" label="选择时间">
|
||||
<TimePicker.RangePicker format="HH:mm" style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="trainTime" label="选择单位">
|
||||
<Select
|
||||
placeholder="请选择单位"
|
||||
optionFilterProp="label"
|
||||
options={[]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="trainType" label="选择学科">
|
||||
<TreeSelect
|
||||
style={{ width: '100%' }}
|
|
@ -0,0 +1,9 @@
|
|||
import TrainPlanCreateForm from "./TrainPlanCreateForm";
|
||||
|
||||
export default function DailyLayout(){
|
||||
return (
|
||||
<div className="w-full h-[calc(100vh-100px)]">
|
||||
<TrainPlanCreateForm></TrainPlanCreateForm>
|
||||
</div>
|
||||
)
|
||||
}
|
|
@ -342,13 +342,13 @@ model TrainContent {
|
|||
trainSituations TrainSituation[]
|
||||
trainPlans TrainPlan[] @relation("TrainPlanContent")
|
||||
|
||||
type String @map("type")
|
||||
parentId String? @map("parent_id")
|
||||
parent TrainContent? @relation("ContentParent", fields: [parentId], references: [id]) // 指向自身
|
||||
children TrainContent[] @relation("ContentParent") // 指向自身
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
type String @map("type")
|
||||
parentId String? @map("parent_id")
|
||||
parent TrainContent? @relation("ContentParent", fields: [parentId], references: [id]) // 指向自身
|
||||
children TrainContent[] @relation("ContentParent") // 指向自身
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@map("train_content")
|
||||
}
|
||||
|
@ -408,6 +408,8 @@ model Department {
|
|||
deptStaffs Staff[] @relation("DeptStaff")
|
||||
terms Term[] @relation("department_term")
|
||||
|
||||
trainPlans TrainPlan[] @relation("TrainPlanDept")
|
||||
|
||||
// watchedPost Post[] @relation("post_watch_dept")
|
||||
hasChildren Boolean? @default(false) @map("has_children")
|
||||
|
||||
|
@ -467,18 +469,20 @@ model Staff {
|
|||
}
|
||||
|
||||
model TrainPlan {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
|
||||
trainDate DateTime @map("train_date")
|
||||
trainTime DateTime @map("train_time")
|
||||
trainType String @map("train_type")
|
||||
trainContext String @map("train_context")
|
||||
trainDate DateTime @map("train_date")
|
||||
trainTime DateTime @map("train_time")
|
||||
trainType String @map("train_type")
|
||||
trainContext String @map("train_context")
|
||||
|
||||
trainContents TrainContent[] @relation("TrainPlanContent")
|
||||
departmentId String? @map("department_id")
|
||||
department Department? @relation("TrainPlanDept", fields: [departmentId], references: [id])
|
||||
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
|
||||
@@map("train_plan")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue