หัวหน้ารายละเอียด
RecordHeader
The top of a record page: a link back to its list, the document number with its status, the item's name, and the actions. Show one main action at most, chosen by the status, and put the rest in the Actions menu. Under it, use KeyFigures, then Tabs for the record's parts.
ใช้เป็นส่วนบนของหน้ารายละเอียด: ลิงก์กลับไปที่รายการ เลขที่เอกสารพร้อมสถานะ ชื่อรายการ และคำสั่ง มีคำสั่งหลักได้ไม่เกินหนึ่งปุ่มตามสถานะ คำสั่งอื่นอยู่ในเมนูคำสั่ง ถัดลงมาใช้ KeyFigures แล้วจึงเป็น Tabs
import { RecordHeader } from "@bsru/ui";ตัวอย่าง
คำขอที่รออนุมัติ
status ใช้รูปแบบเดียวกับป้ายในคอลัมน์สถานะของตาราง primary คือคำสั่งหลักของสถานะนี้ actions ไปอยู่ในเมนูคำสั่ง ในหน้าจริงเลขที่เป็นหัวข้อระดับ 1
PR-2570-0001
รออนุมัติครุภัณฑ์คอมพิวเตอร์โน้ตบุ๊ก 5 เครื่อง
- วงเงิน
- 150,000.00 บาท
- งบคงเหลือหลังอนุมัติ
- 350,000.00 บาท
- ต้องการภายใน
- 15 ธ.ค. 2569
- ผู้ขอ
- นายทดสอบ ตัวอย่าง
<RecordHeader
back={{ href: "#purchase-requests", label: "คำขอซื้อขอจ้าง" }}
number="PR-2570-0001"
status={{ tone: "pending", label: "รออนุมัติ", icon: Clock }}
title="ครุภัณฑ์คอมพิวเตอร์โน้ตบุ๊ก 5 เครื่อง"
primary={{ label: "อนุมัติ", onClick: approve }}
actions={actions}
/>
<KeyFigures items={figures} />| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| back* จำเป็น | ออบเจกต์ 2 ฟิลด์{ href: "#purchase-requests", label: "คำขอซื้อขอจ้าง" } | { href: string; label: string } | The list the record came from, such as คำขอซื้อขอจ้าง. |
| number* จำเป็น | "PR-2570-0001" | string | The document number, the page's heading. |
| status | ออบเจกต์ 3 ฟิลด์{ tone: "pending", label: "รออนุมัติ", icon: Clock } | BadgeStyle | The status badge, the same as the list's status column. |
| title* จำเป็น | "ครุภัณฑ์คอมพิวเตอร์โน้ตบุ๊ก 5 เครื่อง" | string | What the record is, such as its item. |
| primary | { label: "อนุมัติ", onClick: approve } | { label: string; onClick?: () => void; href?: string } | The one main action for this status, such as อนุมัติ for a pending request. Leave it out when there's none. |
| actions | รายการ 4 รายการ[
{ label: "แก้ไข", icon: Pencil },
{ label: "ทำสำเนา", icon: Copy },
{ label: "พิมพ์", icon: Printer, href: "#print" },
{ label: "ลบ", icon: Trash, danger: true },
] | readonly MenuAction[] | The other actions, shown in the Actions menu. |
props ทั้งหมด
ตัวอย่างด้านบนใช้ props เพียงบางตัว ตารางนี้แสดงทุกตัวที่คอมโพเนนต์รับ พร้อมค่าเริ่มต้นและค่าที่ใช้ได้
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| back* จำเป็น | { href: string; label: string } | — | The list the record came from, such as คำขอซื้อขอจ้าง. |
| number* จำเป็น | string | — | The document number, the page's heading. |
| status | BadgeStyle | — | The status badge, the same as the list's status column. |
| title* จำเป็น | string | — | What the record is, such as its item. |
| primary | { label: string; onClick?: () => void; href?: string } | — | The one main action for this status, such as อนุมัติ for a pending request. Leave it out when there's none. |
| actions | readonly MenuAction[] | — | The other actions, shown in the Actions menu. |
| level | 1 | 2 | 1 | The number's heading level. 1 on a record page, where it's the page's heading. |
ชนิดข้อมูล
BadgeStyle
How a badge column shows one value, such as pending.
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| tone* จำเป็น | BadgeTone ค่าที่ใช้ได้: "draft""pending""approved""paid""request""rejected""line" | — | — |
| label* จำเป็น | string | — | The badge text, already in the screen language. |
| icon | LucideIcon | — | — |
BadgeTone
The state a badge reports. Each one has its own colour. line is for facts that aren't a state.
type BadgeTone = "draft" | "pending" | "approved" | "paid" | "request" | "rejected" | "line";MenuAction
One action in an ActionMenu.
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| label* จำเป็น | string | — | What it does, already in the screen language, such as Print. |
| icon | LucideIcon | — | Shown before the label. |
| danger | boolean | — | Red, for an action that deletes or can't be undone. Put it last. |
| disabled | boolean | — | Can't be used now, such as Edit on an approved record. |
| onSelect | () => void | — | Called after the menu closes. |
| href | string | — | Makes it a link instead, such as to a print page. |
ข้อควรปฏิบัติ
- คำสั่งตามสถานะ: รออนุมัติมีอนุมัติและไม่อนุมัติ ร่างมีแก้ไข อนุมัติแล้วหรือชำระแล้วมีพิมพ์ และไม่อนุมัติไม่มีคำสั่ง
ซอร์สโค้ด: ui/src/record-header.tsx