fix(/person/report): add /person/report
This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
|||||||
} from "@mantine/core"
|
} from "@mantine/core"
|
||||||
import { useCallback, useEffect, useState } from "react"
|
import { useCallback, useEffect, useState } from "react"
|
||||||
|
|
||||||
export const convertTreeNodeToTreeNodeData = (
|
const convertTreeNodeToTreeNodeData = (
|
||||||
list: TreeNode[],
|
list: TreeNode[],
|
||||||
level: number = 1
|
level: number = 1
|
||||||
): TreeNodeData[] =>
|
): TreeNodeData[] =>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import "@mantine/core/styles.css"
|
import "@mantine/core/styles.css"
|
||||||
import "@mantine/core/styles.layer.css"
|
import "@mantine/core/styles.layer.css"
|
||||||
import "@mantine/notifications/styles.css"
|
import "@mantine/notifications/styles.css"
|
||||||
import "mantine-datatable/styles.layer.css"
|
import "mantine-datatable/styles.css"
|
||||||
import Script from "next/script"
|
import Script from "next/script"
|
||||||
|
|
||||||
import { InfoCheck } from "@/app/store/InfoCheck"
|
import { InfoCheck } from "@/app/store/InfoCheck"
|
||||||
|
|||||||
@@ -1,24 +1,18 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { getPersonProjectDashBoard } from "@/components/label/api/project"
|
import { getPersonProjectDashBoard } from "@/components/label/api/project"
|
||||||
import {
|
import { Project } from "@/components/label/api/project/typing"
|
||||||
Button,
|
import { Button, Group, Text, UnstyledButton } from "@mantine/core"
|
||||||
Group,
|
|
||||||
Pagination,
|
|
||||||
ScrollArea,
|
|
||||||
Select,
|
|
||||||
Table,
|
|
||||||
} from "@mantine/core"
|
|
||||||
|
|
||||||
import { IconRefresh } from "@tabler/icons-react"
|
import { IconRefresh } from "@tabler/icons-react"
|
||||||
import dayjs from "dayjs"
|
import dayjs from "dayjs"
|
||||||
import duration from "dayjs/plugin/duration"
|
import duration from "dayjs/plugin/duration"
|
||||||
|
import { DataTable, DataTableColumn } from "mantine-datatable"
|
||||||
|
import { useRouter } from "next/navigation"
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react"
|
import { useCallback, useEffect, useMemo, useState } from "react"
|
||||||
|
|
||||||
dayjs.extend(duration)
|
dayjs.extend(duration)
|
||||||
|
|
||||||
const pageSizeOptions = [50, 100, 200]
|
|
||||||
|
|
||||||
function formatDurationSeconds(seconds?: number | null) {
|
function formatDurationSeconds(seconds?: number | null) {
|
||||||
const value = seconds ?? 0
|
const value = seconds ?? 0
|
||||||
if (!value) return "-"
|
if (!value) return "-"
|
||||||
@@ -31,11 +25,15 @@ function formatDurationSeconds(seconds?: number | null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function PersonalProjectTable() {
|
export default function PersonalProjectTable() {
|
||||||
const [records, setRecords] = useState<any[]>([])
|
const router = useRouter()
|
||||||
|
const [records, setRecords] = useState<
|
||||||
|
Project.PersonProjectDashboardResponseItem[]
|
||||||
|
>([])
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
|
|
||||||
const [page, setPage] = useState(1)
|
const [page, setPage] = useState(1)
|
||||||
const [pageSize, setPageSize] = useState(50)
|
const [pageSize, setPageSize] = useState(50)
|
||||||
|
const [totalItems, setTotalItems] = useState(0)
|
||||||
|
|
||||||
const totalPages = useMemo(() => {
|
const totalPages = useMemo(() => {
|
||||||
const totalItems = records.length
|
const totalItems = records.length
|
||||||
@@ -52,6 +50,7 @@ export default function PersonalProjectTable() {
|
|||||||
try {
|
try {
|
||||||
const res = await getPersonProjectDashBoard()
|
const res = await getPersonProjectDashBoard()
|
||||||
setRecords(res ?? [])
|
setRecords(res ?? [])
|
||||||
|
setTotalItems(res?.length ?? 0)
|
||||||
setPage(1)
|
setPage(1)
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
@@ -66,13 +65,96 @@ export default function PersonalProjectTable() {
|
|||||||
if (page > totalPages) setPage(totalPages)
|
if (page > totalPages) setPage(totalPages)
|
||||||
}, [page, totalPages])
|
}, [page, totalPages])
|
||||||
|
|
||||||
|
const [currentRowId, setCurrentRowId] = useState<number>(0)
|
||||||
|
|
||||||
|
const originColumn = useMemo(() => {
|
||||||
|
let column: DataTableColumn<Project.PersonProjectDashboardResponseItem>[] =
|
||||||
|
[
|
||||||
|
{
|
||||||
|
accessor: "project_id",
|
||||||
|
title: "项目ID",
|
||||||
|
width: 150,
|
||||||
|
render: (record: Project.PersonProjectDashboardResponseItem) => {
|
||||||
|
return (
|
||||||
|
<UnstyledButton
|
||||||
|
px={6}
|
||||||
|
variant="transparent"
|
||||||
|
onClick={async () => {
|
||||||
|
setCurrentRowId(record.project_id)
|
||||||
|
router.push(`/project/info/detail?id=${record.project_id}`)
|
||||||
|
}}
|
||||||
|
title={record.project_id.toString()}
|
||||||
|
c={"brand"}
|
||||||
|
style={{
|
||||||
|
fontSize: "14px",
|
||||||
|
maxWidth: "100%",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
}}>
|
||||||
|
{record.project_id}
|
||||||
|
</UnstyledButton>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessor: "project_name",
|
||||||
|
title: "项目名称",
|
||||||
|
width: 160,
|
||||||
|
render: (record: Project.PersonProjectDashboardResponseItem) => {
|
||||||
|
return record.project_name ?? "-"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessor: "project_type",
|
||||||
|
title: "所属业务",
|
||||||
|
width: 160,
|
||||||
|
render: (record: Project.PersonProjectDashboardResponseItem) => {
|
||||||
|
return (
|
||||||
|
<Text
|
||||||
|
title={record.project_id.toString()}
|
||||||
|
style={{
|
||||||
|
fontSize: "14px",
|
||||||
|
maxWidth: "100%",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
}}>
|
||||||
|
{record.project_type ?? "-"}
|
||||||
|
</Text>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessor: "work_time",
|
||||||
|
title: "任务耗时",
|
||||||
|
width: 140,
|
||||||
|
render: (record: Project.PersonProjectDashboardResponseItem) => {
|
||||||
|
return formatDurationSeconds(record.work_time)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessor: "project_label_type",
|
||||||
|
title: "标注类别",
|
||||||
|
width: 160,
|
||||||
|
render: (record: Project.PersonProjectDashboardResponseItem) => {
|
||||||
|
return record.project_label_type ?? "-"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
return column
|
||||||
|
}, [router])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group
|
<Group
|
||||||
gap="sm"
|
gap="sm"
|
||||||
h="100%"
|
h="100%"
|
||||||
align="stretch"
|
align="stretch"
|
||||||
style={{ flexDirection: "column" }}>
|
style={{ flexDirection: "column" }}>
|
||||||
<Group justify="flex-end">
|
<Group justify="space-between" align="center">
|
||||||
|
<Text fw={700} fz="lg" style={{ marginBottom: 8 }}>
|
||||||
|
参与项目
|
||||||
|
</Text>
|
||||||
<Button
|
<Button
|
||||||
size={"xs"}
|
size={"xs"}
|
||||||
fz={"sm"}
|
fz={"sm"}
|
||||||
@@ -84,48 +166,38 @@ export default function PersonalProjectTable() {
|
|||||||
更新
|
更新
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
<Group gap={0} align="stretch" style={{ flex: 1, minHeight: 0 }}>
|
<Group
|
||||||
<ScrollArea style={{ flex: 1 }}>
|
gap={0}
|
||||||
<Table withTableBorder withColumnBorders striped highlightOnHover>
|
align="stretch"
|
||||||
<Table.Thead>
|
style={{ flex: 1, minHeight: 0, width: "100%" }}>
|
||||||
<Table.Tr>
|
<DataTable<Project.PersonProjectDashboardResponseItem>
|
||||||
<Table.Th style={{ width: 96 }}>项目ID</Table.Th>
|
width="100%"
|
||||||
<Table.Th style={{ width: 160 }}>项目名称</Table.Th>
|
style={{ width: "100%" }}
|
||||||
<Table.Th style={{ width: 160 }}>所属业务</Table.Th>
|
styles={{
|
||||||
<Table.Th style={{ width: 140 }}>任务耗时</Table.Th>
|
header: {
|
||||||
<Table.Th style={{ width: 160 }}>标注类别</Table.Th>
|
color: "var(--mantine-color-grey-text)",
|
||||||
</Table.Tr>
|
backgroundColor: "var(--mantine-datatable-striped-color)",
|
||||||
</Table.Thead>
|
},
|
||||||
<Table.Tbody>
|
}}
|
||||||
{pageRecords.map((record) => (
|
withTableBorder
|
||||||
<Table.Tr key={record.project_id}>
|
withRowBorders
|
||||||
<Table.Td>{record.project_id ?? "-"}</Table.Td>
|
pinFirstColumn
|
||||||
<Table.Td>{record.project_name ?? "-"}</Table.Td>
|
rowBackgroundColor={(record) => {
|
||||||
<Table.Td>{record.project_type ?? "-"}</Table.Td>
|
if (record.project_id === currentRowId)
|
||||||
<Table.Td>{formatDurationSeconds(record.work_time)}</Table.Td>
|
return "var(--mantine-datatable-highlight-on-hover-color-light, var(--mantine-datatable-highlight-on-hover-color))"
|
||||||
<Table.Td>{record.project_label_type ?? "-"}</Table.Td>
|
}}
|
||||||
</Table.Tr>
|
scrollAreaProps={{ type: "auto" }}
|
||||||
))}
|
records={pageRecords}
|
||||||
</Table.Tbody>
|
onRecordsPerPageChange={setPageSize}
|
||||||
</Table>
|
recordsPerPageOptions={[10, 15, 20]}
|
||||||
</ScrollArea>
|
columns={originColumn}
|
||||||
</Group>
|
totalRecords={totalItems}
|
||||||
<Group justify="space-between">
|
recordsPerPage={pageSize}
|
||||||
<Group gap="xs">
|
page={page}
|
||||||
<Select
|
onPageChange={setPage}
|
||||||
w={120}
|
noRecordsText="暂无数据"
|
||||||
value={String(pageSize)}
|
recordsPerPageLabel="当前页数"
|
||||||
data={pageSizeOptions.map((v) => String(v))}
|
/>
|
||||||
allowDeselect={false}
|
|
||||||
onChange={(value) => {
|
|
||||||
const next = Number(value)
|
|
||||||
if (!Number.isFinite(next)) return
|
|
||||||
setPageSize(next)
|
|
||||||
setPage(1)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Group>
|
|
||||||
<Pagination value={page} onChange={setPage} total={totalPages} />
|
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -167,7 +167,10 @@ export default function PersonalTaskTable() {
|
|||||||
h="100%"
|
h="100%"
|
||||||
align="stretch"
|
align="stretch"
|
||||||
style={{ flexDirection: "column" }}>
|
style={{ flexDirection: "column" }}>
|
||||||
<Group justify="flex-end">
|
<Group justify="space-between" align="center">
|
||||||
|
<Text fw={700} fz="lg" style={{ marginBottom: 8 }}>
|
||||||
|
我的任务
|
||||||
|
</Text>
|
||||||
<Button
|
<Button
|
||||||
size={"xs"}
|
size={"xs"}
|
||||||
fz={"sm"}
|
fz={"sm"}
|
||||||
|
|||||||
@@ -256,9 +256,6 @@ export default function PersonDashboardPage() {
|
|||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
minHeight: 0,
|
minHeight: 0,
|
||||||
}}>
|
}}>
|
||||||
<Text fw={700} fz="lg" style={{ marginBottom: 8 }}>
|
|
||||||
我的任务
|
|
||||||
</Text>
|
|
||||||
<div style={{ flex: 1, minHeight: 0 }}>
|
<div style={{ flex: 1, minHeight: 0 }}>
|
||||||
<PersonalTaskTable />
|
<PersonalTaskTable />
|
||||||
</div>
|
</div>
|
||||||
@@ -274,9 +271,6 @@ export default function PersonDashboardPage() {
|
|||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
minHeight: 0,
|
minHeight: 0,
|
||||||
}}>
|
}}>
|
||||||
<Text fw={700} fz="lg" style={{ marginBottom: 8 }}>
|
|
||||||
参与项目
|
|
||||||
</Text>
|
|
||||||
<div style={{ flex: 1, minHeight: 0 }}>
|
<div style={{ flex: 1, minHeight: 0 }}>
|
||||||
<PersonalProjectTable />
|
<PersonalProjectTable />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
541
app/management/person/report/components/DailyReportModal.tsx
Normal file
541
app/management/person/report/components/DailyReportModal.tsx
Normal file
@@ -0,0 +1,541 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import {
|
||||||
|
addDailyWorkData,
|
||||||
|
editDailyWorkData,
|
||||||
|
} from "@/components/label/api/daily"
|
||||||
|
import { Daily } from "@/components/label/api/daily/typing"
|
||||||
|
import {
|
||||||
|
useAllUserStore,
|
||||||
|
usePermissionStore,
|
||||||
|
} from "@/components/label/store/auth"
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Group,
|
||||||
|
Modal,
|
||||||
|
NumberInput,
|
||||||
|
Select,
|
||||||
|
SimpleGrid,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
TextInput,
|
||||||
|
} from "@mantine/core"
|
||||||
|
import { useForm } from "@mantine/form"
|
||||||
|
import { notifications } from "@mantine/notifications"
|
||||||
|
import { useEffect, useMemo } from "react"
|
||||||
|
import {
|
||||||
|
accountTypeOpts,
|
||||||
|
actualTypeOpts,
|
||||||
|
objTypeOpts,
|
||||||
|
performanceOpts,
|
||||||
|
setTypeOpts,
|
||||||
|
workTypeOpts,
|
||||||
|
} from "../config"
|
||||||
|
|
||||||
|
function normalizeTimeValue(value?: string | null) {
|
||||||
|
if (!value) return ""
|
||||||
|
return value.length >= 5 ? value.slice(0, 5) : value
|
||||||
|
}
|
||||||
|
|
||||||
|
function toTimeWithSeconds(value?: string) {
|
||||||
|
if (!value) return undefined
|
||||||
|
return value.length === 5 ? `${value}:00` : value
|
||||||
|
}
|
||||||
|
|
||||||
|
type LeaderTreeNode = {
|
||||||
|
title?: string
|
||||||
|
value?: string | number
|
||||||
|
children?: LeaderTreeNode[]
|
||||||
|
}
|
||||||
|
|
||||||
|
function flattenLeaderTree(
|
||||||
|
nodes: LeaderTreeNode[],
|
||||||
|
prefixTitle: string[] = []
|
||||||
|
): Array<{ label: string; value: string }> {
|
||||||
|
const result: Array<{ label: string; value: string }> = []
|
||||||
|
|
||||||
|
nodes.forEach((node) => {
|
||||||
|
const title = node.title ?? ""
|
||||||
|
const nextPrefix = title ? [...prefixTitle, title] : prefixTitle
|
||||||
|
const children = node.children ?? []
|
||||||
|
const hasChildren = children.length > 0
|
||||||
|
const valueRaw = node.value
|
||||||
|
|
||||||
|
if (hasChildren) {
|
||||||
|
result.push(...flattenLeaderTree(children, nextPrefix))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valueRaw === undefined || valueRaw === null) return
|
||||||
|
if (typeof valueRaw === "string" && valueRaw.includes("-")) return
|
||||||
|
|
||||||
|
result.push({
|
||||||
|
label: nextPrefix.join(" / "),
|
||||||
|
value: String(valueRaw),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
function HourRightSection() {
|
||||||
|
return (
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
小时(H)
|
||||||
|
</Text>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function DailyReportModal(props: {
|
||||||
|
opened: boolean
|
||||||
|
record: Daily.DailyWorkList | null
|
||||||
|
projectOptions: Array<{ label: string; value: string }>
|
||||||
|
onCloseAction: (refresh?: boolean) => void
|
||||||
|
}) {
|
||||||
|
const { opened, record, onCloseAction, projectOptions } = props
|
||||||
|
|
||||||
|
const user_id = usePermissionStore((s) => s.user_id)
|
||||||
|
const user_name = usePermissionStore((s) => s.user_name)
|
||||||
|
const treeData = useAllUserStore((s) => s.treeData)
|
||||||
|
|
||||||
|
const leaderOptions = useMemo(() => {
|
||||||
|
return flattenLeaderTree(treeData ?? [])
|
||||||
|
}, [treeData])
|
||||||
|
|
||||||
|
const form = useForm({
|
||||||
|
initialValues: {
|
||||||
|
user_name: user_name ?? "",
|
||||||
|
date: "",
|
||||||
|
start_time: "",
|
||||||
|
end_time: "",
|
||||||
|
set_type: "",
|
||||||
|
actual_type: "",
|
||||||
|
project_id: "",
|
||||||
|
leader_uid: "",
|
||||||
|
work_type: "",
|
||||||
|
accounting_type: "",
|
||||||
|
performance_accounting: "",
|
||||||
|
obj_type: "",
|
||||||
|
work_time: undefined as number | undefined,
|
||||||
|
rate: undefined as number | undefined,
|
||||||
|
standard_size: undefined as number | undefined,
|
||||||
|
completed_size: undefined as number | undefined,
|
||||||
|
residual_size: undefined as number | undefined,
|
||||||
|
residual_work_time: undefined as number | undefined,
|
||||||
|
residual_pm: "",
|
||||||
|
remarks: "",
|
||||||
|
},
|
||||||
|
validate: {
|
||||||
|
date: (v) => (v ? null : "请输入日期"),
|
||||||
|
// set_type: (v) => (v ? null : "请选择规定类型"),
|
||||||
|
actual_type: (v) => (v ? null : "请选择出勤类型"),
|
||||||
|
},
|
||||||
|
validateInputOnChange: true,
|
||||||
|
validateInputOnBlur: true,
|
||||||
|
clearInputErrorOnChange: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!opened) return
|
||||||
|
|
||||||
|
if (!record) {
|
||||||
|
form.setValues({
|
||||||
|
user_name: user_name ?? "",
|
||||||
|
date: new Date().toISOString().slice(0, 10),
|
||||||
|
start_time: "",
|
||||||
|
end_time: "",
|
||||||
|
set_type: "",
|
||||||
|
actual_type: "",
|
||||||
|
project_id: "",
|
||||||
|
leader_uid: "",
|
||||||
|
work_type: "",
|
||||||
|
accounting_type: "",
|
||||||
|
performance_accounting: "",
|
||||||
|
obj_type: "",
|
||||||
|
work_time: undefined,
|
||||||
|
rate: undefined,
|
||||||
|
standard_size: undefined,
|
||||||
|
completed_size: undefined,
|
||||||
|
residual_size: undefined,
|
||||||
|
residual_work_time: undefined,
|
||||||
|
residual_pm: "",
|
||||||
|
remarks: "",
|
||||||
|
})
|
||||||
|
form.resetDirty()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
form.setValues({
|
||||||
|
user_name: user_name ?? "",
|
||||||
|
date: record.date ?? "",
|
||||||
|
start_time: normalizeTimeValue(record.start_time),
|
||||||
|
end_time: normalizeTimeValue(record.end_time),
|
||||||
|
set_type: record.set_type ?? "",
|
||||||
|
actual_type: record.actual_type ?? "",
|
||||||
|
project_id:
|
||||||
|
record.project_id === undefined || record.project_id === null
|
||||||
|
? ""
|
||||||
|
: String(record.project_id),
|
||||||
|
leader_uid:
|
||||||
|
record.leader_uid === undefined || record.leader_uid === null
|
||||||
|
? ""
|
||||||
|
: String(record.leader_uid),
|
||||||
|
work_type: record.work_type ?? "",
|
||||||
|
accounting_type: record.accounting_type ?? "",
|
||||||
|
performance_accounting:
|
||||||
|
record.performance_accounting === true
|
||||||
|
? "true"
|
||||||
|
: record.performance_accounting === false
|
||||||
|
? "false"
|
||||||
|
: "",
|
||||||
|
obj_type:
|
||||||
|
record.obj_type === undefined || record.obj_type === null
|
||||||
|
? ""
|
||||||
|
: String(record.obj_type),
|
||||||
|
work_time: record.work_time ?? undefined,
|
||||||
|
rate: record.rate ?? undefined,
|
||||||
|
standard_size: record.standard_size ?? undefined,
|
||||||
|
completed_size: record.completed_size ?? undefined,
|
||||||
|
residual_size: record.residual_size ?? undefined,
|
||||||
|
residual_work_time: record.residual_work_time ?? undefined,
|
||||||
|
residual_pm:
|
||||||
|
record.residual_pm === true
|
||||||
|
? "正"
|
||||||
|
: record.residual_pm === false
|
||||||
|
? "负"
|
||||||
|
: "",
|
||||||
|
remarks: record.remarks ?? "",
|
||||||
|
})
|
||||||
|
form.resetDirty()
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [opened, record, user_name])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const workTime = form.values.work_time
|
||||||
|
const rate = form.values.rate
|
||||||
|
if (workTime !== undefined && rate !== undefined) {
|
||||||
|
form.setFieldValue("standard_size", Number((workTime * rate).toFixed(1)))
|
||||||
|
} else {
|
||||||
|
form.setFieldValue("standard_size", undefined)
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const standardSize = form.values.standard_size
|
||||||
|
const completedSize = form.values.completed_size
|
||||||
|
const workTime = form.values.work_time
|
||||||
|
|
||||||
|
if (
|
||||||
|
standardSize !== undefined &&
|
||||||
|
completedSize !== undefined &&
|
||||||
|
workTime !== undefined &&
|
||||||
|
standardSize !== 0
|
||||||
|
) {
|
||||||
|
const residualSize = completedSize - standardSize
|
||||||
|
const residualWorkTime = Number(
|
||||||
|
((residualSize / standardSize) * workTime).toFixed(1)
|
||||||
|
)
|
||||||
|
form.setFieldValue("residual_size", Number(residualSize.toFixed(1)))
|
||||||
|
form.setFieldValue("residual_work_time", residualWorkTime)
|
||||||
|
form.setFieldValue("residual_pm", residualSize >= 0 ? "正" : "负")
|
||||||
|
} else {
|
||||||
|
form.setFieldValue("residual_size", undefined)
|
||||||
|
form.setFieldValue("residual_work_time", undefined)
|
||||||
|
form.setFieldValue("residual_pm", "")
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const handleSubmit = form.onSubmit(async (values) => {
|
||||||
|
const uid = typeof user_id === "number" ? user_id : Number(user_id ?? 0)
|
||||||
|
if (!uid) {
|
||||||
|
notifications.show({
|
||||||
|
color: "red",
|
||||||
|
title: "提交失败",
|
||||||
|
message: "未获取到用户信息",
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const params: Daily.CreateProps = {
|
||||||
|
uid,
|
||||||
|
date: values.date,
|
||||||
|
start_time: toTimeWithSeconds(values.start_time),
|
||||||
|
end_time: toTimeWithSeconds(values.end_time),
|
||||||
|
set_type: values.set_type,
|
||||||
|
actual_type: values.actual_type,
|
||||||
|
project_id: values.project_id ? Number(values.project_id) : undefined,
|
||||||
|
leader_uid: values.leader_uid ? Number(values.leader_uid) : undefined,
|
||||||
|
work_type: values.work_type || undefined,
|
||||||
|
accounting_type: values.accounting_type || undefined,
|
||||||
|
performance_accounting:
|
||||||
|
values.performance_accounting === "true"
|
||||||
|
? true
|
||||||
|
: values.performance_accounting === "false"
|
||||||
|
? false
|
||||||
|
: undefined,
|
||||||
|
obj_type: values.obj_type ? Number(values.obj_type) : undefined,
|
||||||
|
work_time: values.work_time,
|
||||||
|
rate: values.rate,
|
||||||
|
standard_size: values.standard_size,
|
||||||
|
completed_size: values.completed_size,
|
||||||
|
residual_size: values.residual_size,
|
||||||
|
residual_work_time: values.residual_work_time,
|
||||||
|
residual_pm:
|
||||||
|
values.residual_pm === "正"
|
||||||
|
? true
|
||||||
|
: values.residual_pm === "负"
|
||||||
|
? false
|
||||||
|
: undefined,
|
||||||
|
remarks: values.remarks || undefined,
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (record?.id) {
|
||||||
|
await editDailyWorkData(params, record.id)
|
||||||
|
notifications.show({
|
||||||
|
color: "green",
|
||||||
|
title: "操作成功",
|
||||||
|
message: "已更新日报",
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
await addDailyWorkData(params)
|
||||||
|
notifications.show({
|
||||||
|
color: "green",
|
||||||
|
title: "操作成功",
|
||||||
|
message: "已提交日报",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
onCloseAction(true)
|
||||||
|
form.reset()
|
||||||
|
} catch (e) {
|
||||||
|
notifications.show({
|
||||||
|
color: "red",
|
||||||
|
title: "操作失败",
|
||||||
|
message: e instanceof Error ? e.message : "请求失败",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
opened={opened}
|
||||||
|
onClose={() => {
|
||||||
|
form.reset()
|
||||||
|
onCloseAction()
|
||||||
|
}}
|
||||||
|
title={record ? "编辑日报" : "填写日报"}
|
||||||
|
size={840}
|
||||||
|
centered
|
||||||
|
closeOnClickOutside={false}>
|
||||||
|
<form onSubmit={handleSubmit}>
|
||||||
|
<Stack gap="sm">
|
||||||
|
<SimpleGrid cols={{ base: 1, sm: 3 }} spacing="sm">
|
||||||
|
<TextInput
|
||||||
|
label="姓名"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
value={form.values.user_name}
|
||||||
|
readOnly
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label="日期"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
type="date"
|
||||||
|
withAsterisk
|
||||||
|
{...form.getInputProps("date")}
|
||||||
|
/>
|
||||||
|
<div />
|
||||||
|
|
||||||
|
<TextInput
|
||||||
|
label="开始时间"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
type="time"
|
||||||
|
{...form.getInputProps("start_time")}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label="结束时间"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
type="time"
|
||||||
|
{...form.getInputProps("end_time")}
|
||||||
|
/>
|
||||||
|
<div />
|
||||||
|
|
||||||
|
<Select
|
||||||
|
label="规定类型"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
withAsterisk
|
||||||
|
data={setTypeOpts}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
{...form.getInputProps("set_type")}
|
||||||
|
/>
|
||||||
|
<Select
|
||||||
|
label="出勤类型"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
withAsterisk
|
||||||
|
data={actualTypeOpts}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
{...form.getInputProps("actual_type")}
|
||||||
|
/>
|
||||||
|
<div />
|
||||||
|
|
||||||
|
<Select
|
||||||
|
label="项目名称"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
data={projectOptions}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
{...form.getInputProps("project_id")}
|
||||||
|
/>
|
||||||
|
<Select
|
||||||
|
label="任务组长"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
data={leaderOptions}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
{...form.getInputProps("leader_uid")}
|
||||||
|
/>
|
||||||
|
<Select
|
||||||
|
label="工作类别"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
data={workTypeOpts}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
{...form.getInputProps("work_type")}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Select
|
||||||
|
label="对象类型"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
data={objTypeOpts}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
{...form.getInputProps("obj_type")}
|
||||||
|
/>
|
||||||
|
<Select
|
||||||
|
label="绩效核算"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
data={performanceOpts}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
{...form.getInputProps("performance_accounting")}
|
||||||
|
/>
|
||||||
|
<Select
|
||||||
|
label="核算方式"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
data={accountTypeOpts}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
{...form.getInputProps("accounting_type")}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<NumberInput
|
||||||
|
label="工时"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
min={0}
|
||||||
|
decimalScale={1}
|
||||||
|
allowNegative={false}
|
||||||
|
hideControls
|
||||||
|
rightSection={<HourRightSection />}
|
||||||
|
rightSectionWidth={78}
|
||||||
|
{...form.getInputProps("work_time")}
|
||||||
|
/>
|
||||||
|
<NumberInput
|
||||||
|
label="额定倍速"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
min={0}
|
||||||
|
allowNegative={false}
|
||||||
|
hideControls
|
||||||
|
{...form.getInputProps("rate")}
|
||||||
|
/>
|
||||||
|
<div />
|
||||||
|
|
||||||
|
<NumberInput
|
||||||
|
label="标准量"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
value={form.values.standard_size}
|
||||||
|
readOnly
|
||||||
|
hideControls
|
||||||
|
/>
|
||||||
|
<NumberInput
|
||||||
|
label="完成量"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
min={0}
|
||||||
|
allowNegative={false}
|
||||||
|
hideControls
|
||||||
|
{...form.getInputProps("completed_size")}
|
||||||
|
/>
|
||||||
|
<div />
|
||||||
|
|
||||||
|
<NumberInput
|
||||||
|
label="余量"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
value={form.values.residual_size}
|
||||||
|
readOnly
|
||||||
|
hideControls
|
||||||
|
/>
|
||||||
|
<NumberInput
|
||||||
|
label="余量工时"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
value={form.values.residual_work_time}
|
||||||
|
readOnly
|
||||||
|
hideControls
|
||||||
|
rightSection={<HourRightSection />}
|
||||||
|
rightSectionWidth={78}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label="余量正负"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
value={form.values.residual_pm}
|
||||||
|
readOnly
|
||||||
|
/>
|
||||||
|
</SimpleGrid>
|
||||||
|
|
||||||
|
<TextInput
|
||||||
|
label="备注"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
{...form.getInputProps("remarks")}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Group justify="flex-end" gap="sm">
|
||||||
|
<Button
|
||||||
|
variant="default"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
onClick={() => {
|
||||||
|
form.reset()
|
||||||
|
onCloseAction()
|
||||||
|
}}>
|
||||||
|
取消
|
||||||
|
</Button>
|
||||||
|
<Button size="xs" radius="xs" type="submit">
|
||||||
|
提交
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</form>
|
||||||
|
</Modal>
|
||||||
|
)
|
||||||
|
}
|
||||||
69
app/management/person/report/config.ts
Normal file
69
app/management/person/report/config.ts
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
export const setTypeOpts = [
|
||||||
|
{ label: "出勤", value: "出勤" },
|
||||||
|
{ label: "周末休", value: "周末休" },
|
||||||
|
{ label: "节假休", value: "节假休" },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const actualTypeOpts = [
|
||||||
|
{ label: "出勤", value: "出勤" },
|
||||||
|
{ label: "周末休", value: "周末休" },
|
||||||
|
{ label: "节假休", value: "节假休" },
|
||||||
|
{ label: "调休", value: "调休" },
|
||||||
|
{ label: "补勤", value: "补勤" },
|
||||||
|
{ label: "增勤", value: "增勤" },
|
||||||
|
{ label: "年假", value: "年假" },
|
||||||
|
{ label: "事假", value: "事假" },
|
||||||
|
{ label: "病假", value: "病假" },
|
||||||
|
{ label: "婚假", value: "婚假" },
|
||||||
|
{ label: "产假", value: "产假" },
|
||||||
|
{ label: "陪产假", value: "陪产假" },
|
||||||
|
{ label: "丧假", value: "丧假" },
|
||||||
|
{ label: "其他", value: "其他" },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const workTypeOpts = [
|
||||||
|
{ label: "标注", value: "标注" },
|
||||||
|
{ label: "审核", value: "审核" },
|
||||||
|
{ label: "复审", value: "复审" },
|
||||||
|
{ label: "标注返工", value: "标注返工" },
|
||||||
|
{ label: "审核返工", value: "审核返工" },
|
||||||
|
{ label: "复审返工", value: "复审返工" },
|
||||||
|
{ label: "管理", value: "管理" },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const accountTypeOpts = [
|
||||||
|
{ label: "对象核算", value: "对象核算" },
|
||||||
|
{ label: "素材核算", value: "素材核算" },
|
||||||
|
{ label: "会议", value: "会议" },
|
||||||
|
{ label: "培训", value: "培训" },
|
||||||
|
{ label: "项目管理", value: "项目管理" },
|
||||||
|
{ label: "出差", value: "出差" },
|
||||||
|
{ label: "断电", value: "断电" },
|
||||||
|
{ label: "网络故障", value: "网络故障" },
|
||||||
|
{ label: "平台故障", value: "平台故障" },
|
||||||
|
{ label: "支援行政", value: "支援行政" },
|
||||||
|
{ label: "公司活动", value: "公司活动" },
|
||||||
|
{ label: "请假", value: "请假" },
|
||||||
|
{ label: "其他", value: "其他" },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const performanceOpts = [
|
||||||
|
{ label: "是", value: "true" },
|
||||||
|
{ label: "否", value: "false" },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const objTypeOpts = [
|
||||||
|
{ label: "静态", value: "0" },
|
||||||
|
{ label: "动态", value: "1" },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const performanceTextMap = new Map<boolean, string>([
|
||||||
|
[true, "是"],
|
||||||
|
[false, "否"],
|
||||||
|
])
|
||||||
|
|
||||||
|
export const objTypeTextMap = new Map<number, string>([
|
||||||
|
[0, "静态"],
|
||||||
|
[1, "动态"],
|
||||||
|
])
|
||||||
|
|
||||||
706
app/management/person/report/page.tsx
Normal file
706
app/management/person/report/page.tsx
Normal file
@@ -0,0 +1,706 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import {
|
||||||
|
deleteDailyWorkData,
|
||||||
|
getDailyWorkList,
|
||||||
|
} from "@/components/label/api/daily"
|
||||||
|
import { Daily } from "@/components/label/api/daily/typing"
|
||||||
|
import { getSelfProjectList } from "@/components/label/api/project"
|
||||||
|
import { useAllUserStore } from "@/components/label/store/auth"
|
||||||
|
import {
|
||||||
|
ActionIcon,
|
||||||
|
Badge,
|
||||||
|
Button,
|
||||||
|
Collapse,
|
||||||
|
Flex,
|
||||||
|
Group,
|
||||||
|
MultiSelect,
|
||||||
|
Paper,
|
||||||
|
SimpleGrid,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
TextInput,
|
||||||
|
} from "@mantine/core"
|
||||||
|
import { modals } from "@mantine/modals"
|
||||||
|
import { notifications } from "@mantine/notifications"
|
||||||
|
import {
|
||||||
|
IconChevronDown,
|
||||||
|
IconChevronUp,
|
||||||
|
IconPencil,
|
||||||
|
IconPlus,
|
||||||
|
IconRefresh,
|
||||||
|
IconSearch,
|
||||||
|
IconTrash,
|
||||||
|
} from "@tabler/icons-react"
|
||||||
|
|
||||||
|
import dayjs from "dayjs"
|
||||||
|
import {
|
||||||
|
DataTable,
|
||||||
|
DataTableColumn,
|
||||||
|
DataTableSortStatus,
|
||||||
|
} from "mantine-datatable"
|
||||||
|
import { useCallback, useEffect, useMemo, useState } from "react"
|
||||||
|
import DailyReportModal from "./components/DailyReportModal"
|
||||||
|
import {
|
||||||
|
accountTypeOpts,
|
||||||
|
actualTypeOpts,
|
||||||
|
objTypeOpts,
|
||||||
|
objTypeTextMap,
|
||||||
|
performanceOpts,
|
||||||
|
performanceTextMap,
|
||||||
|
setTypeOpts,
|
||||||
|
workTypeOpts,
|
||||||
|
} from "./config"
|
||||||
|
|
||||||
|
type LeaderTreeNode = {
|
||||||
|
title?: string
|
||||||
|
value?: string | number
|
||||||
|
children?: LeaderTreeNode[]
|
||||||
|
}
|
||||||
|
|
||||||
|
function flattenLeaderTree(
|
||||||
|
nodes: LeaderTreeNode[],
|
||||||
|
prefixTitle: string[] = []
|
||||||
|
): Array<{ label: string; value: string }> {
|
||||||
|
const result: Array<{ label: string; value: string }> = []
|
||||||
|
|
||||||
|
nodes.forEach((node) => {
|
||||||
|
const title = node.title ?? ""
|
||||||
|
const nextPrefix = title ? [...prefixTitle, title] : prefixTitle
|
||||||
|
const children = node.children ?? []
|
||||||
|
const hasChildren = children.length > 0
|
||||||
|
const valueRaw = node.value
|
||||||
|
|
||||||
|
if (hasChildren) {
|
||||||
|
result.push(...flattenLeaderTree(children, nextPrefix))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valueRaw === undefined || valueRaw === null) return
|
||||||
|
if (typeof valueRaw === "string" && valueRaw.includes("-")) return
|
||||||
|
|
||||||
|
result.push({
|
||||||
|
label: nextPrefix.join(" / "),
|
||||||
|
value: String(valueRaw),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
function weekDayText(day: number) {
|
||||||
|
const list = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]
|
||||||
|
return list[day] ?? "-"
|
||||||
|
}
|
||||||
|
|
||||||
|
function toBoolean(value?: string) {
|
||||||
|
if (value === "true") return true
|
||||||
|
if (value === "false") return false
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
function toNumber(value?: string) {
|
||||||
|
if (!value) return undefined
|
||||||
|
const n = Number(value)
|
||||||
|
return Number.isFinite(n) ? n : undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function PersonReportPage() {
|
||||||
|
const treeData = useAllUserStore((s) => s.treeData)
|
||||||
|
|
||||||
|
const leaderOptions = useMemo(() => {
|
||||||
|
return flattenLeaderTree(treeData ?? [])
|
||||||
|
}, [treeData])
|
||||||
|
|
||||||
|
const defaultFilters = useMemo(() => {
|
||||||
|
return {
|
||||||
|
date_start: dayjs().subtract(6, "day").format("YYYY-MM-DD"),
|
||||||
|
date_end: dayjs().format("YYYY-MM-DD"),
|
||||||
|
set_type: "",
|
||||||
|
actual_type: "",
|
||||||
|
leader_uid: [] as string[],
|
||||||
|
work_type: "",
|
||||||
|
accounting_type: "",
|
||||||
|
project_id: [] as string[],
|
||||||
|
performance_accounting: "",
|
||||||
|
obj_type: "",
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const [projectOptions, setProjectOptions] = useState<
|
||||||
|
Array<{ label: string; value: string }>
|
||||||
|
>([])
|
||||||
|
|
||||||
|
const [filters, setFilters] = useState(defaultFilters)
|
||||||
|
const [appliedFilters, setAppliedFilters] = useState(defaultFilters)
|
||||||
|
const [queryTrigger, setQueryTrigger] = useState(0)
|
||||||
|
|
||||||
|
const [page, setPage] = useState(1)
|
||||||
|
const [pageSize, setPageSize] = useState(20)
|
||||||
|
const [totalItems, setTotalItems] = useState(0)
|
||||||
|
const [loading, setLoading] = useState(false)
|
||||||
|
const [records, setRecords] = useState<Daily.DailyWorkList[]>([])
|
||||||
|
const [summary, setSummary] = useState<Daily.Summary | null>(null)
|
||||||
|
|
||||||
|
const [sortStatus, setSortStatus] = useState<DataTableSortStatus>({
|
||||||
|
columnAccessor: "id",
|
||||||
|
direction: "desc",
|
||||||
|
})
|
||||||
|
|
||||||
|
const [modalOpened, setModalOpened] = useState(false)
|
||||||
|
const [editingRecord, setEditingRecord] =
|
||||||
|
useState<Daily.DailyWorkList | null>(null)
|
||||||
|
|
||||||
|
const [searchExpanded, setSearchExpanded] = useState(false)
|
||||||
|
|
||||||
|
const queryParams = useMemo(() => {
|
||||||
|
const params: Daily.Request = {
|
||||||
|
page_number: page,
|
||||||
|
page_size: pageSize,
|
||||||
|
flag: 0,
|
||||||
|
date_start: appliedFilters.date_start || undefined,
|
||||||
|
date_end: appliedFilters.date_end || undefined,
|
||||||
|
set_type: appliedFilters.set_type || undefined,
|
||||||
|
actual_type: appliedFilters.actual_type || undefined,
|
||||||
|
leader_uid: appliedFilters.leader_uid.length
|
||||||
|
? appliedFilters.leader_uid
|
||||||
|
.map((v) => Number(v))
|
||||||
|
.filter((v) => Number.isFinite(v))
|
||||||
|
: undefined,
|
||||||
|
work_type: appliedFilters.work_type || undefined,
|
||||||
|
accounting_type: appliedFilters.accounting_type || undefined,
|
||||||
|
project_id: appliedFilters.project_id.length
|
||||||
|
? appliedFilters.project_id
|
||||||
|
.map((v) => Number(v))
|
||||||
|
.filter((v) => Number.isFinite(v))
|
||||||
|
: undefined,
|
||||||
|
performance_accounting: toBoolean(appliedFilters.performance_accounting),
|
||||||
|
obj_type: toNumber(appliedFilters.obj_type),
|
||||||
|
order_by: `${sortStatus.columnAccessor} ${sortStatus.direction}`,
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.keys(params).forEach((k) => {
|
||||||
|
const key = k as keyof Daily.Request
|
||||||
|
const value = params[key]
|
||||||
|
if (value === "" || value === null) delete params[key]
|
||||||
|
if (Array.isArray(value) && value.length === 0) delete params[key]
|
||||||
|
if (value !== 0 && value !== false && value !== "" && !value)
|
||||||
|
delete params[key]
|
||||||
|
})
|
||||||
|
|
||||||
|
return params
|
||||||
|
}, [
|
||||||
|
appliedFilters,
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
sortStatus.columnAccessor,
|
||||||
|
sortStatus.direction,
|
||||||
|
])
|
||||||
|
|
||||||
|
const load = useCallback(async () => {
|
||||||
|
if (!queryTrigger) return
|
||||||
|
setLoading(true)
|
||||||
|
try {
|
||||||
|
const res = await getDailyWorkList(queryParams)
|
||||||
|
setRecords(res?.daily_work_list ?? [])
|
||||||
|
setTotalItems(res?.total_items ?? 0)
|
||||||
|
setSummary(res?.total_summary ?? null)
|
||||||
|
} catch (e) {
|
||||||
|
setRecords([])
|
||||||
|
setTotalItems(0)
|
||||||
|
setSummary(null)
|
||||||
|
notifications.show({
|
||||||
|
color: "red",
|
||||||
|
title: "加载失败",
|
||||||
|
message: e instanceof Error ? e.message : "请求失败",
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
|
}
|
||||||
|
}, [queryParams, queryTrigger])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
load()
|
||||||
|
}, [load])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
queueMicrotask(() => {
|
||||||
|
setQueryTrigger((v) => v + 1)
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const columns = useMemo(() => {
|
||||||
|
const cols: DataTableColumn<Daily.DailyWorkList>[] = [
|
||||||
|
{ accessor: "id", title: "ID", width: 80, sortable: true },
|
||||||
|
{
|
||||||
|
accessor: "date",
|
||||||
|
title: "日期",
|
||||||
|
width: 120,
|
||||||
|
sortable: true,
|
||||||
|
render: (record) => record.date ?? "-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessor: "week",
|
||||||
|
title: "星期",
|
||||||
|
width: 90,
|
||||||
|
render: (record) =>
|
||||||
|
record.date ? weekDayText(dayjs(record.date).day()) : "-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessor: "set_type",
|
||||||
|
title: "规定类型",
|
||||||
|
width: 120,
|
||||||
|
render: (record) => record.set_type ?? "-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessor: "actual_type",
|
||||||
|
title: "实际类型",
|
||||||
|
width: 120,
|
||||||
|
render: (record) => record.actual_type ?? "-",
|
||||||
|
},
|
||||||
|
{ accessor: "leader_name", title: "任务组长", width: 120 },
|
||||||
|
{ accessor: "work_type", title: "工作类别", width: 140 },
|
||||||
|
{ accessor: "accounting_type", title: "核算方式", width: 140 },
|
||||||
|
{
|
||||||
|
accessor: "project_name",
|
||||||
|
title: "项目名称",
|
||||||
|
width: 220,
|
||||||
|
render: (record) => (
|
||||||
|
<Text
|
||||||
|
size="sm"
|
||||||
|
style={{
|
||||||
|
maxWidth: 220,
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
}}>
|
||||||
|
{record.project_name ?? "-"}
|
||||||
|
</Text>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessor: "performance_accounting",
|
||||||
|
title: "绩效核算",
|
||||||
|
width: 110,
|
||||||
|
render: (record) => {
|
||||||
|
if (record.performance_accounting === true)
|
||||||
|
return <Badge color="green">{performanceTextMap.get(true)}</Badge>
|
||||||
|
if (record.performance_accounting === false)
|
||||||
|
return <Badge color="gray">{performanceTextMap.get(false)}</Badge>
|
||||||
|
return "-"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessor: "obj_type",
|
||||||
|
title: "对象类型",
|
||||||
|
width: 100,
|
||||||
|
render: (record) => {
|
||||||
|
if (record.obj_type === 0 || record.obj_type === 1)
|
||||||
|
return objTypeTextMap.get(record.obj_type) ?? "-"
|
||||||
|
return "-"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ accessor: "start_time", title: "开始时间", width: 120 },
|
||||||
|
{ accessor: "end_time", title: "结束时间", width: 120 },
|
||||||
|
{
|
||||||
|
accessor: "work_time",
|
||||||
|
title: "工时",
|
||||||
|
width: 90,
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{ accessor: "rate", title: "额定倍率", width: 90 },
|
||||||
|
{
|
||||||
|
accessor: "standard_size",
|
||||||
|
title: "标准量",
|
||||||
|
width: 90,
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessor: "completed_size",
|
||||||
|
title: "完成量",
|
||||||
|
width: 90,
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessor: "residual_size",
|
||||||
|
title: "余量",
|
||||||
|
width: 90,
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessor: "residual_work_time",
|
||||||
|
title: "余量工时",
|
||||||
|
width: 110,
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessor: "remarks",
|
||||||
|
title: "备注",
|
||||||
|
width: 200,
|
||||||
|
render: (record) => (
|
||||||
|
<Text
|
||||||
|
size="sm"
|
||||||
|
style={{
|
||||||
|
maxWidth: 200,
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
}}>
|
||||||
|
{record.remarks ?? "-"}
|
||||||
|
</Text>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessor: "operation",
|
||||||
|
title: "操作",
|
||||||
|
width: 90,
|
||||||
|
textAlign: "center",
|
||||||
|
render: (record) => {
|
||||||
|
const disabled = !!record.lock_status
|
||||||
|
return (
|
||||||
|
<Group gap={6} justify="center" wrap="nowrap">
|
||||||
|
<ActionIcon
|
||||||
|
variant="subtle"
|
||||||
|
color="blue"
|
||||||
|
disabled={disabled}
|
||||||
|
onClick={() => {
|
||||||
|
if (disabled) return
|
||||||
|
setEditingRecord(record)
|
||||||
|
setModalOpened(true)
|
||||||
|
}}>
|
||||||
|
<IconPencil size={16} />
|
||||||
|
</ActionIcon>
|
||||||
|
<ActionIcon
|
||||||
|
variant="subtle"
|
||||||
|
color="red"
|
||||||
|
disabled={disabled}
|
||||||
|
onClick={() => {
|
||||||
|
if (disabled || !record.id) return
|
||||||
|
modals.openConfirmModal({
|
||||||
|
title: "删除日报",
|
||||||
|
centered: true,
|
||||||
|
children: (
|
||||||
|
<Text size="sm">
|
||||||
|
删除后不可恢复,你确定删除该日报吗?
|
||||||
|
</Text>
|
||||||
|
),
|
||||||
|
labels: { confirm: "删除", cancel: "取消" },
|
||||||
|
confirmProps: { color: "red" },
|
||||||
|
onConfirm: async () => {
|
||||||
|
await deleteDailyWorkData(record.id as number)
|
||||||
|
notifications.show({
|
||||||
|
color: "green",
|
||||||
|
title: "操作成功",
|
||||||
|
message: "已删除日报",
|
||||||
|
})
|
||||||
|
load()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}}>
|
||||||
|
<IconTrash size={16} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Group>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
return cols
|
||||||
|
}, [load])
|
||||||
|
|
||||||
|
const summaryText = useMemo(() => {
|
||||||
|
return {
|
||||||
|
total_work_time: summary?.total_work_time ?? 0,
|
||||||
|
total_standard_size: summary?.total_standard_size ?? 0,
|
||||||
|
total_completed_size: summary?.total_completed_size ?? 0,
|
||||||
|
total_residual_size: summary?.total_residual_size ?? 0,
|
||||||
|
total_residual_work_time: summary?.total_residual_work_time ?? 0,
|
||||||
|
}
|
||||||
|
}, [summary])
|
||||||
|
|
||||||
|
const asyncGetSelfProjectList = useCallback(async () => {
|
||||||
|
const res = await getSelfProjectList()
|
||||||
|
setProjectOptions(
|
||||||
|
(res ?? []).map((r) => ({ label: r.label, value: String(r.value) }))
|
||||||
|
)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
queueMicrotask(() => asyncGetSelfProjectList())
|
||||||
|
}, [asyncGetSelfProjectList])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack w="100%" h="calc(100vh - 56px)" p="md" gap="md">
|
||||||
|
<Paper
|
||||||
|
withBorder
|
||||||
|
p="md"
|
||||||
|
radius="md"
|
||||||
|
style={{ borderColor: "rgba(0,0,0,0.06)" }}>
|
||||||
|
<Stack gap="sm">
|
||||||
|
<Group justify="space-between" wrap="wrap" gap="sm">
|
||||||
|
<Group gap="xs">
|
||||||
|
<Text fw={700}>搜索条件</Text>
|
||||||
|
<Button
|
||||||
|
size="xs"
|
||||||
|
variant="transparent"
|
||||||
|
rightSection={
|
||||||
|
searchExpanded ? (
|
||||||
|
<IconChevronUp size={16} />
|
||||||
|
) : (
|
||||||
|
<IconChevronDown size={16} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onClick={() => setSearchExpanded((v) => !v)}>
|
||||||
|
{searchExpanded ? "收起" : "展开"}
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<Group gap="sm">
|
||||||
|
<Button
|
||||||
|
variant="default"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
leftSection={<IconRefresh size={16} />}
|
||||||
|
onClick={() => {
|
||||||
|
setFilters(defaultFilters)
|
||||||
|
setAppliedFilters(defaultFilters)
|
||||||
|
setPage(1)
|
||||||
|
setQueryTrigger((v) => v + 1)
|
||||||
|
}}>
|
||||||
|
重置
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
leftSection={<IconSearch size={16} />}
|
||||||
|
onClick={() => {
|
||||||
|
setAppliedFilters(filters)
|
||||||
|
setPage(1)
|
||||||
|
setQueryTrigger((v) => v + 1)
|
||||||
|
}}>
|
||||||
|
查询
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Collapse
|
||||||
|
in={searchExpanded}
|
||||||
|
transitionDuration={150}
|
||||||
|
transitionTimingFunction="ease"
|
||||||
|
animateOpacity>
|
||||||
|
<SimpleGrid cols={{ base: 1, sm: 2, md: 3, lg: 4 }} spacing="sm">
|
||||||
|
<TextInput
|
||||||
|
label="开始日期"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
type="date"
|
||||||
|
value={filters.date_start}
|
||||||
|
onChange={(e) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
date_start: e.target.value,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label="结束日期"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
type="date"
|
||||||
|
value={filters.date_end}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFilters((s) => ({ ...s, date_end: e.target.value }))
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<MultiSelect
|
||||||
|
label="项目名称"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
data={projectOptions}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
value={filters.project_id}
|
||||||
|
onChange={(v) => setFilters((s) => ({ ...s, project_id: v }))}
|
||||||
|
/>
|
||||||
|
<MultiSelect
|
||||||
|
label="任务组长"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
data={leaderOptions}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
value={filters.leader_uid}
|
||||||
|
onChange={(v) => setFilters((s) => ({ ...s, leader_uid: v }))}
|
||||||
|
/>
|
||||||
|
<MultiSelect
|
||||||
|
label="规定类型"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
data={setTypeOpts}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
value={filters.set_type ? [filters.set_type] : []}
|
||||||
|
onChange={(v) =>
|
||||||
|
setFilters((s) => ({ ...s, set_type: v[0] ?? "" }))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<MultiSelect
|
||||||
|
label="出勤类型"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
data={actualTypeOpts}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
value={filters.actual_type ? [filters.actual_type] : []}
|
||||||
|
onChange={(v) =>
|
||||||
|
setFilters((s) => ({ ...s, actual_type: v[0] ?? "" }))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<MultiSelect
|
||||||
|
label="工作类别"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
data={workTypeOpts}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
value={filters.work_type ? [filters.work_type] : []}
|
||||||
|
onChange={(v) =>
|
||||||
|
setFilters((s) => ({ ...s, work_type: v[0] ?? "" }))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<MultiSelect
|
||||||
|
label="核算方式"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
data={accountTypeOpts}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
value={filters.accounting_type ? [filters.accounting_type] : []}
|
||||||
|
onChange={(v) =>
|
||||||
|
setFilters((s) => ({ ...s, accounting_type: v[0] ?? "" }))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<MultiSelect
|
||||||
|
label="绩效核算"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
data={performanceOpts}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
value={
|
||||||
|
filters.performance_accounting
|
||||||
|
? [filters.performance_accounting]
|
||||||
|
: []
|
||||||
|
}
|
||||||
|
onChange={(v) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
performance_accounting: v[0] ?? "",
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<MultiSelect
|
||||||
|
label="对象类型"
|
||||||
|
size="xs"
|
||||||
|
radius="xs"
|
||||||
|
data={objTypeOpts}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
value={filters.obj_type ? [filters.obj_type] : []}
|
||||||
|
onChange={(v) =>
|
||||||
|
setFilters((s) => ({ ...s, obj_type: v[0] ?? "" }))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</SimpleGrid>
|
||||||
|
</Collapse>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
|
||||||
|
<Paper
|
||||||
|
withBorder
|
||||||
|
p="md"
|
||||||
|
radius="md"
|
||||||
|
style={{
|
||||||
|
borderColor: "rgba(0,0,0,0.06)",
|
||||||
|
flex: 1,
|
||||||
|
minHeight: 0,
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
gap: 12,
|
||||||
|
}}>
|
||||||
|
<Stack gap={12} align="stretch" style={{ flex: 1, minHeight: 0 }}>
|
||||||
|
<Flex justify={"space-between"} align="center" w="100%">
|
||||||
|
<Button
|
||||||
|
leftSection={<IconPlus size={12} />}
|
||||||
|
size="xs"
|
||||||
|
radius={"xs"}
|
||||||
|
onClick={() => {
|
||||||
|
setEditingRecord(null)
|
||||||
|
setModalOpened(true)
|
||||||
|
}}>
|
||||||
|
填写日报
|
||||||
|
</Button>
|
||||||
|
<ActionIcon onClick={load} variant="transparent">
|
||||||
|
<IconRefresh size={16} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Flex>
|
||||||
|
<DataTable<Daily.DailyWorkList>
|
||||||
|
width="100%"
|
||||||
|
style={{ width: "100%" }}
|
||||||
|
withTableBorder
|
||||||
|
withRowBorders
|
||||||
|
pinFirstColumn
|
||||||
|
pinLastColumn
|
||||||
|
scrollAreaProps={{ type: "auto" }}
|
||||||
|
fetching={loading}
|
||||||
|
records={records}
|
||||||
|
columns={columns}
|
||||||
|
totalRecords={totalItems}
|
||||||
|
recordsPerPage={pageSize}
|
||||||
|
page={page}
|
||||||
|
onPageChange={setPage}
|
||||||
|
onRecordsPerPageChange={(v) => {
|
||||||
|
setPageSize(v)
|
||||||
|
setPage(1)
|
||||||
|
}}
|
||||||
|
recordsPerPageOptions={[10, 15, 20, 50]}
|
||||||
|
noRecordsText="暂无数据"
|
||||||
|
recordsPerPageLabel="当前页数"
|
||||||
|
sortStatus={sortStatus}
|
||||||
|
onSortStatusChange={(s) => {
|
||||||
|
setSortStatus(s)
|
||||||
|
setPage(1)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Paper withBorder radius="xs" p="sm">
|
||||||
|
<Group justify="space-between" wrap="wrap">
|
||||||
|
<Text size="sm" fw={700}>
|
||||||
|
当前页总计
|
||||||
|
</Text>
|
||||||
|
<Group gap="md">
|
||||||
|
<Text size="sm">工时:{summaryText.total_work_time}</Text>
|
||||||
|
<Text size="sm">标准量:{summaryText.total_standard_size}</Text>
|
||||||
|
<Text size="sm">
|
||||||
|
完成量:{summaryText.total_completed_size}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm">余量:{summaryText.total_residual_size}</Text>
|
||||||
|
<Text size="sm">
|
||||||
|
余量工时:{summaryText.total_residual_work_time}
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</Paper>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
|
||||||
|
<DailyReportModal
|
||||||
|
opened={modalOpened}
|
||||||
|
record={editingRecord}
|
||||||
|
projectOptions={projectOptions}
|
||||||
|
onCloseAction={(refresh) => {
|
||||||
|
setModalOpened(false)
|
||||||
|
setEditingRecord(null)
|
||||||
|
if (refresh) load()
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
)
|
||||||
|
}
|
||||||
63
components/label/api/daily/index.ts
Normal file
63
components/label/api/daily/index.ts
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import httpFetch from "@/api/fetch"
|
||||||
|
import { usePermissionStore } from "../../store/auth"
|
||||||
|
import { BASE_LABEL_API } from "../label"
|
||||||
|
import { Daily } from "./typing"
|
||||||
|
|
||||||
|
export const getDailyWorkList = (data: Daily.Request) => {
|
||||||
|
return httpFetch<Daily.Response>({
|
||||||
|
url: BASE_LABEL_API + "/api/v1/label_server/daily_work/list",
|
||||||
|
method: "post",
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
headerAttr: {
|
||||||
|
["Token"]: usePermissionStore.getState().token,
|
||||||
|
["Refresh-Token"]: usePermissionStore.getState().refresh_token,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const addDailyWorkData = (data: Daily.CreateProps) => {
|
||||||
|
return httpFetch({
|
||||||
|
url: BASE_LABEL_API + "/api/v1/label_server/daily_work/add",
|
||||||
|
method: "post",
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
headerAttr: {
|
||||||
|
["Token"]: usePermissionStore.getState().token,
|
||||||
|
["Refresh-Token"]: usePermissionStore.getState().refresh_token,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const editDailyWorkData = (data: Daily.CreateProps, id: number) => {
|
||||||
|
return httpFetch({
|
||||||
|
url: BASE_LABEL_API + `/api/v1/label_server/daily_work/edit/${id}`,
|
||||||
|
method: "put",
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
headerAttr: {
|
||||||
|
["Token"]: usePermissionStore.getState().token,
|
||||||
|
["Refresh-Token"]: usePermissionStore.getState().refresh_token,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const deleteDailyWorkData = (id: number) => {
|
||||||
|
return httpFetch({
|
||||||
|
url: BASE_LABEL_API + `/api/v1/label_server/daily_work/delete/${id}`,
|
||||||
|
method: "delete",
|
||||||
|
headerAttr: {
|
||||||
|
["Token"]: usePermissionStore.getState().token,
|
||||||
|
["Refresh-Token"]: usePermissionStore.getState().refresh_token,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const lockDailyWorkData = (lock_status: boolean, id: number) => {
|
||||||
|
return httpFetch({
|
||||||
|
url: BASE_LABEL_API + `/api/v1/label_server/daily_work/lock/${id}`,
|
||||||
|
method: "put",
|
||||||
|
body: JSON.stringify({ lock_status }),
|
||||||
|
headerAttr: {
|
||||||
|
["Token"]: usePermissionStore.getState().token,
|
||||||
|
["Refresh-Token"]: usePermissionStore.getState().refresh_token,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
84
components/label/api/daily/typing.ts
Normal file
84
components/label/api/daily/typing.ts
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
export namespace Daily {
|
||||||
|
export interface Request {
|
||||||
|
date_end?: string
|
||||||
|
date_start?: string
|
||||||
|
/**
|
||||||
|
* 0-个人日报 1-团队日报
|
||||||
|
*/
|
||||||
|
flag?: number
|
||||||
|
name?: string
|
||||||
|
order_by?: string
|
||||||
|
page_number?: number
|
||||||
|
page_size?: number
|
||||||
|
[property: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Summary {
|
||||||
|
total_work_time: number
|
||||||
|
total_standard_size: number
|
||||||
|
total_completed_size: number
|
||||||
|
total_residual_size: number
|
||||||
|
total_residual_work_time: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Response {
|
||||||
|
daily_work_list: DailyWorkList[]
|
||||||
|
total_items: number
|
||||||
|
total_pages: number
|
||||||
|
total_summary: Summary
|
||||||
|
[property: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DailyWorkList {
|
||||||
|
accounting_type?: string | null
|
||||||
|
actual_type?: string
|
||||||
|
completed_size?: number
|
||||||
|
date?: string
|
||||||
|
end_time?: string
|
||||||
|
id?: number
|
||||||
|
leader_name?: string | null
|
||||||
|
leader_uid?: number | null
|
||||||
|
lock_status?: boolean
|
||||||
|
obj_type?: number | null
|
||||||
|
performance_accounting?: boolean | null
|
||||||
|
project_id?: number | null
|
||||||
|
project_name?: string | null
|
||||||
|
rate?: number
|
||||||
|
remarks?: string | null
|
||||||
|
residual_pm?: boolean | null
|
||||||
|
residual_size?: number
|
||||||
|
residual_work_time?: number
|
||||||
|
set_type?: string
|
||||||
|
standard_size?: number
|
||||||
|
start_time?: string
|
||||||
|
uid?: number
|
||||||
|
username?: string
|
||||||
|
work_time?: number
|
||||||
|
work_type?: string | null
|
||||||
|
[property: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateProps {
|
||||||
|
accounting_type?: string
|
||||||
|
actual_type: string
|
||||||
|
completed_size?: number
|
||||||
|
date: string
|
||||||
|
end_time?: string
|
||||||
|
leader_uid?: number
|
||||||
|
obj_type?: number
|
||||||
|
performance_accounting?: boolean
|
||||||
|
project_id?: number
|
||||||
|
rate?: number
|
||||||
|
remarks?: string
|
||||||
|
residual_pm?: boolean
|
||||||
|
residual_size?: number
|
||||||
|
residual_work_time?: number
|
||||||
|
set_type: string
|
||||||
|
standard_size?: number
|
||||||
|
start_time?: string
|
||||||
|
uid: number
|
||||||
|
work_time?: number
|
||||||
|
work_type?: string
|
||||||
|
[property: string]: any
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -200,7 +200,7 @@ export const regenerateProjectEmbedding = (data: { project_id: number }) => {
|
|||||||
|
|
||||||
// 获取个人参与项目
|
// 获取个人参与项目
|
||||||
export const getPersonProjectDashBoard = () => {
|
export const getPersonProjectDashBoard = () => {
|
||||||
return httpFetch<any>({
|
return httpFetch<Array<Project.PersonProjectDashboardResponseItem>>({
|
||||||
url:
|
url:
|
||||||
BASE_LABEL_API + `/api/v1/label_server/data_statistics/personal_project`,
|
BASE_LABEL_API + `/api/v1/label_server/data_statistics/personal_project`,
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|||||||
@@ -299,6 +299,14 @@ export namespace Project {
|
|||||||
/**
|
/**
|
||||||
* DetailResponse
|
* DetailResponse
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
export interface PersonProjectDashboardResponseItem {
|
||||||
|
project_id: number
|
||||||
|
project_label_type: string
|
||||||
|
project_name: string
|
||||||
|
project_type: string
|
||||||
|
work_time: number
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReviewUsers {
|
export interface ReviewUsers {
|
||||||
|
|||||||
Reference in New Issue
Block a user