diff --git a/app/person/dashboard/components/PersonalProjectTable.tsx b/app/person/dashboard/components/PersonalProjectTable.tsx
index 45db5e8..f875591 100644
--- a/app/person/dashboard/components/PersonalProjectTable.tsx
+++ b/app/person/dashboard/components/PersonalProjectTable.tsx
@@ -35,6 +35,18 @@ interface FilterFormRecord {
query_date: DatesRangeValue
}
+function normalizeQueryDateRange(value: DatesRangeValue): [string, string] {
+ const today = dayjs().format("YYYY-MM-DD")
+ const [start, end] = value
+ const normalizedStart = start ?? end ?? today
+ const normalizedEnd = end ?? normalizedStart
+
+ return [
+ dayjs(normalizedStart).format("YYYY-MM-DD"),
+ dayjs(normalizedEnd).format("YYYY-MM-DD"),
+ ]
+}
+
function createInitialFilters(): FilterFormRecord {
return {
query_date: [
@@ -77,16 +89,12 @@ export default function PersonalProjectTable() {
}, [page, pageSize, records])
const appliedParams = useMemo(() => {
- const obj: Project.ReqPersonProjectDashBoard = {
- start_date: dayjs().format("YYYY-MM-DD"),
- end_date: dayjs().format("YYYY-MM-DD"),
+ const [start_date, end_date] = normalizeQueryDateRange(form.query_date)
+ const params: Project.ReqPersonProjectDashBoard = {
+ start_date,
+ end_date,
}
- if (form.query_date[0] && form.query_date[1]) {
- obj.start_date = dayjs(form.query_date[0]).format("YYYY-MM-DD")
- obj.end_date = dayjs(form.query_date[1]).format("YYYY-MM-DD")
- }
-
- return obj
+ return params
}, [form.query_date])
const load = useCallback(async () => {
@@ -259,7 +267,8 @@ export default function PersonalProjectTable() {
- 个人工作台 /{" "}
- 个人看板
+ 个人中心 / 个人看板
diff --git a/app/person/report/components/DailyReportModal.tsx b/app/person/report/components/DailyReportModal.tsx
index 7435666..ed52c21 100644
--- a/app/person/report/components/DailyReportModal.tsx
+++ b/app/person/report/components/DailyReportModal.tsx
@@ -9,6 +9,8 @@ import {
useAllUserStore,
usePermissionStore,
} from "@/components/label/store/auth"
+import { formatUserTreeOptions } from "@/components/tree-select/libs/util"
+import { VirtualTreeSelect } from "@/components/tree-select/tree"
import {
Button,
Group,
@@ -46,42 +48,6 @@ function toTimeWithSeconds(value?: string) {
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 (
@@ -181,9 +147,10 @@ export default function DailyReportModal(props: {
const user_name = usePermissionStore((s) => s.user_name)
const treeData = useAllUserStore((s) => s.treeData)
- const leaderOptions = useMemo(() => {
- return flattenLeaderTree(treeData ?? [])
- }, [treeData])
+ const leaderOptions = useMemo(
+ () => formatUserTreeOptions(treeData ?? []),
+ [treeData]
+ )
const form = useForm({
initialValues: getEmptyFormValues(user_name),
@@ -419,16 +386,15 @@ export default function DailyReportModal(props: {
form.setFieldValue("project_id", value ?? "")
}
/>
-