แถบงบประมาณ
BudgetBar
A budget line's four figures and its split as one bar: actual from the left, committed after it, and the rest remaining. Display only: the figures come from the server.
ใช้แสดงยอดสี่ตัวของรายการงบประมาณหนึ่งรายการ คือ จัดสรร ผูกพัน ใช้จ่ายจริง และคงเหลือ พร้อมแถบสัดส่วน ใช้ในหน้ารายละเอียดของงบ ถ้าเทียบหลายรายการ ใช้ BarChart แบบแท่งซ้อน หรือ BulletChart
import { BudgetBar } from "@bsru/ui";ตัวอย่าง
หลังออกใบสั่งซื้อ
ใบสั่งซื้อผูกพันงบ 150,000 บาท ยอดคงเหลือลดทันที แม้ยังไม่จ่ายเงิน
- จัดสรร
- 500,000.00
- ผูกพัน
- 150,000.00
- ใช้จ่ายจริง
- 0.00
- คงเหลือ
- 350,000.00
ใช้จ่ายจริงผูกพันคงเหลือ
<BudgetBar allocated={500000} committed={150000} actual={0} />| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| allocated* จำเป็น | 500000 | number | The budget line's total, in baht. |
| committed* จำเป็น | 150000 | number | Held by purchase orders and contracts not yet paid, in baht. |
| actual* จำเป็น | 0 | number | Already paid, in baht. Remaining is allocated less committed and actual. |
หลังเบิกจ่าย
ยอดย้ายจากผูกพันเป็นใช้จ่ายจริง ยอดคงเหลือไม่เปลี่ยน
- จัดสรร
- 500,000.00
- ผูกพัน
- 0.00
- ใช้จ่ายจริง
- 150,000.00
- คงเหลือ
- 350,000.00
ใช้จ่ายจริงผูกพันคงเหลือ
<BudgetBar allocated={500000} committed={0} actual={150000} />| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| allocated* จำเป็น | 500000 | number | The budget line's total, in baht. |
| committed* จำเป็น | 0 | number | Held by purchase orders and contracts not yet paid, in baht. |
| actual* จำเป็น | 150000 | number | Already paid, in baht. Remaining is allocated less committed and actual. |
props ทั้งหมด
ตัวอย่างด้านบนใช้ props เพียงบางตัว ตารางนี้แสดงทุกตัวที่คอมโพเนนต์รับ พร้อมค่าเริ่มต้นและค่าที่ใช้ได้
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| allocated* จำเป็น | number | — | The budget line's total, in baht. |
| committed* จำเป็น | number | — | Held by purchase orders and contracts not yet paid, in baht. |
| actual* จำเป็น | number | — | Already paid, in baht. Remaining is allocated less committed and actual. |
ข้อควรปฏิบัติ
- ส่งยอดเป็นบาทจากเซิร์ฟเวอร์ คอมโพเนนต์จัดรูปแบบเงินและคำนวณคงเหลือให้ คือ จัดสรร ลบ ผูกพัน ลบ ใช้จ่ายจริง
- ผูกพันรวมใช้จ่ายจริงต้องไม่เกินยอดจัดสรร ถ้าเกิน ให้แสดงข้อความแจ้งเตือนแยก
- แถบเป็นภาพประกอบ ยอดทั้งสี่แสดงเป็นตัวเลขด้านบน จึงอ่านได้โดยไม่ต้องพึ่งสี
- หน้าที่มีแถบนี้ต้องวาง <ChartPaints /> หนึ่งครั้ง ไม่เช่นนั้นแถบจะไม่มีสี
- ข้อมูลในตัวอย่างและการทดสอบต้องเป็นข้อมูลสมมติ
ซอร์สโค้ด: ui/src/charts/budget-bar.tsx