Giao diện
Cài đặt và sử dụng
Cài đặt
Plugin @digiforce-nc/plugin-action-template-print có cả client và server. Kích hoạt qua Plugin Manager.
Khi install, plugin tự động:
- Tạo collection
printingTemplatestrong database. - Thêm quyền
templatePrintvào admin và member role strategies. - Tạo thư mục
storage/print-templates/để lưu file template.
Upload template
Bước 1: Tạo template DOCX/XLSX
Tạo file Word (.docx) hoặc Excel (.xlsx) chứa placeholder theo cú pháp Carbone:
{d.customerName}— field đơn giản{d.items[i].productName}— loop qua mảng{d.total:formatN(2)}— format số
Bước 2: Upload lên hệ thống
- Vào Settings → Printing Templates (hoặc dùng API
printingTemplates:upload). - Chọn collection mà template áp dụng.
- Đặt tên template và upload file.
Bước 3: Thêm nút Template Print
- Mở Schema Editor trên block Detail hoặc Table row.
- Vào Configure actions → chọn Template Print.
- Chọn template từ danh sách.
- Lưu schema.
Sử dụng
- Mở detail view hoặc click row action Template Print.
- Chọn template (nếu có nhiều template cho collection).
- Server lấy dữ liệu bản ghi, render vào template qua Carbone engine.
- Trình duyệt tải file kết quả (DOCX hoặc XLSX).
Các loại template hỗ trợ
| Định dạng | Input | Output |
|---|---|---|
| DOCX | File Word template | File Word đã render dữ liệu |
| XLSX | File Excel template | File Excel đã render dữ liệu |
Mẹo
Template DOCX phù hợp cho hóa đơn, hợp đồng, báo cáo dạng văn bản. Template XLSX phù hợp cho bảng tổng hợp, phiếu kho, báo cáo dạng bảng.