fix(filter): daterangeinput
This commit is contained in:
@@ -35,6 +35,18 @@ interface FilterFormRecord {
|
|||||||
query_date: DatesRangeValue
|
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 {
|
function createInitialFilters(): FilterFormRecord {
|
||||||
return {
|
return {
|
||||||
query_date: [
|
query_date: [
|
||||||
@@ -77,16 +89,12 @@ export default function PersonalProjectTable() {
|
|||||||
}, [page, pageSize, records])
|
}, [page, pageSize, records])
|
||||||
|
|
||||||
const appliedParams = useMemo(() => {
|
const appliedParams = useMemo(() => {
|
||||||
const obj: Project.ReqPersonProjectDashBoard = {
|
const [start_date, end_date] = normalizeQueryDateRange(form.query_date)
|
||||||
start_date: dayjs().format("YYYY-MM-DD"),
|
const params: Project.ReqPersonProjectDashBoard = {
|
||||||
end_date: dayjs().format("YYYY-MM-DD"),
|
start_date,
|
||||||
|
end_date,
|
||||||
}
|
}
|
||||||
if (form.query_date[0] && form.query_date[1]) {
|
return params
|
||||||
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
|
|
||||||
}, [form.query_date])
|
}, [form.query_date])
|
||||||
|
|
||||||
const load = useCallback(async () => {
|
const load = useCallback(async () => {
|
||||||
@@ -259,7 +267,8 @@ export default function PersonalProjectTable() {
|
|||||||
<div className={classes.dashboardFilterControl}>
|
<div className={classes.dashboardFilterControl}>
|
||||||
<DatePickerInput
|
<DatePickerInput
|
||||||
type="range"
|
type="range"
|
||||||
placeholder="请选择时间范围,默认一周"
|
allowSingleDateInRange
|
||||||
|
placeholder="请选择时间范围,默认为当天一天"
|
||||||
valueFormat="YYYY-MM-DD"
|
valueFormat="YYYY-MM-DD"
|
||||||
locale="zh-cn"
|
locale="zh-cn"
|
||||||
clearable
|
clearable
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ export default function PersonReportPage() {
|
|||||||
title: "工时",
|
title: "工时",
|
||||||
width: 90,
|
width: 90,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
footer: sum(records.map((r) => r.work_time ?? 0)),
|
footer: sum(records.map((r) => r.work_time ?? 0)).toLocaleString(),
|
||||||
},
|
},
|
||||||
{ accessor: "rate", title: "额定倍率", width: 90 },
|
{ accessor: "rate", title: "额定倍率", width: 90 },
|
||||||
{
|
{
|
||||||
@@ -407,28 +407,30 @@ export default function PersonReportPage() {
|
|||||||
title: "标准量",
|
title: "标准量",
|
||||||
width: 90,
|
width: 90,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
footer: sum(records.map((r) => r.standard_size ?? 0)),
|
footer: sum(records.map((r) => r.standard_size ?? 0)).toLocaleString(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessor: "completed_size",
|
accessor: "completed_size",
|
||||||
title: "完成量",
|
title: "完成量",
|
||||||
width: 90,
|
width: 90,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
footer: sum(records.map((r) => r.completed_size ?? 0)),
|
footer: sum(records.map((r) => r.completed_size ?? 0)).toLocaleString(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessor: "residual_size",
|
accessor: "residual_size",
|
||||||
title: "余量",
|
title: "余量",
|
||||||
width: 90,
|
width: 90,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
footer: sum(records.map((r) => r.residual_size ?? 0)),
|
footer: sum(records.map((r) => r.residual_size ?? 0)).toLocaleString(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessor: "residual_work_time",
|
accessor: "residual_work_time",
|
||||||
title: "余量工时",
|
title: "余量工时",
|
||||||
width: 110,
|
width: 110,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
footer: sum(records.map((r) => r.residual_work_time ?? 0)),
|
footer: sum(
|
||||||
|
records.map((r) => r.residual_work_time ?? 0)
|
||||||
|
).toLocaleString(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessor: "remarks",
|
accessor: "remarks",
|
||||||
@@ -437,6 +439,7 @@ export default function PersonReportPage() {
|
|||||||
render: (record) => (
|
render: (record) => (
|
||||||
<Text
|
<Text
|
||||||
size="sm"
|
size="sm"
|
||||||
|
title={record.remarks ?? "-"}
|
||||||
className={classes.ellipsisText}
|
className={classes.ellipsisText}
|
||||||
style={{ maxWidth: 200 }}>
|
style={{ maxWidth: 200 }}>
|
||||||
{record.remarks ?? "-"}
|
{record.remarks ?? "-"}
|
||||||
|
|||||||
Reference in New Issue
Block a user