Sfoglia il codice sorgente

發貨與配送>員工發貨績效 added a new access right 績效

doTruckUpdate
PC-20260115JRSN\Administrator 1 mese fa
parent
commit
d22ef70f74
2 ha cambiato i file con 19 aggiunte e 2 eliminazioni
  1. +17
    -2
      src/app/(main)/chart/delivery/page.tsx
  2. +2
    -0
      src/authorities.ts

+ 17
- 2
src/app/(main)/chart/delivery/page.tsx Vedi File

@@ -1,6 +1,8 @@
"use client";

import React, { useCallback, useMemo, useState } from "react";
import { useSession } from "next-auth/react";
import { AUTH, hasAbility } from "@/authorities";
import {
Box,
Typography,
@@ -68,6 +70,9 @@ const defaultCriteria: Criteria = {

/** FP-MTMS Version Checklist | Functions Ref. No. 61 | v1.0.0 | 2026-08-10 */
export default function DeliveryChartPage() {
const { data: session } = useSession();
const abilities = session?.abilities ?? session?.user?.abilities ?? [];
const canSeeStaffPerformance = hasAbility(abilities, AUTH.PERFORMANCE);
const [criteria, setCriteria] = useState<Criteria>(defaultCriteria);
const [topItemsSelected, setTopItemsSelected] = useState<TopDeliveryItemOption[]>([]);
const [topItemOptions, setTopItemOptions] = useState<TopDeliveryItemOption[]>([]);
@@ -132,6 +137,10 @@ export default function DeliveryChartPage() {
}, [criteria.topItems, topItemsSelected, setChartLoading]);

React.useEffect(() => {
if (!canSeeStaffPerformance) {
setChartData((prev) => ({ ...prev, staffPerf: [] }));
return;
}
const s = criteria.staffPerf.startDate;
const e = criteria.staffPerf.endDate;
if (!s || !e) {
@@ -161,13 +170,17 @@ export default function DeliveryChartPage() {
)
.catch((err) => setError(err instanceof Error ? err.message : "Request failed"))
.finally(() => setChartLoading("staffPerf", false));
}, [criteria.staffPerf, staffSelected, setChartLoading]);
}, [canSeeStaffPerformance, criteria.staffPerf, staffSelected, setChartLoading]);

React.useEffect(() => {
if (!canSeeStaffPerformance) {
setStaffOptions([]);
return;
}
fetchStaffDeliveryPerformanceHandlers()
.then(setStaffOptions)
.catch(() => setStaffOptions([]));
}, []);
}, [canSeeStaffPerformance]);
React.useEffect(() => {
const { startDate: s, endDate: e } = toDateRange(criteria.topItems.rangeDays);
fetchTopDeliveryItemsItemOptions(s, e).then(setTopItemOptions).catch(() => setTopItemOptions([]));
@@ -317,6 +330,7 @@ export default function DeliveryChartPage() {
)}
</ChartCard>

{canSeeStaffPerformance && (
<ChartCard
title="員工發貨績效(每日揀貨數量與耗時)"
exportFilename="員工發貨績效"
@@ -496,6 +510,7 @@ export default function DeliveryChartPage() {
</>
)}
</ChartCard>
)}
</Box>
);
}

+ 2
- 0
src/authorities.ts Vedi File

@@ -29,6 +29,8 @@ export const AUTH = {
M18_SYNC: "M18_SYNC",
/** Route board (/settings/shop/board): ADMIN or this ability (DB name: 車線) */
TRUCK_LANE: "TRUCK_LANE",
/** 員工發貨績效 on /chart/delivery (DB name: 績效) */
PERFORMANCE: "PERFORMANCE",
} as const;

/**


Caricamento…
Annulla
Salva