From ba20fd43fa97f551e984cff7f205d5ff81dbf1d9 Mon Sep 17 00:00:00 2001 From: "CANCERYS\\kw093" Date: Fri, 23 Oct 2026 11:29:53 +0800 Subject: [PATCH] ui update --- .../stock/service/StockTakeRecordService.kt | 16 +++++++++++----- .../stock/web/StockTakeRecordController.kt | 6 ++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/ffii/fpsms/modules/stock/service/StockTakeRecordService.kt b/src/main/java/com/ffii/fpsms/modules/stock/service/StockTakeRecordService.kt index 095e0eea..597458d7 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/service/StockTakeRecordService.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/service/StockTakeRecordService.kt @@ -1250,7 +1250,7 @@ open class StockTakeRecordService( return toRemove.size } - open fun listStockTakeRoundCards(yearMonth: String?): StockTakeRoundCardsRes { + open fun listStockTakeRoundCards(yearMonth: String?, view: String? = null): StockTakeRoundCardsRes { val all = stockTakeRepository.findAll().filter { !it.deleted } if (all.isEmpty()) { val thisMonth = java.time.YearMonth.now().toString() @@ -1285,13 +1285,19 @@ open class StockTakeRecordService( val completedYearMonths = ( cards.filter { !it.open }.map { it.yearMonth } + thisMonth ).distinct().filter { it <= thisMonth }.sortedDescending() - val rounds = if (hasOpenRounds) { + val openRoundsSorted = run { val openCards = cards.filter { it.open } val thisMonthOpen = openCards.filter { it.yearMonth == thisMonth } thisMonthOpen + openCards.filter { it.yearMonth != thisMonth } - } else { - val ym = yearMonth?.trim()?.takeIf { it.matches(Regex("\\d{4}-\\d{2}")) } ?: thisMonth - cards.filter { !it.open && it.yearMonth == ym } + } + val historyYm = yearMonth?.trim()?.takeIf { it.matches(Regex("\\d{4}-\\d{2}")) } ?: thisMonth + val historyRounds = cards.filter { !it.open && it.yearMonth == historyYm } + val viewNorm = view?.trim()?.lowercase().orEmpty() + val rounds = when (viewNorm) { + "open" -> openRoundsSorted + "history" -> historyRounds + // 舊行為:有進行中只回 open,否則回該月歷史(PickerCardList 等相容) + else -> if (hasOpenRounds) openRoundsSorted else historyRounds } return StockTakeRoundCardsRes( hasOpenRounds = hasOpenRounds, diff --git a/src/main/java/com/ffii/fpsms/modules/stock/web/StockTakeRecordController.kt b/src/main/java/com/ffii/fpsms/modules/stock/web/StockTakeRecordController.kt index d24bfef4..27ccf41c 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/web/StockTakeRecordController.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/web/StockTakeRecordController.kt @@ -190,9 +190,11 @@ class StockTakeRecordController( @GetMapping("/stockTakeRoundCards") fun stockTakeRoundCards( - @RequestParam(required = false) yearMonth: String? + @RequestParam(required = false) yearMonth: String?, + /** open=進行中;history=歷史(依 yearMonth);未傳則維持舊互斥行為 */ + @RequestParam(required = false) view: String?, ): StockTakeRoundCardsRes { - return stockOutRecordService.listStockTakeRoundCards(yearMonth) + return stockOutRecordService.listStockTakeRoundCards(yearMonth, view) } @GetMapping("/busyStockTakeSections")