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

รายการสินค้า

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 แสดงต่อจากจำนวน บนมือถือแต่ละแถวเรียงซ้อนพร้อมชื่อคอลัมน์

รายการในคำขอ PR-2570-0001
รายการจำนวนราคาต่อหน่วยจำนวนเงิน (บาท)
คอมพิวเตอร์โน้ตบุ๊ก5 เครื่อง27,000.00135,000.00
กระเป๋าใส่โน้ตบุ๊ก5 ใบ1,000.005,000.00
ติดตั้งและตั้งค่าซอฟต์แวร์1 งาน10,000.0010,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}
/>

ไม่มีหน่วย

ละ unit ไว้เมื่อไม่มีหน่วยนับ

รายการในคำขอ PR-2570-0004
รายการจำนวนราคาต่อหน่วยจำนวนเงิน (บาท)
จ้างซ่อมเครื่องปรับอากาศ อาคาร 2312,500.0037,500.00
ค่าอะไหล่16,000.006,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}
/>

props ทั้งหมด

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

LineItems 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.

LineItem fields
ชื่อชนิดข้อมูลค่าเริ่มต้นคำอธิบาย
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.
unitstring—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