chore: add env example and fix default sort order
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
6
.env.example
Normal file
6
.env.example
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Database connection for Warehouse Query System
|
||||||
|
DB_SERVER=192.168.110.114
|
||||||
|
DB_PORT=1433
|
||||||
|
DB_DATABASE=CompanyDB
|
||||||
|
DB_USER=
|
||||||
|
DB_PASSWORD=
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -32,6 +32,7 @@ yarn-error.log*
|
|||||||
|
|
||||||
# env files (can opt-in for committing if needed)
|
# env files (can opt-in for committing if needed)
|
||||||
.env*
|
.env*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
# vercel
|
# vercel
|
||||||
.vercel
|
.vercel
|
||||||
|
|||||||
@@ -147,8 +147,12 @@ export async function GET(request: NextRequest) {
|
|||||||
const total = countResult.recordset[0].total;
|
const total = countResult.recordset[0].total;
|
||||||
|
|
||||||
// --- Data query with sorting & pagination ---
|
// --- Data query with sorting & pagination ---
|
||||||
const sortCol = SORT_MAP[params.sortKey || ""] || "c.总排号";
|
const userSortCol = SORT_MAP[params.sortKey || ""];
|
||||||
const sortDir = params.sortDir === "desc" ? "DESC" : "ASC";
|
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 page = Math.max(1, params.page || 1);
|
||||||
const pageSize = params.pageSize || 20;
|
const pageSize = params.pageSize || 20;
|
||||||
const offset = (page - 1) * pageSize;
|
const offset = (page - 1) * pageSize;
|
||||||
@@ -170,7 +174,7 @@ export async function GET(request: NextRequest) {
|
|||||||
ISNULL(c.经办人, '') AS 经办人,
|
ISNULL(c.经办人, '') AS 经办人,
|
||||||
ISNULL(c.订单号, '') AS 订单号,
|
ISNULL(c.订单号, '') AS 订单号,
|
||||||
wh.日期 AS 入库日期,
|
wh.日期 AS 入库日期,
|
||||||
ROW_NUMBER() OVER (ORDER BY ${sortCol} ${sortDir}) AS _rownum
|
ROW_NUMBER() OVER (ORDER BY ${orderBy}) AS _rownum
|
||||||
${mainFrom}
|
${mainFrom}
|
||||||
${where}
|
${where}
|
||||||
) numbered
|
) numbered
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const COLUMNS = [
|
|||||||
{ key: "paichan", label: "排产号", mono: true, align: "left" },
|
{ key: "paichan", label: "排产号", mono: true, align: "left" },
|
||||||
{ key: "zongpai", label: "总排号", mono: true, align: "left" },
|
{ key: "zongpai", label: "总排号", mono: true, align: "left" },
|
||||||
{ key: "workshop", label: "车间", align: "left" },
|
{ key: "workshop", label: "车间", align: "left" },
|
||||||
{ key: "model", label: "产品型号", align: "left" },
|
{ key: "model", label: "产品型号", strong: true, align: "left" },
|
||||||
{ key: "range", label: "量程", align: "left" },
|
{ key: "range", label: "量程", align: "left" },
|
||||||
{ key: "qty", label: "数量", num: true, align: "right" },
|
{ key: "qty", label: "数量", num: true, align: "right" },
|
||||||
{ key: "boxNo", label: "箱号", mono: true, align: "left" },
|
{ key: "boxNo", label: "箱号", mono: true, align: "left" },
|
||||||
@@ -374,7 +374,9 @@ export default function WarehouseDashboard() {
|
|||||||
const align = col.align === "right" ? "text-right" : "text-left";
|
const align = col.align === "right" ? "text-right" : "text-left";
|
||||||
const font = col.mono ? "font-mono" : "";
|
const font = col.mono ? "font-mono" : "";
|
||||||
const num = col.num ? "tabular-nums" : "";
|
const num = col.num ? "tabular-nums" : "";
|
||||||
const color = col.mono ? "text-slate-600" : "text-slate-700";
|
const color = col.strong
|
||||||
|
? "font-medium text-slate-900"
|
||||||
|
: col.mono ? "text-slate-600" : "text-slate-700";
|
||||||
return (
|
return (
|
||||||
<td key={col.key} className={`whitespace-nowrap border-b border-slate-100 px-4 py-2.5 ${align} ${font} ${num} ${color}`}>
|
<td key={col.key} className={`whitespace-nowrap border-b border-slate-100 px-4 py-2.5 ${align} ${font} ${num} ${color}`}>
|
||||||
{empty ? <span className="text-slate-300">—</span> : String(raw)}
|
{empty ? <span className="text-slate-300">—</span> : String(raw)}
|
||||||
|
|||||||
Reference in New Issue
Block a user