ข้ามไปยังเนื้อหา

หัวหน้ารายละเอียด

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} />

props ทั้งหมด

ตัวอย่างด้านบนใช้ props เพียงบางตัว ตารางนี้แสดงทุกตัวที่คอมโพเนนต์รับ พร้อมค่าเริ่มต้นและค่าที่ใช้ได้

RecordHeader props
ชื่อชนิดข้อมูลค่าเริ่มต้นคำอธิบาย
back* จำเป็น{ href: string; label: string }—The list the record came from, such as คำขอซื้อขอจ้าง.
number* จำเป็นstring—The document number, the page's heading.
statusBadgeStyle—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.
actionsreadonly MenuAction[]—The other actions, shown in the Actions menu.
level1 | 21The 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.

BadgeStyle fields
ชื่อชนิดข้อมูลค่าเริ่มต้นคำอธิบาย
tone* จำเป็นBadgeTone
ค่าที่ใช้ได้:"draft""pending""approved""paid""request""rejected""line"
——
label* จำเป็นstring—The badge text, already in the screen language.
iconLucideIcon——

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.

MenuAction fields
ชื่อชนิดข้อมูลค่าเริ่มต้นคำอธิบาย
label* จำเป็นstring—What it does, already in the screen language, such as Print.
iconLucideIcon—Shown before the label.
dangerboolean—Red, for an action that deletes or can't be undone. Put it last.
disabledboolean—Can't be used now, such as Edit on an approved record.
onSelect() => void—Called after the menu closes.
hrefstring—Makes it a link instead, such as to a print page.

ข้อควรปฏิบัติ

  • คำสั่งตามสถานะ: รออนุมัติมีอนุมัติและไม่อนุมัติ ร่างมีแก้ไข อนุมัติแล้วหรือชำระแล้วมีพิมพ์ และไม่อนุมัติไม่มีคำสั่ง

ซอร์สโค้ด: ui/src/record-header.tsx