รายการสินค้า
LineItems
The lines of a request or document, with money right-aligned and a total row. Pass the total from the core API, so it always matches the record's amount.
ใช้แสดงรายการสินค้าหรือบริการในคำขอหรือเอกสาร พร้อมจำนวนเงินชิดขวาและแถวรวม ส่งตัวเลขเป็น number ส่วนประกอบจัดรูปแบบเงินเอง และส่งยอดรวมจาก core API ถ้าเป็นรายการของหลายเอกสารที่ค้นหาหรือเรียงได้ ใช้ตารางข้อมูล
import { LineItems } from "@bsru/ui";ตัวอย่าง
รายการในคำขอซื้อ
unit แสดงต่อจากจำนวน บนมือถือแต่ละแถวเรียงซ้อนพร้อมชื่อคอลัมน์
| รายการ | จำนวน | ราคาต่อหน่วย | จำนวนเงิน (บาท) |
|---|---|---|---|
| คอมพิวเตอร์โน้ตบุ๊ก | 5 เครื่อง | 27,000.00 | 135,000.00 |
| กระเป๋าใส่โน้ตบุ๊ก | 5 ใบ | 1,000.00 | 5,000.00 |
| ติดตั้งและตั้งค่าซอฟต์แวร์ | 1 งาน | 10,000.00 | 10,000.00 |
| รวมทั้งสิ้น | 150,000.00 | ||
<LineItems
caption="รายการในคำขอ PR-2570-0001"
columns={{
description: "รายการ",
quantity: "จำนวน",
unitPrice: "ราคาต่อหน่วย",
amount: "จำนวนเงิน (บาท)",
}}
items={[
{
key: "1",
description: "คอมพิวเตอร์โน้ตบุ๊ก",
quantity: 5,
unit: "เครื่อง",
unitPrice: 27000,
amount: 135000,
},
{
key: "2",
description: "กระเป๋าใส่โน้ตบุ๊ก",
quantity: 5,
unit: "ใบ",
unitPrice: 1000,
amount: 5000,
},
{
key: "3",
description: "ติดตั้งและตั้งค่าซอฟต์แวร์",
quantity: 1,
unit: "งาน",
unitPrice: 10000,
amount: 10000,
},
]}
totalLabel="รวมทั้งสิ้น"
total={150000}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| caption* จำเป็น | "รายการในคำขอ PR-2570-0001" | string | Names the table for screen readers, such as รายการในคำขอ PR-2570-0001. |
| columns* จำเป็น | ออบเจกต์ 4 ฟิลด์{
description: "รายการ",
quantity: "จำนวน",
unitPrice: "ราคาต่อหน่วย",
amount: "จำนวนเงิน (บาท)",
} | { description: string; quantity: string; unitPrice: string; amount: string } | The four column headings, already in the screen language. |
| items* จำเป็น | รายการ 3 รายการ[
{
key: "1",
description: "คอมพิวเตอร์โน้ตบุ๊ก",
quantity: 5,
unit: "เครื่อง",
unitPrice: 27000,
amount: 135000,
},
{
key: "2",
description: "กระเป๋าใส่โน้ตบุ๊ก",
quantity: 5,
unit: "ใบ",
unitPrice: 1000,
amount: 5000,
},
{
key: "3",
description: "ติดตั้งและตั้งค่าซอฟต์แวร์",
quantity: 1,
unit: "งาน",
unitPrice: 10000,
amount: 10000,
},
] | readonly LineItem[] | The lines, in order. |
| totalLabel* จำเป็น | "รวมทั้งสิ้น" | string | The label of the total row, such as รวมทั้งสิ้น. |
| total* จำเป็น | 150000 | number | The record's total in baht, from the core API. |
ไม่มีหน่วย
ละ unit ไว้เมื่อไม่มีหน่วยนับ
| รายการ | จำนวน | ราคาต่อหน่วย | จำนวนเงิน (บาท) |
|---|---|---|---|
| จ้างซ่อมเครื่องปรับอากาศ อาคาร 2 | 3 | 12,500.00 | 37,500.00 |
| ค่าอะไหล่ | 1 | 6,000.00 | 6,000.00 |
| รวมทั้งสิ้น | 43,500.00 | ||
<LineItems
caption="รายการในคำขอ PR-2570-0004"
columns={{
description: "รายการ",
quantity: "จำนวน",
unitPrice: "ราคาต่อหน่วย",
amount: "จำนวนเงิน (บาท)",
}}
items={[
{
key: "1",
description: "จ้างซ่อมเครื่องปรับอากาศ อาคาร 2",
quantity: 3,
unitPrice: 12500,
amount: 37500,
},
{
key: "2",
description: "ค่าอะไหล่",
quantity: 1,
unitPrice: 6000,
amount: 6000,
},
]}
totalLabel="รวมทั้งสิ้น"
total={43500}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| caption* จำเป็น | "รายการในคำขอ PR-2570-0004" | string | Names the table for screen readers, such as รายการในคำขอ PR-2570-0001. |
| columns* จำเป็น | ออบเจกต์ 4 ฟิลด์{
description: "รายการ",
quantity: "จำนวน",
unitPrice: "ราคาต่อหน่วย",
amount: "จำนวนเงิน (บาท)",
} | { description: string; quantity: string; unitPrice: string; amount: string } | The four column headings, already in the screen language. |
| items* จำเป็น | รายการ 2 รายการ[
{
key: "1",
description: "จ้างซ่อมเครื่องปรับอากาศ อาคาร 2",
quantity: 3,
unitPrice: 12500,
amount: 37500,
},
{
key: "2",
description: "ค่าอะไหล่",
quantity: 1,
unitPrice: 6000,
amount: 6000,
},
] | readonly LineItem[] | The lines, in order. |
| totalLabel* จำเป็น | "รวมทั้งสิ้น" | string | The label of the total row, such as รวมทั้งสิ้น. |
| total* จำเป็น | 43500 | number | The record's total in baht, from the core API. |
props ทั้งหมด
ตัวอย่างด้านบนใช้ props เพียงบางตัว ตารางนี้แสดงทุกตัวที่คอมโพเนนต์รับ พร้อมค่าเริ่มต้นและค่าที่ใช้ได้
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| caption* จำเป็น | string | — | Names the table for screen readers, such as รายการในคำขอ PR-2570-0001. |
| columns* จำเป็น | { description: string; quantity: string; unitPrice: string; amount: string } | — | The four column headings, already in the screen language. |
| items* จำเป็น | readonly LineItem[] | — | The lines, in order. |
| totalLabel* จำเป็น | string | — | The label of the total row, such as รวมทั้งสิ้น. |
| total* จำเป็น | number | — | The record's total in baht, from the core API. |
ชนิดข้อมูล
LineItem
One line of a request or document.
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| key* จำเป็น | string | — | Unique among the lines, such as the line number. |
| description* จำเป็น | string | — | What the line is for. |
| quantity* จำเป็น | number | — | How many, as a number. The unit follows it. |
| unit | string | — | The unit after the quantity, such as เครื่อง. |
| unitPrice* จำเป็น | number | — | The price of one unit in baht, as a number. The list formats it. |
| amount* จำเป็น | number | — | From the core API. The screen never works out money. |
ข้อควรปฏิบัติ
- หน้าจอไม่คำนวณเงินเอง amount และ total มาจาก core API เพื่อให้ตรงกับยอดของรายการเสมอ
- ส่งเงินเป็น number ในหน่วยบาท ส่วนประกอบแสดงทศนิยมสองตำแหน่งและตัวคั่นหลักพันเอง
- caption ตั้งชื่อตารางให้โปรแกรมอ่านหน้าจอ ใส่เลขที่ของเอกสารด้วย
ซอร์สโค้ด: ui/src/record.tsx