แถบงบประมาณ
BudgetBar
A budget line's figures and its split as one bar: actual from the left, committed after it, then reserved when given, 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
- ใช้จ่ายจริง
- 0.00
- คงเหลือ
- 350,000.00
<BudgetBar allocated={500000} reserved={150000} committed={0} actual={0} />| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| allocated* จำเป็น | 500000 | number | The budget line's total, in baht. |
| reserved | 150000 | number | Held by purchase requests that have no purchase order yet (ก่อนผูกพัน), in baht. Leave it out where the budget has no reservations, and the bar shows allocated, committed, actual and remaining as before. Pass it, even as 0, to show the reserved figure, its segment and its legend entry. |
| committed* จำเป็น | 0 | number | Held by purchase orders and contracts not yet paid, in baht. |
| actual* จำเป็น | 0 | number | Already paid, in baht. Remaining is allocated less reserved, committed and actual. |
หลังออกใบสั่งซื้อ
ใบสั่งซื้อย้ายยอด 150,000 บาทจากก่อนผูกพันเป็นผูกพัน ยอดคงเหลือไม่เปลี่ยน
- จัดสรร
- 500,000.00
- ก่อนผูกพัน
- 0.00
- ผูกพัน
- 150,000.00
- ใช้จ่ายจริง
- 0.00
- คงเหลือ
- 350,000.00
<BudgetBar allocated={500000} reserved={0} committed={150000} actual={0} />| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| allocated* จำเป็น | 500000 | number | The budget line's total, in baht. |
| reserved | 0 | number | Held by purchase requests that have no purchase order yet (ก่อนผูกพัน), in baht. Leave it out where the budget has no reservations, and the bar shows allocated, committed, actual and remaining as before. Pass it, even as 0, to show the reserved figure, its segment and its legend entry. |
| 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 reserved, committed and actual. |
หลังเบิกจ่าย
ยอดย้ายจากผูกพันเป็นใช้จ่ายจริง ยอดคงเหลือไม่เปลี่ยน
- จัดสรร
- 500,000.00
- ก่อนผูกพัน
- 0.00
- ผูกพัน
- 0.00
- ใช้จ่ายจริง
- 150,000.00
- คงเหลือ
- 350,000.00
<BudgetBar allocated={500000} reserved={0} committed={0} actual={150000} />| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| allocated* จำเป็น | 500000 | number | The budget line's total, in baht. |
| reserved | 0 | number | Held by purchase requests that have no purchase order yet (ก่อนผูกพัน), in baht. Leave it out where the budget has no reservations, and the bar shows allocated, committed, actual and remaining as before. Pass it, even as 0, to show the reserved figure, its segment and its legend entry. |
| 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 reserved, committed and actual. |
ไม่มียอดก่อนผูกพัน
ถ้าไม่ส่ง reserved แถบแสดงยอดจัดสรร ผูกพัน ใช้จ่ายจริง และคงเหลือ เหมือนรุ่นก่อน 0.39.0
- จัดสรร
- 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 reserved, 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 reserved, committed and actual. |
| reserved | number | — | Held by purchase requests that have no purchase order yet (ก่อนผูกพัน), in baht. Leave it out where the budget has no reservations, and the bar shows allocated, committed, actual and remaining as before. Pass it, even as 0, to show the reserved figure, its segment and its legend entry. |
ข้อควรปฏิบัติ
- ส่งยอดเป็นบาทจากเซิร์ฟเวอร์ คอมโพเนนต์จัดรูปแบบเงินและคำนวณคงเหลือให้ คือ จัดสรร ลบ ก่อนผูกพัน ลบ ผูกพัน ลบ ใช้จ่ายจริง
- ก่อนผูกพัน ผูกพัน และใช้จ่ายจริงรวมกันต้องไม่เกินยอดจัดสรร ถ้าเกิน ให้แสดงข้อความแจ้งเตือนแยก
- แถบเป็นภาพประกอบ ทุกยอดแสดงเป็นตัวเลขด้านบน จึงอ่านได้โดยไม่ต้องพึ่งสี
- หน้าที่มีแถบนี้ต้องวาง <ChartPaints /> หนึ่งครั้ง ไม่เช่นนั้นแถบจะไม่มีสี
- ข้อมูลในตัวอย่างและการทดสอบต้องเป็นข้อมูลสมมติ
ซอร์สโค้ด: ui/src/charts/budget-bar.tsx