chore: add env example and fix default sort order

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-06-04 09:53:50 +08:00
parent 086ad62614
commit 7d6de48df3
4 changed files with 18 additions and 5 deletions

View File

@@ -147,8 +147,12 @@ export async function GET(request: NextRequest) {
const total = countResult.recordset[0].total;
// --- Data query with sorting & pagination ---
const sortCol = SORT_MAP[params.sortKey || ""] || "c.总排号";
const sortDir = params.sortDir === "desc" ? "DESC" : "ASC";
const userSortCol = SORT_MAP[params.sortKey || ""];
const userSortDir = params.sortDir === "desc" ? "DESC" : "ASC";
// Default multi-column sort: 排产号(车间号) ASC, 总排号 ASC, 箱号 ASC (FR-3)
const orderBy = userSortCol
? `${userSortCol} ${userSortDir}`
: "c.车间号 ASC, c.总排号 ASC, b.box_no ASC";
const page = Math.max(1, params.page || 1);
const pageSize = params.pageSize || 20;
const offset = (page - 1) * pageSize;
@@ -170,7 +174,7 @@ export async function GET(request: NextRequest) {
ISNULL(c.经办人, '') AS 经办人,
ISNULL(c.订单号, '') AS 订单号,
wh.日期 AS 入库日期,
ROW_NUMBER() OVER (ORDER BY ${sortCol} ${sortDir}) AS _rownum
ROW_NUMBER() OVER (ORDER BY ${orderBy}) AS _rownum
${mainFrom}
${where}
) numbered