|
@@ -111,7 +111,6 @@ const batchPath = (holderId: string, batchNo: string) =>
|
|
|
/** URL 搜索参数筛选(返回列表时保留条件;⛔ 路由级收敛另行处理)。 */
|
|
/** URL 搜索参数筛选(返回列表时保留条件;⛔ 路由级收敛另行处理)。 */
|
|
|
function useListFilters() {
|
|
function useListFilters() {
|
|
|
const [params, setParams] = useSearchParams();
|
|
const [params, setParams] = useSearchParams();
|
|
|
- const has = (key: string) => params.has(key);
|
|
|
|
|
const get = (key: string) => params.get(key) ?? "";
|
|
const get = (key: string) => params.get(key) ?? "";
|
|
|
const set = (key: string, value: string, resetPage = false) =>
|
|
const set = (key: string, value: string, resetPage = false) =>
|
|
|
setParams((current) => {
|
|
setParams((current) => {
|
|
@@ -122,7 +121,7 @@ function useListFilters() {
|
|
|
return next;
|
|
return next;
|
|
|
}, { replace: true });
|
|
}, { replace: true });
|
|
|
const reset = () => setParams({}, { replace: true });
|
|
const reset = () => setParams({}, { replace: true });
|
|
|
- return { has, get, set, reset };
|
|
|
|
|
|
|
+ return { get, set, reset };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** 失败原因行末红点(fail_reason 原文悬浮;⚠️ 不是 KLT-* 码,对账§7.1 末格)。 */
|
|
/** 失败原因行末红点(fail_reason 原文悬浮;⚠️ 不是 KLT-* 码,对账§7.1 末格)。 */
|
|
@@ -280,10 +279,10 @@ export function SettlementStatementListPage() {
|
|
|
const canExportAll = !identity || identity.role === "admin" || identity.role === "regAdmin";
|
|
const canExportAll = !identity || identity.role === "admin" || identity.role === "regAdmin";
|
|
|
const isAdmin = !identity || identity.role === "admin";
|
|
const isAdmin = !identity || identity.role === "admin";
|
|
|
|
|
|
|
|
- const defaultMonth = lastClosedMonth();
|
|
|
|
|
- // 自然月三态:参数缺席 ⇒ 默认预选 lastClosedMonth();显式 "all" ⇒ 全部自然月(空值项,⛔ 不得删除)。
|
|
|
|
|
- const monthAll = filters.get("month") === "all";
|
|
|
|
|
- const month = monthAll ? "" : filters.get("month") || defaultMonth;
|
|
|
|
|
|
|
+ const lastClosedPeriod = lastClosedMonth();
|
|
|
|
|
+ const monthParam = filters.get("month");
|
|
|
|
|
+ // 无参数时显示全部自然月,同时兼容旧链接的 month=all。
|
|
|
|
|
+ const month = monthParam === "all" ? "" : monthParam;
|
|
|
const type = filters.get("type");
|
|
const type = filters.get("type");
|
|
|
const party = filters.get("party");
|
|
const party = filters.get("party");
|
|
|
const reconcile = filters.get("reconcile");
|
|
const reconcile = filters.get("reconcile");
|
|
@@ -292,8 +291,7 @@ export function SettlementStatementListPage() {
|
|
|
const zero = filters.get("zero") === "1";
|
|
const zero = filters.get("zero") === "1";
|
|
|
const q = filters.get("q");
|
|
const q = filters.get("q");
|
|
|
const page = Number(filters.get("page") || "1") || 1;
|
|
const page = Number(filters.get("page") || "1") || 1;
|
|
|
- const setMonth = (value: string) => filters.set("month", value === "" ? "all" : value === defaultMonth ? "" : value, true);
|
|
|
|
|
- const hasFilter = Boolean(monthAll || filters.get("month") || type || party || reconcile || status || trigger || zero || q);
|
|
|
|
|
|
|
+ const hasFilter = Boolean(month || type || party || reconcile || status || trigger || zero || q);
|
|
|
|
|
|
|
|
const periodsFetch = useReconPeriods();
|
|
const periodsFetch = useReconPeriods();
|
|
|
// D-19:下拉选项=接口期次 ∪ 上一个已结束自然月(与人工补跑弹窗 `lastClosedMonth()` 同基准)。
|
|
// D-19:下拉选项=接口期次 ∪ 上一个已结束自然月(与人工补跑弹窗 `lastClosedMonth()` 同基准)。
|
|
@@ -301,29 +299,21 @@ export function SettlementStatementListPage() {
|
|
|
const periods = (() => {
|
|
const periods = (() => {
|
|
|
const raw = periodsFetch.data?.periods ?? null;
|
|
const raw = periodsFetch.data?.periods ?? null;
|
|
|
if (!raw) return null;
|
|
if (!raw) return null;
|
|
|
- if (raw.includes(defaultMonth)) return raw;
|
|
|
|
|
- return [defaultMonth, ...raw];
|
|
|
|
|
|
|
+ if (raw.includes(lastClosedPeriod)) return raw;
|
|
|
|
|
+ return [lastClosedPeriod, ...raw];
|
|
|
})();
|
|
})();
|
|
|
- // 仅当**用户显式选了**不在选项内的历史月(例如书签)才纠偏;默认预选月即使暂无批次也保留。
|
|
|
|
|
|
|
+ // 仅纠正不在选项内的显式月份(例如旧书签中的月份)。
|
|
|
const [monthFallback, setMonthFallback] = useState(false);
|
|
const [monthFallback, setMonthFallback] = useState(false);
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (!periods?.length) return;
|
|
if (!periods?.length) return;
|
|
|
- if (monthAll) {
|
|
|
|
|
- setMonthFallback(false);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if (!filters.has("month")) {
|
|
|
|
|
- setMonthFallback(false);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if (periods.includes(month)) {
|
|
|
|
|
|
|
+ if (!month || periods.includes(month)) {
|
|
|
setMonthFallback(false);
|
|
setMonthFallback(false);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
filters.set("month", periods[0], true);
|
|
filters.set("month", periods[0], true);
|
|
|
setMonthFallback(true);
|
|
setMonthFallback(true);
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
- }, [periods, month, monthAll]);
|
|
|
|
|
|
|
+ }, [periods, month]);
|
|
|
|
|
|
|
|
const list = useReconList({
|
|
const list = useReconList({
|
|
|
period: month,
|
|
period: month,
|
|
@@ -461,7 +451,7 @@ export function SettlementStatementListPage() {
|
|
|
onCommit={(value) => filters.set("party", value, true)} />
|
|
onCommit={(value) => filters.set("party", value, true)} />
|
|
|
{party && <button type="button" aria-label="清空分成方" onClick={() => filters.set("party", "", true)}><X size={15} aria-hidden="true" /></button>}
|
|
{party && <button type="button" aria-label="清空分成方" onClick={() => filters.set("party", "", true)}><X size={15} aria-hidden="true" /></button>}
|
|
|
</label>
|
|
</label>
|
|
|
- <FilterSelect icon="month" aria-label="自然月" value={monthAll ? "" : month} onChange={(event) => setMonth(event.target.value)}>
|
|
|
|
|
|
|
+ <FilterSelect icon="month" aria-label="自然月" value={month} onChange={(event) => filters.set("month", event.target.value, true)}>
|
|
|
<option value="">{ALL_PERIODS_LABEL}</option>
|
|
<option value="">{ALL_PERIODS_LABEL}</option>
|
|
|
{(periods ?? (month ? [month] : [])).map((p) => <option key={p} value={p}>{p}</option>)}
|
|
{(periods ?? (month ? [month] : [])).map((p) => <option key={p} value={p}>{p}</option>)}
|
|
|
</FilterSelect>
|
|
</FilterSelect>
|